bcsamples.pas 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302
  1. // SPDX-License-Identifier: LGPL-3.0-linking-exception
  2. {******************************* CONTRIBUTOR(S) ******************************
  3. - Edivando S. Santos Brasil | [email protected]
  4. (Compatibility with delphi VCL 11/2018)
  5. ***************************** END CONTRIBUTOR(S) *****************************}
  6. unit BCSamples;
  7. {$I bgracontrols.inc}
  8. interface
  9. uses
  10. Classes, Controls, Graphics,
  11. {$IFDEF FPC}LCLProc, LCLType, LazUTF8,{$ENDIF}
  12. StdCtrls, BCButton, BCButtonFocus, BCTypes,
  13. {$IFNDEF FPC}Types, Windows, Sysutils, BGRAGraphics, GraphType, FPImage, {$ENDIF}
  14. BGRABitmap, BGRABitmapTypes, BGRAGradients, MaterialColors, BCBrightAndContrast;
  15. {$IFNDEF FPC}
  16. type
  17. TWinControlHack = class(TWinControl);
  18. {$ENDIF}
  19. const
  20. {Accent Colors}
  21. acMagenta = TColor($009700FF);
  22. acPurple = TColor($00FF00A2);
  23. acTeal = TColor($00A9AB00);
  24. acLime = TColor($0026BF8C);
  25. acBrown = TColor($000050A0);
  26. acPink = TColor($00B871E6);
  27. acOrange = TColor($000996F0);
  28. acBlue = TColor($00E2A11B);
  29. acRed = TColor($000014E5);
  30. acGreen = TColor($00339933);
  31. {Facebook Colors}
  32. fbBlue = TColor($00AA785F);
  33. fbGreen = TColor($004BA567);
  34. fbGray = TColor($00F8F8F8);
  35. {Windows 8 Color Scheme - Background}
  36. clScheme1_Background = TColor($00252525);
  37. clScheme2_Background = TColor($00252525);
  38. clScheme3_Background = TColor($00252525);
  39. clScheme4_Background = TColor($00252525);
  40. clScheme5_Background = TColor($0000172E);
  41. clScheme6_Background = TColor($0000004E);
  42. clScheme7_Background = TColor($0038004E);
  43. clScheme8_Background = TColor($004E002D);
  44. clScheme9_Background = TColor($0068001F);
  45. clScheme10_Background = TColor($004E1E00);
  46. clScheme11_Background = TColor($00604D00);
  47. clScheme12_Background = TColor($00004A00);
  48. clScheme13_Background = TColor($002A9915);
  49. clScheme14_Background = TColor($00196CE5);
  50. clScheme15_Background = TColor($001B1BB8);
  51. clScheme16_Background = TColor($006C1BB8);
  52. clScheme17_Background = TColor($00B81B69);
  53. clScheme18_Background = TColor($00B8581B);
  54. clScheme19_Background = TColor($00E39C56);
  55. clScheme20_Background = TColor($00AAAA00);
  56. clScheme21_Background = TColor($001FBA83);
  57. clScheme22_Background = TColor($00099DD3);
  58. clScheme23_Background = TColor($00B764E0);
  59. clScheme24_Background = TColor($00696969);
  60. clScheme25_Background = TColor($00696969);
  61. {Windows 8 Color Scheme - Selection}
  62. clScheme1_Selection = TColor($0000B3F4);
  63. clScheme2_Selection = TColor($0000BA78);
  64. clScheme3_Selection = TColor($00EC7326);
  65. clScheme4_Selection = TColor($003D11AE);
  66. clScheme5_Selection = TColor($00002F63);
  67. clScheme6_Selection = TColor($00001EB0);
  68. clScheme7_Selection = TColor($004F00C1);
  69. clScheme8_Selection = TColor($00AC0072);
  70. clScheme9_Selection = TColor($00B41746);
  71. clScheme10_Selection = TColor($00C16A00);
  72. clScheme11_Selection = TColor($00878200);
  73. clScheme12_Selection = TColor($00009919);
  74. clScheme13_Selection = TColor($003FC100);
  75. clScheme14_Selection = TColor($001D98FF);
  76. clScheme15_Selection = TColor($00122EFF);
  77. clScheme16_Selection = TColor($00771DFF);
  78. clScheme17_Selection = TColor($00FF40AA);
  79. clScheme18_Selection = TColor($00FFAE1F);
  80. clScheme19_Selection = TColor($00FFC556);
  81. clScheme20_Selection = TColor($00CCD800);
  82. clScheme21_Selection = TColor($0000D191);
  83. clScheme22_Selection = TColor($0000B7E1);
  84. clScheme23_Selection = TColor($00BC76FF);
  85. clScheme24_Selection = TColor($00A4A400);
  86. clScheme25_Selection = TColor($00237DFF);
  87. type
  88. TBCSampleStyle = (ssDefault, ssWindows7, ssWindows7ToolBar, ssOffice2010,
  89. ssFlashPlayer, ssMacOSXLion, ssWindows8_1, ssWindows8_2, ssWindows8_3,
  90. ssWindows8_4, ssWindows8_5, ssWindows8_6, ssWindows8_7, ssWindows8_8,
  91. ssWindows8_9, ssWindows8_10, ssWindows8_11, ssWindows8_12, ssWindows8_13,
  92. ssWindows8_14, ssWindows8_15, ssWindows8_16, ssWindows8_17, ssWindows8_18,
  93. ssWindows8_19, ssWindows8_20, ssWindows8_21, ssWindows8_22, ssWindows8_23,
  94. ssWindows8_24, ssWindows8_25, ssMaterialRed, ssMaterialPink, ssMaterialPurple,
  95. ssMaterialDeepPurple, ssMaterialIndigo, ssMaterialBlue, ssMaterialLightBlue,
  96. ssMaterialCyan, ssMaterialTeal, ssMaterialGreen, ssMaterialLightGreen,
  97. ssMaterialLime, ssMaterialYellow, ssMaterialAmber, ssMaterialOrange,
  98. ssMaterialDeepOrange, ssMaterialBrown, ssMaterialGrey, ssMaterialBlueGrey);
  99. TBCSampleDrawing = (sdDefault, sdFlashPlayerBody, sdFlashPlayerButtonPanel,
  100. sdWindows7Toolbar, sdiOSBar, sdiOSToolBar, sdiOSBackground,
  101. sdWindows8_1, sdWindows8_2, sdWindows8_3,
  102. sdWindows8_4, sdWindows8_5, sdWindows8_6, sdWindows8_7, sdWindows8_8,
  103. sdWindows8_9, sdWindows8_10, sdWindows8_11, sdWindows8_12, sdWindows8_13,
  104. sdWindows8_14, sdWindows8_15, sdWindows8_16, sdWindows8_17, sdWindows8_18,
  105. sdWindows8_19, sdWindows8_20, sdWindows8_21, sdWindows8_22, sdWindows8_23,
  106. sdWindows8_24, sdWindows8_25);
  107. const
  108. BCSampleStyleStr: array[TBCSampleStyle] of string =
  109. ('Default', 'Windows 7', 'Windows 7 ToolBar', 'Office 2010',
  110. 'Flash Player', 'Mac OSX Lion', 'Windows 8 Scheme 1', 'Windows 8 Scheme 2',
  111. 'Windows 8 Scheme 3', 'Windows 8 Scheme 4', 'Windows 8 Scheme 5'
  112. , 'Windows 8 Scheme 6', 'Windows 8 Scheme 7', 'Windows 8 Scheme 8'
  113. , 'Windows 8 Scheme 9', 'Windows 8 Scheme 10', 'Windows 8 Scheme 11'
  114. , 'Windows 8 Scheme 12', 'Windows 8 Scheme 13', 'Windows 8 Scheme 14'
  115. , 'Windows 8 Scheme 15', 'Windows 8 Scheme 16', 'Windows 8 Scheme 17'
  116. , 'Windows 8 Scheme 18', 'Windows 8 Scheme 19', 'Windows 8 Scheme 20'
  117. , 'Windows 8 Scheme 21', 'Windows 8 Scheme 22', 'Windows 8 Scheme 23'
  118. , 'Windows 8 Scheme 24', 'Windows 8 Scheme 25', 'Material Red', 'Material Pink',
  119. 'Material Purple', 'Material Deep Purple', 'Material Indigo', 'Material Blue',
  120. 'Material Light Blue', 'Material Cyan', 'Material Teal', 'Material Green',
  121. 'Material Light Green', 'Material Lime', 'Material Yellow', 'Material Amber',
  122. 'Material Orange', 'Material Deep Orange', 'Material Brown', 'Material Grey',
  123. 'Material Blue Grey');
  124. BCSampleDrawingStr: array[TBCSampleDrawing] of string =
  125. ('Default', 'Flash Player Body', 'Flash Player Button Panel',
  126. 'Windows 7 ToolBar', 'iOS Bar', 'iOS ToolBar', 'iOS Background',
  127. 'Windows 8 Scheme 1', 'Windows 8 Scheme 2',
  128. 'Windows 8 Scheme 3', 'Windows 8 Scheme 4', 'Windows 8 Scheme 5'
  129. , 'Windows 8 Scheme 6', 'Windows 8 Scheme 7', 'Windows 8 Scheme 8'
  130. , 'Windows 8 Scheme 9', 'Windows 8 Scheme 10', 'Windows 8 Scheme 11'
  131. , 'Windows 8 Scheme 12', 'Windows 8 Scheme 13', 'Windows 8 Scheme 14'
  132. , 'Windows 8 Scheme 15', 'Windows 8 Scheme 16', 'Windows 8 Scheme 17'
  133. , 'Windows 8 Scheme 18', 'Windows 8 Scheme 19', 'Windows 8 Scheme 20'
  134. , 'Windows 8 Scheme 21', 'Windows 8 Scheme 22', 'Windows 8 Scheme 23'
  135. , 'Windows 8 Scheme 24', 'Windows 8 Scheme 25');
  136. function StrToTBCSampleStyle(const s: ansistring): TBCSampleStyle;
  137. procedure BCSampleStyleStrList(s: TStrings);
  138. function StrToTBCSampleDrawing(const s: ansistring): TBCSampleDrawing;
  139. procedure BCSampleDrawingStrList(s: TStrings);
  140. procedure StyleButtons(AControl: TControl; AButton: TBCButton); overload;
  141. procedure StyleButtons(AControl: TControl; AButton: TBCButtonFocus); overload;
  142. procedure StyleButtonsSample(AControl: TControl; AStyle: TBCSampleStyle);
  143. procedure StyleButtonsFocusSample(AControl: TControl; AStyle: TBCSampleStyle);
  144. procedure DrawSample(ABitmap: TBGRABitmap; Element: TBCSampleDrawing;
  145. Align: TAlign = alNone); overload;
  146. function DrawSample(AWidth, AHeight: integer; Element: TBCSampleDrawing;
  147. Align: TAlign = alNone): TBGRABitmap; overload;
  148. procedure DrawItem(Control: TWinControl; Index: integer; ARect: TRect;
  149. State: TOwnerDrawState; Style: TBCSampleDrawing);
  150. { Buttons }
  151. procedure BCButtonWindows7(AButton: TBCButton); overload;
  152. procedure BCButtonWindows7ToolBar(AButton: TBCButton); overload;
  153. procedure BCButtonOffice2010(AButton: TBCButton); overload;
  154. procedure BCButtonFlashPlayer(AButton: TBCButton); overload;
  155. procedure BCButtonMacOSXLion(AButton: TBCButton); overload;
  156. procedure BCButtonWindows8(AButton: TBCButton; cl1, cl2: TColor; rounding: integer = 1); overload;
  157. procedure BCButtonWindows7(AButton: TBCButtonFocus); overload;
  158. procedure BCButtonWindows7ToolBar(AButton: TBCButtonFocus);overload;
  159. procedure BCButtonOffice2010(AButton: TBCButtonFocus);overload;
  160. procedure BCButtonFlashPlayer(AButton: TBCButtonFocus);overload;
  161. procedure BCButtonMacOSXLion(AButton: TBCButtonFocus);overload;
  162. procedure BCButtonWindows8(AButton: TBCButtonFocus; cl1, cl2: TColor;
  163. rounding: integer = 1); overload;
  164. { Drawings }
  165. procedure DrawFlashPlayerBody(ABitmap: TBGRABitmap);
  166. procedure DrawFlashPlayerButtonPanel(ABitmap: TBGRABitmap);
  167. procedure DrawWindows7ToolBar(ABitmap: TBGRABitmap; ADir: TAlign;
  168. Smooth: boolean = False);
  169. procedure DrawiOSBar(ABitmap: TBGRABitmap);
  170. procedure DrawiOSToolBar(ABitmap: TBGRABitmap; Shadow: boolean = True);
  171. procedure DrawiOSBackground(ABitmap: TBGRABitmap);
  172. procedure DrawWindows8Background(ABitmap: TBGRABitmap; {%H-}cl1, cl2: TColor);
  173. implementation
  174. function StrToTBCSampleStyle(const s: ansistring): TBCSampleStyle;
  175. var
  176. ss: TBCSampleStyle;
  177. ls: ansistring;
  178. begin
  179. Result := ssDefault;
  180. ls := {$IFDEF FPC}UTF8LowerCase{$ELSE}LowerCase{$ENDIF}(s);
  181. for ss := low(TBCSampleStyle) to high(TBCSampleStyle) do
  182. if ls = {$IFDEF FPC}UTF8LowerCase{$ELSE}LowerCase{$ENDIF}(BCSampleStyleStr[ss]) then
  183. begin
  184. Result := ss;
  185. break;
  186. end;
  187. end;
  188. procedure BCSampleStyleStrList(s: TStrings);
  189. var
  190. ss: TBCSampleStyle;
  191. begin
  192. for ss := low(TBCSampleStyle) to high(TBCSampleStyle) do
  193. s.Add(BCSampleStyleStr[ss]);
  194. end;
  195. procedure StyleButtons(AControl: TControl; AButton: TBCButton);
  196. var
  197. i: integer;
  198. WinControl: TWinControl;
  199. begin
  200. if AControl is TBCButton then
  201. with AControl as TBCButton do
  202. begin
  203. // Those are recomended properties to keep unchanged
  204. AButton.Glyph := Glyph;
  205. AButton.GlyphMargin := GlyphMargin;
  206. AButton.StaticButton := StaticButton;
  207. AButton.Down := Down;
  208. AButton.Style := Style;
  209. Assign(AButton);
  210. end;
  211. if AControl is TWinControl then
  212. begin
  213. WinControl := TWinControl(AControl);
  214. if WinControl.ControlCount = 0 then
  215. exit;
  216. for i := 0 to WinControl.ControlCount - 1 do
  217. StyleButtons(WinControl.Controls[i], AButton);
  218. end;
  219. end;
  220. procedure StyleButtons(AControl: TControl; AButton: TBCButtonFocus);
  221. var
  222. i: integer;
  223. WinControl: TWinControl;
  224. begin
  225. if AControl is TBCButtonFocus then
  226. with AControl as TBCButtonFocus do
  227. begin
  228. // Those are recomended properties to keep unchanged
  229. AButton.Glyph := Glyph;
  230. AButton.GlyphMargin := GlyphMargin;
  231. AButton.StaticButton := StaticButton;
  232. AButton.Down := Down;
  233. AButton.Style := Style;
  234. Assign(AButton);
  235. end;
  236. if AControl is TWinControl then
  237. begin
  238. WinControl := TWinControl(AControl);
  239. if WinControl.ControlCount = 0 then
  240. exit;
  241. for i := 0 to WinControl.ControlCount - 1 do
  242. StyleButtons(WinControl.Controls[i], AButton);
  243. end;
  244. end;
  245. procedure StyleButtonsSample(AControl: TControl; AStyle: TBCSampleStyle);
  246. var
  247. temp: TBCButton;
  248. begin
  249. temp := TBCButton.Create(nil);
  250. case AStyle of
  251. ssWindows7: BCButtonWindows7(temp);
  252. ssWindows7ToolBar: BCButtonWindows7ToolBar(temp);
  253. ssOffice2010: BCButtonOffice2010(temp);
  254. ssFlashPlayer: BCButtonFlashPlayer(temp);
  255. ssMacOSXLion: BCButtonMacOSXLion(temp);
  256. ssWindows8_1: BCButtonWindows8(temp, clScheme1_Background, clScheme1_Selection);
  257. ssWindows8_2: BCButtonWindows8(temp, clScheme2_Background, clScheme2_Selection);
  258. ssWindows8_3: BCButtonWindows8(temp, clScheme3_Background, clScheme3_Selection);
  259. ssWindows8_4: BCButtonWindows8(temp, clScheme4_Background, clScheme4_Selection);
  260. ssWindows8_5: BCButtonWindows8(temp, clScheme5_Background, clScheme5_Selection);
  261. ssWindows8_6: BCButtonWindows8(temp, clScheme6_Background, clScheme6_Selection);
  262. ssWindows8_7: BCButtonWindows8(temp, clScheme7_Background, clScheme7_Selection);
  263. ssWindows8_8: BCButtonWindows8(temp, clScheme8_Background, clScheme8_Selection);
  264. ssWindows8_9: BCButtonWindows8(temp, clScheme9_Background, clScheme9_Selection);
  265. ssWindows8_10: BCButtonWindows8(temp, clScheme10_Background, clScheme10_Selection);
  266. ssWindows8_11: BCButtonWindows8(temp, clScheme11_Background, clScheme11_Selection);
  267. ssWindows8_12: BCButtonWindows8(temp, clScheme12_Background, clScheme12_Selection);
  268. ssWindows8_13: BCButtonWindows8(temp, clScheme13_Background, clScheme13_Selection);
  269. ssWindows8_14: BCButtonWindows8(temp, clScheme14_Background, clScheme14_Selection);
  270. ssWindows8_15: BCButtonWindows8(temp, clScheme15_Background, clScheme15_Selection);
  271. ssWindows8_16: BCButtonWindows8(temp, clScheme16_Background, clScheme16_Selection);
  272. ssWindows8_17: BCButtonWindows8(temp, clScheme17_Background, clScheme17_Selection);
  273. ssWindows8_18: BCButtonWindows8(temp, clScheme18_Background, clScheme18_Selection);
  274. ssWindows8_19: BCButtonWindows8(temp, clScheme19_Background, clScheme19_Selection);
  275. ssWindows8_20: BCButtonWindows8(temp, clScheme20_Background, clScheme20_Selection);
  276. ssWindows8_21: BCButtonWindows8(temp, clScheme21_Background, clScheme21_Selection);
  277. ssWindows8_22: BCButtonWindows8(temp, clScheme22_Background, clScheme22_Selection);
  278. ssWindows8_23: BCButtonWindows8(temp, clScheme23_Background, clScheme23_Selection);
  279. ssWindows8_24: BCButtonWindows8(temp, clScheme24_Background, clScheme24_Selection);
  280. ssWindows8_25: BCButtonWindows8(temp, clScheme25_Background, clScheme25_Selection);
  281. ssMaterialRed: BCButtonWindows8(temp, MaterialRed.M500, MaterialRed.M300, 5);
  282. ssMaterialPink: BCButtonWindows8(temp, MaterialPink.M500, MaterialPink.M300, 5);
  283. ssMaterialPurple: BCButtonWindows8(temp, MaterialPurple.M500,
  284. MaterialPurple.M300, 5);
  285. ssMaterialDeepPurple: BCButtonWindows8(temp, MaterialDeepPurple.M500,
  286. MaterialDeepPurple.M300, 5);
  287. ssMaterialIndigo: BCButtonWindows8(temp, MaterialIndigo.M500,
  288. MaterialIndigo.M300, 5);
  289. ssMaterialBlue: BCButtonWindows8(temp, MaterialBlue.M500, MaterialBlue.M300, 5);
  290. ssMaterialLightBlue: BCButtonWindows8(temp, MaterialLightBlue.M500,
  291. MaterialLightBlue.M300, 5);
  292. ssMaterialCyan: BCButtonWindows8(temp, MaterialCyan.M500, MaterialCyan.M300, 5);
  293. ssMaterialTeal: BCButtonWindows8(temp, MaterialTeal.M500, MaterialTeal.M300, 5);
  294. ssMaterialGreen: BCButtonWindows8(temp, MaterialGreen.M500, MaterialGreen.M300, 5);
  295. ssMaterialLightGreen: BCButtonWindows8(temp, MaterialLightGreen.M500,
  296. MaterialLightGreen.M300, 5);
  297. ssMaterialLime: BCButtonWindows8(temp, MaterialLime.M500, MaterialLime.M300, 5);
  298. ssMaterialYellow: BCButtonWindows8(temp, MaterialYellow.M500,
  299. MaterialYellow.M300, 5);
  300. ssMaterialAmber: BCButtonWindows8(temp, MaterialAmber.M500, MaterialAmber.M300, 5);
  301. ssMaterialOrange: BCButtonWindows8(temp, MaterialOrange.M500,
  302. MaterialOrange.M300, 5);
  303. ssMaterialDeepOrange: BCButtonWindows8(temp, MaterialDeepOrange.M500,
  304. MaterialDeepOrange.M300, 5);
  305. ssMaterialBrown: BCButtonWindows8(temp, MaterialBrown.M500, MaterialBrown.M300, 5);
  306. ssMaterialGrey: BCButtonWindows8(temp, MaterialGrey.M500, MaterialGrey.M300, 5);
  307. ssMaterialBlueGrey: BCButtonWindows8(temp, MaterialBlueGrey.M500,
  308. MaterialBlueGrey.M300, 5);
  309. end;
  310. StyleButtons(AControl, temp);
  311. temp.Free;
  312. end;
  313. procedure StyleButtonsFocusSample(AControl: TControl; AStyle: TBCSampleStyle);
  314. var
  315. temp: TBCButtonFocus;
  316. begin
  317. temp := TBCButtonFocus.Create(nil);
  318. case AStyle of
  319. ssWindows7: BCButtonWindows7(temp);
  320. ssWindows7ToolBar: BCButtonWindows7ToolBar(temp);
  321. ssOffice2010: BCButtonOffice2010(temp);
  322. ssFlashPlayer: BCButtonFlashPlayer(temp);
  323. ssMacOSXLion: BCButtonMacOSXLion(temp);
  324. ssWindows8_1: BCButtonWindows8(temp, clScheme1_Background, clScheme1_Selection);
  325. ssWindows8_2: BCButtonWindows8(temp, clScheme2_Background, clScheme2_Selection);
  326. ssWindows8_3: BCButtonWindows8(temp, clScheme3_Background, clScheme3_Selection);
  327. ssWindows8_4: BCButtonWindows8(temp, clScheme4_Background, clScheme4_Selection);
  328. ssWindows8_5: BCButtonWindows8(temp, clScheme5_Background, clScheme5_Selection);
  329. ssWindows8_6: BCButtonWindows8(temp, clScheme6_Background, clScheme6_Selection);
  330. ssWindows8_7: BCButtonWindows8(temp, clScheme7_Background, clScheme7_Selection);
  331. ssWindows8_8: BCButtonWindows8(temp, clScheme8_Background, clScheme8_Selection);
  332. ssWindows8_9: BCButtonWindows8(temp, clScheme9_Background, clScheme9_Selection);
  333. ssWindows8_10: BCButtonWindows8(temp, clScheme10_Background, clScheme10_Selection);
  334. ssWindows8_11: BCButtonWindows8(temp, clScheme11_Background, clScheme11_Selection);
  335. ssWindows8_12: BCButtonWindows8(temp, clScheme12_Background, clScheme12_Selection);
  336. ssWindows8_13: BCButtonWindows8(temp, clScheme13_Background, clScheme13_Selection);
  337. ssWindows8_14: BCButtonWindows8(temp, clScheme14_Background, clScheme14_Selection);
  338. ssWindows8_15: BCButtonWindows8(temp, clScheme15_Background, clScheme15_Selection);
  339. ssWindows8_16: BCButtonWindows8(temp, clScheme16_Background, clScheme16_Selection);
  340. ssWindows8_17: BCButtonWindows8(temp, clScheme17_Background, clScheme17_Selection);
  341. ssWindows8_18: BCButtonWindows8(temp, clScheme18_Background, clScheme18_Selection);
  342. ssWindows8_19: BCButtonWindows8(temp, clScheme19_Background, clScheme19_Selection);
  343. ssWindows8_20: BCButtonWindows8(temp, clScheme20_Background, clScheme20_Selection);
  344. ssWindows8_21: BCButtonWindows8(temp, clScheme21_Background, clScheme21_Selection);
  345. ssWindows8_22: BCButtonWindows8(temp, clScheme22_Background, clScheme22_Selection);
  346. ssWindows8_23: BCButtonWindows8(temp, clScheme23_Background, clScheme23_Selection);
  347. ssWindows8_24: BCButtonWindows8(temp, clScheme24_Background, clScheme24_Selection);
  348. ssWindows8_25: BCButtonWindows8(temp, clScheme25_Background, clScheme25_Selection);
  349. ssMaterialRed: BCButtonWindows8(temp, MaterialRed.M500, MaterialRed.M300, 5);
  350. ssMaterialPink: BCButtonWindows8(temp, MaterialPink.M500, MaterialPink.M300, 5);
  351. ssMaterialPurple: BCButtonWindows8(temp, MaterialPurple.M500,
  352. MaterialPurple.M300, 5);
  353. ssMaterialDeepPurple: BCButtonWindows8(temp, MaterialDeepPurple.M500,
  354. MaterialDeepPurple.M300, 5);
  355. ssMaterialIndigo: BCButtonWindows8(temp, MaterialIndigo.M500,
  356. MaterialIndigo.M300, 5);
  357. ssMaterialBlue: BCButtonWindows8(temp, MaterialBlue.M500, MaterialBlue.M300, 5);
  358. ssMaterialLightBlue: BCButtonWindows8(temp, MaterialLightBlue.M500,
  359. MaterialLightBlue.M300, 5);
  360. ssMaterialCyan: BCButtonWindows8(temp, MaterialCyan.M500, MaterialCyan.M300, 5);
  361. ssMaterialTeal: BCButtonWindows8(temp, MaterialTeal.M500, MaterialTeal.M300, 5);
  362. ssMaterialGreen: BCButtonWindows8(temp, MaterialGreen.M500, MaterialGreen.M300, 5);
  363. ssMaterialLightGreen: BCButtonWindows8(temp, MaterialLightGreen.M500,
  364. MaterialLightGreen.M300, 5);
  365. ssMaterialLime: BCButtonWindows8(temp, MaterialLime.M500, MaterialLime.M300, 5);
  366. ssMaterialYellow: BCButtonWindows8(temp, MaterialYellow.M500,
  367. MaterialYellow.M300, 5);
  368. ssMaterialAmber: BCButtonWindows8(temp, MaterialAmber.M500, MaterialAmber.M300, 5);
  369. ssMaterialOrange: BCButtonWindows8(temp, MaterialOrange.M500,
  370. MaterialOrange.M300, 5);
  371. ssMaterialDeepOrange: BCButtonWindows8(temp, MaterialDeepOrange.M500,
  372. MaterialDeepOrange.M300, 5);
  373. ssMaterialBrown: BCButtonWindows8(temp, MaterialBrown.M500, MaterialBrown.M300, 5);
  374. ssMaterialGrey: BCButtonWindows8(temp, MaterialGrey.M500, MaterialGrey.M300, 5);
  375. ssMaterialBlueGrey: BCButtonWindows8(temp, MaterialBlueGrey.M500,
  376. MaterialBlueGrey.M300, 5);
  377. end;
  378. StyleButtons(AControl, temp);
  379. temp.Free;
  380. end;
  381. procedure DrawItem(Control: TWinControl; Index: integer; ARect: TRect;
  382. State: TOwnerDrawState; Style: TBCSampleDrawing);
  383. var
  384. temp: TBGRABitmap;
  385. str: string;
  386. begin
  387. if Control is TListBox then
  388. str := TListBox(Control).Items[Index]
  389. else if Control is TComboBox then
  390. str := TComboBox(Control).Items[Index];
  391. temp := TBGRABitmap.Create(ARect.Right - ARect.Left, ARect.Bottom -
  392. ARect.Top, {$IFNDEF FPC}TWinControlHack(Control).{$ELSE}Control.{$ENDIF}Color);
  393. temp.FontAntialias := True;
  394. temp.FontHeight := 0;
  395. temp.FontQuality := fqSystemClearType;
  396. if odSelected in State then
  397. DrawSample(temp, Style, alNone);
  398. temp.TextOut(2, 0, {%H-}str, BGRABlack);
  399. if Control is TListBox then
  400. temp.Draw(TListBox(Control).Canvas, ARect, False)
  401. else if Control is TComboBox then
  402. temp.Draw(TComboBox(Control).Canvas, ARect, False);
  403. temp.Free;
  404. end;
  405. procedure BCButtonWindows7(AButton: TBCButton);
  406. begin
  407. AButton.Rounding.RoundX := 3;
  408. AButton.Rounding.RoundY := 3;
  409. AButton.RoundingDropDown.Assign(AButton.Rounding);
  410. with AButton.StateNormal do
  411. begin
  412. Background.Gradient1EndPercent := 50;
  413. Background.Gradient2.Point1XPercent := 0;
  414. Background.Gradient2.Point1YPercent := 0;
  415. Background.Gradient2.Point2YPercent := 100;
  416. Background.Gradient2.GradientType := gtLinear;
  417. Border.Color := RGBToColor(112, 112, 112);
  418. Border.LightWidth := 1;
  419. Border.LightOpacity := 175;
  420. Border.Style := bboSolid;
  421. FontEx.Color := clBlack;
  422. FontEx.Shadow := False;
  423. FontEx.Style := [];
  424. end;
  425. AButton.StateHover.Assign(AButton.StateNormal);
  426. AButton.StateClicked.Assign(AButton.StateNormal);
  427. with AButton.StateNormal do
  428. begin
  429. Background.Gradient1.StartColor := RGBToColor(242, 242, 242);
  430. Background.Gradient1.EndColor := RGBToColor(235, 235, 235);
  431. Background.Gradient2.StartColor := RGBToColor(221, 221, 221);
  432. Background.Gradient2.EndColor := RGBToColor(207, 207, 207);
  433. end;
  434. with AButton.StateHover do
  435. begin
  436. Background.Gradient1.StartColor := RGBToColor(234, 246, 253);
  437. Background.Gradient1.EndColor := RGBToColor(217, 240, 252);
  438. Background.Gradient2.StartColor := RGBToColor(190, 230, 253);
  439. Background.Gradient2.EndColor := RGBToColor(167, 217, 245);
  440. Border.Color := RGBToColor(60, 127, 177);
  441. end;
  442. with AButton.StateClicked do
  443. begin
  444. Background.Gradient1.StartColor := RGBToColor(229, 244, 252);
  445. Background.Gradient1.EndColor := RGBToColor(196, 229, 246);
  446. Background.Gradient2.StartColor := RGBToColor(152, 209, 239);
  447. Background.Gradient2.EndColor := RGBToColor(104, 179, 219);
  448. Background.Gradient1EndPercent := 55;
  449. Border.Color := RGBToColor(44, 98, 139);
  450. Border.LightOpacity := 100;
  451. Border.LightColor := clBlack;
  452. end;
  453. end;
  454. procedure BCButtonWindows7ToolBar(AButton: TBCButton);
  455. begin
  456. AButton.Rounding.RoundX := 2;
  457. AButton.Rounding.RoundY := 2;
  458. AButton.RoundingDropDown.Assign(AButton.Rounding);
  459. with AButton.StateNormal do
  460. begin
  461. Background.Gradient1EndPercent := 50;
  462. Background.Gradient2.Point1XPercent := 0;
  463. Background.Gradient2.Point1YPercent := 0;
  464. Background.Gradient2.Point2YPercent := 100;
  465. Background.Gradient2.GradientType := gtLinear;
  466. Border.Color := RGBToColor(187, 202, 219);
  467. Border.LightWidth := 1;
  468. Border.LightOpacity := 200;
  469. Border.Style := bboSolid;
  470. FontEx.Color := RGBToColor(30, 57, 91);
  471. FontEx.Shadow := False;
  472. FontEx.Style := [];
  473. end;
  474. AButton.StateHover.Assign(AButton.StateNormal);
  475. AButton.StateClicked.Assign(AButton.StateNormal);
  476. with AButton.StateNormal do
  477. begin
  478. Background.Gradient1.StartColor := RGBToColor(245, 250, 255);
  479. Background.Gradient1.EndColor := RGBToColor(230, 240, 250);
  480. Background.Gradient2.StartColor := RGBToColor(220, 230, 244);
  481. Background.Gradient2.EndColor := RGBToColor(221, 233, 247);
  482. end;
  483. with AButton.StateHover do
  484. begin
  485. Background.Gradient1.StartColor := RGBToColor(248, 251, 254);
  486. Background.Gradient1.EndColor := RGBToColor(237, 242, 250);
  487. Background.Gradient2.StartColor := RGBToColor(215, 228, 244);
  488. Background.Gradient2.EndColor := RGBToColor(193, 210, 232);
  489. end;
  490. with AButton.StateClicked do
  491. begin
  492. Background.Gradient1.StartColor := RGBToColor(226, 236, 245);
  493. Background.Gradient1.EndColor := RGBToColor(216, 228, 241);
  494. Background.Gradient2.StartColor := RGBToColor(207, 219, 236);
  495. Background.Gradient2.EndColor := RGBToColor(207, 220, 237);
  496. end;
  497. end;
  498. procedure BCButtonOffice2010(AButton: TBCButton);
  499. begin
  500. AButton.Rounding.RoundX := 3;
  501. AButton.Rounding.RoundY := 3;
  502. AButton.RoundingDropDown.Assign(AButton.Rounding);
  503. with AButton.StateNormal do
  504. begin
  505. Background.Gradient1EndPercent := 50;
  506. Background.Gradient2.Point1XPercent := 0;
  507. Background.Gradient2.Point1YPercent := 0;
  508. Background.Gradient2.Point2YPercent := 100;
  509. Background.Gradient2.GradientType := gtLinear;
  510. Border.Color := RGBToColor(207, 208, 210);
  511. Border.LightWidth := 1;
  512. Border.LightOpacity := 175;
  513. Border.Style := bboSolid;
  514. FontEx.Color := clBlack;
  515. FontEx.Shadow := False;
  516. FontEx.Style := [];
  517. end;
  518. AButton.StateHover.Assign(AButton.StateNormal);
  519. AButton.StateClicked.Assign(AButton.StateNormal);
  520. with AButton.StateNormal do
  521. begin
  522. Background.Gradient1.StartColor := RGBToColor(255, 255, 255);
  523. Background.Gradient1.EndColor := RGBToColor(237, 239, 241);
  524. Background.Gradient1EndPercent := 100;
  525. end;
  526. with AButton.StateHover do
  527. begin
  528. Background.Gradient1.StartColor := RGBToColor(254, 241, 189);
  529. Background.Gradient1.EndColor := RGBToColor(254, 228, 134);
  530. Background.Gradient2.StartColor := RGBToColor(254, 228, 134);
  531. Background.Gradient2.EndColor := RGBToColor(254, 248, 196);
  532. Border.Color := RGBToColor(244, 210, 81);
  533. end;
  534. with AButton.StateClicked do
  535. begin
  536. Background.Gradient1.StartColor := RGBToColor(255, 229, 117);
  537. Background.Gradient1.EndColor := RGBToColor(255, 216, 107);
  538. Background.Gradient2.StartColor := RGBToColor(255, 216, 107);
  539. Background.Gradient2.EndColor := RGBToColor(255, 239, 129);
  540. Border.Color := RGBToColor(194, 161, 63);
  541. Border.LightWidth := 0;
  542. end;
  543. end;
  544. procedure BCButtonFlashPlayer(AButton: TBCButton);
  545. begin
  546. AButton.Rounding.RoundX := 1;
  547. AButton.Rounding.RoundY := 1;
  548. AButton.RoundingDropDown.Assign(AButton.Rounding);
  549. with AButton.StateNormal do
  550. begin
  551. Background.Gradient1EndPercent := 50;
  552. Background.Gradient2.Point1XPercent := 0;
  553. Background.Gradient2.Point1YPercent := 0;
  554. Background.Gradient2.Point2YPercent := 100;
  555. Background.Gradient2.GradientType := gtLinear;
  556. Border.Color := RGBToColor(24, 24, 24);
  557. Border.LightWidth := 1;
  558. Border.LightOpacity := 20;
  559. Border.Style := bboSolid;
  560. FontEx.Color := clWhite;
  561. FontEx.Shadow := True;
  562. FontEx.ShadowRadius := 1;
  563. FontEx.ShadowOffsetX := 1;
  564. FontEx.ShadowOffsetY := 1;
  565. FontEx.Style := [];
  566. end;
  567. AButton.StateHover.Assign(AButton.StateNormal);
  568. AButton.StateClicked.Assign(AButton.StateNormal);
  569. with AButton.StateNormal do
  570. begin
  571. Background.Gradient1.StartColor := RGBToColor(104, 104, 104);
  572. Background.Gradient1.EndColor := RGBToColor(104, 104, 104);
  573. Background.Gradient2.StartColor := RGBToColor(103, 103, 103);
  574. Background.Gradient2.EndColor := RGBToColor(71, 71, 71);
  575. end;
  576. with AButton.StateHover do
  577. begin
  578. Background.Gradient1.StartColor := RGBToColor(118, 118, 118);
  579. Background.Gradient1.EndColor := RGBToColor(118, 118, 118);
  580. Background.Gradient2.StartColor := RGBToColor(117, 117, 117);
  581. Background.Gradient2.EndColor := RGBToColor(81, 81, 81);
  582. Border.Color := RGBToColor(24, 24, 24);
  583. end;
  584. with AButton.StateClicked do
  585. begin
  586. Background.Gradient1.StartColor := RGBToColor(92, 92, 92);
  587. Background.Gradient1.EndColor := RGBToColor(92, 92, 92);
  588. Background.Gradient2.StartColor := RGBToColor(91, 91, 91);
  589. Background.Gradient2.EndColor := RGBToColor(62, 62, 62);
  590. Background.Gradient1EndPercent := 55;
  591. Border.Color := RGBToColor(24, 24, 24);
  592. end;
  593. end;
  594. procedure BCButtonMacOSXLion(AButton: TBCButton);
  595. begin
  596. AButton.Rounding.RoundX := 3;
  597. AButton.Rounding.RoundY := 3;
  598. AButton.RoundingDropDown.Assign(AButton.Rounding);
  599. with AButton.StateNormal do
  600. begin
  601. Background.Gradient1EndPercent := 50;
  602. Background.Gradient2.Point1XPercent := 0;
  603. Background.Gradient2.Point1YPercent := 0;
  604. Background.Gradient2.Point2YPercent := 100;
  605. Background.Gradient2.GradientType := gtLinear;
  606. Border.Color := RGBToColor(154, 154, 154);
  607. Border.LightWidth := 1;
  608. Border.LightOpacity := 175;
  609. Border.Style := bboSolid;
  610. FontEx.Color := clBlack;
  611. FontEx.Shadow := False;
  612. FontEx.Style := [];
  613. end;
  614. AButton.StateHover.Assign(AButton.StateNormal);
  615. AButton.StateClicked.Assign(AButton.StateNormal);
  616. with AButton.StateNormal do
  617. begin
  618. Background.Gradient1.StartColor := RGBToColor(255, 255, 255);
  619. Background.Gradient1.EndColor := RGBToColor(243, 243, 243);
  620. Background.Gradient2.StartColor := RGBToColor(236, 236, 236);
  621. Background.Gradient2.EndColor := RGBToColor(235, 235, 235);
  622. end;
  623. with AButton.StateHover do
  624. begin
  625. Background.Gradient1.StartColor := RGBToColor(204, 229, 252);
  626. Background.Gradient1.EndColor := RGBToColor(161, 209, 249);
  627. Background.Gradient2.StartColor := RGBToColor(143, 202, 251);
  628. Background.Gradient2.EndColor := RGBToColor(207, 245, 253);
  629. Border.Color := RGBToColor(86, 87, 143);
  630. end;
  631. with AButton.StateClicked do
  632. begin
  633. Background.Gradient1.StartColor := RGBToColor(144, 195, 241);
  634. Background.Gradient1.EndColor := RGBToColor(113, 180, 239);
  635. Background.Gradient2.StartColor := RGBToColor(97, 173, 240);
  636. Background.Gradient2.EndColor := RGBToColor(147, 206, 241);
  637. Background.Gradient1EndPercent := 55;
  638. Border.Color := RGBToColor(86, 87, 143);
  639. Border.LightWidth := 0;
  640. end;
  641. end;
  642. procedure BCButtonWindows8(AButton: TBCButton; cl1, cl2: TColor; rounding: integer = 1);
  643. begin
  644. AButton.Rounding.RoundX := rounding;
  645. AButton.Rounding.RoundY := rounding;
  646. AButton.RoundingDropDown.Assign(AButton.Rounding);
  647. with AButton.StateNormal do
  648. begin
  649. Background.Style := bbsColor;
  650. Background.Color := cl1;
  651. Border.Style := bboSolid;
  652. Border.Width := 1;
  653. Border.Color := cl1;
  654. Border.LightWidth := 0;
  655. Border.LightOpacity := 255;
  656. Border.Style := bboSolid;
  657. FontEx.Color := GetContrastColor(cl1);
  658. FontEx.Shadow := False;
  659. FontEx.Style := [];
  660. end;
  661. AButton.StateHover.Assign(AButton.StateNormal);
  662. AButton.StateClicked.Assign(AButton.StateNormal);
  663. with AButton.StateHover do
  664. begin
  665. Background.Color := cl2;
  666. Border.Color := cl2;
  667. end;
  668. with AButton.StateClicked do
  669. begin
  670. Background.Color := cl2;
  671. Border.Color := cl2;
  672. end;
  673. end;
  674. procedure BCButtonWindows7(AButton: TBCButtonFocus);
  675. begin
  676. AButton.Rounding.RoundX := 3;
  677. AButton.Rounding.RoundY := 3;
  678. AButton.RoundingDropDown.Assign(AButton.Rounding);
  679. with AButton.StateNormal do
  680. begin
  681. Background.Gradient1EndPercent := 50;
  682. Background.Gradient2.Point1XPercent := 0;
  683. Background.Gradient2.Point1YPercent := 0;
  684. Background.Gradient2.Point2YPercent := 100;
  685. Background.Gradient2.GradientType := gtLinear;
  686. Border.Color := RGBToColor(112, 112, 112);
  687. Border.LightWidth := 1;
  688. Border.LightOpacity := 175;
  689. Border.Style := bboSolid;
  690. FontEx.Color := clBlack;
  691. FontEx.Shadow := False;
  692. FontEx.Style := [];
  693. end;
  694. AButton.StateHover.Assign(AButton.StateNormal);
  695. AButton.StateClicked.Assign(AButton.StateNormal);
  696. with AButton.StateNormal do
  697. begin
  698. Background.Gradient1.StartColor := RGBToColor(242, 242, 242);
  699. Background.Gradient1.EndColor := RGBToColor(235, 235, 235);
  700. Background.Gradient2.StartColor := RGBToColor(221, 221, 221);
  701. Background.Gradient2.EndColor := RGBToColor(207, 207, 207);
  702. end;
  703. with AButton.StateHover do
  704. begin
  705. Background.Gradient1.StartColor := RGBToColor(234, 246, 253);
  706. Background.Gradient1.EndColor := RGBToColor(217, 240, 252);
  707. Background.Gradient2.StartColor := RGBToColor(190, 230, 253);
  708. Background.Gradient2.EndColor := RGBToColor(167, 217, 245);
  709. Border.Color := RGBToColor(60, 127, 177);
  710. end;
  711. with AButton.StateClicked do
  712. begin
  713. Background.Gradient1.StartColor := RGBToColor(229, 244, 252);
  714. Background.Gradient1.EndColor := RGBToColor(196, 229, 246);
  715. Background.Gradient2.StartColor := RGBToColor(152, 209, 239);
  716. Background.Gradient2.EndColor := RGBToColor(104, 179, 219);
  717. Background.Gradient1EndPercent := 55;
  718. Border.Color := RGBToColor(44, 98, 139);
  719. Border.LightOpacity := 100;
  720. Border.LightColor := clBlack;
  721. end;
  722. end;
  723. procedure BCButtonWindows7ToolBar(AButton: TBCButtonFocus);
  724. begin
  725. AButton.Rounding.RoundX := 2;
  726. AButton.Rounding.RoundY := 2;
  727. AButton.RoundingDropDown.Assign(AButton.Rounding);
  728. with AButton.StateNormal do
  729. begin
  730. Background.Gradient1EndPercent := 50;
  731. Background.Gradient2.Point1XPercent := 0;
  732. Background.Gradient2.Point1YPercent := 0;
  733. Background.Gradient2.Point2YPercent := 100;
  734. Background.Gradient2.GradientType := gtLinear;
  735. Border.Color := RGBToColor(187, 202, 219);
  736. Border.LightWidth := 1;
  737. Border.LightOpacity := 200;
  738. Border.Style := bboSolid;
  739. FontEx.Color := RGBToColor(30, 57, 91);
  740. FontEx.Shadow := False;
  741. FontEx.Style := [];
  742. end;
  743. AButton.StateHover.Assign(AButton.StateNormal);
  744. AButton.StateClicked.Assign(AButton.StateNormal);
  745. with AButton.StateNormal do
  746. begin
  747. Background.Gradient1.StartColor := RGBToColor(245, 250, 255);
  748. Background.Gradient1.EndColor := RGBToColor(230, 240, 250);
  749. Background.Gradient2.StartColor := RGBToColor(220, 230, 244);
  750. Background.Gradient2.EndColor := RGBToColor(221, 233, 247);
  751. end;
  752. with AButton.StateHover do
  753. begin
  754. Background.Gradient1.StartColor := RGBToColor(248, 251, 254);
  755. Background.Gradient1.EndColor := RGBToColor(237, 242, 250);
  756. Background.Gradient2.StartColor := RGBToColor(215, 228, 244);
  757. Background.Gradient2.EndColor := RGBToColor(193, 210, 232);
  758. end;
  759. with AButton.StateClicked do
  760. begin
  761. Background.Gradient1.StartColor := RGBToColor(226, 236, 245);
  762. Background.Gradient1.EndColor := RGBToColor(216, 228, 241);
  763. Background.Gradient2.StartColor := RGBToColor(207, 219, 236);
  764. Background.Gradient2.EndColor := RGBToColor(207, 220, 237);
  765. end;
  766. end;
  767. procedure BCButtonOffice2010(AButton: TBCButtonFocus);
  768. begin
  769. AButton.Rounding.RoundX := 3;
  770. AButton.Rounding.RoundY := 3;
  771. AButton.RoundingDropDown.Assign(AButton.Rounding);
  772. with AButton.StateNormal do
  773. begin
  774. Background.Gradient1EndPercent := 50;
  775. Background.Gradient2.Point1XPercent := 0;
  776. Background.Gradient2.Point1YPercent := 0;
  777. Background.Gradient2.Point2YPercent := 100;
  778. Background.Gradient2.GradientType := gtLinear;
  779. Border.Color := RGBToColor(207, 208, 210);
  780. Border.LightWidth := 1;
  781. Border.LightOpacity := 175;
  782. Border.Style := bboSolid;
  783. FontEx.Color := clBlack;
  784. FontEx.Shadow := False;
  785. FontEx.Style := [];
  786. end;
  787. AButton.StateHover.Assign(AButton.StateNormal);
  788. AButton.StateClicked.Assign(AButton.StateNormal);
  789. with AButton.StateNormal do
  790. begin
  791. Background.Gradient1.StartColor := RGBToColor(255, 255, 255);
  792. Background.Gradient1.EndColor := RGBToColor(237, 239, 241);
  793. Background.Gradient1EndPercent := 100;
  794. end;
  795. with AButton.StateHover do
  796. begin
  797. Background.Gradient1.StartColor := RGBToColor(254, 241, 189);
  798. Background.Gradient1.EndColor := RGBToColor(254, 228, 134);
  799. Background.Gradient2.StartColor := RGBToColor(254, 228, 134);
  800. Background.Gradient2.EndColor := RGBToColor(254, 248, 196);
  801. Border.Color := RGBToColor(244, 210, 81);
  802. end;
  803. with AButton.StateClicked do
  804. begin
  805. Background.Gradient1.StartColor := RGBToColor(255, 229, 117);
  806. Background.Gradient1.EndColor := RGBToColor(255, 216, 107);
  807. Background.Gradient2.StartColor := RGBToColor(255, 216, 107);
  808. Background.Gradient2.EndColor := RGBToColor(255, 239, 129);
  809. Border.Color := RGBToColor(194, 161, 63);
  810. Border.LightWidth := 0;
  811. end;
  812. end;
  813. procedure BCButtonFlashPlayer(AButton: TBCButtonFocus);
  814. begin
  815. AButton.Rounding.RoundX := 1;
  816. AButton.Rounding.RoundY := 1;
  817. AButton.RoundingDropDown.Assign(AButton.Rounding);
  818. with AButton.StateNormal do
  819. begin
  820. Background.Gradient1EndPercent := 50;
  821. Background.Gradient2.Point1XPercent := 0;
  822. Background.Gradient2.Point1YPercent := 0;
  823. Background.Gradient2.Point2YPercent := 100;
  824. Background.Gradient2.GradientType := gtLinear;
  825. Border.Color := RGBToColor(24, 24, 24);
  826. Border.LightWidth := 1;
  827. Border.LightOpacity := 20;
  828. Border.Style := bboSolid;
  829. FontEx.Color := clWhite;
  830. FontEx.Shadow := True;
  831. FontEx.ShadowRadius := 1;
  832. FontEx.ShadowOffsetX := 1;
  833. FontEx.ShadowOffsetY := 1;
  834. FontEx.Style := [];
  835. end;
  836. AButton.StateHover.Assign(AButton.StateNormal);
  837. AButton.StateClicked.Assign(AButton.StateNormal);
  838. with AButton.StateNormal do
  839. begin
  840. Background.Gradient1.StartColor := RGBToColor(104, 104, 104);
  841. Background.Gradient1.EndColor := RGBToColor(104, 104, 104);
  842. Background.Gradient2.StartColor := RGBToColor(103, 103, 103);
  843. Background.Gradient2.EndColor := RGBToColor(71, 71, 71);
  844. end;
  845. with AButton.StateHover do
  846. begin
  847. Background.Gradient1.StartColor := RGBToColor(118, 118, 118);
  848. Background.Gradient1.EndColor := RGBToColor(118, 118, 118);
  849. Background.Gradient2.StartColor := RGBToColor(117, 117, 117);
  850. Background.Gradient2.EndColor := RGBToColor(81, 81, 81);
  851. Border.Color := RGBToColor(24, 24, 24);
  852. end;
  853. with AButton.StateClicked do
  854. begin
  855. Background.Gradient1.StartColor := RGBToColor(92, 92, 92);
  856. Background.Gradient1.EndColor := RGBToColor(92, 92, 92);
  857. Background.Gradient2.StartColor := RGBToColor(91, 91, 91);
  858. Background.Gradient2.EndColor := RGBToColor(62, 62, 62);
  859. Background.Gradient1EndPercent := 55;
  860. Border.Color := RGBToColor(24, 24, 24);
  861. end;
  862. end;
  863. procedure BCButtonMacOSXLion(AButton: TBCButtonFocus);
  864. begin
  865. AButton.Rounding.RoundX := 3;
  866. AButton.Rounding.RoundY := 3;
  867. AButton.RoundingDropDown.Assign(AButton.Rounding);
  868. with AButton.StateNormal do
  869. begin
  870. Background.Gradient1EndPercent := 50;
  871. Background.Gradient2.Point1XPercent := 0;
  872. Background.Gradient2.Point1YPercent := 0;
  873. Background.Gradient2.Point2YPercent := 100;
  874. Background.Gradient2.GradientType := gtLinear;
  875. Border.Color := RGBToColor(154, 154, 154);
  876. Border.LightWidth := 1;
  877. Border.LightOpacity := 175;
  878. Border.Style := bboSolid;
  879. FontEx.Color := clBlack;
  880. FontEx.Shadow := False;
  881. FontEx.Style := [];
  882. end;
  883. AButton.StateHover.Assign(AButton.StateNormal);
  884. AButton.StateClicked.Assign(AButton.StateNormal);
  885. with AButton.StateNormal do
  886. begin
  887. Background.Gradient1.StartColor := RGBToColor(255, 255, 255);
  888. Background.Gradient1.EndColor := RGBToColor(243, 243, 243);
  889. Background.Gradient2.StartColor := RGBToColor(236, 236, 236);
  890. Background.Gradient2.EndColor := RGBToColor(235, 235, 235);
  891. end;
  892. with AButton.StateHover do
  893. begin
  894. Background.Gradient1.StartColor := RGBToColor(204, 229, 252);
  895. Background.Gradient1.EndColor := RGBToColor(161, 209, 249);
  896. Background.Gradient2.StartColor := RGBToColor(143, 202, 251);
  897. Background.Gradient2.EndColor := RGBToColor(207, 245, 253);
  898. Border.Color := RGBToColor(86, 87, 143);
  899. end;
  900. with AButton.StateClicked do
  901. begin
  902. Background.Gradient1.StartColor := RGBToColor(144, 195, 241);
  903. Background.Gradient1.EndColor := RGBToColor(113, 180, 239);
  904. Background.Gradient2.StartColor := RGBToColor(97, 173, 240);
  905. Background.Gradient2.EndColor := RGBToColor(147, 206, 241);
  906. Background.Gradient1EndPercent := 55;
  907. Border.Color := RGBToColor(86, 87, 143);
  908. Border.LightWidth := 0;
  909. end;
  910. end;
  911. procedure BCButtonWindows8(AButton: TBCButtonFocus; cl1, cl2: TColor;
  912. rounding: integer = 1);
  913. begin
  914. AButton.Rounding.RoundX := rounding;
  915. AButton.Rounding.RoundY := rounding;
  916. AButton.RoundingDropDown.Assign(AButton.Rounding);
  917. with AButton.StateNormal do
  918. begin
  919. Background.Style := bbsColor;
  920. Background.Color := cl1;
  921. Border.Style := bboSolid;
  922. Border.Width := 1;
  923. Border.Color := cl1;
  924. Border.LightWidth := 0;
  925. Border.LightOpacity := 255;
  926. Border.Style := bboSolid;
  927. FontEx.Color := GetContrastColor(cl1);
  928. FontEx.Shadow := False;
  929. FontEx.Style := [];
  930. end;
  931. AButton.StateHover.Assign(AButton.StateNormal);
  932. AButton.StateClicked.Assign(AButton.StateNormal);
  933. with AButton.StateHover do
  934. begin
  935. Background.Color := cl2;
  936. Border.Color := cl2;
  937. end;
  938. with AButton.StateClicked do
  939. begin
  940. Background.Color := cl2;
  941. Border.Color := cl2;
  942. end;
  943. end;
  944. procedure DrawFlashPlayerBody(ABitmap: TBGRABitmap);
  945. begin
  946. with ABitmap do
  947. begin
  948. GradientFill(0, 0, Width, Height, BGRA(203, 19, 23, 255), BGRA(110, 3, 20, 255),
  949. gtLinear, PointF(0, 0), PointF(0, Height), dmSet);
  950. Rectangle(0, 0, Width, Height + 1, BGRA(0, 0, 0, 215), dmDrawWithTransparency);
  951. end;
  952. end;
  953. procedure DrawFlashPlayerButtonPanel(ABitmap: TBGRABitmap);
  954. begin
  955. with ABitmap do
  956. begin
  957. DrawHorizLine(0, 0, Width, BGRA(30, 30, 30, 255));
  958. DrawHorizLine(0, Height - 1, Width, BGRA(62, 62, 62, 255));
  959. Rectangle(0, 1, Width, Height - 1, BGRA(91, 91, 91, 255),
  960. BGRA(76, 76, 76, 255), dmSet);
  961. end;
  962. end;
  963. procedure DrawWindows7ToolBar(ABitmap: TBGRABitmap; ADir: TAlign;
  964. Smooth: boolean = False);
  965. var
  966. tempBmp: TBGRABitmap;
  967. begin
  968. if Smooth then
  969. tempBmp := DoubleGradientAlphaFill(Rect(0, 0, ABitmap.Width, ABitmap.Height),
  970. BGRA(245, 249, 255, 255), BGRA(222, 232, 245, 255), BGRA(220, 230, 245, 255),
  971. BGRA(222, 230, 245, 255), gdVertical, gdVertical, gdVertical, 0.50)
  972. else
  973. tempBmp := DoubleGradientAlphaFill(Rect(0, 0, ABitmap.Width, ABitmap.Height),
  974. BGRA(245, 250, 255, 255), BGRA(230, 240, 250, 255), BGRA(220, 230, 244, 255),
  975. BGRA(221, 233, 247, 255), gdVertical, gdVertical, gdVertical, 0.50);
  976. ABitmap.BlendImage(0, 0, tempBmp, boLinearBlend);
  977. tempBmp.Free;
  978. case ADir of
  979. alLeft: with ABitmap do
  980. begin
  981. if not Smooth then
  982. Rectangle(0, 0, Width - 2, Height, BGRA(255, 255, 255, 100),
  983. dmDrawWithTransparency);
  984. SetVertLine(Width - 1, 0, Height - 1, BGRA(160, 175, 195, 255));
  985. SetVertLine(Width - 2, 0, Height - 1, BGRA(205, 218, 234, 255));
  986. end;
  987. alTop: with ABitmap do
  988. begin
  989. if not Smooth then
  990. Rectangle(0, 0, Width, Height - 2, BGRA(255, 255, 255, 100),
  991. dmDrawWithTransparency);
  992. SetHorizLine(0, Height - 1, Width - 1, BGRA(160, 175, 195, 255));
  993. SetHorizLine(0, Height - 2, Width - 1, BGRA(205, 218, 234, 255));
  994. end;
  995. alRight: with ABitmap do
  996. begin
  997. if not Smooth then
  998. Rectangle(2, 0, Width, Height, BGRA(255, 255, 255, 100),
  999. dmDrawWithTransparency);
  1000. SetVertLine(0, 0, Height, BGRA(160, 175, 195, 255));
  1001. SetVertLine(1, 0, Height, BGRA(205, 218, 234, 255));
  1002. end;
  1003. alBottom: with ABitmap do
  1004. begin
  1005. if not Smooth then
  1006. Rectangle(0, 2, Width, Height, BGRA(255, 255, 255, 100),
  1007. dmDrawWithTransparency);
  1008. SetHorizLine(0, 0, Width - 1, BGRA(160, 175, 195, 255));
  1009. SetHorizLine(0, 1, Width - 1, BGRA(205, 218, 234, 255));
  1010. end;
  1011. alClient, alCustom, alNone: with ABitmap do
  1012. begin
  1013. if not Smooth then
  1014. Rectangle(0, 0, Width, Height, BGRA(255, 255, 255, 100),
  1015. dmDrawWithTransparency);
  1016. end;
  1017. end;
  1018. end;
  1019. function StrToTBCSampleDrawing(const s: ansistring): TBCSampleDrawing;
  1020. var
  1021. ss: TBCSampleDrawing;
  1022. ls: ansistring;
  1023. begin
  1024. Result := sdDefault;
  1025. ls := {$IFDEF FPC}UTF8LowerCase{$ELSE}LowerCase{$ENDIF}(s);
  1026. for ss := low(TBCSampleDrawing) to high(TBCSampleDrawing) do
  1027. if ls = {$IFDEF FPC}UTF8LowerCase{$ELSE}LowerCase{$ENDIF}(BCSampleDrawingStr[ss]) then
  1028. begin
  1029. Result := ss;
  1030. break;
  1031. end;
  1032. end;
  1033. procedure BCSampleDrawingStrList(s: TStrings);
  1034. var
  1035. ss: TBCSampleDrawing;
  1036. begin
  1037. for ss := low(TBCSampleDrawing) to high(TBCSampleDrawing) do
  1038. s.Add(BCSampleDrawingStr[ss]);
  1039. end;
  1040. procedure DrawSample(ABitmap: TBGRABitmap; Element: TBCSampleDrawing;
  1041. Align: TAlign = alNone);
  1042. begin
  1043. case Element of
  1044. sdFlashPlayerBody: DrawFlashPlayerBody(ABitmap);
  1045. sdFlashPlayerButtonPanel: DrawFlashPlayerButtonPanel(ABitmap);
  1046. sdWindows7Toolbar: DrawWindows7ToolBar(ABitmap, Align);
  1047. sdiOSBar: DrawiOSBar(ABitmap);
  1048. sdiOSToolBar: DrawiOSToolBar(ABitmap, False);
  1049. sdiOSBackground: DrawiOSBackground(ABitmap);
  1050. sdWindows8_1: DrawWindows8Background(ABitmap, clScheme1_Background,
  1051. clScheme1_Selection);
  1052. sdWindows8_2: DrawWindows8Background(ABitmap, clScheme2_Background,
  1053. clScheme2_Selection);
  1054. sdWindows8_3: DrawWindows8Background(ABitmap, clScheme3_Background,
  1055. clScheme3_Selection);
  1056. sdWindows8_4: DrawWindows8Background(ABitmap, clScheme4_Background,
  1057. clScheme4_Selection);
  1058. sdWindows8_5: DrawWindows8Background(ABitmap, clScheme5_Background,
  1059. clScheme5_Selection);
  1060. sdWindows8_6: DrawWindows8Background(ABitmap, clScheme6_Background,
  1061. clScheme6_Selection);
  1062. sdWindows8_7: DrawWindows8Background(ABitmap, clScheme7_Background,
  1063. clScheme7_Selection);
  1064. sdWindows8_8: DrawWindows8Background(ABitmap, clScheme8_Background,
  1065. clScheme8_Selection);
  1066. sdWindows8_9: DrawWindows8Background(ABitmap, clScheme9_Background,
  1067. clScheme9_Selection);
  1068. sdWindows8_10: DrawWindows8Background(ABitmap, clScheme10_Background,
  1069. clScheme10_Selection);
  1070. sdWindows8_11: DrawWindows8Background(ABitmap, clScheme11_Background,
  1071. clScheme11_Selection);
  1072. sdWindows8_12: DrawWindows8Background(ABitmap, clScheme12_Background,
  1073. clScheme12_Selection);
  1074. sdWindows8_13: DrawWindows8Background(ABitmap, clScheme13_Background,
  1075. clScheme13_Selection);
  1076. sdWindows8_14: DrawWindows8Background(ABitmap, clScheme14_Background,
  1077. clScheme14_Selection);
  1078. sdWindows8_15: DrawWindows8Background(ABitmap, clScheme15_Background,
  1079. clScheme15_Selection);
  1080. sdWindows8_16: DrawWindows8Background(ABitmap, clScheme16_Background,
  1081. clScheme16_Selection);
  1082. sdWindows8_17: DrawWindows8Background(ABitmap, clScheme17_Background,
  1083. clScheme17_Selection);
  1084. sdWindows8_18: DrawWindows8Background(ABitmap, clScheme18_Background,
  1085. clScheme18_Selection);
  1086. sdWindows8_19: DrawWindows8Background(ABitmap, clScheme19_Background,
  1087. clScheme19_Selection);
  1088. sdWindows8_20: DrawWindows8Background(ABitmap, clScheme20_Background,
  1089. clScheme20_Selection);
  1090. sdWindows8_21: DrawWindows8Background(ABitmap, clScheme21_Background,
  1091. clScheme21_Selection);
  1092. sdWindows8_22: DrawWindows8Background(ABitmap, clScheme22_Background,
  1093. clScheme22_Selection);
  1094. sdWindows8_23: DrawWindows8Background(ABitmap, clScheme23_Background,
  1095. clScheme23_Selection);
  1096. sdWindows8_24: DrawWindows8Background(ABitmap, clScheme24_Background,
  1097. clScheme24_Selection);
  1098. sdWindows8_25: DrawWindows8Background(ABitmap, clScheme25_Background,
  1099. clScheme25_Selection);
  1100. end;
  1101. end;
  1102. function DrawSample(AWidth, AHeight: integer; Element: TBCSampleDrawing;
  1103. Align: TAlign = alNone): TBGRABitmap;
  1104. var
  1105. ABitmap: TBGRABitmap;
  1106. begin
  1107. ABitmap := TBGRABitmap.Create(AWidth, AHeight);
  1108. DrawSample(ABitmap, Element, Align);
  1109. Result := ABitmap;
  1110. end;
  1111. procedure DrawiOSBar(ABitmap: TBGRABitmap);
  1112. begin
  1113. ABitmap.GradientFill(0, 0, ABitmap.Width, ABitmap.Height - 4,
  1114. BGRA(238, 245, 248, 255), BGRA(196, 204, 208, 255), gtLinear,
  1115. PointF(0, 0), PointF(0, ABitmap.Height - 4), dmSet);
  1116. with ABitmap do
  1117. begin
  1118. // Bottom Bevel
  1119. SetHorizLine(0, Height - 4, Width - 1, BGRA(190, 198, 202, 255));
  1120. SetHorizLine(0, Height - 3, Width - 1, BGRA(201, 209, 213, 255));
  1121. SetHorizLine(0, Height - 2, Width - 1, BGRA(134, 142, 147, 255));
  1122. SetHorizLine(0, Height - 1, Width - 1, BGRA(177, 180, 182, 255));
  1123. end;
  1124. end;
  1125. procedure DrawiOSToolBar(ABitmap: TBGRABitmap; Shadow: boolean = True);
  1126. begin
  1127. if Shadow then
  1128. begin
  1129. DoubleGradientAlphaFill(ABitmap, Rect(0, 3, ABitmap.Width, ABitmap.Height - 6),
  1130. BGRA(172, 185, 201), BGRA(134, 153, 178, 255),
  1131. BGRA(125, 147, 175, 255), BGRA(110, 132, 162, 255),
  1132. gdVertical, gdVertical, gdVertical, 0.5);
  1133. with ABitmap do
  1134. begin
  1135. // Top Bevel
  1136. SetHorizLine(0, 0, Width - 1, BGRA(201, 210, 221, 255));
  1137. SetHorizLine(0, 1, Width - 1, BGRA(173, 184, 200, 255));
  1138. SetHorizLine(0, 2, Width - 1, BGRA(179, 190, 205, 255));
  1139. // Bottom Bevel
  1140. SetHorizLine(0, Height - 6, Width - 1, BGRA(107, 129, 158, 255));
  1141. SetHorizLine(0, Height - 5, Width - 1, BGRA(116, 139, 170, 255));
  1142. SetHorizLine(0, Height - 4, Width - 1, BGRA(48, 54, 62, 255));
  1143. // Bottom Shadow
  1144. SetHorizLine(0, Height - 3, Width - 1, BGRA(0, 0, 0, 75));
  1145. SetHorizLine(0, Height - 2, Width - 1, BGRA(255, 255, 255, 50));
  1146. SetHorizLine(0, Height - 1, Width - 1, BGRA(0, 0, 0, 10));
  1147. end;
  1148. end
  1149. else
  1150. begin
  1151. DoubleGradientAlphaFill(ABitmap, Rect(0, 3, ABitmap.Width, ABitmap.Height - 3),
  1152. BGRA(172, 185, 201), BGRA(134, 153, 178, 255),
  1153. BGRA(125, 147, 175, 255), BGRA(110, 132, 162, 255),
  1154. gdVertical, gdVertical, gdVertical, 0.5);
  1155. with ABitmap do
  1156. begin
  1157. // Top Bevel
  1158. SetHorizLine(0, 0, Width - 1, BGRA(201, 210, 221, 255));
  1159. SetHorizLine(0, 1, Width - 1, BGRA(173, 184, 200, 255));
  1160. SetHorizLine(0, 2, Width - 1, BGRA(179, 190, 205, 255));
  1161. // Bottom Bevel
  1162. SetHorizLine(0, Height - 3, Width - 1, BGRA(107, 129, 158, 255));
  1163. SetHorizLine(0, Height - 2, Width - 1, BGRA(116, 139, 170, 255));
  1164. SetHorizLine(0, Height - 1, Width - 1, BGRA(48, 54, 62, 255));
  1165. end;
  1166. end;
  1167. end;
  1168. procedure DrawiOSBackground(ABitmap: TBGRABitmap);
  1169. var
  1170. temp: TBGRABitmap;
  1171. begin
  1172. temp := TBGRABitmap.Create(16, 1, BGRA(197, 204, 211));
  1173. with temp do
  1174. begin
  1175. SetPixel(7, 0, BGRA(203, 210, 217));
  1176. SetPixel(14, 0, BGRA(204, 211, 218));
  1177. BGRAReplace(temp, temp.FilterBlurRadial(1, rbFast));
  1178. BGRAReplace(temp, temp.FilterSharpen);
  1179. end;
  1180. ABitmap.Fill(temp);
  1181. temp.Free;
  1182. end;
  1183. procedure DrawWindows8Background(ABitmap: TBGRABitmap; cl1, cl2: TColor);
  1184. begin
  1185. ABitmap.Fill(cl2);
  1186. end;
  1187. end.