Skip to content

Commit 5ab78ab

Browse files
committed
Add compiler directive FMX
1 parent 3c83e34 commit 5ab78ab

File tree

5 files changed

+65
-13
lines changed

5 files changed

+65
-13
lines changed

SimpleDAO.pas

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ interface
99
System.Classes,
1010
Data.DB,
1111
{$IFNDEF CONSOLE}
12-
VCL.Forms,
12+
{$IFDEF FMX}
13+
FMX.Forms,
14+
{$ELSE}
15+
Vcl.Forms,
16+
{$ENDIF}
1317
{$ENDIF}
1418
SimpleDAOSQLAttribute,
1519
System.Threading;

SimpleEntity.pas

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ interface
44

55
uses
66
{$IFNDEF CONSOLE}
7-
Vcl.Forms,
7+
{$IFDEF FMX}
8+
FMX.Forms,
9+
{$ELSE}
10+
Vcl.Forms,
11+
{$ENDIF}
812
{$ENDIF}
913
Data.DB, System.Generics.Collections, System.SysUtils;
1014

SimpleInterface.pas

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ interface
88
Data.DB,
99
System.TypInfo,
1010
{$IFNDEF CONSOLE}
11-
VCL.Forms,
11+
{$IFDEF FMX}
12+
FMX.Forms,
13+
{$ELSE}
14+
Vcl.Forms,
15+
{$ENDIF}
1216
{$ENDIF}
1317
System.SysUtils;
1418
type

SimpleRTTI.pas

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,12 @@ interface
8989
Data.DB,
9090
TypInfo,
9191
{$IFNDEF CONSOLE}
92-
VCL.Forms,
93-
VCL.StdCtrls,
94-
Vcl.ExtCtrls,
92+
FMX.Types,
93+
{$IFDEF FMX}
94+
FMX.Forms, FMX.Edit, FMX.ListBox, FMX.StdCtrls, FMX.DateTimeCtrls,
95+
{$ELSE}
96+
Vcl.Forms, VCL.StdCtrls, Vcl.ExtCtrls,
97+
{$ENDIF}
9598
{$ENDIF}
9699
System.Classes,
97100
System.SysUtils;
@@ -139,6 +142,8 @@ implementation
139142

140143
uses
141144
SimpleAttributes,
145+
146+
142147
{$IFNDEF CONSOLE}
143148
Vcl.ComCtrls,
144149
Vcl.Graphics,
@@ -161,20 +166,37 @@ function TSimpleRTTI<T>.__BindValueToComponent(aComponent: TComponent;
161166
if aComponent is TComboBox then
162167
(aComponent as TComboBox).ItemIndex := (aComponent as TComboBox).Items.IndexOf(aValue);
163168

169+
{$IFDEF VCL}
164170
if aComponent is TRadioGroup then
165171
(aComponent as TRadioGroup).ItemIndex := (aComponent as TRadioGroup).Items.IndexOf(aValue);
166172

173+
if aComponent is TShape then
174+
(aComponent as TShape).Brush.Color := aValue;
175+
{$ENDIF}
176+
177+
//DateControls
178+
{$IFDEF VCL}
179+
if aComponent is TDateTimePicker then
180+
(aComponent as TDateTimePicker).Date := aValue;
181+
{$ENDIF}
182+
{$IFDEF FMX}
183+
if aComponent is TDateEdit then
184+
(aComponent as TDateEdit).Date := aValue;
185+
{$ENDIF}
186+
167187
if aComponent is TCheckBox then
188+
{$IFDEF VCL}
168189
(aComponent as TCheckBox).Checked := aValue;
190+
{$ELSEIF IFDEF FMX}
191+
(aComponent as TCheckBox).IsChecked := aValue;
192+
{$ENDIF}
169193

170194
if aComponent is TTrackBar then
171195
(aComponent as TTrackBar).Position := aValue;
172196

173-
if aComponent is TDateTimePicker then
174-
(aComponent as TDateTimePicker).Date := aValue;
175197

176-
if aComponent is TShape then
177-
(aComponent as TShape).Brush.Color := aValue;
198+
199+
178200
end;
179201
{$ENDIF}
180202

@@ -242,20 +264,34 @@ function TSimpleRTTI<T>.__GetComponentToValue(aComponent: TComponent): TValue;
242264
if aComponent is TComboBox then
243265
Result := TValue.FromVariant((aComponent as TComboBox).Items[(aComponent as TComboBox).ItemIndex]);
244266

267+
{$IFDEF VCL}
245268
if aComponent is TRadioGroup then
246269
Result := TValue.FromVariant((aComponent as TRadioGroup).Items[(aComponent as TRadioGroup).ItemIndex]);
247270

271+
if aComponent is TShape then
272+
Result := TValue.FromVariant((aComponent as TShape).Brush.Color);
273+
{$ENDIF}
274+
248275
if aComponent is TCheckBox then
276+
{$IFDEF VCL}
249277
Result := TValue.FromVariant((aComponent as TCheckBox).Checked);
278+
{$ELSEIF IFDEF FMX}
279+
Result := TValue.FromVariant((aComponent as TCheckBox).IsChecked);
280+
{$ENDIF}
281+
250282

251283
if aComponent is TTrackBar then
252284
Result := TValue.FromVariant((aComponent as TTrackBar).Position);
253285

286+
{$IFDEF VCL}
254287
if aComponent is TDateTimePicker then
255288
Result := TValue.FromVariant((aComponent as TDateTimePicker).DateTime);
289+
{$ENDIF}
290+
{$IFDEF FMX}
291+
if aComponent is TDateEdit then
292+
Result := TValue.FromVariant((aComponent as TDateEdit).DateTime);
293+
{$ENDIF}
256294

257-
if aComponent is TShape then
258-
Result := TValue.FromVariant((aComponent as TShape).Brush.Color);
259295

260296
a := Result.TOString;
261297
end;

SimpleUtil.pas

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ interface
55
uses
66
System.Classes, Data.DB, System.Generics.Collections,
77
{$IFNDEF CONSOLE}
8-
Vcl.Forms, Vcl.StdCtrls, Vcl.ComCtrls,
8+
{$IFDEF FMX}
9+
FMX.Forms, FMX.StdCtrls, FMX.DateTimeCtrls,
10+
{$ELSE}
11+
Vcl.Forms, Vcl.StdCtrls, Vcl.ComCtrls,
12+
{$ENDIF}
913
{$ENDIF}
1014
SimpleEntity;
1115

0 commit comments

Comments
 (0)