TBXOfficeXPTheme.pas 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412
  1. unit TBXOfficeXPTheme;
  2. // TBX Package
  3. // Copyright 2001-2004 Alex A. Denisov. All Rights Reserved
  4. // See TBX.chm for license and installation instructions
  5. //
  6. // Id: TBXOfficeXPTheme.pas 16 2004-05-26 02:02:55Z Alex@ZEISS
  7. interface
  8. {$I TB2Ver.inc}
  9. uses
  10. Windows, Messages, Graphics, TBXThemes, ImgList, Controls, TB2Item, Forms;
  11. type
  12. TItemPart = (ipBody, ipText, ipFrame);
  13. TBtnItemState = (bisNormal, bisDisabled, bisSelected, bisPressed, bisHot,
  14. bisDisabledHot, bisSelectedHot, bisPopupParent);
  15. TMenuItemState = (misNormal, misDisabled, misHot, misDisabledHot);
  16. TWinFramePart = (wfpBorder, wfpCaption, wfpCaptionText);
  17. TWinFrameState = (wfsActive, wfsInactive);
  18. TTBXOfficeXPTheme = class(TTBXTheme)
  19. private
  20. procedure TBXSysCommand(var Message: TMessage); message TBX_SYSCOMMAND;
  21. protected
  22. { View/Window Colors }
  23. MenubarColor: TColor;
  24. ToolbarColor: TColor;
  25. PopupColor: TColor;
  26. DockPanelColor: TColor;
  27. PopupFrameColor: TColor;
  28. WinFrameColors: array [TWinFrameState, TWinFramePart] of TColor;
  29. PnlFrameColors: array [TWinFrameState, TWinFramePart] of TColor;
  30. MenuItemColors: array [TMenuItemState, TItemPart] of TColor;
  31. BtnItemColors: array [TBtnItemState, TItemPart] of TColor;
  32. { Other Colors }
  33. DragHandleColor: TColor;
  34. PopupSeparatorColor: TColor;
  35. ToolbarSeparatorColor: TColor;
  36. IconShadowColor: TColor;
  37. StatusPanelFrameColor: TColor;
  38. procedure SetupColorCache; virtual;
  39. protected
  40. { Internal Methods }
  41. function GetPartColor(const ItemInfo: TTBXItemInfo; ItemPart: TItemPart): TColor;
  42. function GetBtnColor(const ItemInfo: TTBXItemInfo; ItemPart: TItemPart): TColor;
  43. public
  44. constructor Create(const AName: string); override;
  45. destructor Destroy; override;
  46. { Metrics access}
  47. function GetBooleanMetrics(Index: Integer): Boolean; override;
  48. function GetIntegerMetrics(Monitor: TMonitor; Index: Integer): Integer; override;
  49. procedure GetMargins(MarginID: Integer; out Margins: TTBXMargins); override;
  50. function GetImageOffset(Canvas: TCanvas; const ItemInfo: TTBXItemInfo; ImageList: TCustomImageList): TPoint; override;
  51. function GetItemColor(const ItemInfo: TTBXItemInfo): TColor; override;
  52. function GetItemTextColor(const ItemInfo: TTBXItemInfo): TColor; override;
  53. function GetItemImageBackground(const ItemInfo: TTBXItemInfo): TColor; override;
  54. function GetPopupShadowType: Integer; override;
  55. procedure GetViewBorder(Control: TControl; ViewType: Integer; out Border: TPoint); override;
  56. function GetViewColor(AViewType: Integer): TColor; override;
  57. procedure GetViewMargins(ViewType: Integer; out Margins: TTBXMargins); override;
  58. { Painting routines }
  59. procedure PaintBackgnd(Canvas: TCanvas; const ADockRect, ARect, AClipRect: TRect; AColor: TColor; Transparent: Boolean; AViewType: Integer); override;
  60. procedure PaintButton(Canvas: TCanvas; const ARect: TRect; const ItemInfo: TTBXItemInfo); override;
  61. procedure PaintCaption(Canvas: TCanvas; const ARect: TRect; const ItemInfo: TTBXItemInfo; const ACaption: string; AFormat: Cardinal; Rotated: Boolean); override;
  62. procedure PaintCheckMark(Canvas: TCanvas; ARect: TRect; const ItemInfo: TTBXItemInfo); override;
  63. procedure PaintChevron(Canvas: TCanvas; ARect: TRect; const ItemInfo: TTBXItemInfo); override;
  64. procedure PaintDock(Canvas: TCanvas; const ClientRect, DockRect: TRect; DockPosition: Integer); override;
  65. procedure PaintDropDownArrow(Canvas: TCanvas; const ARect: TRect; const ItemInfo: TTBXItemInfo); override;
  66. procedure PaintEditButton(Canvas: TCanvas; const ARect: TRect; var ItemInfo: TTBXItemInfo; ButtonInfo: TTBXEditBtnInfo); override;
  67. procedure PaintEditFrame(Monitor: TMonitor; Canvas: TCanvas; const ARect: TRect; var ItemInfo: TTBXItemInfo; const EditInfo: TTBXEditInfo); override;
  68. procedure PaintFloatingBorder(Canvas: TCanvas; const ARect: TRect; const WindowInfo: TTBXWindowInfo); override;
  69. procedure PaintFrame(Canvas: TCanvas; const ARect: TRect; const ItemInfo: TTBXItemInfo); override;
  70. procedure PaintImage(Canvas: TCanvas; ARect: TRect; const ItemInfo: TTBXItemInfo; ImageList: TCustomImageList; ImageIndex: Integer); override;
  71. procedure PaintMenuItem(Canvas: TCanvas; const ARect: TRect; var ItemInfo: TTBXItemInfo); override;
  72. procedure PaintMenuItemFrame(Canvas: TCanvas; const ARect: TRect; const ItemInfo: TTBXItemInfo); override;
  73. procedure PaintPopupNCArea(Canvas: TCanvas; R: TRect; const PopupInfo: TTBXPopupInfo); override;
  74. procedure PaintSeparator(Canvas: TCanvas; ARect: TRect; ItemInfo: TTBXItemInfo; Horizontal, LineSeparator: Boolean); override;
  75. procedure PaintToolbarNCArea(Monitor: TMonitor; Canvas: TCanvas; R: TRect; const ToolbarInfo: TTBXToolbarInfo); override;
  76. procedure PaintStatusBar(Control: TWinControl; Canvas: TCanvas; R: TRect; Part: Integer); override;
  77. end;
  78. implementation
  79. uses
  80. TBXUtils, TB2Common, Classes, Commctrl, SysUtils,
  81. Types, UITypes, UxTheme, PasTools;
  82. var
  83. StockImgList: TImageList;
  84. CounterLock: Integer;
  85. procedure InitializeStock;
  86. begin
  87. StockImgList := TImageList.Create(nil);
  88. StockImgList.Handle := ImageList_LoadBitmap(HInstance, 'TBXGLYPHS', 16, 0, clWhite);
  89. end;
  90. procedure FinalizeStock;
  91. begin
  92. StockImgList.Free;
  93. end;
  94. { TTBXOfficeXPTheme }
  95. function TTBXOfficeXPTheme.GetBooleanMetrics(Index: Integer): Boolean;
  96. begin
  97. case Index of
  98. TMB_OFFICEXPPOPUPALIGNMENT: Result := True;
  99. TMB_EDITMENUFULLSELECT: Result := True;
  100. TMB_EDITHEIGHTEVEN: Result := False;
  101. TMB_SOLIDTOOLBARNCAREA: Result := False;
  102. else
  103. Result := False;
  104. end;
  105. end;
  106. function TTBXOfficeXPTheme.GetIntegerMetrics(Monitor: TMonitor; Index: Integer): Integer;
  107. const
  108. DEFAULT = -1;
  109. begin
  110. case Index of
  111. TMI_SPLITBTN_ARROWWIDTH: Result := 12;
  112. TMI_DROPDOWN_ARROWWIDTH: Result := 8;
  113. TMI_DROPDOWN_ARROWMARGIN: Result := 3;
  114. TMI_MENU_IMGTEXTSPACE: Result := 5;
  115. TMI_MENU_LCAPTIONMARGIN: Result := 3;
  116. TMI_MENU_RCAPTIONMARGIN: Result := 3;
  117. TMI_MENU_SEPARATORSIZE: Result := 3;
  118. TMI_TLBR_SEPARATORSIZE: Result := 6;
  119. TMI_EDIT_FRAMEWIDTH: Result := 1;
  120. TMI_EDIT_TEXTMARGINHORZ: Result := 2;
  121. TMI_EDIT_TEXTMARGINVERT: Result := 2;
  122. TMI_EDIT_BTNWIDTH: Result := 14;
  123. TMI_EDIT_MENURIGHTINDENT: Result := 1;
  124. else
  125. Result := DEFAULT;
  126. end;
  127. if Result > 0 then
  128. begin
  129. Result := ScaleByPixelsPerInch(Result, Monitor);
  130. end;
  131. end;
  132. function TTBXOfficeXPTheme.GetViewColor(AViewType: Integer): TColor;
  133. begin
  134. Result := clBtnFace;
  135. if (AViewType and VT_TOOLBAR) = VT_TOOLBAR then
  136. begin
  137. if (AViewType and TVT_MENUBAR) = TVT_MENUBAR then Result := MenubarColor
  138. else Result := ToolbarColor;
  139. end
  140. else if (AViewType and VT_POPUP) = VT_POPUP then
  141. begin
  142. if (AViewType and PVT_LISTBOX) = PVT_LISTBOX then Result := clWindow
  143. else Result := PopupColor;
  144. end
  145. else if (AViewType and VT_DOCKPANEL) = VT_DOCKPANEL then Result := DockPanelColor
  146. else if (AViewType and VT_SECTIONHEADER) = VT_SECTIONHEADER then Result := ToolbarColor;
  147. end;
  148. function TTBXOfficeXPTheme.GetBtnColor(const ItemInfo: TTBXItemInfo; ItemPart: TItemPart): TColor;
  149. const
  150. BFlags1: array [Boolean] of TBtnItemState = (bisDisabled, bisDisabledHot);
  151. BFlags2: array [Boolean] of TBtnItemState = (bisSelected, bisSelectedHot);
  152. BFlags3: array [Boolean] of TBtnItemState = (bisNormal, bisHot);
  153. var
  154. B: TBtnItemState;
  155. Embedded: Boolean;
  156. begin
  157. with ItemInfo do
  158. begin
  159. Embedded := (ViewType and VT_TOOLBAR = VT_TOOLBAR) and
  160. (ViewType and TVT_EMBEDDED = TVT_EMBEDDED);
  161. if not Enabled then B := BFlags1[HoverKind = hkKeyboardHover]
  162. else if ItemInfo.IsPopupParent then B := bisPopupParent
  163. else if Pushed then B := bisPressed
  164. else if Selected then B := BFlags2[HoverKind <> hkNone]
  165. else B := BFlags3[HoverKind <> hkNone];
  166. Result := BtnItemColors[B, ItemPart];
  167. if Embedded then
  168. begin
  169. if (ItemPart = ipBody) and (Result = clNone) then Result := ToolbarColor;
  170. if ItemPart = ipFrame then
  171. begin
  172. if Selected then Result := clWindowFrame
  173. else if (Result = clNone) then Result := clBtnShadow;
  174. end;
  175. end;
  176. end;
  177. end;
  178. function TTBXOfficeXPTheme.GetPartColor(const ItemInfo: TTBXItemInfo; ItemPart: TItemPart): TColor;
  179. const
  180. MFlags1: array [Boolean] of TMenuItemState = (misDisabled, misDisabledHot);
  181. MFlags2: array [Boolean] of TMenuItemState = (misNormal, misHot);
  182. BFlags1: array [Boolean] of TBtnItemState = (bisDisabled, bisDisabledHot);
  183. BFlags2: array [Boolean] of TBtnItemState = (bisSelected, bisSelectedHot);
  184. BFlags3: array [Boolean] of TBtnItemState = (bisNormal, bisHot);
  185. var
  186. IsMenuItem, Embedded: Boolean;
  187. M: TMenuItemState;
  188. B: TBtnItemState;
  189. begin
  190. with ItemInfo do
  191. begin
  192. IsMenuItem := ((ViewType and PVT_POPUPMENU) = PVT_POPUPMENU) and
  193. ((ItemOptions and IO_TOOLBARSTYLE) = 0);
  194. Embedded := ((ViewType and VT_TOOLBAR) = VT_TOOLBAR) and
  195. ((ViewType and TVT_EMBEDDED) = TVT_EMBEDDED);
  196. if IsMenuItem then
  197. begin
  198. if not Enabled then M := MFlags1[HoverKind = hkKeyboardHover]
  199. else M := MFlags2[HoverKind <> hkNone];
  200. Result := MenuItemColors[M, ItemPart];
  201. end
  202. else
  203. begin
  204. if not Enabled then B := BFlags1[HoverKind = hkKeyboardHover]
  205. else if ItemInfo.IsPopupParent then B := bisPopupParent
  206. else if Pushed then B := bisPressed
  207. else if Selected then B := BFlags2[HoverKind <> hkNone]
  208. else B := BFlags3[HoverKind <> hkNone];
  209. Result := BtnItemColors[B, ItemPart];
  210. if Embedded and (Result = clNone) then
  211. begin
  212. if ItemPart = ipBody then Result := ToolbarColor;
  213. if ItemPart = ipFrame then Result := clBtnShadow;
  214. end;
  215. end;
  216. end;
  217. end;
  218. function TTBXOfficeXPTheme.GetItemColor(const ItemInfo: TTBXItemInfo): TColor;
  219. begin
  220. Result := GetPartColor(ItemInfo, ipBody);
  221. if Result = clNone then Result := GetViewColor(ItemInfo.ViewType);
  222. end;
  223. function TTBXOfficeXPTheme.GetItemTextColor(const ItemInfo: TTBXItemInfo): TColor;
  224. begin
  225. Result := GetPartColor(ItemInfo, ipText);
  226. end;
  227. function TTBXOfficeXPTheme.GetItemImageBackground(const ItemInfo: TTBXItemInfo): TColor;
  228. begin
  229. Result := GetBtnColor(ItemInfo, ipBody);
  230. if Result = clNone then Result := GetViewColor(ItemInfo.ViewType);
  231. end;
  232. procedure TTBXOfficeXPTheme.GetViewBorder(Control: TControl; ViewType: Integer; out Border: TPoint);
  233. const
  234. XMetrics: array [Boolean] of Integer = (SM_CXDLGFRAME, SM_CXFRAME);
  235. YMetrics: array [Boolean] of Integer = (SM_CYDLGFRAME, SM_CYFRAME);
  236. var
  237. Resizable: Boolean;
  238. procedure SetBorder(X, Y: Integer);
  239. begin
  240. Border.X := X;
  241. Border.Y := Y;
  242. end;
  243. begin
  244. if (ViewType and VT_TOOLBAR) = VT_TOOLBAR then
  245. begin
  246. if (ViewType and TVT_FLOATING) = TVT_FLOATING then
  247. begin
  248. Resizable := (ViewType and TVT_RESIZABLE) = TVT_RESIZABLE;
  249. Border.X := GetSystemMetricsForControl(Control, XMetrics[Resizable]) - 1;
  250. Border.Y := GetSystemMetricsForControl(Control, YMetrics[Resizable]) - 1;
  251. end
  252. else SetBorder(2, 2);
  253. end
  254. else if (ViewType and VT_POPUP) = VT_POPUP then
  255. begin
  256. if (ViewType and PVT_POPUPMENU) = PVT_POPUPMENU then Border.X := 1
  257. else Border.X := 2;
  258. Border.Y := 2;
  259. end
  260. else if (ViewType and VT_DOCKPANEL) = VT_DOCKPANEL then
  261. begin
  262. if (ViewType and DPVT_FLOATING) = DPVT_FLOATING then
  263. begin
  264. Resizable := (ViewType and DPVT_RESIZABLE) = DPVT_RESIZABLE;
  265. Border.X := GetSystemMetricsForControl(Control, XMetrics[Resizable]) - 1;
  266. Border.Y := GetSystemMetricsForControl(Control, YMetrics[Resizable]) - 1;
  267. end
  268. else SetBorder(2, 2);
  269. end
  270. else SetBorder(0, 0);
  271. end;
  272. procedure TTBXOfficeXPTheme.GetMargins(MarginID: Integer; out Margins: TTBXMargins);
  273. begin
  274. with Margins do
  275. case MarginID of
  276. MID_TOOLBARITEM:
  277. begin
  278. LeftWidth := 2; RightWidth := 2;
  279. TopHeight := 2; BottomHeight := 2;
  280. end;
  281. MID_MENUITEM:
  282. begin
  283. LeftWidth := 1; RightWidth := 1;
  284. TopHeight := 3; BottomHeight := 3;
  285. end;
  286. MID_STATUSPANE:
  287. begin
  288. LeftWidth := 1; RightWidth := 3;
  289. TopHeight := 1; BottomHeight := 1;
  290. end;
  291. else
  292. LeftWidth := 0;
  293. RightWidth := 0;
  294. TopHeight := 0;
  295. BottomHeight := 0;
  296. end;
  297. end;
  298. procedure TTBXOfficeXPTheme.PaintBackgnd(Canvas: TCanvas; const ADockRect, ARect, AClipRect: TRect;
  299. AColor: TColor; Transparent: Boolean; AViewType: Integer);
  300. var
  301. DC: HDC;
  302. R: TRect;
  303. begin
  304. DC := Canvas.Handle;
  305. if not Transparent then
  306. begin
  307. IntersectRect(R, ARect, AClipRect);
  308. FillRectEx(DC, R, AColor);
  309. end;
  310. end;
  311. procedure TTBXOfficeXPTheme.PaintCaption(Canvas: TCanvas;
  312. const ARect: TRect; const ItemInfo: TTBXItemInfo; const ACaption: string;
  313. AFormat: Cardinal; Rotated: Boolean);
  314. var
  315. R: TRect;
  316. begin
  317. with ItemInfo, Canvas do
  318. begin
  319. R := ARect;
  320. Brush.Style := bsClear;
  321. if Font.Color = clNone then Font.Color := GetPartColor(ItemInfo, ipText);
  322. if not Rotated then Windows.DrawText(Handle, PChar(ACaption), Length(ACaption), R, AFormat)
  323. else DrawRotatedText(Handle, ACaption, R, AFormat);
  324. Brush.Style := bsSolid;
  325. end;
  326. end;
  327. procedure TTBXOfficeXPTheme.PaintCheckMark(Canvas: TCanvas; ARect: TRect; const ItemInfo: TTBXItemInfo);
  328. var
  329. DC: HDC;
  330. X, Y: Integer;
  331. C: TColor;
  332. Two, Three, Four: Integer;
  333. Diag: Integer;
  334. I: Integer;
  335. begin
  336. Two := TBXScaleByTextHeightRunTime(Canvas, 2);
  337. Three := TBXScaleByTextHeightRunTime(Canvas, 3);
  338. Four := TBXScaleByTextHeightRunTime(Canvas, 4);
  339. DC := Canvas.Handle;
  340. X := (ARect.Left + ARect.Right) div 2 - 1;
  341. Y := (ARect.Top + ARect.Bottom) div 2 + 1;
  342. C := GetBtnColor(ItemInfo, ipText);
  343. if ItemInfo.ItemOptions and IO_RADIO > 0 then
  344. begin
  345. // Should we use SM_CXMENUCHECK to determine the size?
  346. // 10 div 14 is approximation of division by square root of 2 (pythagorean theorem)
  347. Diag := (Three * 10 div 14) + 1;
  348. RoundRectEx(DC, X-Diag+1, Y-Diag-1, X+Diag+1, Y+Diag-1, Four div 2, Four div 2,
  349. MixColors(C, ToolbarColor, 200), C);
  350. // Using Ellipse instead of RoundRect to draw circle was an attempt to draw it nicely on
  351. // high DPI. It didn't work. But using ellipse seems better anyway, so we kept it.
  352. EllipseEx(DC, X-Three+1, Y-Three-1, X+Three+1, Y+Three-1,
  353. C, C);
  354. end
  355. else
  356. begin
  357. for I := 1 to Two do
  358. begin
  359. PolyLineEx(DC, [Point(X-Two, Y-Two+I), Point(X, Y+I), Point(X+Four+1, Y-Four-1+I)], C);
  360. end;
  361. end;
  362. end;
  363. procedure TTBXOfficeXPTheme.PaintChevron(Canvas: TCanvas; ARect: TRect; const ItemInfo: TTBXItemInfo);
  364. const
  365. Pattern: array[Boolean, 0..15] of Byte = (
  366. ($CC, 0, $66, 0, $33, 0, $66, 0, $CC, 0, 0, 0, 0, 0, 0, 0),
  367. ($88, 0, $D8, 0, $70, 0, $20, 0, $88, 0, $D8, 0, $70, 0, $20, 0));
  368. var
  369. R2: TRect;
  370. W, H: Integer;
  371. begin
  372. R2 := ARect;
  373. PaintButton(Canvas, ARect, ItemInfo);
  374. if not ItemInfo.IsVertical then
  375. begin
  376. Inc(R2.Top, 4);
  377. R2.Bottom := R2.Top + 5;
  378. W := 8;
  379. H := 5;
  380. end
  381. else
  382. begin
  383. R2.Left := R2.Right - 9;
  384. R2.Right := R2.Left + 5;
  385. W := 5;
  386. H := 8;
  387. end;
  388. DrawGlyph(Canvas.Handle, R2, W, H, Pattern[ItemInfo.IsVertical][0], GetPartColor(ItemInfo, ipText));
  389. end;
  390. procedure TTBXOfficeXPTheme.PaintEditButton(Canvas: TCanvas; const ARect: TRect;
  391. var ItemInfo: TTBXItemInfo; ButtonInfo: TTBXEditBtnInfo);
  392. var
  393. DC: HDC;
  394. BtnDisabled, BtnHot, BtnPressed, Embedded: Boolean;
  395. R, BR: TRect;
  396. X, Y: Integer;
  397. SaveItemInfoPushed: Boolean;
  398. C: TColor;
  399. begin
  400. DC := Canvas.Handle;
  401. R := ARect;
  402. Embedded := ((ItemInfo.ViewType and VT_TOOLBAR) = VT_TOOLBAR) and
  403. ((ItemInfo.ViewType and TVT_EMBEDDED) = TVT_EMBEDDED);
  404. InflateRect(R, 1, 1);
  405. Inc(R.Left);
  406. with Canvas do
  407. if ButtonInfo.ButtonType = EBT_DROPDOWN then
  408. begin
  409. BtnDisabled := (ButtonInfo.ButtonState and EBDS_DISABLED) <> 0;
  410. BtnHot := (ButtonInfo.ButtonState and EBDS_HOT) <> 0;
  411. BtnPressed := (ButtonInfo.ButtonState and EBDS_PRESSED) <> 0;
  412. if not BtnDisabled then
  413. begin
  414. if BtnPressed or BtnHot or Embedded then PaintButton(Canvas, R, ItemInfo)
  415. else if (ItemInfo.ViewType and VT_TOOLBAR) = VT_TOOLBAR then
  416. begin
  417. R := ARect;
  418. if not Embedded then
  419. begin
  420. FrameRectEx(DC, R, clWindow, False);
  421. C := clWindow;
  422. end
  423. else C := GetBtnColor(ItemInfo, ipFrame);
  424. DrawLineEx(DC, R.Left - 1, R.Top, R.Left - 1, R.Bottom, C);
  425. end;
  426. end;
  427. PaintDropDownArrow(Canvas, R, ItemInfo);
  428. end
  429. else if ButtonInfo.ButtonType = EBT_SPIN then
  430. begin
  431. BtnDisabled := (ButtonInfo.ButtonState and EBSS_DISABLED) <> 0;
  432. BtnHot := (ButtonInfo.ButtonState and EBSS_HOT) <> 0;
  433. { Upper button }
  434. BR := R;
  435. BR.Bottom := (R.Top + R.Bottom + 1) div 2;
  436. BtnPressed := (ButtonInfo.ButtonState and EBSS_UP) <> 0;
  437. SaveItemInfoPushed := ItemInfo.Pushed;
  438. ItemInfo.Pushed := BtnPressed;
  439. if not BtnDisabled then
  440. begin
  441. if BtnPressed or BtnHot or Embedded then PaintButton(Canvas, BR, ItemInfo)
  442. else if (ItemInfo.ViewType and VT_TOOLBAR) = VT_TOOLBAR then
  443. begin
  444. BR.Left := ARect.Left; BR.Top := ARect.Top; BR.Right := ARect.Right;
  445. if not Embedded then
  446. begin
  447. FrameRectEx(DC, BR, clWindow, False);
  448. C := clWindow;
  449. end
  450. else C := GetBtnColor(ItemInfo, ipFrame);
  451. DrawLineEx(DC, BR.Left - 1, BR.Top, BR.Left - 1, BR.Bottom, C);
  452. end;
  453. end;
  454. X := (BR.Left + BR.Right) div 2;
  455. Y := (BR.Top + BR.Bottom - 1) div 2;
  456. Pen.Color := GetPartColor(ItemInfo, ipText);
  457. Brush.Color := Pen.Color;
  458. Polygon([Point(X - 2, Y + 1), Point(X + 2, Y + 1), Point(X, Y - 1)]);
  459. { Lower button }
  460. BR := R;
  461. BR.Top := (R.Top + R.Bottom) div 2;
  462. BtnPressed := (ButtonInfo.ButtonState and EBSS_DOWN) <> 0;
  463. ItemInfo.Pushed := BtnPressed;
  464. if not BtnDisabled then
  465. begin
  466. if BtnPressed or BtnHot or Embedded then PaintButton(Canvas, BR, ItemInfo)
  467. else if (ItemInfo.ViewType and VT_TOOLBAR) = VT_TOOLBAR then
  468. begin
  469. BR.Left := ARect.Left; BR.Bottom := ARect.Bottom; BR.Right := ARect.Right;
  470. if not Embedded then
  471. begin
  472. FrameRectEx(DC, BR, clWindow, False);
  473. C := clWindow;
  474. end
  475. else C := GetBtnColor(ItemInfo, ipFrame);
  476. DrawLineEx(DC, BR.Left - 1, BR.Top, BR.Left - 1, BR.Bottom, C);
  477. end;
  478. end;
  479. X := (BR.Left + BR.Right) div 2;
  480. Y := (BR.Top + BR.Bottom) div 2;
  481. C := GetPartColor(ItemInfo, ipText);
  482. PolygonEx(DC, [Point(X - 2, Y - 1), Point(X + 2, Y - 1), Point(X, Y + 1)], C, C);
  483. ItemInfo.Pushed := SaveItemInfoPushed;
  484. end;
  485. end;
  486. procedure TTBXOfficeXPTheme.PaintEditFrame(Monitor: TMonitor; Canvas: TCanvas;
  487. const ARect: TRect; var ItemInfo: TTBXItemInfo; const EditInfo: TTBXEditInfo);
  488. var
  489. DC: HDC;
  490. R: TRect;
  491. W: Integer;
  492. Embedded: Boolean;
  493. begin
  494. DC := Canvas.Handle;
  495. R := ARect;
  496. PaintFrame(Canvas, R, ItemInfo);
  497. W := GetIntegerMetrics(Monitor, TMI_EDIT_FRAMEWIDTH);
  498. InflateRect(R, -W, -W);
  499. Embedded := ((ItemInfo.ViewType and VT_TOOLBAR) = VT_TOOLBAR) and
  500. ((ItemInfo.ViewType and TVT_EMBEDDED) = TVT_EMBEDDED);
  501. if not (ItemInfo.Enabled or Embedded) then
  502. FrameRectEx(DC, R, BtnItemColors[bisDisabled, ipText], False);
  503. with EditInfo do if RightBtnWidth > 0 then Dec(R.Right, RightBtnWidth - 2);
  504. if ItemInfo.Enabled then
  505. begin
  506. if ((ItemInfo.ViewType and VT_TOOLBAR) <> VT_TOOLBAR) and (GetPartColor(ItemInfo, ipFrame) = clNone) then
  507. FrameRectEx(DC, R, ToolbarColor, False)
  508. else
  509. FrameRectEx(DC, R, clWindow, False);
  510. InflateRect(R, -1, -1);
  511. FillRectEx(DC, R, clWindow);
  512. if ((ItemInfo.ViewType and VT_TOOLBAR) <> VT_TOOLBAR) and (GetPartColor(ItemInfo, ipFrame) = clNone) then
  513. begin
  514. R := ARect;
  515. InflateRect(R, -1, -1);
  516. FrameRectEx(DC, R, ToolbarColor, False);
  517. end;
  518. end
  519. else InflateRect(R, -1, -1);
  520. with EditInfo do if LeftBtnWidth > 0 then Inc(R.Left, LeftBtnWidth - 2);
  521. if EditInfo.RightBtnWidth > 0 then
  522. begin
  523. R := ARect;
  524. InflateRect(R, -W, -W);
  525. R.Left := R.Right - EditInfo.RightBtnWidth;
  526. PaintEditButton(Canvas, R, ItemInfo, EditInfo.RightBtnInfo);
  527. end;
  528. end;
  529. procedure TTBXOfficeXPTheme.PaintDropDownArrow(Canvas: TCanvas;
  530. const ARect: TRect; const ItemInfo: TTBXItemInfo);
  531. var
  532. X, Y: Integer;
  533. Two: Integer;
  534. begin
  535. with ARect, Canvas do
  536. begin
  537. X := (Left + Right) div 2;
  538. Y := (Top + Bottom) div 2 - 1;
  539. Pen.Color := GetPartColor(ItemInfo, ipText);
  540. Brush.Color := Pen.Color;
  541. Two := TBXScaleByTextHeightRunTime(Canvas, 2);
  542. if ItemInfo.IsVertical then Polygon([Point(X, Y + Two), Point(X, Y - Two), Point(X - Two, Y)])
  543. else Polygon([Point(X - Two, Y), Point(X + Two, Y), Point(X, Y + Two)]);
  544. end;
  545. end;
  546. procedure TTBXOfficeXPTheme.PaintButton(Canvas: TCanvas; const ARect: TRect; const ItemInfo: TTBXItemInfo);
  547. var
  548. DC: HDC;
  549. R: TRect;
  550. begin
  551. DC := Canvas.Handle;
  552. with ItemInfo do
  553. begin
  554. R := ARect;
  555. if ((ItemOptions and IO_DESIGNING) <> 0) and not Selected then
  556. begin
  557. if ComboPart = cpSplitRight then Dec(R.Left);
  558. FrameRectEx(DC, R, GetNearestColor(DC, MixColors(clBtnShadow, clBtnFace, 100)), False);
  559. end
  560. else
  561. begin
  562. FrameRectEx(DC, R, GetBtnColor(ItemInfo, ipFrame), True);
  563. if (ComboPart = cpSplitLeft) and IsPopupParent then Inc(R.Right);
  564. if ComboPart = cpSplitRight then Dec(R.Left);
  565. FillRectEx(DC, R, GetBtnColor(ItemInfo, ipBody));
  566. end;
  567. if ComboPart = cpSplitRight then PaintDropDownArrow(Canvas, R, ItemInfo);
  568. end;
  569. end;
  570. procedure TTBXOfficeXPTheme.PaintFloatingBorder(Canvas: TCanvas; const ARect: TRect;
  571. const WindowInfo: TTBXWindowInfo);
  572. const
  573. WinStates: array [Boolean] of TWinFramestate = (wfsInactive, wfsActive);
  574. function GetBtnItemState(BtnState: Integer): TBtnItemState;
  575. begin
  576. if not WindowInfo.Active then Result := bisDisabled
  577. else if (BtnState and CDBS_PRESSED) <> 0 then Result := bisPressed
  578. else if (BtnState and CDBS_HOT) <> 0 then Result := bisHot
  579. else Result := bisNormal;
  580. end;
  581. var
  582. WinState: TWinFrameState;
  583. BtnItemState: TBtnItemState;
  584. SaveIndex, X, Y: Integer;
  585. Sz: TPoint;
  586. R: TRect;
  587. BodyColor, CaptionColor, CaptionText: TColor;
  588. IsDockPanel: Boolean;
  589. begin
  590. with Canvas do
  591. begin
  592. WinState := WinStates[WindowInfo.Active];
  593. IsDockPanel := (WindowInfo.ViewType and VT_DOCKPANEL) = VT_DOCKPANEL;
  594. BodyColor := Brush.Color;
  595. if (WRP_BORDER and WindowInfo.RedrawPart) <> 0 then
  596. begin
  597. R := ARect;
  598. if not IsDockPanel then Brush.Color := WinFrameColors[WinState, wfpBorder]
  599. else Brush.Color := PnlFrameColors[WinState, wfpBorder];
  600. SaveIndex := SaveDC(Canvas.Handle);
  601. Sz := WindowInfo.FloatingBorderSize;
  602. with R, Sz do ExcludeClipRect(Canvas.Handle, Left + X, Top + Y, Right - X, Bottom - Y);
  603. FillRect(R);
  604. RestoreDC(Canvas.Handle, SaveIndex);
  605. InflateRect(R, -Sz.X, -Sz.Y);
  606. Pen.Color := BodyColor;
  607. with R do
  608. if not IsDockPanel then
  609. Canvas.Polyline([
  610. Point(Left, Top - 1), Point(Right - 1, Top - 1),
  611. Point(Right, Top), Point(Right, Bottom - 1),
  612. Point(Right - 1, Bottom),
  613. Point(Left, Bottom), Point(Left - 1, Bottom - 1),
  614. Point(Left - 1, Top), Point(Left, Top - 1)
  615. ])
  616. else
  617. Canvas.Polyline([
  618. Point(Left, Top - 1), Point(Right - 1, Top - 1),
  619. Point(Right, Top), Point(Right, Bottom),
  620. Point(Left - 1, Bottom),
  621. Point(Left - 1, Top), Point(Left, Top - 1)
  622. ]);
  623. end;
  624. if not WindowInfo.ShowCaption then Exit;
  625. if (WindowInfo.ViewType and VT_TOOLBAR) = VT_TOOLBAR then
  626. begin
  627. CaptionColor := WinFrameColors[WinState, wfpCaption];
  628. CaptionText := WinFrameColors[WinState, wfpCaptionText];
  629. end
  630. else
  631. begin
  632. CaptionColor := PnlFrameColors[WinState, wfpCaption];
  633. CaptionText := PnlFrameColors[WinState, wfpCaptionText];
  634. end;
  635. { Caption }
  636. if (WRP_CAPTION and WindowInfo.RedrawPart) <> 0 then
  637. begin
  638. R := Rect(0, 0, WindowInfo.ClientWidth, GetSystemMetricsForControl(WindowInfo.ParentControl, SM_CYSMCAPTION) - 1);
  639. with WindowInfo.FloatingBorderSize do OffsetRect(R, X, Y);
  640. DrawLineEx(Canvas.Handle, R.Left, R.Bottom, R.Right, R.Bottom, BodyColor);
  641. if ((CDBS_VISIBLE and WindowInfo.CloseButtonState) <> 0) and
  642. ((WRP_CLOSEBTN and WindowInfo.RedrawPart) <> 0) then
  643. Dec(R.Right, GetSystemMetricsForControl(WindowInfo.ParentControl, SM_CYSMCAPTION) - 1);
  644. Brush.Color := CaptionColor;
  645. FillRect(R);
  646. InflateRect(R, -2, 0);
  647. Font.Assign(SmCaptionFont);
  648. Font.Color := CaptionText;
  649. DrawText(Canvas.Handle, WindowInfo.Caption, -1, R,
  650. DT_SINGLELINE or DT_VCENTER or DT_END_ELLIPSIS or DT_NOPREFIX);
  651. end;
  652. { Close button }
  653. if (CDBS_VISIBLE and WindowInfo.CloseButtonState) <> 0 then
  654. begin
  655. R := Rect(0, 0, WindowInfo.ClientWidth, GetSystemMetricsForControl(WindowInfo.ParentControl, SM_CYSMCAPTION) - 1);
  656. with WindowInfo.FloatingBorderSize do OffsetRect(R, X, Y);
  657. R.Left := R.Right - (R.Bottom - R.Top);
  658. DrawLineEx(Canvas.Handle, R.Left - 1, R.Bottom, R.Right, R.Bottom, BodyColor);
  659. Brush.Color := CaptionColor;
  660. FillRect(R);
  661. with R do
  662. begin
  663. X := (Left + Right - StockImgList.Width + 1) div 2;
  664. Y := (Top + Bottom - StockImgList.Height) div 2;
  665. end;
  666. BtnItemState := GetBtnItemState(WindowInfo.CloseButtonState);
  667. FrameRectEx(Canvas.Handle, R, BtnItemColors[BtnItemState, ipFrame], True);
  668. if FillRectEx(Canvas.Handle, R, BtnItemColors[BtnItemState, ipBody]) then
  669. DrawGlyph(Canvas.Handle, X, Y, StockImgList, 0, BtnItemColors[BtnItemState, ipText])
  670. else
  671. DrawGlyph(Canvas.Handle, X, Y, StockImgList, 0, CaptionText);
  672. end;
  673. end;
  674. end;
  675. procedure TTBXOfficeXPTheme.PaintFrame(Canvas: TCanvas; const ARect: TRect;
  676. const ItemInfo: TTBXItemInfo);
  677. var
  678. DC: HDC;
  679. R: TRect;
  680. begin
  681. DC := Canvas.Handle;
  682. R := ARect;
  683. FrameRectEx(DC, R, GetPartColor(ItemInfo, ipFrame), True);
  684. FillRectEx(DC, R, GetPartColor(ItemInfo, ipBody));
  685. end;
  686. function TTBXOfficeXPTheme.GetImageOffset(Canvas: TCanvas;
  687. const ItemInfo: TTBXItemInfo; ImageList: TCustomImageList): TPoint;
  688. begin
  689. Result.X := 0;
  690. if not (ImageList is TTBCustomImageList) then
  691. with ItemInfo do
  692. if Enabled and (HoverKind <> hkNone) and
  693. not (Selected or Pushed and not IsPopupParent) then
  694. Result.X := -1;
  695. Result.Y := Result.X
  696. end;
  697. procedure TTBXOfficeXPTheme.PaintImage(Canvas: TCanvas; ARect: TRect;
  698. const ItemInfo: TTBXItemInfo; ImageList: TCustomImageList; ImageIndex: Integer);
  699. var
  700. HiContrast: Boolean;
  701. begin
  702. with ItemInfo do
  703. begin
  704. if ImageList is TTBCustomImageList then
  705. begin
  706. TTBCustomImageList(ImageList).DrawState(Canvas, ARect.Left, ARect.Top,
  707. ImageIndex, Enabled, (HoverKind <> hkNone), Selected);
  708. Exit;
  709. end;
  710. if not Enabled then
  711. begin
  712. HiContrast := ColorIntensity(GetItemImageBackground(ItemInfo)) < 80;
  713. if not HiContrast then
  714. DrawTBXIconShadow(Canvas, ARect, ImageList, ImageIndex, 0)
  715. else
  716. DrawTBXIconFlatShadow(Canvas, ARect, ImageList, ImageIndex, clBtnShadow);
  717. end
  718. else if Selected or Pushed or (HoverKind <> hkNone) then
  719. begin
  720. if not (Selected or Pushed and not IsPopupParent) then
  721. begin
  722. DrawTBXIconShadow(Canvas, ARect, ImageList, ImageIndex, 1);
  723. OffsetRect(ARect, 1, 1);
  724. DrawTBXIconShadow(Canvas, ARect, ImageList, ImageIndex, 1);
  725. OffsetRect(ARect, -2, -2);
  726. end;
  727. DrawTBXIcon(Canvas, ARect, ImageList, ImageIndex);
  728. end
  729. else
  730. DrawTBXIcon(Canvas, ARect, ImageList, ImageIndex)
  731. end;
  732. end;
  733. procedure TTBXOfficeXPTheme.PaintMenuItemFrame(Canvas: TCanvas;
  734. const ARect: TRect; const ItemInfo: TTBXItemInfo);
  735. var
  736. R: TRect;
  737. begin
  738. R := ARect;
  739. if (ItemInfo.ViewType and PVT_TOOLBOX) <> PVT_TOOLBOX then with Canvas do
  740. begin
  741. R.Right := R.Left + ItemInfo.PopupMargin + 2;
  742. Brush.Color := ToolbarColor;
  743. FillRect(R);
  744. Inc(R.Left);
  745. R.Right := ARect.Right - 1;
  746. end;
  747. PaintFrame(Canvas, R, ItemInfo);
  748. end;
  749. procedure TTBXOfficeXPTheme.PaintMenuItem(Canvas: TCanvas; const ARect: TRect; var ItemInfo: TTBXItemInfo);
  750. var
  751. DC: HDC;
  752. R: TRect;
  753. X, Y: Integer;
  754. ArrowWidth: Integer;
  755. C, ClrText: TColor;
  756. begin
  757. DC := Canvas.Handle;
  758. with ItemInfo do
  759. begin
  760. ArrowWidth := GetSystemMetricsForControl(ItemInfo.Control, SM_CXMENUCHECK);
  761. PaintMenuItemFrame(Canvas, ARect, ItemInfo);
  762. ClrText := GetPartColor(ItemInfo, ipText);
  763. R := ARect;
  764. if (ItemOptions and IO_COMBO) <> 0 then
  765. begin
  766. // WinSCP: One pixel to the right (+ 1) to make combos with keyboard accelerator look better.
  767. // This moves the line into hitarea of the arrow (while it was in hitarea of the command originally)
  768. // Further move would require changes in hitarea testing.
  769. X := R.Right - ArrowWidth - 1 + 1;
  770. if not ItemInfo.Enabled then C := ClrText
  771. else if HoverKind = hkMouseHover then C := GetPartColor(ItemInfo, ipFrame)
  772. else C := PopupSeparatorColor;
  773. DrawLineEx(DC, X, R.Top + 1, X, R.Bottom - 1, C);
  774. end;
  775. if (ItemOptions and IO_SUBMENUITEM) <> 0 then
  776. begin
  777. Y := ARect.Bottom div 2;
  778. X := ARect.Right - ArrowWidth * 2 div 3 - 1;
  779. PolygonEx(DC, [Point(X, Y - (ArrowWidth div 5)), Point(X, Y + (ArrowWidth div 5)), Point(X + (ArrowWidth div 5), Y)], ClrText, ClrText);
  780. end;
  781. if Selected and Enabled then
  782. begin
  783. R := ARect;
  784. R.Left := ARect.Left + 1;
  785. R.Right := R.Left + ItemInfo.PopupMargin;
  786. InflateRect(R, -1, -1);
  787. FrameRectEx(DC, R, GetBtnColor(ItemInfo, ipFrame), True);
  788. FillRectEx(DC, R, GetBtnColor(ItemInfo, ipBody));
  789. end;
  790. end;
  791. end;
  792. procedure TTBXOfficeXPTheme.PaintPopupNCArea(Canvas: TCanvas; R: TRect; const PopupInfo: TTBXPopupInfo);
  793. var
  794. PR: TRect;
  795. begin
  796. with Canvas do
  797. begin
  798. Brush.Color := PopupFrameColor;
  799. FrameRect(R);
  800. InflateRect(R, -1, -1);
  801. Brush.Color := PopupColor;
  802. FillRect(R);
  803. if not IsRectEmpty(PopupInfo.ParentRect) then
  804. begin
  805. PR := PopupInfo.ParentRect;
  806. if not IsRectEmpty(PR) then with PR do
  807. begin
  808. Pen.Color := ToolbarColor;
  809. if Bottom = R.Top then
  810. begin
  811. if Left <= R.Left then Left := R.Left - 1;
  812. if Right >= R.Right then Right := R.Right + 1;
  813. MoveTo(Left + 1, Bottom - 1); LineTo(Right - 1, Bottom- 1);
  814. end
  815. else if Top = R.Bottom then
  816. begin
  817. if Left <= R.Left then Left := R.Left - 1;
  818. if Right >= R.Right then Right := R.Right + 1;
  819. MoveTo(Left + 1, Top); LineTo(Right - 1, Top);
  820. end;
  821. if Right = R.Left then
  822. begin
  823. if Top <= R.Top then Top := R.Top - 1;
  824. if Bottom >= R.Bottom then Bottom := R.Bottom + 1;
  825. MoveTo(Right - 1, Top + 1); LineTo(Right - 1, Bottom - 1);
  826. end
  827. else if Left = R.Right then
  828. begin
  829. if Top <= R.Top then Top := R.Top - 1;
  830. if Bottom >= R.Bottom then Bottom := R.Bottom + 1;
  831. MoveTo(Left, Top + 1); LineTo(Left, Bottom - 1);
  832. end;
  833. end;
  834. end;
  835. end;
  836. end;
  837. procedure TTBXOfficeXPTheme.PaintSeparator(Canvas: TCanvas; ARect: TRect;
  838. ItemInfo: TTBXItemInfo; Horizontal, LineSeparator: Boolean);
  839. var
  840. DC: HDC;
  841. IsToolbox: Boolean;
  842. R: TRect;
  843. C: TColor;
  844. begin
  845. { Note: for blank separators, Enabled = False }
  846. DC := Canvas.Handle;
  847. with ItemInfo, ARect do
  848. begin
  849. if Horizontal then
  850. begin
  851. IsToolbox := (ViewType and PVT_TOOLBOX) = PVT_TOOLBOX;
  852. if ((ItemOptions and IO_TOOLBARSTYLE) = 0) and not IsToolBox then
  853. begin
  854. R := ARect;
  855. R.Right := ItemInfo.PopupMargin + 2;
  856. FillRectEx(DC, R, ToolbarColor);
  857. Inc(Left, ItemInfo.PopupMargin + 9);
  858. C := PopupSeparatorColor;
  859. end
  860. else
  861. C := ToolbarSeparatorColor;
  862. Top := (Top + Bottom) div 2;
  863. if Enabled then DrawLineEx(DC, Left, Top, Right, Top, C);
  864. end
  865. else if Enabled then
  866. begin
  867. Left := (Left + Right) div 2;
  868. DrawLineEx(DC, Left, Top, Left, Bottom, ToolbarSeparatorColor);
  869. end;
  870. end;
  871. end;
  872. procedure DrawButtonBitmap(DC: HDC; R: TRect; Color: TColor);
  873. const
  874. {$IFNDEF SMALL_CLOSE_BUTTON}
  875. Pattern: array [0..15] of Byte =
  876. ($C3, 0, $66, 0, $3C, 0, $18, 0, $3C, 0, $66, 0, $C3, 0, 0, 0);
  877. {$ELSE}
  878. Pattern: array [0..15] of Byte =
  879. (0, 0, $63, 0, $36, 0, $1C, 0, $1C, 0, $36, 0, $63, 0, 0, 0);
  880. {$ENDIF}
  881. begin
  882. DrawGlyph(DC, R, 8, 7, Pattern[0], Color);
  883. end;
  884. procedure TTBXOfficeXPTheme.PaintToolbarNCArea(Monitor: TMonitor; Canvas: TCanvas; R: TRect; const ToolbarInfo: TTBXToolbarInfo);
  885. const
  886. DragHandleOffsets: array [Boolean, DHS_DOUBLE..DHS_SINGLE] of Integer = ((2, 0, 1), (5, 0, 5));
  887. function GetBtnItemState(BtnState: Integer): TBtnItemState;
  888. begin
  889. if (BtnState and CDBS_PRESSED) <> 0 then Result := bisPressed
  890. else if (BtnState and CDBS_HOT) <> 0 then Result := bisHot
  891. else Result := bisNormal;
  892. end;
  893. var
  894. DC: HDC;
  895. Sz: Integer;
  896. R2: TRect;
  897. SaveColor: TColor;
  898. SaveStyle: TBrushStyle;
  899. I: Integer;
  900. BtnVisible, Horz: Boolean;
  901. BtnItemState: TBtnItemState;
  902. Two, Three: Integer;
  903. begin
  904. DC := Canvas.Handle;
  905. with Canvas do
  906. begin
  907. SaveColor := Brush.Color;
  908. SaveStyle := Brush.Style;
  909. if ToolbarInfo.BorderStyle = bsSingle then
  910. begin
  911. I := ColorIntensity(clBtnFace);
  912. if not (TBXLoColor or not (I in [50..254])) or
  913. ((ToolbarInfo.ViewType and TVT_MENUBAR) = TVT_MENUBAR) then
  914. begin
  915. InflateRect(R, -1, -1);
  916. Dec(R.Right); Dec(R.Bottom);
  917. Pen.Color := SaveColor;
  918. Pen.Style := psSolid;
  919. Brush.Color := SaveColor;
  920. Brush.Style := SaveStyle; // should be either bsSolid or bsClear
  921. with R do
  922. Polygon([Point(Left + 1, Top), Point(Right - 1, Top), Point(Right, Top + 1),
  923. Point(Right, Bottom - 1), Point(Right - 1, Bottom), Point(Left + 1, Bottom),
  924. Point(Left, Bottom - 1), Point(Left, Top + 1)]);
  925. Brush.Style := bsSolid;
  926. Inc(R.Left);
  927. Inc(R.Top);
  928. end
  929. else
  930. begin
  931. Brush.Bitmap := AllocPatternBitmap(ToolbarColor, BtnItemColors[bisDisabled, ipText]);
  932. with R do
  933. begin
  934. FillRect(Rect(Left + 1, Top, Right - 1, Top + 1));
  935. FillRect(Rect(Left + 1, Bottom - 1, Right - 1, Bottom));
  936. FillRect(Rect(Left, Top + 1, Left + 1, Bottom - 1));
  937. FillRect(Rect(Right - 1, Top + 1, Right, Bottom - 1));
  938. end;
  939. InflateRect(R, -1, -1);
  940. Brush.Color := SaveColor;
  941. FillRect(R);
  942. end;
  943. end
  944. else
  945. InflateRect(R, -1, -1);
  946. InflateRect(R, -1, -1);
  947. if not ToolbarInfo.AllowDrag then Exit;
  948. BtnVisible := (ToolbarInfo.CloseButtonState and CDBS_VISIBLE) <> 0;
  949. Sz := GetTBXDragHandleSize(ToolbarInfo);
  950. Horz := not ToolbarInfo.IsVertical;
  951. if Horz then R.Right := R.Left + Sz
  952. else R.Bottom := R.Top + Sz;
  953. { Drag Handle }
  954. if ToolbarInfo.DragHandleStyle <> DHS_NONE then
  955. begin
  956. R2 := R;
  957. // Using DPI scaling instead of text-height scaling because
  958. // toolbar NC area pieces are already DPI-scaled in
  959. // TB2Dock initialization section
  960. Two := ScaleByPixelsPerInch(2, Monitor);
  961. Three := ScaleByPixelsPerInch(3, Monitor);
  962. if Horz then
  963. begin
  964. Inc(R2.Left, DragHandleOffsets[BtnVisible, ToolbarInfo.DragHandleStyle]);
  965. if BtnVisible then Inc(R2.Top, Sz - 2);
  966. R2.Right := R2.Left + Three;
  967. end
  968. else
  969. begin
  970. Inc(R2.Top, DragHandleOffsets[BtnVisible, ToolbarInfo.DragHandleStyle]);
  971. if BtnVisible then Dec(R2.Right, Sz - 2);
  972. R2.Bottom := R2.Top + Three;
  973. end;
  974. Pen.Color := DragHandleColor;
  975. if Horz then
  976. begin
  977. I := R2.Top + Three;
  978. while I < R2.Bottom - Three do
  979. begin
  980. MoveTo(R2.Left, I); LineTo(R2.Right, I);
  981. Inc(I, Two);
  982. end;
  983. end
  984. else
  985. begin
  986. I := R2.Left + Three;
  987. while I < R2.Right - Three do
  988. begin
  989. MoveTo(I, R2.Top); LineTo(I, R2.Bottom);
  990. Inc(I, Two);
  991. end;
  992. end;
  993. end;
  994. { Close button }
  995. if BtnVisible then
  996. begin
  997. R2 := R;
  998. if Horz then
  999. begin
  1000. Dec(R2.Right);
  1001. R2.Bottom := R2.Top + R2.Right - R2.Left;
  1002. end
  1003. else
  1004. begin
  1005. Dec(R2.Bottom);
  1006. R2.Left := R2.Right - R2.Bottom + R2.Top;
  1007. end;
  1008. BtnItemState := GetBtnItemState(ToolbarInfo.CloseButtonState);
  1009. FrameRectEx(DC, R2, BtnItemColors[BtnItemState, ipFrame], True);
  1010. FillRectEx(DC, R2, BtnItemColors[BtnItemState, ipBody]);
  1011. DrawButtonBitmap(DC, R2, BtnItemColors[BtnItemState, ipText]);
  1012. end;
  1013. end;
  1014. end;
  1015. procedure TTBXOfficeXPTheme.PaintDock(Canvas: TCanvas; const ClientRect,
  1016. DockRect: TRect; DockPosition: Integer);
  1017. begin
  1018. // this theme does not support dock painting
  1019. end;
  1020. procedure TTBXOfficeXPTheme.SetupColorCache;
  1021. var
  1022. DC: HDC;
  1023. HotBtnFace, DisabledText: TColor;
  1024. procedure Undither(var C: TColor);
  1025. begin
  1026. if C <> clNone then C := GetNearestColor(DC, ColorToRGB(C));
  1027. end;
  1028. begin
  1029. DC := StockCompatibleBitmap.Canvas.Handle;
  1030. if TBXLoColor then
  1031. begin
  1032. { View/Window Colors }
  1033. MenubarColor := clBtnFace;
  1034. ToolbarColor := clBtnFace;
  1035. PopupColor := clWindow;
  1036. DockPanelColor := clWindow;
  1037. StatusPanelFrameColor := clBtnShadow;
  1038. PopupFrameColor := clBtnText;
  1039. WinFrameColors[wfsActive, wfpBorder] := clBtnShadow;
  1040. WinFrameColors[wfsActive, wfpCaption] := clBtnShadow;
  1041. WinFrameColors[wfsActive, wfpCaptionText] := clBtnHighlight;
  1042. WinFrameColors[wfsInactive, wfpBorder] := clBtnShadow;
  1043. WinFrameColors[wfsInactive, wfpCaption] := clBtnShadow;
  1044. WinFrameColors[wfsInactive, wfpCaptionText] := clBtnHighlight;
  1045. PnlFrameColors[wfsActive, wfpBorder] := clBtnShadow;
  1046. PnlFrameColors[wfsActive, wfpCaption] := clBtnFace;
  1047. PnlFrameColors[wfsActive, wfpCaptionText] := clBtnText;
  1048. PnlFrameColors[wfsInactive, wfpBorder] := clBtnShadow;
  1049. PnlFrameColors[wfsInactive, wfpCaption] := clBtnFace;
  1050. PnlFrameColors[wfsInactive, wfpCaptionText] := clBtnText;
  1051. MenuItemColors[misNormal, ipBody] := clNone;
  1052. MenuItemColors[misNormal, ipText] := clWindowText;
  1053. MenuItemColors[misNormal, ipFrame] := clNone;
  1054. MenuItemColors[misDisabled, ipBody] := clNone;
  1055. MenuItemColors[misDisabled, ipText] := clGrayText;
  1056. MenuItemColors[misDisabled, ipFrame] := clNone;
  1057. MenuItemColors[misHot, ipBody] := clWindow;
  1058. MenuItemColors[misHot, ipText] := clWindowtext;
  1059. MenuItemColors[misHot, ipFrame] := clHighlight;
  1060. MenuItemColors[misDisabledHot, ipBody] := clWindow;
  1061. MenuItemColors[misDisabledHot, ipText] := clGrayText;
  1062. MenuItemColors[misDisabledHot, ipFrame] := clHighlight;
  1063. BtnItemColors[bisNormal, ipBody] := clNone;
  1064. BtnItemColors[bisNormal, ipText] := clBtnText;
  1065. BtnItemColors[bisNormal, ipFrame] := clNone;
  1066. BtnItemColors[bisDisabled, ipBody] := clNone;
  1067. BtnItemColors[bisDisabled, ipText] := clBtnShadow;
  1068. BtnItemColors[bisDisabled, ipFrame] := clNone;
  1069. BtnItemColors[bisSelected, ipBody] := clWindow;
  1070. BtnItemColors[bisSelected, ipText] := clWindowText;
  1071. BtnItemColors[bisSelected, ipFrame] := clHighlight;
  1072. BtnItemColors[bisPressed, ipBody] := clHighlight;
  1073. BtnItemColors[bisPressed, ipText] := clHighlightText;
  1074. BtnItemColors[bisPressed, ipFrame] := clHighlight;
  1075. BtnItemColors[bisHot, ipBody] := clWindow;
  1076. BtnItemColors[bisHot, ipText] := clWindowText;
  1077. BtnItemColors[bisHot, ipFrame] := clHighlight;
  1078. BtnItemColors[bisDisabledHot, ipBody] := clWindow;
  1079. BtnItemColors[bisDisabledHot, ipText] := clBtnShadow;
  1080. BtnItemColors[bisDisabledHot, ipFrame] := clHighlight;
  1081. BtnItemColors[bisSelectedHot, ipBody] := clHighlight;
  1082. BtnItemColors[bisSelectedHot, ipText] := clHighlightText;
  1083. BtnItemColors[bisSelectedHot, ipFrame] := clHighlight;
  1084. BtnItemColors[bisPopupParent, ipBody] := clBtnFace;
  1085. BtnItemColors[bisPopupParent, ipText] := clBtnText;
  1086. BtnItemColors[bisPopupParent, ipFrame] := PopupFrameColor;
  1087. { Other Colors }
  1088. DragHandleColor := clBtnText;
  1089. IconShadowColor := clBtnFace;
  1090. PopupSeparatorColor := clBtnShadow;
  1091. ToolbarSeparatorColor := clBtnShadow;
  1092. end
  1093. else
  1094. begin
  1095. { View/Window Colors }
  1096. MenubarColor := clBtnFace;
  1097. ToolbarColor := Blend(clWindow, clBtnFace, 165);
  1098. PopupColor := Blend(clBtnFace, clWindow, 143);
  1099. DockPanelColor := PopupColor;
  1100. PopupFrameColor := Blend(clBtnText, clBtnShadow, 20);
  1101. SetContrast(PopupFrameColor, PopupColor, 100);
  1102. HotBtnFace := Blend(clHighlight, clWindow, 30);
  1103. SetContrast(HotBtnFace, ToolbarColor, 50);
  1104. DisabledText := Blend(clBtnshadow, clWindow, 90);
  1105. WinFrameColors[wfsActive, wfpBorder] := Blend(clBtnText, clBtnShadow, 15);
  1106. SetContrast(WinFrameColors[wfsActive, wfpBorder], ToolbarColor, 120);
  1107. WinFrameColors[wfsActive, wfpCaption] := clBtnShadow;
  1108. WinFrameColors[wfsActive, wfpCaptionText] := clBtnHighlight;
  1109. SetContrast(WinFrameColors[wfsActive, wfpCaptionText], clBtnShadow, 180);
  1110. WinFrameColors[wfsInactive, wfpBorder] := WinFrameColors[wfsActive, wfpBorder];
  1111. WinFrameColors[wfsInactive, wfpCaption] := clBtnFace;
  1112. WinFrameColors[wfsInactive, wfpCaptionText] := DisabledText;
  1113. SetContrast(WinFrameColors[wfsInactive, wfpCaptionText], clBtnFace, 120);
  1114. PnlFrameColors[wfsActive, wfpBorder] := clBtnShadow;
  1115. PnlFrameColors[wfsActive, wfpCaption] := clBtnFace;
  1116. PnlFrameColors[wfsActive, wfpCaptionText] := clBtnText;
  1117. PnlFrameColors[wfsInactive, wfpBorder] := clBtnShadow;
  1118. PnlFrameColors[wfsInactive, wfpCaption] := clBtnFace;
  1119. PnlFrameColors[wfsInactive, wfpCaptionText] := DisabledText;
  1120. SetContrast(PnlFrameColors[wfsInactive, wfpCaptionText], clBtnFace, 120);
  1121. BtnItemColors[bisNormal, ipBody] := clNone;
  1122. BtnItemColors[bisNormal, ipText] := clBtnText;
  1123. SetContrast(BtnItemColors[bisNormal, ipText], ToolbarColor, 180);
  1124. BtnItemColors[bisNormal, ipFrame] := clNone;
  1125. BtnItemColors[bisDisabled, ipBody] := clNone;
  1126. BtnItemColors[bisDisabled, ipText] := DisabledText;
  1127. SetContrast(BtnItemColors[bisDisabled, ipText], ToolbarColor, 80);
  1128. BtnItemColors[bisDisabled, ipFrame] := clNone;
  1129. BtnItemColors[bisSelected, ipBody] := Blend(clHighlight, Blend(clBtnFace, clWindow, 50), 10);
  1130. SetContrast(BtnItemColors[bisSelected, ipBody], ToolbarColor, 5);
  1131. BtnItemColors[bisSelected, ipText] := BtnItemColors[bisNormal, ipText];
  1132. BtnItemColors[bisSelected, ipFrame] := clHighlight;
  1133. BtnItemColors[bisPressed, ipBody] := Blend(clHighlight, clWindow, 50);
  1134. BtnItemColors[bisPressed, ipText] := clHighlightText;
  1135. BtnItemColors[bisPressed, ipFrame] := clHighlight;
  1136. BtnItemColors[bisHot, ipBody] := HotBtnFace;
  1137. BtnItemColors[bisHot, ipText] := clMenuText;
  1138. SetContrast(BtnItemColors[bisHot, ipText], BtnItemColors[bisHot, ipBody], 180);
  1139. BtnItemColors[bisHot, ipFrame] := clHighlight;
  1140. SetContrast(BtnItemColors[bisHot, ipFrame], ToolbarColor, 100);
  1141. BtnItemColors[bisDisabledHot, ipBody] := HotBtnFace;
  1142. BtnItemColors[bisDisabledHot, ipText] := DisabledText;
  1143. BtnItemColors[bisDisabledHot, ipFrame] := clHighlight;
  1144. BtnItemColors[bisSelectedHot, ipBody] := Blend(clHighlight, clWindow, 50);
  1145. SetContrast(BtnItemColors[bisSelectedHot, ipBody], ToolbarColor, 30);
  1146. BtnItemColors[bisSelectedHot, ipText] := clHighlightText;
  1147. SetContrast(BtnItemColors[bisSelectedHot, ipText], BtnItemColors[bisSelectedHot, ipBody], 180);
  1148. BtnItemColors[bisSelectedHot, ipFrame] := clHighlight;
  1149. SetContrast(BtnItemColors[bisSelectedHot, ipFrame], BtnItemColors[bisSelectedHot, ipBody], 100);
  1150. BtnItemColors[bisPopupParent, ipBody] := ToolbarColor;
  1151. BtnItemColors[bisPopupParent, ipText] := BtnItemColors[bisNormal, ipText];
  1152. BtnItemColors[bisPopupParent, ipFrame] := PopupFrameColor;
  1153. MenuItemColors[misNormal, ipBody] := clNone;
  1154. MenuItemColors[misNormal, ipText] := clWindowText;
  1155. SetContrast(MenuItemColors[misNormal, ipText], PopupColor, 180);
  1156. MenuItemColors[misNormal, ipFrame] := clNone;
  1157. MenuItemColors[misDisabled, ipBody] := clNone;
  1158. MenuItemColors[misDisabled, ipText] := Blend(clGrayText, clWindow, 70);
  1159. SetContrast(MenuItemColors[misDisabled, ipText], PopupColor, 80); // 145?
  1160. MenuItemColors[misDisabled, ipFrame] := clNone;
  1161. MenuItemColors[misHot, ipBody] := BtnItemColors[bisHot, ipBody];
  1162. MenuItemColors[misHot, ipText] := BtnItemColors[bisHot, ipText];
  1163. MenuItemColors[misHot, ipFrame] := BtnItemColors[bisHot, ipFrame];
  1164. MenuItemColors[misDisabledHot, ipBody] := PopupColor;
  1165. MenuItemColors[misDisabledHot, ipText] := Blend(clGrayText, clWindow, 70);
  1166. MenuItemColors[misDisabledHot, ipFrame] := clHighlight;
  1167. { Other Colors }
  1168. DragHandleColor := Blend(clBtnShadow, clWindow, 75);
  1169. SetContrast(DragHandleColor, ToolbarColor, 85);
  1170. IconShadowColor := Blend(clBlack, HotBtnFace, 25);
  1171. ToolbarSeparatorColor := Blend(clBtnShadow, clWindow, 70);
  1172. SetContrast(ToolbarSeparatorColor, ToolbarColor, 50);
  1173. PopupSeparatorColor := ToolbarSeparatorColor;
  1174. StatusPanelFrameColor := Blend(clWindow, clBtnFace, 30);
  1175. SetContrast(StatusPanelFrameColor, clBtnFace, 30);
  1176. Undither(MenubarColor);
  1177. Undither(ToolbarColor);
  1178. Undither(PopupColor);
  1179. Undither(DockPanelColor);
  1180. Undither(PopupFrameColor);
  1181. Undither(WinFrameColors[wfsActive, wfpBorder]);
  1182. Undither(WinFrameColors[wfsActive, wfpCaption]);
  1183. Undither(WinFrameColors[wfsActive, wfpCaptionText]);
  1184. Undither(WinFrameColors[wfsInactive, wfpBorder]);
  1185. Undither(WinFrameColors[wfsInactive, wfpCaption]);
  1186. Undither(WinFrameColors[wfsInactive, wfpCaptionText]);
  1187. Undither(PnlFrameColors[wfsActive, wfpBorder]);
  1188. Undither(PnlFrameColors[wfsActive, wfpCaption]);
  1189. Undither(PnlFrameColors[wfsActive, wfpCaptionText]);
  1190. Undither(PnlFrameColors[wfsInactive, wfpBorder]);
  1191. Undither(PnlFrameColors[wfsInactive, wfpCaption]);
  1192. Undither(PnlFrameColors[wfsInactive, wfpCaptionText]);
  1193. Undither(BtnItemColors[bisNormal, ipBody]);
  1194. Undither(BtnItemColors[bisNormal, ipText]);
  1195. Undither(BtnItemColors[bisNormal, ipFrame]);
  1196. Undither(BtnItemColors[bisDisabled, ipBody]);
  1197. Undither(BtnItemColors[bisDisabled, ipText]);
  1198. Undither(BtnItemColors[bisDisabled, ipFrame]);
  1199. Undither(BtnItemColors[bisSelected, ipBody]);
  1200. Undither(BtnItemColors[bisSelected, ipText]);
  1201. Undither(BtnItemColors[bisSelected, ipFrame]);
  1202. Undither(BtnItemColors[bisPressed, ipBody]);
  1203. Undither(BtnItemColors[bisPressed, ipText]);
  1204. Undither(BtnItemColors[bisPressed, ipFrame]);
  1205. Undither(BtnItemColors[bisHot, ipBody]);
  1206. Undither(BtnItemColors[bisHot, ipText]);
  1207. Undither(BtnItemColors[bisHot, ipFrame]);
  1208. Undither(BtnItemColors[bisDisabledHot, ipBody]);
  1209. Undither(BtnItemColors[bisDisabledHot, ipText]);
  1210. Undither(BtnItemColors[bisDisabledHot, ipFrame]);
  1211. Undither(BtnItemColors[bisSelectedHot, ipBody]);
  1212. Undither(BtnItemColors[bisSelectedHot, ipText]);
  1213. Undither(BtnItemColors[bisSelectedHot, ipFrame]);
  1214. Undither(BtnItemColors[bisPopupParent, ipBody]);
  1215. Undither(BtnItemColors[bisPopupParent, ipText]);
  1216. Undither(BtnItemColors[bisPopupParent, ipFrame]);
  1217. Undither(MenuItemColors[misNormal, ipBody]);
  1218. Undither(MenuItemColors[misNormal, ipText]);
  1219. Undither(MenuItemColors[misNormal, ipFrame]);
  1220. Undither(MenuItemColors[misDisabled, ipBody]);
  1221. Undither(MenuItemColors[misDisabled, ipText]);
  1222. Undither(MenuItemColors[misDisabled, ipFrame]);
  1223. Undither(MenuItemColors[misHot, ipBody]);
  1224. Undither(MenuItemColors[misHot, ipText]);
  1225. Undither(MenuItemColors[misHot, ipFrame]);
  1226. Undither(MenuItemColors[misDisabledHot, ipBody]);
  1227. Undither(MenuItemColors[misDisabledHot, ipText]);
  1228. Undither(MenuItemColors[misDisabledHot, ipFrame]);
  1229. Undither(DragHandleColor);
  1230. Undither(IconShadowColor);
  1231. Undither(ToolbarSeparatorColor);
  1232. Undither(PopupSeparatorColor);
  1233. Undither(StatusPanelFrameColor);
  1234. end;
  1235. end;
  1236. function TTBXOfficeXPTheme.GetPopupShadowType: Integer;
  1237. begin
  1238. Result := PST_OFFICEXP;
  1239. end;
  1240. constructor TTBXOfficeXPTheme.Create(const AName: string);
  1241. begin
  1242. inherited;
  1243. if CounterLock = 0 then InitializeStock;
  1244. Inc(CounterLock);
  1245. AddTBXSysChangeNotification(Self);
  1246. SetupColorCache;
  1247. end;
  1248. destructor TTBXOfficeXPTheme.Destroy;
  1249. begin
  1250. RemoveTBXSysChangeNotification(Self);
  1251. Dec(CounterLock);
  1252. if CounterLock = 0 then FinalizeStock;
  1253. inherited;
  1254. end;
  1255. procedure TTBXOfficeXPTheme.GetViewMargins(ViewType: Integer; out Margins: TTBXMargins);
  1256. begin
  1257. Margins.LeftWidth := 0;
  1258. Margins.TopHeight := 0;
  1259. Margins.RightWidth := 0;
  1260. Margins.BottomHeight := 0;
  1261. end;
  1262. procedure TTBXOfficeXPTheme.PaintStatusBar(Control: TWinControl; Canvas: TCanvas; R: TRect; Part: Integer);
  1263. var
  1264. D: Integer;
  1265. DC: HDC;
  1266. procedure DiagLine(C: TColor);
  1267. begin
  1268. with R do
  1269. DrawLineEx(DC, Right - 1 - D, Bottom - 1, Right, Bottom - D - 2, C);
  1270. Inc(D);
  1271. end;
  1272. var
  1273. Theme: THandle;
  1274. begin
  1275. DC := Canvas.Handle;
  1276. case Part of
  1277. SBP_BODY:
  1278. begin
  1279. FillRectEx(DC, R, clBtnFace);
  1280. end;
  1281. SBP_PANE, SBP_LASTPANE:
  1282. begin
  1283. if Part = SBP_PANE then Dec(R.Right, 2);
  1284. FrameRectEx(DC, R, StatusPanelFrameColor, False);
  1285. end;
  1286. SBP_GRIPPER:
  1287. begin
  1288. Inc(R.Right);
  1289. Theme := OpenThemeData(Control.Handle, 'STATUS');
  1290. DrawThemeBackground(Theme, DC, SP_GRIPPER, 0, R, nil);
  1291. CloseThemeData(Theme);
  1292. end;
  1293. end;
  1294. end;
  1295. procedure TTBXOfficeXPTheme.TBXSysCommand(var Message: TMessage);
  1296. begin
  1297. if Message.WParam = TSC_VIEWCHANGE then SetupColorCache;
  1298. end;
  1299. end.