-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBase.pas
117 lines (98 loc) · 3.26 KB
/
Base.pas
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
unit Base;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects,
FMX.Controls.Presentation, FMX.StdCtrls, FMX.ScrollBox, FMX.Memo,
FMX.TMSCustomEdit, FMX.TMSEdit;
type
TfrmBase = class(TForm)
pnlMain: TPanel;
procedure pnlMainResize(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
Resized: Boolean;
DesignHeight: Single;
procedure ResizeFonts;
public
{ Public declarations }
procedure LCARSLabelClick(Sender: TObject);
procedure CheckLCARSLabel(Sender: TObject; Checked: Boolean);
function LCARSLabelIsChecked(Sender: TObject): Boolean;
procedure LoadForm; virtual;
procedure HideForm; virtual;
end;
var
frmBase: TfrmBase;
implementation
{$R *.fmx}
procedure TfrmBase.LoadForm;
begin
// virtual
end;
procedure TfrmBase.pnlMainResize(Sender: TObject);
begin
ResizeFonts;
end;
procedure TfrmBase.FormCreate(Sender: TObject);
begin
Resized := False;
DesignHeight := pnlMain.Height;
end;
procedure TfrmBase.HideForm;
begin
pnlMain.Parent := Self;
end;
procedure TfrmBase.LCARSLabelClick(Sender: TObject);
begin
CheckLCARSLabel(Sender, not LCARSLabelIsChecked(Sender));
end;
procedure TfrmBase.CheckLCARSLabel(Sender: TObject; Checked: Boolean);
var
Rectangle: TRoundRect;
Text, Check: TText;
begin
Rectangle := TRoundRect(TLabel(Sender).FindStyleResource('rectangle'));
Text := TText(TLabel(Sender).FindStyleResource('text'));
Check := TText(TLabel(Sender).FindStyleResource('check'));
if (Rectangle <> nil) and (Text <> nil) then begin
if Checked then begin
Rectangle.Stroke.Color := TAlphaColorRec.Yellow;
Rectangle.Fill.Color := TAlphaColorRec.Yellow;
Check.Visible := True;
Text.TextSettings.Font.Style := Text.TextSettings.Font.Style + [TFontStyle.fsBold];
TLabel(Sender).Tag := 1;
end else begin
Rectangle.Stroke.Color := TAlphaColorRec.Gray;
Rectangle.Fill.Color := TAlphaColorRec.Black;
Check.Visible := False;
Text.TextSettings.Font.Style := Text.TextSettings.Font.Style - [TFontStyle.fsBold];
TLabel(Sender).Tag := 0;
end;
end;
end;
function TfrmBase.LCARSLabelIsChecked(Sender: TObject): Boolean;
begin
Result := TLabel(Sender).Tag <> 0;
end;
procedure TfrmBase.ResizeFonts;
var
i: Integer;
Component: TComponent;
begin
if not Resized then begin
Resized := True;
for i := 0 to pnlMain.ComponentCount-1 do begin
Component := pnlMain.Components[i];
if Component is TLabel then begin
TLabel(Component).Font.Size := TLabel(Component).Font.Size * pnlMain.Height / DesignHeight;
end else if Component is TMemo then begin
TMemo(Component).TextSettings.Font.Size := TMemo(Component).TextSettings.Font.Size * pnlMain.Height / DesignHeight;
end else if Component is TTMSFMXEdit then begin
TTMSFMXEdit(Component).TextSettings.Font.Size := TTMSFMXEdit(Component).TextSettings.Font.Size * pnlMain.Height / DesignHeight;
end;
end;
end;
end;
end.