source: trunk/Packages/bgracontrols/bctest/bcsamples.pas

Last change on this file was 2, checked in by chronos, 5 years ago
File size: 31.3 KB
Line 
1unit bcsamples;
2
3{$mode objfpc}{$H+}
4
5interface
6
7uses
8 Classes, Controls, Graphics,
9 StdCtrls, LCLProc, LCLType,
10 BCButton, BCTypes,
11 BGRABitmap, BGRABitmapTypes, BGRAGradients;
12
13const
14 {Accent Colors}
15 acMagenta = TColor($009700FF);
16 acPurple = TColor($00FF00A2);
17 acTeal = TColor($00A9AB00);
18 acLime = TColor($0026BF8C);
19 acBrown = TColor($000050A0);
20 acPink = TColor($00B871E6);
21 acOrange = TColor($000996F0);
22 acBlue = TColor($00E2A11B);
23 acRed = TColor($000014E5);
24 acGreen = TColor($00339933);
25 {Facebook Colors}
26 fbBlue = TColor($00AA785F);
27 fbGreen = TColor($004BA567);
28 fbGray = TColor($00F8F8F8);
29 {Windows 8 Color Scheme - Background}
30 clScheme1_Background = TColor($00252525);
31 clScheme2_Background = TColor($00252525);
32 clScheme3_Background = TColor($00252525);
33 clScheme4_Background = TColor($00252525);
34 clScheme5_Background = TColor($0000172E);
35 clScheme6_Background = TColor($0000004E);
36 clScheme7_Background = TColor($0038004E);
37 clScheme8_Background = TColor($004E002D);
38 clScheme9_Background = TColor($0068001F);
39 clScheme10_Background = TColor($004E1E00);
40 clScheme11_Background = TColor($00604D00);
41 clScheme12_Background = TColor($00004A00);
42 clScheme13_Background = TColor($002A9915);
43 clScheme14_Background = TColor($00196CE5);
44 clScheme15_Background = TColor($001B1BB8);
45 clScheme16_Background = TColor($006C1BB8);
46 clScheme17_Background = TColor($00B81B69);
47 clScheme18_Background = TColor($00B8581B);
48 clScheme19_Background = TColor($00E39C56);
49 clScheme20_Background = TColor($00AAAA00);
50 clScheme21_Background = TColor($001FBA83);
51 clScheme22_Background = TColor($00099DD3);
52 clScheme23_Background = TColor($00B764E0);
53 clScheme24_Background = TColor($00696969);
54 clScheme25_Background = TColor($00696969);
55 {Windows 8 Color Scheme - Selection}
56 clScheme1_Selection = TColor($0000B3F4);
57 clScheme2_Selection = TColor($0000BA78);
58 clScheme3_Selection = TColor($00EC7326);
59 clScheme4_Selection = TColor($003D11AE);
60 clScheme5_Selection = TColor($00002F63);
61 clScheme6_Selection = TColor($00001EB0);
62 clScheme7_Selection = TColor($004F00C1);
63 clScheme8_Selection = TColor($00AC0072);
64 clScheme9_Selection = TColor($00B41746);
65 clScheme10_Selection = TColor($00C16A00);
66 clScheme11_Selection = TColor($00878200);
67 clScheme12_Selection = TColor($00009919);
68 clScheme13_Selection = TColor($003FC100);
69 clScheme14_Selection = TColor($001D98FF);
70 clScheme15_Selection = TColor($00122EFF);
71 clScheme16_Selection = TColor($00771DFF);
72 clScheme17_Selection = TColor($00FF40AA);
73 clScheme18_Selection = TColor($00FFAE1F);
74 clScheme19_Selection = TColor($00FFC556);
75 clScheme20_Selection = TColor($00CCD800);
76 clScheme21_Selection = TColor($0000D191);
77 clScheme22_Selection = TColor($0000B7E1);
78 clScheme23_Selection = TColor($00BC76FF);
79 clScheme24_Selection = TColor($00A4A400);
80 clScheme25_Selection = TColor($00237DFF);
81
82type
83 TBCSampleStyle = (ssDefault, ssWindows7, ssWindows7ToolBar, ssOffice2010,
84 ssFlashPlayer, ssMacOSXLion, ssWindows8_1, ssWindows8_2, ssWindows8_3,
85 ssWindows8_4, ssWindows8_5, ssWindows8_6, ssWindows8_7, ssWindows8_8,
86 ssWindows8_9, ssWindows8_10, ssWindows8_11, ssWindows8_12, ssWindows8_13,
87 ssWindows8_14, ssWindows8_15, ssWindows8_16, ssWindows8_17, ssWindows8_18,
88 ssWindows8_19, ssWindows8_20, ssWindows8_21, ssWindows8_22, ssWindows8_23,
89 ssWindows8_24, ssWindows8_25);
90
91 TBCSampleDrawing = (sdDefault, sdFlashPlayerBody, sdFlashPlayerButtonPanel,
92 sdWindows7Toolbar, sdiOSBar, sdiOSToolBar, sdiOSBackground,
93 sdWindows8_1, sdWindows8_2, sdWindows8_3,
94 sdWindows8_4, sdWindows8_5, sdWindows8_6, sdWindows8_7, sdWindows8_8,
95 sdWindows8_9, sdWindows8_10, sdWindows8_11, sdWindows8_12, sdWindows8_13,
96 sdWindows8_14, sdWindows8_15, sdWindows8_16, sdWindows8_17, sdWindows8_18,
97 sdWindows8_19, sdWindows8_20, sdWindows8_21, sdWindows8_22, sdWindows8_23,
98 sdWindows8_24, sdWindows8_25);
99
100const
101 BCSampleStyleStr: array[TBCSampleStyle] of string =
102 ('Default', 'Windows 7', 'Windows 7 ToolBar', 'Office 2010',
103 'Flash Player', 'Mac OSX Lion', 'Windows 8 Scheme 1', 'Windows 8 Scheme 2',
104 'Windows 8 Scheme 3', 'Windows 8 Scheme 4', 'Windows 8 Scheme 5'
105 , 'Windows 8 Scheme 6', 'Windows 8 Scheme 7', 'Windows 8 Scheme 8'
106 , 'Windows 8 Scheme 9', 'Windows 8 Scheme 10', 'Windows 8 Scheme 11'
107 , 'Windows 8 Scheme 12', 'Windows 8 Scheme 13', 'Windows 8 Scheme 14'
108 , 'Windows 8 Scheme 15', 'Windows 8 Scheme 16', 'Windows 8 Scheme 17'
109 , 'Windows 8 Scheme 18', 'Windows 8 Scheme 19', 'Windows 8 Scheme 20'
110 , 'Windows 8 Scheme 21', 'Windows 8 Scheme 22', 'Windows 8 Scheme 23'
111 , 'Windows 8 Scheme 24', 'Windows 8 Scheme 25');
112
113 BCSampleDrawingStr: array[TBCSampleDrawing] of string =
114 ('Default', 'Flash Player Body', 'Flash Player Button Panel',
115 'Windows 7 ToolBar', 'iOS Bar', 'iOS ToolBar', 'iOS Background',
116 'Windows 8 Scheme 1', 'Windows 8 Scheme 2',
117 'Windows 8 Scheme 3', 'Windows 8 Scheme 4', 'Windows 8 Scheme 5'
118 , 'Windows 8 Scheme 6', 'Windows 8 Scheme 7', 'Windows 8 Scheme 8'
119 , 'Windows 8 Scheme 9', 'Windows 8 Scheme 10', 'Windows 8 Scheme 11'
120 , 'Windows 8 Scheme 12', 'Windows 8 Scheme 13', 'Windows 8 Scheme 14'
121 , 'Windows 8 Scheme 15', 'Windows 8 Scheme 16', 'Windows 8 Scheme 17'
122 , 'Windows 8 Scheme 18', 'Windows 8 Scheme 19', 'Windows 8 Scheme 20'
123 , 'Windows 8 Scheme 21', 'Windows 8 Scheme 22', 'Windows 8 Scheme 23'
124 , 'Windows 8 Scheme 24', 'Windows 8 Scheme 25');
125
126function StrToTBCSampleStyle(const s: ansistring): TBCSampleStyle;
127procedure BCSampleStyleStrList(s: TStrings);
128
129function StrToTBCSampleDrawing(const s: ansistring): TBCSampleDrawing;
130procedure BCSampleDrawingStrList(s: TStrings);
131
132procedure StyleButtons(AControl: TControl; AButton: TBCButton);
133procedure StyleButtonsSample(AControl: TControl; AStyle: TBCSampleStyle);
134
135procedure DrawSample(ABitmap: TBGRABitmap; Element: TBCSampleDrawing;
136 Align: TAlign = alNone);
137function DrawSample(AWidth, AHeight: integer; Element: TBCSampleDrawing;
138 Align: TAlign = alNone): TBGRABitmap;
139procedure DrawItem(Control: TWinControl; Index: integer; ARect: TRect;
140 State: TOwnerDrawState; Style: TBCSampleDrawing);
141
142{ Buttons }
143procedure BCButtonWindows7(AButton: TBCButton);
144procedure BCButtonWindows7ToolBar(AButton: TBCButton);
145procedure BCButtonOffice2010(AButton: TBCButton);
146procedure BCButtonFlashPlayer(AButton: TBCButton);
147procedure BCButtonMacOSXLion(AButton: TBCButton);
148procedure BCButtonWindows8(AButton: TBCButton; cl1, cl2: TColor);
149
150{ Drawings }
151procedure DrawFlashPlayerBody(ABitmap: TBGRABitmap);
152procedure DrawFlashPlayerButtonPanel(ABitmap: TBGRABitmap);
153procedure DrawWindows7ToolBar(ABitmap: TBGRABitmap; ADir: TAlign;
154 Smooth: boolean = False);
155procedure DrawiOSBar(ABitmap: TBGRABitmap);
156procedure DrawiOSToolBar(ABitmap: TBGRABitmap; Shadow: boolean = True);
157procedure DrawiOSBackground(ABitmap: TBGRABitmap);
158procedure DrawWindows8Background(ABitmap: TBGRABitmap; cl1, cl2: TColor);
159
160implementation
161
162function StrToTBCSampleStyle(const s: ansistring): TBCSampleStyle;
163var
164 ss: TBCSampleStyle;
165 ls: ansistring;
166begin
167 Result := ssDefault;
168 ls := UTF8LowerCase(s);
169 for ss := low(TBCSampleStyle) to high(TBCSampleStyle) do
170 if ls = UTF8LowerCase(BCSampleStyleStr[ss]) then
171 begin
172 Result := ss;
173 break;
174 end;
175end;
176
177procedure BCSampleStyleStrList(s: TStrings);
178var
179 ss: TBCSampleStyle;
180begin
181 for ss := low(TBCSampleStyle) to high(TBCSampleStyle) do
182 s.Add(BCSampleStyleStr[ss]);
183end;
184
185procedure StyleButtons(AControl: TControl; AButton: TBCButton);
186var
187 i: integer;
188 WinControl: TWinControl;
189begin
190 if AControl is TBCButton then
191 with AControl as TBCButton do
192 begin
193 // Those are recomended properties to keep unchanged
194 AButton.Glyph := Glyph;
195 AButton.GlyphMargin := GlyphMargin;
196 AButton.StaticButton := StaticButton;
197 AButton.Down := Down;
198 AButton.Style := Style;
199 Assign(AButton);
200 end;
201 if AControl is TWinControl then
202 begin
203 WinControl := TWinControl(AControl);
204 if WinControl.ControlCount = 0 then
205 exit;
206 for i := 0 to WinControl.ControlCount - 1 do
207 StyleButtons(WinControl.Controls[i], AButton);
208 end;
209end;
210
211procedure StyleButtonsSample(AControl: TControl; AStyle: TBCSampleStyle);
212var
213 temp: TBCButton;
214begin
215 temp := TBCButton.Create(nil);
216 case AStyle of
217 ssWindows7: BCButtonWindows7(temp);
218 ssWindows7ToolBar: BCButtonWindows7ToolBar(temp);
219 ssOffice2010: BCButtonOffice2010(temp);
220 ssFlashPlayer: BCButtonFlashPlayer(temp);
221 ssMacOSXLion: BCButtonMacOSXLion(temp);
222 ssWindows8_1: BCButtonWindows8(temp, clScheme1_Background, clScheme1_Selection);
223 ssWindows8_2: BCButtonWindows8(temp, clScheme2_Background, clScheme2_Selection);
224 ssWindows8_3: BCButtonWindows8(temp, clScheme3_Background, clScheme3_Selection);
225 ssWindows8_4: BCButtonWindows8(temp, clScheme4_Background, clScheme4_Selection);
226 ssWindows8_5: BCButtonWindows8(temp, clScheme5_Background, clScheme5_Selection);
227 ssWindows8_6: BCButtonWindows8(temp, clScheme6_Background, clScheme6_Selection);
228 ssWindows8_7: BCButtonWindows8(temp, clScheme7_Background, clScheme7_Selection);
229 ssWindows8_8: BCButtonWindows8(temp, clScheme8_Background, clScheme8_Selection);
230 ssWindows8_9: BCButtonWindows8(temp, clScheme9_Background, clScheme9_Selection);
231 ssWindows8_10: BCButtonWindows8(temp, clScheme10_Background, clScheme10_Selection);
232 ssWindows8_11: BCButtonWindows8(temp, clScheme11_Background, clScheme11_Selection);
233 ssWindows8_12: BCButtonWindows8(temp, clScheme12_Background, clScheme12_Selection);
234 ssWindows8_13: BCButtonWindows8(temp, clScheme13_Background, clScheme13_Selection);
235 ssWindows8_14: BCButtonWindows8(temp, clScheme14_Background, clScheme14_Selection);
236 ssWindows8_15: BCButtonWindows8(temp, clScheme15_Background, clScheme15_Selection);
237 ssWindows8_16: BCButtonWindows8(temp, clScheme16_Background, clScheme16_Selection);
238 ssWindows8_17: BCButtonWindows8(temp, clScheme17_Background, clScheme17_Selection);
239 ssWindows8_18: BCButtonWindows8(temp, clScheme18_Background, clScheme18_Selection);
240 ssWindows8_19: BCButtonWindows8(temp, clScheme19_Background, clScheme19_Selection);
241 ssWindows8_20: BCButtonWindows8(temp, clScheme20_Background, clScheme20_Selection);
242 ssWindows8_21: BCButtonWindows8(temp, clScheme21_Background, clScheme21_Selection);
243 ssWindows8_22: BCButtonWindows8(temp, clScheme22_Background, clScheme22_Selection);
244 ssWindows8_23: BCButtonWindows8(temp, clScheme23_Background, clScheme23_Selection);
245 ssWindows8_24: BCButtonWindows8(temp, clScheme24_Background, clScheme24_Selection);
246 ssWindows8_25: BCButtonWindows8(temp, clScheme25_Background, clScheme25_Selection);
247 end;
248 StyleButtons(AControl, temp);
249 temp.Free;
250end;
251
252procedure DrawItem(Control: TWinControl; Index: integer; ARect: TRect;
253 State: TOwnerDrawState; Style: TBCSampleDrawing);
254var
255 temp: TBGRABitmap;
256 str: string;
257begin
258 if Control is TListBox then
259 str := TListBox(Control).Items[Index]
260 else if Control is TComboBox then
261 str := TComboBox(Control).Items[Index];
262
263 temp := TBGRABitmap.Create(ARect.Right - ARect.Left, ARect.Bottom -
264 ARect.Top, Control.Color);
265
266 temp.FontAntialias := True;
267 temp.FontHeight := 0;
268 temp.FontQuality := fqSystemClearType;
269
270 if odSelected in State then
271 DrawSample(temp, Style, alNone);
272
273 temp.TextOut(2, 0, str, BGRABlack);
274
275 if Control is TListBox then
276 temp.Draw(TListBox(Control).Canvas, ARect, False)
277 else if Control is TComboBox then
278 temp.Draw(TComboBox(Control).Canvas, ARect, False);
279
280 temp.Free;
281end;
282
283procedure BCButtonWindows7(AButton: TBCButton);
284begin
285 AButton.Rounding.RoundX := 3;
286 AButton.Rounding.RoundY := 3;
287 AButton.RoundingDropDown.Assign(AButton.Rounding);
288
289 with AButton.StateNormal do
290 begin
291 Background.Gradient1EndPercent := 50;
292 Background.Gradient2.Point1XPercent := 0;
293 Background.Gradient2.Point1YPercent := 0;
294 Background.Gradient2.Point2YPercent := 100;
295 Background.Gradient2.GradientType := gtLinear;
296 Border.Color := RGBToColor(112, 112, 112);
297 Border.LightWidth := 1;
298 Border.LightOpacity := 175;
299 Border.Style := bboSolid;
300 FontEx.Color := clBlack;
301 FontEx.Shadow := False;
302 FontEx.Style := [];
303 end;
304
305 AButton.StateHover.Assign(AButton.StateNormal);
306 AButton.StateClicked.Assign(AButton.StateNormal);
307
308 with AButton.StateNormal do
309 begin
310 Background.Gradient1.StartColor := RGBToColor(242, 242, 242);
311 Background.Gradient1.EndColor := RGBToColor(235, 235, 235);
312 Background.Gradient2.StartColor := RGBToColor(221, 221, 221);
313 Background.Gradient2.EndColor := RGBToColor(207, 207, 207);
314 end;
315
316 with AButton.StateHover do
317 begin
318 Background.Gradient1.StartColor := RGBToColor(234, 246, 253);
319 Background.Gradient1.EndColor := RGBToColor(217, 240, 252);
320 Background.Gradient2.StartColor := RGBToColor(190, 230, 253);
321 Background.Gradient2.EndColor := RGBToColor(167, 217, 245);
322 Border.Color := RGBToColor(60, 127, 177);
323 end;
324
325 with AButton.StateClicked do
326 begin
327 Background.Gradient1.StartColor := RGBToColor(229, 244, 252);
328 Background.Gradient1.EndColor := RGBToColor(196, 229, 246);
329 Background.Gradient2.StartColor := RGBToColor(152, 209, 239);
330 Background.Gradient2.EndColor := RGBToColor(104, 179, 219);
331 Background.Gradient1EndPercent := 55;
332 Border.Color := RGBToColor(44, 98, 139);
333 Border.LightOpacity := 100;
334 Border.LightColor := clBlack;
335 end;
336end;
337
338procedure BCButtonWindows7ToolBar(AButton: TBCButton);
339begin
340 AButton.Rounding.RoundX := 2;
341 AButton.Rounding.RoundY := 2;
342 AButton.RoundingDropDown.Assign(AButton.Rounding);
343
344 with AButton.StateNormal do
345 begin
346 Background.Gradient1EndPercent := 50;
347 Background.Gradient2.Point1XPercent := 0;
348 Background.Gradient2.Point1YPercent := 0;
349 Background.Gradient2.Point2YPercent := 100;
350 Background.Gradient2.GradientType := gtLinear;
351 Border.Color := RGBToColor(187, 202, 219);
352 Border.LightWidth := 1;
353 Border.LightOpacity := 200;
354 Border.Style := bboSolid;
355 FontEx.Color := RGBToColor(30, 57, 91);
356 FontEx.Shadow := False;
357 FontEx.Style := [];
358 end;
359
360 AButton.StateHover.Assign(AButton.StateNormal);
361 AButton.StateClicked.Assign(AButton.StateNormal);
362
363 with AButton.StateNormal do
364 begin
365 Background.Gradient1.StartColor := RGBToColor(245, 250, 255);
366 Background.Gradient1.EndColor := RGBToColor(230, 240, 250);
367 Background.Gradient2.StartColor := RGBToColor(220, 230, 244);
368 Background.Gradient2.EndColor := RGBToColor(221, 233, 247);
369 end;
370
371 with AButton.StateHover do
372 begin
373 Background.Gradient1.StartColor := RGBToColor(248, 251, 254);
374 Background.Gradient1.EndColor := RGBToColor(237, 242, 250);
375 Background.Gradient2.StartColor := RGBToColor(215, 228, 244);
376 Background.Gradient2.EndColor := RGBToColor(193, 210, 232);
377 end;
378
379 with AButton.StateClicked do
380 begin
381 Background.Gradient1.StartColor := RGBToColor(226, 236, 245);
382 Background.Gradient1.EndColor := RGBToColor(216, 228, 241);
383 Background.Gradient2.StartColor := RGBToColor(207, 219, 236);
384 Background.Gradient2.EndColor := RGBToColor(207, 220, 237);
385 end;
386end;
387
388procedure BCButtonOffice2010(AButton: TBCButton);
389begin
390 AButton.Rounding.RoundX := 3;
391 AButton.Rounding.RoundY := 3;
392 AButton.RoundingDropDown.Assign(AButton.Rounding);
393
394 with AButton.StateNormal do
395 begin
396 Background.Gradient1EndPercent := 50;
397 Background.Gradient2.Point1XPercent := 0;
398 Background.Gradient2.Point1YPercent := 0;
399 Background.Gradient2.Point2YPercent := 100;
400 Background.Gradient2.GradientType := gtLinear;
401 Border.Color := RGBToColor(207, 208, 210);
402 Border.LightWidth := 1;
403 Border.LightOpacity := 175;
404 Border.Style := bboSolid;
405 FontEx.Color := clBlack;
406 FontEx.Shadow := False;
407 FontEx.Style := [];
408 end;
409
410 AButton.StateHover.Assign(AButton.StateNormal);
411 AButton.StateClicked.Assign(AButton.StateNormal);
412
413 with AButton.StateNormal do
414 begin
415 Background.Gradient1.StartColor := RGBToColor(255, 255, 255);
416 Background.Gradient1.EndColor := RGBToColor(237, 239, 241);
417 Background.Gradient1EndPercent := 100;
418 end;
419
420 with AButton.StateHover do
421 begin
422 Background.Gradient1.StartColor := RGBToColor(254, 241, 189);
423 Background.Gradient1.EndColor := RGBToColor(254, 228, 134);
424 Background.Gradient2.StartColor := RGBToColor(254, 228, 134);
425 Background.Gradient2.EndColor := RGBToColor(254, 248, 196);
426 Border.Color := RGBToColor(244, 210, 81);
427 end;
428
429 with AButton.StateClicked do
430 begin
431 Background.Gradient1.StartColor := RGBToColor(255, 229, 117);
432 Background.Gradient1.EndColor := RGBToColor(255, 216, 107);
433 Background.Gradient2.StartColor := RGBToColor(255, 216, 107);
434 Background.Gradient2.EndColor := RGBToColor(255, 239, 129);
435 Border.Color := RGBToColor(194, 161, 63);
436 Border.LightWidth := 0;
437 end;
438end;
439
440procedure BCButtonFlashPlayer(AButton: TBCButton);
441begin
442 AButton.Rounding.RoundX := 1;
443 AButton.Rounding.RoundY := 1;
444 AButton.RoundingDropDown.Assign(AButton.Rounding);
445
446 with AButton.StateNormal do
447 begin
448 Background.Gradient1EndPercent := 50;
449 Background.Gradient2.Point1XPercent := 0;
450 Background.Gradient2.Point1YPercent := 0;
451 Background.Gradient2.Point2YPercent := 100;
452 Background.Gradient2.GradientType := gtLinear;
453 Border.Color := RGBToColor(24, 24, 24);
454 Border.LightWidth := 1;
455 Border.LightOpacity := 20;
456 Border.Style := bboSolid;
457 FontEx.Color := clWhite;
458 FontEx.Shadow := True;
459 FontEx.ShadowRadius := 1;
460 FontEx.ShadowOffsetX := 1;
461 FontEx.ShadowOffsetY := 1;
462 FontEx.Style := [];
463 end;
464
465 AButton.StateHover.Assign(AButton.StateNormal);
466 AButton.StateClicked.Assign(AButton.StateNormal);
467
468 with AButton.StateNormal do
469 begin
470 Background.Gradient1.StartColor := RGBToColor(104, 104, 104);
471 Background.Gradient1.EndColor := RGBToColor(104, 104, 104);
472 Background.Gradient2.StartColor := RGBToColor(103, 103, 103);
473 Background.Gradient2.EndColor := RGBToColor(71, 71, 71);
474 end;
475
476 with AButton.StateHover do
477 begin
478 Background.Gradient1.StartColor := RGBToColor(118, 118, 118);
479 Background.Gradient1.EndColor := RGBToColor(118, 118, 118);
480 Background.Gradient2.StartColor := RGBToColor(117, 117, 117);
481 Background.Gradient2.EndColor := RGBToColor(81, 81, 81);
482 Border.Color := RGBToColor(24, 24, 24);
483 end;
484
485 with AButton.StateClicked do
486 begin
487 Background.Gradient1.StartColor := RGBToColor(92, 92, 92);
488 Background.Gradient1.EndColor := RGBToColor(92, 92, 92);
489 Background.Gradient2.StartColor := RGBToColor(91, 91, 91);
490 Background.Gradient2.EndColor := RGBToColor(62, 62, 62);
491 Background.Gradient1EndPercent := 55;
492 Border.Color := RGBToColor(24, 24, 24);
493 end;
494end;
495
496procedure BCButtonMacOSXLion(AButton: TBCButton);
497begin
498 AButton.Rounding.RoundX := 3;
499 AButton.Rounding.RoundY := 3;
500 AButton.RoundingDropDown.Assign(AButton.Rounding);
501
502 with AButton.StateNormal do
503 begin
504 Background.Gradient1EndPercent := 50;
505 Background.Gradient2.Point1XPercent := 0;
506 Background.Gradient2.Point1YPercent := 0;
507 Background.Gradient2.Point2YPercent := 100;
508 Background.Gradient2.GradientType := gtLinear;
509 Border.Color := RGBToColor(154, 154, 154);
510 Border.LightWidth := 1;
511 Border.LightOpacity := 175;
512 Border.Style := bboSolid;
513 FontEx.Color := clBlack;
514 FontEx.Shadow := False;
515 FontEx.Style := [];
516 end;
517
518 AButton.StateHover.Assign(AButton.StateNormal);
519 AButton.StateClicked.Assign(AButton.StateNormal);
520
521 with AButton.StateNormal do
522 begin
523 Background.Gradient1.StartColor := RGBToColor(255, 255, 255);
524 Background.Gradient1.EndColor := RGBToColor(243, 243, 243);
525 Background.Gradient2.StartColor := RGBToColor(236, 236, 236);
526 Background.Gradient2.EndColor := RGBToColor(235, 235, 235);
527 end;
528
529 with AButton.StateHover do
530 begin
531 Background.Gradient1.StartColor := RGBToColor(204, 229, 252);
532 Background.Gradient1.EndColor := RGBToColor(161, 209, 249);
533 Background.Gradient2.StartColor := RGBToColor(143, 202, 251);
534 Background.Gradient2.EndColor := RGBToColor(207, 245, 253);
535 Border.Color := RGBToColor(86, 87, 143);
536 end;
537
538 with AButton.StateClicked do
539 begin
540 Background.Gradient1.StartColor := RGBToColor(144, 195, 241);
541 Background.Gradient1.EndColor := RGBToColor(113, 180, 239);
542 Background.Gradient2.StartColor := RGBToColor(97, 173, 240);
543 Background.Gradient2.EndColor := RGBToColor(147, 206, 241);
544 Background.Gradient1EndPercent := 55;
545 Border.Color := RGBToColor(86, 87, 143);
546 Border.LightWidth := 0;
547 end;
548end;
549
550procedure BCButtonWindows8(AButton: TBCButton; cl1, cl2: TColor);
551begin
552 AButton.Rounding.RoundX := 1;
553 AButton.Rounding.RoundY := 1;
554 AButton.RoundingDropDown.Assign(AButton.Rounding);
555
556 with AButton.StateNormal do
557 begin
558 Background.Style := bbsColor;
559 Background.Color := cl1;
560 Border.Style := bboSolid;
561 Border.Width := 1;
562 Border.Color := cl1;
563 Border.LightWidth := 0;
564 Border.LightOpacity := 255;
565 Border.Style := bboSolid;
566 FontEx.Color := clWhite;
567 FontEx.Shadow := False;
568 FontEx.Style := [];
569 end;
570
571 AButton.StateHover.Assign(AButton.StateNormal);
572 AButton.StateClicked.Assign(AButton.StateNormal);
573
574 with AButton.StateHover do
575 begin
576 Background.Color := cl2;
577 Border.Color := cl2;
578 end;
579
580 with AButton.StateClicked do
581 begin
582 Background.Color := cl2;
583 Border.Color := cl2;
584 end;
585end;
586
587procedure DrawFlashPlayerBody(ABitmap: TBGRABitmap);
588begin
589 with ABitmap do
590 begin
591 GradientFill(0, 0, Width, Height, BGRA(203, 19, 23, 255), BGRA(110, 3, 20, 255),
592 gtLinear, PointF(0, 0), PointF(0, Height), dmSet);
593 Rectangle(0, 0, Width, Height + 1, BGRA(0, 0, 0, 215), dmDrawWithTransparency);
594 end;
595end;
596
597procedure DrawFlashPlayerButtonPanel(ABitmap: TBGRABitmap);
598begin
599 with ABitmap do
600 begin
601 DrawHorizLine(0, 0, Width, BGRA(30, 30, 30, 255));
602 DrawHorizLine(0, Height - 1, Width, BGRA(62, 62, 62, 255));
603 Rectangle(0, 1, Width, Height - 1, BGRA(91, 91, 91, 255),
604 BGRA(76, 76, 76, 255), dmSet);
605 end;
606end;
607
608procedure DrawWindows7ToolBar(ABitmap: TBGRABitmap; ADir: TAlign;
609 Smooth: boolean = False);
610var
611 tempBmp: TBGRABitmap;
612begin
613 if Smooth then
614 tempBmp := DoubleGradientAlphaFill(Rect(0, 0, ABitmap.Width, ABitmap.Height),
615 BGRA(245, 249, 255, 255), BGRA(222, 232, 245, 255), BGRA(220, 230, 245, 255),
616 BGRA(222, 230, 245, 255), gdVertical, gdVertical, gdVertical, 0.50)
617 else
618 tempBmp := DoubleGradientAlphaFill(Rect(0, 0, ABitmap.Width, ABitmap.Height),
619 BGRA(245, 250, 255, 255), BGRA(230, 240, 250, 255), BGRA(220, 230, 244, 255),
620 BGRA(221, 233, 247, 255), gdVertical, gdVertical, gdVertical, 0.50);
621
622 ABitmap.PutImage(0, 0, tempBmp, dmSet);
623 tempBmp.Free;
624
625 case ADir of
626 alLeft: with ABitmap do
627 begin
628 if not Smooth then
629 Rectangle(0, 0, Width - 2, Height, BGRA(255, 255, 255, 100),
630 dmDrawWithTransparency);
631 SetVertLine(Width - 1, 0, Height - 1, BGRA(160, 175, 195, 255));
632 SetVertLine(Width - 2, 0, Height - 1, BGRA(205, 218, 234, 255));
633 end;
634 alTop: with ABitmap do
635 begin
636 if not Smooth then
637 Rectangle(0, 0, Width, Height - 2, BGRA(255, 255, 255, 100),
638 dmDrawWithTransparency);
639 SetHorizLine(0, Height - 1, Width - 1, BGRA(160, 175, 195, 255));
640 SetHorizLine(0, Height - 2, Width - 1, BGRA(205, 218, 234, 255));
641 end;
642 alRight: with ABitmap do
643 begin
644 if not Smooth then
645 Rectangle(2, 0, Width, Height, BGRA(255, 255, 255, 100),
646 dmDrawWithTransparency);
647 SetVertLine(0, 0, Height, BGRA(160, 175, 195, 255));
648 SetVertLine(1, 0, Height, BGRA(205, 218, 234, 255));
649 end;
650 alBottom: with ABitmap do
651 begin
652 if not Smooth then
653 Rectangle(0, 2, Width, Height, BGRA(255, 255, 255, 100),
654 dmDrawWithTransparency);
655 SetHorizLine(0, 0, Width - 1, BGRA(160, 175, 195, 255));
656 SetHorizLine(0, 1, Width - 1, BGRA(205, 218, 234, 255));
657 end;
658 alClient, alCustom, alNone: with ABitmap do
659 begin
660 if not Smooth then
661 Rectangle(0, 0, Width, Height, BGRA(255, 255, 255, 100),
662 dmDrawWithTransparency);
663 end;
664 end;
665end;
666
667function StrToTBCSampleDrawing(const s: ansistring): TBCSampleDrawing;
668var
669 ss: TBCSampleDrawing;
670 ls: ansistring;
671begin
672 Result := sdDefault;
673 ls := UTF8LowerCase(s);
674 for ss := low(TBCSampleDrawing) to high(TBCSampleDrawing) do
675 if ls = UTF8LowerCase(BCSampleDrawingStr[ss]) then
676 begin
677 Result := ss;
678 break;
679 end;
680end;
681
682procedure BCSampleDrawingStrList(s: TStrings);
683var
684 ss: TBCSampleDrawing;
685begin
686 for ss := low(TBCSampleDrawing) to high(TBCSampleDrawing) do
687 s.Add(BCSampleDrawingStr[ss]);
688end;
689
690procedure DrawSample(ABitmap: TBGRABitmap; Element: TBCSampleDrawing;
691 Align: TAlign = alNone);
692begin
693 case Element of
694 sdFlashPlayerBody: DrawFlashPlayerBody(ABitmap);
695 sdFlashPlayerButtonPanel: DrawFlashPlayerButtonPanel(ABitmap);
696 sdWindows7Toolbar: DrawWindows7ToolBar(ABitmap, Align);
697 sdiOSBar: DrawiOSBar(ABitmap);
698 sdiOSToolBar: DrawiOSToolBar(ABitmap, False);
699 sdiOSBackground: DrawiOSBackground(ABitmap);
700 sdWindows8_1: DrawWindows8Background(ABitmap, clScheme1_Background,
701 clScheme1_Selection);
702 sdWindows8_2: DrawWindows8Background(ABitmap, clScheme2_Background,
703 clScheme2_Selection);
704 sdWindows8_3: DrawWindows8Background(ABitmap, clScheme3_Background,
705 clScheme3_Selection);
706 sdWindows8_4: DrawWindows8Background(ABitmap, clScheme4_Background,
707 clScheme4_Selection);
708 sdWindows8_5: DrawWindows8Background(ABitmap, clScheme5_Background,
709 clScheme5_Selection);
710 sdWindows8_6: DrawWindows8Background(ABitmap, clScheme6_Background,
711 clScheme6_Selection);
712 sdWindows8_7: DrawWindows8Background(ABitmap, clScheme7_Background,
713 clScheme7_Selection);
714 sdWindows8_8: DrawWindows8Background(ABitmap, clScheme8_Background,
715 clScheme8_Selection);
716 sdWindows8_9: DrawWindows8Background(ABitmap, clScheme9_Background,
717 clScheme9_Selection);
718 sdWindows8_10: DrawWindows8Background(ABitmap, clScheme10_Background,
719 clScheme10_Selection);
720 sdWindows8_11: DrawWindows8Background(ABitmap, clScheme11_Background,
721 clScheme11_Selection);
722 sdWindows8_12: DrawWindows8Background(ABitmap, clScheme12_Background,
723 clScheme12_Selection);
724 sdWindows8_13: DrawWindows8Background(ABitmap, clScheme13_Background,
725 clScheme13_Selection);
726 sdWindows8_14: DrawWindows8Background(ABitmap, clScheme14_Background,
727 clScheme14_Selection);
728 sdWindows8_15: DrawWindows8Background(ABitmap, clScheme15_Background,
729 clScheme15_Selection);
730 sdWindows8_16: DrawWindows8Background(ABitmap, clScheme16_Background,
731 clScheme16_Selection);
732 sdWindows8_17: DrawWindows8Background(ABitmap, clScheme17_Background,
733 clScheme17_Selection);
734 sdWindows8_18: DrawWindows8Background(ABitmap, clScheme18_Background,
735 clScheme18_Selection);
736 sdWindows8_19: DrawWindows8Background(ABitmap, clScheme19_Background,
737 clScheme19_Selection);
738 sdWindows8_20: DrawWindows8Background(ABitmap, clScheme20_Background,
739 clScheme20_Selection);
740 sdWindows8_21: DrawWindows8Background(ABitmap, clScheme21_Background,
741 clScheme21_Selection);
742 sdWindows8_22: DrawWindows8Background(ABitmap, clScheme22_Background,
743 clScheme22_Selection);
744 sdWindows8_23: DrawWindows8Background(ABitmap, clScheme23_Background,
745 clScheme23_Selection);
746 sdWindows8_24: DrawWindows8Background(ABitmap, clScheme24_Background,
747 clScheme24_Selection);
748 sdWindows8_25: DrawWindows8Background(ABitmap, clScheme25_Background,
749 clScheme25_Selection);
750 end;
751end;
752
753function DrawSample(AWidth, AHeight: integer; Element: TBCSampleDrawing;
754 Align: TAlign = alNone): TBGRABitmap;
755var
756 ABitmap: TBGRABitmap;
757begin
758 ABitmap := TBGRABitmap.Create(AWidth, AHeight);
759 DrawSample(ABitmap, Element, Align);
760 Result := ABitmap;
761end;
762
763procedure DrawiOSBar(ABitmap: TBGRABitmap);
764begin
765 ABitmap.GradientFill(0, 0, ABitmap.Width, ABitmap.Height - 4,
766 BGRA(238, 245, 248, 255), BGRA(196, 204, 208, 255), gtLinear,
767 PointF(0, 0), PointF(0, ABitmap.Height - 4), dmSet);
768 with ABitmap do
769 begin
770 // Bottom Bevel
771 SetHorizLine(0, Height - 4, Width - 1, BGRA(190, 198, 202, 255));
772 SetHorizLine(0, Height - 3, Width - 1, BGRA(201, 209, 213, 255));
773 SetHorizLine(0, Height - 2, Width - 1, BGRA(134, 142, 147, 255));
774 SetHorizLine(0, Height - 1, Width - 1, BGRA(177, 180, 182, 255));
775 end;
776end;
777
778procedure DrawiOSToolBar(ABitmap: TBGRABitmap; Shadow: boolean = True);
779begin
780 if Shadow then
781 begin
782 DoubleGradientAlphaFill(ABitmap, Rect(0, 3, ABitmap.Width, ABitmap.Height - 6),
783 BGRA(172, 185, 201), BGRA(134, 153, 178, 255),
784 BGRA(125, 147, 175, 255), BGRA(110, 132, 162, 255),
785 gdVertical, gdVertical, gdVertical, 0.5);
786 with ABitmap do
787 begin
788 // Top Bevel
789 SetHorizLine(0, 0, Width - 1, BGRA(201, 210, 221, 255));
790 SetHorizLine(0, 1, Width - 1, BGRA(173, 184, 200, 255));
791 SetHorizLine(0, 2, Width - 1, BGRA(179, 190, 205, 255));
792 // Bottom Bevel
793 SetHorizLine(0, Height - 6, Width - 1, BGRA(107, 129, 158, 255));
794 SetHorizLine(0, Height - 5, Width - 1, BGRA(116, 139, 170, 255));
795 SetHorizLine(0, Height - 4, Width - 1, BGRA(48, 54, 62, 255));
796 // Bottom Shadow
797 SetHorizLine(0, Height - 3, Width - 1, BGRA(0, 0, 0, 75));
798 SetHorizLine(0, Height - 2, Width - 1, BGRA(255, 255, 255, 50));
799 SetHorizLine(0, Height - 1, Width - 1, BGRA(0, 0, 0, 10));
800 end;
801 end
802 else
803 begin
804 DoubleGradientAlphaFill(ABitmap, Rect(0, 3, ABitmap.Width, ABitmap.Height - 3),
805 BGRA(172, 185, 201), BGRA(134, 153, 178, 255),
806 BGRA(125, 147, 175, 255), BGRA(110, 132, 162, 255),
807 gdVertical, gdVertical, gdVertical, 0.5);
808 with ABitmap do
809 begin
810 // Top Bevel
811 SetHorizLine(0, 0, Width - 1, BGRA(201, 210, 221, 255));
812 SetHorizLine(0, 1, Width - 1, BGRA(173, 184, 200, 255));
813 SetHorizLine(0, 2, Width - 1, BGRA(179, 190, 205, 255));
814 // Bottom Bevel
815 SetHorizLine(0, Height - 3, Width - 1, BGRA(107, 129, 158, 255));
816 SetHorizLine(0, Height - 2, Width - 1, BGRA(116, 139, 170, 255));
817 SetHorizLine(0, Height - 1, Width - 1, BGRA(48, 54, 62, 255));
818 end;
819 end;
820end;
821
822procedure DrawiOSBackground(ABitmap: TBGRABitmap);
823var
824 temp: TBGRABitmap;
825begin
826 temp := TBGRABitmap.Create(16, 1, BGRA(197, 204, 211));
827 with temp do
828 begin
829 SetPixel(7, 0, BGRA(203, 210, 217));
830 SetPixel(14, 0, BGRA(204, 211, 218));
831 BGRAReplace(temp, temp.FilterBlurRadial(1, rbFast));
832 BGRAReplace(temp, temp.FilterSharpen);
833 end;
834 ABitmap.Fill(temp);
835 temp.Free;
836end;
837
838procedure DrawWindows8Background(ABitmap: TBGRABitmap; cl1, cl2: TColor);
839begin
840 ABitmap.Fill(cl2);
841end;
842
843end.
Note: See TracBrowser for help on using the repository browser.