-
-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathuihelpers.pas
More file actions
135 lines (115 loc) · 3.7 KB
/
Copy pathuihelpers.pas
File metadata and controls
135 lines (115 loc) · 3.7 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
unit uihelpers;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, StdCtrls, ExtCtrls, Buttons, Graphics,
constants;
/// <summary>Apply modern typography recursively to a control and its children.</summary>
procedure ApplyModernTypography(AControl: TWinControl);
/// <summary>Apply modern spacing (margins, padding) recursively.</summary>
procedure ApplyModernSpacing(AControl: TWinControl);
/// <summary>Add Unicode icons to main action buttons on a form.</summary>
procedure ApplyIconsToButtons(AForm: TForm);
/// <summary>Apply Radeon red theme to a form and its immediate controls.</summary>
procedure ApplyRadeonTheme(AForm: TForm);
implementation
procedure ApplyModernTypography(AControl: TWinControl);
var
i: Integer;
begin
AControl.Font.Name := FONT_NAME_PRIMARY;
AControl.Font.Size := FONT_SIZE_BODY;
AControl.Font.Quality := fqAntialiased;
for i := 0 to AControl.ControlCount - 1 do
begin
if AControl.Controls[i] is TGroupBox then
begin
TGroupBox(AControl.Controls[i]).Font.Size := FONT_SIZE_TITLE;
TGroupBox(AControl.Controls[i]).Font.Style := [fsBold];
TGroupBox(AControl.Controls[i]).Font.Quality := fqAntialiased;
end;
if AControl.Controls[i] is TButton then
begin
TButton(AControl.Controls[i]).Font.Size := FONT_SIZE_BODY;
TButton(AControl.Controls[i]).Font.Quality := fqAntialiased;
end;
if AControl.Controls[i] is TLabel then
begin
TLabel(AControl.Controls[i]).Font.Size := FONT_SIZE_BODY;
TLabel(AControl.Controls[i]).Font.Quality := fqAntialiased;
end;
if AControl.Controls[i] is TWinControl then
ApplyModernTypography(TWinControl(AControl.Controls[i]));
end;
end;
procedure ApplyModernSpacing(AControl: TWinControl);
var
i: Integer;
Checkbox: TCheckBox;
PrevCheckbox: TCheckBox;
begin
for i := 0 to AControl.ControlCount - 1 do
begin
if AControl.Controls[i] is TGroupBox then
begin
with TGroupBox(AControl.Controls[i]) do
begin
BorderSpacing.Left := MARGIN_MEDIUM;
BorderSpacing.Top := MARGIN_MEDIUM;
BorderSpacing.Right := MARGIN_MEDIUM;
BorderSpacing.Bottom := MARGIN_MEDIUM;
end;
end;
if AControl.Controls[i] is TCheckBox then
begin
Checkbox := TCheckBox(AControl.Controls[i]);
if i > 0 then
begin
if AControl.Controls[i-1] is TCheckBox then
begin
PrevCheckbox := TCheckBox(AControl.Controls[i-1]);
if Checkbox.Top - (PrevCheckbox.Top + PrevCheckbox.Height) < MARGIN_MEDIUM then
Checkbox.Top := PrevCheckbox.Top + PrevCheckbox.Height + MARGIN_MEDIUM;
end;
end;
end;
if AControl.Controls[i] is TButton then
begin
with TButton(AControl.Controls[i]) do
begin
BorderSpacing.Around := MARGIN_SMALL;
end;
end;
if AControl.Controls[i] is TWinControl then
ApplyModernSpacing(TWinControl(AControl.Controls[i]));
end;
end;
procedure ApplyIconsToButtons(AForm: TForm);
var
Btn: TBitBtn;
begin
if Assigned(AForm.FindComponent('gupdateBitBtn')) then
begin
Btn := TBitBtn(AForm.FindComponent('gupdateBitBtn'));
// Only set the default caption if the update check hasn't already shown the button
if not Btn.Visible then
Btn.Caption := 'Update';
end;
end;
procedure ApplyRadeonTheme(AForm: TForm);
var
i: Integer;
begin
AForm.Color := clRADEON;
for i := 0 to AForm.ControlCount - 1 do
begin
if AForm.Controls[i] is TButton then
begin
TButton(AForm.Controls[i]).Font.Color := clWhite;
TButton(AForm.Controls[i]).Color := clRADEON;
end
else if AForm.Controls[i] is TLabel then
TLabel(AForm.Controls[i]).Font.Color := clWhite;
end;
end;
end.