Changeset 300 for trunk/Forms/UFormItem.pas
- Timestamp:
- Jul 10, 2019, 10:46:20 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormItem.pas
r298 r300 24 24 FItem: TItem; 25 25 DataControls: TFPGObjectList<TControl>; 26 DataLabels: TFPGObjectList<TLabel>; 27 procedure ControlChangeExecute(Sender: TObject); 26 28 procedure SetItem(AValue: TItem); 27 29 procedure LoadData(Item: TItem); virtual; … … 29 31 procedure InitControls; 30 32 public 33 procedure UpdateInterface; 31 34 property Item: TItem read FItem write SetItem; 32 35 end; … … 60 63 Core.ThemeManager1.UseTheme(Self); 61 64 DataControls := TFPGObjectList<TControl>.Create; 65 DataLabels := TFPGObjectList<TLabel>.Create; 62 66 end; 63 67 64 68 procedure TFormItem.FormDestroy(Sender: TObject); 65 69 begin 70 DataLabels.Free; 66 71 DataControls.Free; 67 72 end; … … 70 75 begin 71 76 Core.PersistentForm.Load(Self); 77 end; 78 79 procedure TFormItem.ControlChangeExecute(Sender: TObject); 80 begin 81 UpdateInterface; 72 82 end; 73 83 … … 130 140 end; 131 141 Fields.Free; 142 UpdateInterface; 132 143 end; 133 144 … … 165 176 Y: Integer; 166 177 begin 167 Y := 8; 178 DataControls.Clear; 179 DataLabels.Clear; 180 Y := Scale96ToScreen(8); 168 181 Fields := Item.GetFields; 169 182 for I := 0 to Fields.Count - 1 do 170 183 with TItemField(Fields[I]) do begin 171 184 NewLabel := TLabel.Create(Self); 172 NewLabel.Left := 8;185 NewLabel.Left := Scale96ToScreen(8); 173 186 NewLabel.Top := Y; 174 187 NewLabel.Parent := Self; 175 188 NewLabel.Caption := Name + ':'; 176 189 NewLabel.Visible := True; 190 DataLabels.Add(NewLabel); 177 191 178 192 if DataType = dtInteger then begin 179 193 NewControl := TSpinEdit.Create(nil); 180 NewControl.Width := 100;194 NewControl.Width := Scale96ToScreen(100); 181 195 TSpinEdit(NewControl).MaxValue := High(Integer); 182 196 end else 183 197 if DataType = dtString then begin 184 198 NewControl := TEdit.Create(nil); 185 NewControl.Width := 300;199 NewControl.Width := Scale96ToScreen(300); 186 200 end else 187 201 if DataType = dtColor then begin 188 202 NewControl := TColorBox.Create(nil); 189 NewControl.Width := 200; 203 NewControl.Width := Scale96ToScreen(200); 204 TColorBox(NewControl).Style := [cbStandardColors, cbExtendedColors, 205 cbCustomColor, cbPrettyNames]; 190 206 end else 191 207 if DataType = dtEnumeration then begin 192 208 NewControl := TComboBox.Create(nil); 193 NewControl.Width := 200;209 NewControl.Width := Scale96ToScreen(200); 194 210 TComboBox(NewControl).Style := csDropDownList; 211 TComboBox(NewControl).OnChange := ControlChangeExecute; 195 212 end else 196 213 if DataType = dtReference then begin 197 214 NewControl := TComboBox.Create(nil); 198 NewControl.Width := 200;215 NewControl.Width := Scale96ToScreen(200); 199 216 TComboBox(NewControl).Style := csDropDownList; 200 217 end else … … 203 220 end else 204 221 raise Exception.Create(Format(SUnsupportedDataType, [DataTypeStr[DataType]])); 205 NewControl.Left := 150;222 NewControl.Left := Scale96ToScreen(150); 206 223 NewControl.Top := Y; 207 224 NewControl.Parent := Self; … … 210 227 NewControl.Visible := True; 211 228 DataControls.Add(NewControl); 212 Y := Y + 40;229 Y := Y + Scale96ToScreen(30); 213 230 end; 214 231 Fields.Free; 215 232 end; 216 233 234 procedure TFormItem.UpdateInterface; 235 var 236 I: Integer; 237 Fields: TItemFields; 238 Condition: Boolean; 239 begin 240 Fields := Item.GetFields; 241 try 242 for I := 0 to Fields.Count - 1 do 243 with TItemField(Fields[I]) do begin 244 if VisibleIfIndex > 0 then begin 245 if TItemField(Fields[VisibleIfIndex]).DataType = dtEnumeration then begin 246 Condition := TComboBox(DataControls[VisibleIfIndex]).ItemIndex > 0; 247 end else Condition := False; 248 end; 249 DataControls[I].Visible := (VisibleIfIndex = 0) or ((VisibleIfIndex > 0) and Condition); 250 DataLabels[I].Visible := DataControls[I].Visible; 251 end; 252 finally 253 Fields.Free; 254 end; 255 end; 256 217 257 end. 218 258
Note:
See TracChangeset
for help on using the changeset viewer.