-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSettings.pas
More file actions
161 lines (124 loc) · 4.51 KB
/
Copy pathSettings.pas
File metadata and controls
161 lines (124 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
unit Settings;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
Base, FMX.Controls.Presentation, FMX.Edit, FMX.Layouts, FMX.ListBox,
FMX.TMSCustomEdit, FMX.TMSEdit, FMX.Objects, SettingsBase, LoRaBluetoothSettings;
type
TSettingType = (stString, stInteger, stBoolean, stSerialPort, stBluetooth);
type
TfrmSettings = class(TfrmBase)
btnGPS: TButton;
btnOther: TButton;
btnLoRaSerial: TButton;
pnlCentre: TPanel;
btnLoRaBluetooth: TButton;
pnlTop: TRectangle;
crcBottomRight: TCircle;
rectBottomRight: TRectangle;
crcBottomLeft: TCircle;
rectSources: TRectangle;
rectBottomLeft: TRectangle;
procedure FormCreate(Sender: TObject);
procedure btnGPSClick(Sender: TObject);
procedure btnLoRaSerialClick(Sender: TObject);
procedure btnOtherClick(Sender: TObject);
procedure btnLoRaBluetoothClick(Sender: TObject);
procedure pnlMainResize(Sender: TObject);
private
{ Private declarations }
CurrentForm: TfrmSettingsBase;
procedure ShowSelectedButton(Button: TButton);
procedure LoadSettingsForm(Button: TButton; NewForm: TfrmSettingsBase);
public
{ Public declarations }
procedure LoadForm; override;
procedure LoadPage(PageIndex: Integer);
end;
var
frmSettings: TfrmSettings;
implementation
{$R *.fmx}
uses Main, GPSSettings, OtherSettings, LoRaSerialSettings;
procedure TfrmSettings.LoadSettingsForm(Button: TButton; NewForm: TfrmSettingsBase);
begin
ShowSelectedButton(Button);
if CurrentForm <> nil then begin
CurrentForm.pnlMain.Parent := CurrentForm;
CurrentForm.HideForm;
CurrentForm.Free;
end;
NewForm.pnlMain.Parent := pnlCentre;
CurrentForm := NewForm;
NewForm.LoadForm;
frmMain.ResizeFonts(NewForm);
end;
procedure TfrmSettings.pnlMainResize(Sender: TObject);
begin
pnlTop.Height := frmMain.rectTopBar.Height;
pnlTop.Margins.Left := pnlTop.Height / 2;
pnlTop.Margins.Right := pnlTop.Height / 2;
rectSources.Margins.Left := - pnlTop.Height / 2;
crcBottomLeft.Width := crcBottomLeft.Height;
crcBottomLeft.Margins.Left := -crcBottomLeft.Height/2;
crcBottomRight.Width := crcBottomRight.Height;
crcBottomRight.Margins.Right := -crcBottomRight.Height/2;
rectBottomLeft.Margins.Bottom := crcBottomLeft.Height / 2;
rectBottomRight.Margins.Bottom := crcBottomLeft.Height / 2;
end;
procedure TfrmSettings.btnGPSClick(Sender: TObject);
begin
frmGPSSettings := TfrmGPSSettings.Create(Self);
LoadSettingsForm(btnGPS, frmGPSSettings);
end;
procedure TfrmSettings.btnOtherClick(Sender: TObject);
begin
frmOtherSettings := TfrmOtherSettings.Create(Self);
LoadSettingsForm(btnOther, frmOtherSettings);
end;
procedure TfrmSettings.btnLoRaBluetoothClick(Sender: TObject);
begin
frmBluetoothSettings := TfrmBluetoothSettings.Create(Self);
LoadSettingsForm(btnLoRaBluetooth, frmBluetoothSettings);
end;
procedure TfrmSettings.btnLoRaSerialClick(Sender: TObject);
begin
frmLoRaSerialSettings := TfrmLoRaSerialSettings.Create(Self);
LoadSettingsForm(btnLoRaSerial, frmLoRaSerialSettings);
end;
procedure TfrmSettings.FormCreate(Sender: TObject);
begin
inherited;
{$IF Defined(MSWINDOWS) or Defined(ANDROID)}
{$ELSE}
btnLoRaSerial.Text := '';
btnLoRaBluetooth.Text := 'BLE';
{$ENDIF}
end;
procedure TfrmSettings.LoadForm;
begin
inherited;
frmGPSSettings := TfrmGPSSettings.Create(Self);
LoadSettingsForm(btnGPS, frmGPSSettings);
// btnGPS.Font.Size := btnGPS.Size.Height * 36/64;
// btnLoRaSerial.Font.Size := btnGPS.Font.Size;
// btnLoRaBluetooth.Font.Size := btnGPS.Font.Size;
end;
procedure TfrmSettings.ShowSelectedButton(Button: TButton);
begin
btnGPS.TextSettings.Font.Style := btnGPS.TextSettings.Font.Style - [TFontStyle.fsUnderline];
btnLoRaSerial.TextSettings.Font.Style := btnLoRaSerial.TextSettings.Font.Style - [TFontStyle.fsUnderline];
btnLoRaBluetooth.TextSettings.Font.Style := btnLoRaBluetooth.TextSettings.Font.Style - [TFontStyle.fsUnderline];
btnOther.TextSettings.Font.Style := btnOther.TextSettings.Font.Style - [TFontStyle.fsUnderline];
Button.TextSettings.Font.Style := Button.TextSettings.Font.Style + [TFontStyle.fsUnderline];
end;
procedure TfrmSettings.LoadPage(PageIndex: Integer);
begin
case PageIndex of
0: btnGPSClick(nil);
1: btnLoRaSerialClick(nil);
2: btnLoRaBluetoothClick(nil);
end;
end;
end.