1 | unit bgraribbon;
|
---|
2 |
|
---|
3 | {$mode objfpc}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Controls, Graphics, BGRABitmap, BGRABitmapTypes, BGRAButton;
|
---|
9 |
|
---|
10 | type
|
---|
11 | TBGRARibbonStyle = (rsTab, rsButton, rsSeparator, rsMenu);
|
---|
12 |
|
---|
13 | { StyleButtons }
|
---|
14 |
|
---|
15 | procedure StyleRibbonButtonsSample(AControl: TControl; AStyle: TBGRARibbonStyle);
|
---|
16 | procedure StyleRibbonBody(AControl: TControl);
|
---|
17 |
|
---|
18 | { Drawings }
|
---|
19 |
|
---|
20 | procedure DrawTabGradient(ABitmap: TBGRABitmap);
|
---|
21 | procedure DrawBodyGradient(ABitmap: TBGRABitmap);
|
---|
22 | procedure DrawFormGradient(ABitmap: TBGRABitmap);
|
---|
23 |
|
---|
24 | { Buttons }
|
---|
25 |
|
---|
26 | procedure RibbonTab(AButton: TBGRAButton);
|
---|
27 | procedure RibbonButton(AButton: TBGRAButton);
|
---|
28 | procedure RibbonSeparator(AButton: TBGRAButton);
|
---|
29 | procedure RibbonMenu(AButton: TBGRAButton);
|
---|
30 |
|
---|
31 | implementation
|
---|
32 |
|
---|
33 | { StyleButtons }
|
---|
34 |
|
---|
35 | procedure StyleButtons(AControl: TControl; AButton: TBGRAButton);
|
---|
36 | var
|
---|
37 | i: integer;
|
---|
38 | WinControl: TWinControl;
|
---|
39 | begin
|
---|
40 | if AControl is TBGRAButton then
|
---|
41 | AControl.Assign(AButton);
|
---|
42 | if AControl is TWinControl then
|
---|
43 | begin
|
---|
44 | WinControl := TWinControl(AControl);
|
---|
45 | if WinControl.ControlCount = 0 then
|
---|
46 | exit;
|
---|
47 | for i := 0 to WinControl.ControlCount - 1 do
|
---|
48 | StyleButtons(WinControl.Controls[i], AButton);
|
---|
49 | end;
|
---|
50 | end;
|
---|
51 |
|
---|
52 | procedure StyleRibbonButtonsSample(AControl: TControl; AStyle: TBGRARibbonStyle);
|
---|
53 | var
|
---|
54 | tempBGRAButton: TBGRAButton;
|
---|
55 | begin
|
---|
56 | tempBGRAButton := TBGRAButton.Create(nil);
|
---|
57 | case AStyle of
|
---|
58 | rsTab: RibbonTab(tempBGRAButton);
|
---|
59 | rsButton: RibbonButton(tempBGRAButton);
|
---|
60 | rsSeparator: RibbonSeparator(tempBGRAButton);
|
---|
61 | rsMenu: RibbonMenu(tempBGRAButton);
|
---|
62 | end;
|
---|
63 | StyleButtons(AControl, tempBGRAButton);
|
---|
64 | tempBGRAButton.Free;
|
---|
65 | end;
|
---|
66 |
|
---|
67 | procedure StyleRibbonBody(AControl: TControl);
|
---|
68 | var
|
---|
69 | i: integer;
|
---|
70 | WinControl: TWinControl;
|
---|
71 | begin
|
---|
72 | if AControl is TWinControl then
|
---|
73 | begin
|
---|
74 | WinControl := TWinControl(AControl);
|
---|
75 | if WinControl.ControlCount = 0 then
|
---|
76 | exit;
|
---|
77 | for i := 0 to WinControl.ControlCount - 1 do
|
---|
78 | begin
|
---|
79 | if WinControl.Controls[i] is TBGRAButton then
|
---|
80 | begin
|
---|
81 | if WinControl.Controls[i].Caption = '-' then
|
---|
82 | begin
|
---|
83 | StyleRibbonButtonsSample(WinControl.Controls[i], rsSeparator);
|
---|
84 | WinControl.Controls[i].Caption := '';
|
---|
85 | end
|
---|
86 | else
|
---|
87 | StyleRibbonButtonsSample(WinControl.Controls[i], rsButton);
|
---|
88 | end;
|
---|
89 | end;
|
---|
90 | end;
|
---|
91 | end;
|
---|
92 |
|
---|
93 | { Drawings }
|
---|
94 |
|
---|
95 | procedure DrawTabGradient(ABitmap: TBGRABitmap);
|
---|
96 | begin
|
---|
97 | with ABitmap do
|
---|
98 | begin
|
---|
99 | Fill(BGRA(223, 233, 245, 255));
|
---|
100 | DrawHorizLine(0, Height - 1, Width - 1, BGRA(186, 201, 219, 255));
|
---|
101 | end;
|
---|
102 | end;
|
---|
103 |
|
---|
104 | procedure DrawBodyGradient(ABitmap: TBGRABitmap);
|
---|
105 | begin
|
---|
106 | with ABitmap do
|
---|
107 | begin
|
---|
108 | GradientFill(0, 0, Width, Height, BGRA(247, 251, 255, 255),
|
---|
109 | BGRA(220, 231, 245, 255), gtLinear, PointF(0, 0), PointF(0, Height - 3), dmSet);
|
---|
110 | Rectangle(0, 0, Width, Height - 2, BGRA(255, 255, 255, 75), BGRAPixelTransparent,
|
---|
111 | dmDrawWithTransparency);
|
---|
112 | DrawHorizLine(0, Height - 2, Width - 1, BGRA(206, 219, 235, 255));
|
---|
113 | DrawHorizLine(0, Height - 1, Width - 1, BGRA(159, 174, 194, 255));
|
---|
114 | end;
|
---|
115 | end;
|
---|
116 |
|
---|
117 | procedure DrawFormGradient(ABitmap: TBGRABitmap);
|
---|
118 | begin
|
---|
119 | with ABitmap do
|
---|
120 | begin
|
---|
121 | GradientFill(0, 0, Width, Height, BGRA(197, 207, 223, 255),
|
---|
122 | BGRA(220, 229, 242, 255), gtLinear, PointF(0, 0), PointF(0, Height), dmSet);
|
---|
123 | end;
|
---|
124 | end;
|
---|
125 |
|
---|
126 | { Buttons }
|
---|
127 |
|
---|
128 | procedure RibbonTab(AButton: TBGRAButton);
|
---|
129 | begin
|
---|
130 | with AButton do
|
---|
131 | begin
|
---|
132 | TextCanvas := True;
|
---|
133 | TextShadow := False;
|
---|
134 | RoundX := 1;
|
---|
135 | RoundY := 1;
|
---|
136 | with BodyNormal do
|
---|
137 | begin
|
---|
138 | Font.Color := RGBToColor(30, 57, 91);
|
---|
139 | Color := clWhite;
|
---|
140 | BorderColor := RGBToColor(186, 201, 219);
|
---|
141 | Style := bbsColor;
|
---|
142 | end;
|
---|
143 | with BodyHover do
|
---|
144 | begin
|
---|
145 | Font.Color := RGBToColor(30, 57, 91);
|
---|
146 | Color := clWhite;
|
---|
147 | BorderColor := RGBToColor(186, 201, 219);
|
---|
148 | Style := bbsColor;
|
---|
149 | end;
|
---|
150 | with BodyClicked do
|
---|
151 | begin
|
---|
152 | Font.Color := RGBToColor(30, 57, 91);
|
---|
153 | Color := clWhite;
|
---|
154 | BorderColor := RGBToColor(186, 201, 219);
|
---|
155 | Style := bbsColor;
|
---|
156 | end;
|
---|
157 | end;
|
---|
158 | end;
|
---|
159 |
|
---|
160 | procedure RibbonButton(AButton: TBGRAButton);
|
---|
161 | begin
|
---|
162 | with AButton do
|
---|
163 | begin
|
---|
164 | TextCanvas := True;
|
---|
165 | TextShadow := False;
|
---|
166 | RoundX := 2;
|
---|
167 | RoundY := 2;
|
---|
168 | with BodyNormal do
|
---|
169 | begin
|
---|
170 | Font.Color := RGBToColor(30, 57, 91);
|
---|
171 | BorderStyle := bboNone;
|
---|
172 | Style := bbsClear;
|
---|
173 | end;
|
---|
174 | with BodyHover do
|
---|
175 | begin
|
---|
176 | Font.Color := RGBToColor(30, 57, 91);
|
---|
177 | BorderColor := RGBToColor(255, 183, 0);
|
---|
178 | Gradient1.StartColor := RGBToColor(253, 236, 218);
|
---|
179 | Gradient1.EndColor := RGBToColor(253, 223, 186);
|
---|
180 | Gradient2.StartColor := RGBToColor(255, 206, 105);
|
---|
181 | Gradient2.EndColor := RGBToColor(255, 255, 217);
|
---|
182 | Gradient2.Point1YPercent := 60;
|
---|
183 | Gradient2.Point2YPercent := 100;
|
---|
184 | LightOpacity := 200;
|
---|
185 | LightWidth := 1;
|
---|
186 | end;
|
---|
187 | with BodyClicked do
|
---|
188 | begin
|
---|
189 | Font.Color := RGBToColor(30, 57, 91);
|
---|
190 | BorderColor := RGBToColor(194, 155, 41);
|
---|
191 | Gradient1.StartColor := RGBToColor(241, 206, 146);
|
---|
192 | Gradient1.EndColor := RGBToColor(245, 199, 119);
|
---|
193 | Gradient2.StartColor := RGBToColor(245, 187, 86);
|
---|
194 | Gradient2.EndColor := RGBToColor(242, 242, 177);
|
---|
195 | Gradient2.Point1YPercent := 60;
|
---|
196 | Gradient2.Point2YPercent := 100;
|
---|
197 | end;
|
---|
198 | end;
|
---|
199 | end;
|
---|
200 |
|
---|
201 | procedure RibbonSeparator(AButton: TBGRAButton);
|
---|
202 | begin
|
---|
203 | with AButton do
|
---|
204 | begin
|
---|
205 | StaticButton := True;
|
---|
206 | with BodyNormal do
|
---|
207 | begin
|
---|
208 | BorderColor := clWhite;
|
---|
209 | BorderColorOpacity := 150;
|
---|
210 | Color := RGBToColor(165, 184, 208);
|
---|
211 | Style := bbsColor;
|
---|
212 | end;
|
---|
213 | end;
|
---|
214 | end;
|
---|
215 |
|
---|
216 | procedure RibbonMenu(AButton: TBGRAButton);
|
---|
217 | begin
|
---|
218 | with AButton do
|
---|
219 | begin
|
---|
220 | TextCanvas := True;
|
---|
221 | TextShadowOffSetX := 1;
|
---|
222 | TextShadowOffSetY := 1;
|
---|
223 | TextShadowRadius := 0;
|
---|
224 | with BodyNormal do
|
---|
225 | begin
|
---|
226 | Font.Color := clWhite;
|
---|
227 | BorderColor := RGBToColor(65, 106, 189);
|
---|
228 | Gradient1.StartColor := RGBToColor(70, 129, 190);
|
---|
229 | Gradient1.EndColor := RGBToColor(41, 92, 170);
|
---|
230 | Gradient2.StartColor := RGBToColor(26, 65, 136);
|
---|
231 | Gradient2.EndColor := RGBToColor(66, 154, 207);
|
---|
232 | LightOpacity := 100;
|
---|
233 | LightWidth := 1;
|
---|
234 | Gradient1EndPercent := 50;
|
---|
235 | Gradient1.Point1YPercent := 30;
|
---|
236 | Gradient2.Point1YPercent := 30;
|
---|
237 | end;
|
---|
238 | with BodyHover do
|
---|
239 | begin
|
---|
240 | Font.Color := clWhite;
|
---|
241 | BorderColor := RGBToColor(68, 135, 213);
|
---|
242 | Gradient1.StartColor := RGBToColor(123, 177, 235);
|
---|
243 | Gradient1.EndColor := RGBToColor(71, 128, 207);
|
---|
244 | Gradient2.StartColor := RGBToColor(17, 78, 175);
|
---|
245 | Gradient2.EndColor := RGBToColor(128, 255, 255);
|
---|
246 | LightOpacity := 100;
|
---|
247 | LightWidth := 1;
|
---|
248 | Gradient1EndPercent := 50;
|
---|
249 | Gradient1.Point1YPercent := 30;
|
---|
250 | Gradient2.Point1YPercent := 30;
|
---|
251 | end;
|
---|
252 | with BodyClicked do
|
---|
253 | begin
|
---|
254 | Font.Color := clWhite;
|
---|
255 | BorderStyle := bboNone;
|
---|
256 | Gradient1.StartColor := RGBToColor(75, 138, 197);
|
---|
257 | Gradient1.EndColor := RGBToColor(49, 104, 176);
|
---|
258 | Gradient2.StartColor := RGBToColor(28, 67, 138);
|
---|
259 | Gradient2.EndColor := RGBToColor(53, 139, 201);
|
---|
260 | Gradient1EndPercent := 50;
|
---|
261 | Gradient1.Point1YPercent := 30;
|
---|
262 | Gradient2.Point1YPercent := 30;
|
---|
263 | end;
|
---|
264 | end;
|
---|
265 | end;
|
---|
266 |
|
---|
267 | end.
|
---|