1 // ------------------------------------------------------------------------------------//
2 //    TODO: write cool acknowledgement here                                            //
3 //                                                                                     //
4 // original file name ThemeSrv.pas changed to themes.pas to be compatible with delphi  //
5 // adapted for Lazarus by Lazarus Team                                                 //
6 // ------------------------------------------------------------------------------------//
7 
8 //----------------------------------------------------------------------------------------------------------------------
9 // Windows XP Theme Manager is freeware. You may freely use it in any software, including commercial software, provided
10 // you accept the following conditions:
11 //
12 // 1) The software may not be included into component collections and similar compilations which are sold. If you want
13 //    to distribute this software for money then contact me first and ask for my permission.
14 // 2) My copyright notices in the source code may not be removed or modified.
15 // 3) If you modify and/or distribute the code to any third party then you must not veil the original author. It must
16 //    always be clearly identifiable that I, Mike Lischke, am the original author.
17 // Although it is not required it would be a nice move to recognize my work by adding a citation to the application's
18 // about box or a similar place.
19 //
20 // The original code is ThemeSrv.pas, released 03. February 2002.
21 //
22 // The initial developer of the original code is:
23 //   Mike Lischke (public@soft-gems.net, www.soft-gems.net).
24 //
25 // Portions created by Mike Lischke are
26 // (C) 2001-2005 Mike Lischke. All Rights Reserved.
27 //----------------------------------------------------------------------------------------------------------------------
28 //
29 // This unit contains the implementation of TThemeServices which is a designed to manage all necessary aspects of
30 // the Windows XP (and up) theme APIs. The component is responsible for loading and unloading of the theme DLL
31 // and offers properties and methods to test for various aspects of the theme APIs and to ease painting of themed
32 // window content.
33 //
34 // The TThemeServices class is designed to work for controls which need XP paint stuff. It does not manipulate
35 // any VCL class (for this task TThemeManager is responsible) and can be used standalone (also as general support
36 // tool in an application). Using the global ThemeServices function you can implicitely create and use a single
37 // instance of the class. Theme Manager uses the same approach.
38 //----------------------------------------------------------------------------------------------------------------------
39 // For version information and history see ThemeMgr.pas source file.
40 //----------------------------------------------------------------------------------------------------------------------
41 
42 unit Themes;
43 
44 {$mode objfpc}{$H+}
45 
46 interface
47 
48 uses
49   Classes, SysUtils, Types, Math,
50   // LCL  -  Controls cannot be used here to prevent circular references
51   LCLProc, LCLType, Graphics, TmSchema,
52   // LazUtils
53   GraphType;
54 
55 type
56   // These are all elements which can be themed.
57   TThemedElement = (
58     teButton,
59     teClock,
60     teComboBox,
61     teEdit,
62     teExplorerBar,
63     teHeader,
64     teListView,
65     teMenu,
66     tePage,
67     teProgress,
68     teRebar,
69     teScrollBar,
70     teSpin,
71     teStartPanel,
72     teStatus,
73     teTab,
74     teTaskBand,
75     teTaskBar,
76     teToolBar,
77     teToolTip,
78     teTrackBar,
79     teTrayNotify,
80     teTreeview,
81     teWindow
82   );
83 
84   // 'Button' theme data
85   TThemedButton = (
86     tbButtonDontCare,
87     tbButtonRoot,       // The root part of each element is sometimes used for special painting and does not
88                         // belong to a certain state.
89     tbPushButtonNormal, tbPushButtonHot, tbPushButtonPressed, tbPushButtonDisabled, tbPushButtonDefaulted,
90     tbRadioButtonUncheckedNormal, tbRadioButtonUncheckedHot, tbRadioButtonUncheckedPressed, tbRadioButtonUncheckedDisabled,
91     tbRadioButtonCheckedNormal, tbRadioButtonCheckedHot, tbRadioButtonCheckedPressed, tbRadioButtonCheckedDisabled,
92     tbCheckBoxUncheckedNormal, tbCheckBoxUncheckedHot, tbCheckBoxUncheckedPressed, tbCheckBoxUncheckedDisabled,
93     tbCheckBoxCheckedNormal, tbCheckBoxCheckedHot, tbCheckBoxCheckedPressed, tbCheckBoxCheckedDisabled,
94     tbCheckBoxMixedNormal, tbCheckBoxMixedHot, tbCheckBoxMixedPressed, tbCheckBoxMixedDisabled,
95     tbGroupBoxNormal, tbGroupBoxDisabled,
96     tbUserButton
97   );
98 
99   // 'Clock' theme data
100   TThemedClock = (
101     tcClockDontCare,
102     tcClockRoot,
103     tcTimeNormal
104   );
105 
106   // 'ComboBox' theme data
107   TThemedComboBox = (
108     tcComboBoxDontCare,
109     tcComboBoxRoot,
110     tcDropDownButtonNormal, tcDropDownButtonHot,  tcDropDownButtonPressed,  tcDropDownButtonDisabled
111   );
112 
113   // 'Edit' theme data
114   TThemedEdit = (
115     teEditDontCare,
116     teEditRoot,
117     teEditTextNormal, teEditTextHot, teEditTextSelected, teEditTextDisabled, teEditTextFocused, teEditTextReadOnly, teEditTextAssist,
118     teEditCaret
119   );
120 
121   // 'ExplorerBar' theme data
122   TThemedExplorerBar = (
123     tebExplorerBarDontCare,
124     tebExplorerBarRoot,
125     tebHeaderBackgroundNormal, tebHeaderBackgroundHot,  tebHeaderBackgroundPressed,
126     tebHeaderCloseNormal, tebHeaderCloseHot, tebHeaderClosePressed,
127     tebHeaderPinNormal, tebHeaderPinHot, tebHeaderPinPressed,
128     tebHeaderPinSelectedNormal, tebHeaderPinSelectedHot, tebHeaderPinSelectedPressed,
129     tebIEBarMenuNormal, tebIEBarMenuHot, tebIEBarMenuPressed,
130     tebNormalGroupBackground,
131     tebNormalGroupCollapseNormal, tebNormalGroupCollapseHot,  tebNormalGroupCollapsePressed,
132     tebNormalGroupExpandNormal, tebNormalGroupExpandHot,  tebNormalGroupExpandPressed,
133     tebNormalGroupHead,
134     tebSpecialGroupBackground,
135     tebSpecialGroupCollapseSpecial, tebSpecialGroupCollapseHot,  tebSpecialGroupCollapsePressed,
136     tebSpecialGroupExpandSpecial, tebSpecialGroupExpandHot,  tebSpecialGroupExpandPressed,
137     tebSpecialGroupHead
138   );
139 
140   // 'Header' theme data
141   TThemedHeader = (
142     thHeaderDontCare,
143     thHeaderRoot,
144     thHeaderItemNormal, thHeaderItemHot, thHeaderItemPressed,
145     thHeaderItemLeftNormal, thHeaderItemLeftHot, thHeaderItemLeftPressed,
146     thHeaderItemRightNormal, thHeaderItemRightHot, thHeaderItemRightPressed,
147     thHeaderSortArrowSortedUp, thHeaderSortArrowSortedDown
148   );
149 
150   // 'ListView' theme data
151   TThemedListview = (
152     tlListviewDontCare,
153     tlListviewRoot,
154     tlListItemNormal, tlListItemHot, tlListItemSelected, tlListItemDisabled, tlListItemSelectedNotFocus,
155     tlListGroup,
156     tlListDetail,
157     tlListSortDetail,
158     tlEmptyText
159   );
160 
161   // 'Menu' theme data
162   TThemedMenu = (
163     tmMenuDontCare,
164     tmMenuRoot,
165     tmMenuItemNormal, tmMenuItemSelected, tmMenuItemDemoted,
166     tmMenuDropDown,
167     tmMenuBarItem,
168     tmMenuBarDropDown,
169     tmChevron,
170     tmSeparator,
171     tmBarBackgroundActive, tmBarBackgroundInactive,
172     tmBarItemNormal, tmBarItemHot, tmBarItemPushed, tmBarItemDisabled, tmBarItemDisabledHot, tmBarItemDisabledPushed,
173     tmPopupBackground,
174     tmPopupBorders,
175     tmPopupCheckMarkNormal, tmPopupCheckMarkDisabled, tmPopupBulletNormal, tmPopupBulletDisabled,
176     tmPopupCheckBackgroundDisabled, tmPopupCheckBackgroundNormal, tmPopupCheckBackgroundBitmap,
177     tmPopupGutter,
178     tmPopupItemNormal, tmPopupItemHot, tmPopupItemDisabled, tmPopupItemDisabledHot,
179     tmPopupSeparator,
180     tmPopupSubmenuNormal, tmPopupSubmenuDisabled,
181     tmSystemCloseNormal, tmSystemCloseDisabled,
182     tmSystemMaximizeNormal, tmSystemMaximizeDisabled,
183     tmSystemMinimizeNormal, tmSystemMinimizeDisabled,
184     tmSystemRestoreNormal, tmSystemRestoreDisabled
185   );
186 
187   // 'Page' theme data
188   TThemedPage = (
189     tpPageDontCare,
190     tpPageRoot,
191     tpUpNormal, tpUpHot, tpUpPressed, tpUpDisabled,
192     tpDownNormal, tpDownHot, tpDownPressed, tpDownDisabled,
193     tpUpHorzNormal, tpUpHorzHot, tpUpHorzPressed, tpUpHorzDisabled,
194     tpDownHorzNormal, tpDownHorzHot, tpDownHorzPressed, tpDownHorzDisabled
195   );
196 
197   // 'Progress' theme data
198   TThemedProgress = (
199     tpProgressDontCare,
200     tpProgressRoot,
201     tpBar,
202     tpBarVert,
203     tpChunk,
204     tpChunkVert
205   );
206 
207   // 'Rebar' theme data
208   TThemedRebar = (
209     trRebarDontCare,
210     trRebarRoot,
211     trGripper,
212     trGripperVert,
213     trBandNormal, trBandHot, trBandPressed, trBandDisabled, trBandChecked, trBandHotChecked,
214     trChevronNormal, trChevronHot, trChevronPressed, trChevronDisabled,
215     trChevronVertNormal, trChevronVertHot, trChevronVertPressed, trChevronVertDisabled
216   );
217 
218   // 'ScrollBar' theme data
219   TThemedScrollBar = (
220     tsScrollBarDontCare,
221     tsScrollBarRoot,
222     tsArrowBtnUpNormal, tsArrowBtnUpHot, tsArrowBtnUpPressed, tsArrowBtnUpDisabled,
223     tsArrowBtnDownNormal, tsArrowBtnDownHot, tsArrowBtnDownPressed, tsArrowBtnDownDisabled,
224     tsArrowBtnLeftNormal, tsArrowBtnLeftHot, tsArrowBtnLeftPressed, tsArrowBtnLeftDisabled,
225     tsArrowBtnRightNormal, tsArrowBtnRightHot, tsArrowBtnRightPressed, tsArrowBtnRightDisabled,
226     tsThumbBtnHorzNormal, tsThumbBtnHorzHot, tsThumbBtnHorzPressed, tsThumbBtnHorzDisabled,
227     tsThumbBtnVertNormal, tsThumbBtnVertHot, tsThumbBtnVertPressed, tsThumbBtnVertDisabled,
228     tsLowerTrackHorzNormal, tsLowerTrackHorzHot, tsLowerTrackHorzPressed, tsLowerTrackHorzDisabled,
229     tsUpperTrackHorzNormal, tsUpperTrackHorzHot, tsUpperTrackHorzPressed, tsUpperTrackHorzDisabled,
230     tsLowerTrackVertNormal, tsLowerTrackVertHot, tsLowerTrackVertPressed, tsLowerTrackVertDisabled,
231     tsUpperTrackVertNormal, tsUpperTrackVertHot, tsUpperTrackVertPressed, tsUpperTrackVertDisabled,
232     tsGripperHorzNormal, tsGripperHorzHot, tsGripperHorzPressed, tsGripperHorzDisabled,
233     tsGripperVertNormal, tsGripperVertHot, tsGripperVertPressed, tsGripperVertDisabled,
234     tsSizeBoxRightAlign, tsSizeBoxLeftAlign
235   );
236 
237   // 'Spin' theme data
238   TThemedSpin = (
239     tsSpinDontCare,
240     tsSpinRoot,
241     tsUpNormal, tsUpHot, tsUpPressed, tsUpDisabled,
242     tsDownNormal, tsDownHot, tsDownPressed, tsDownDisabled,
243     tsUpHorzNormal, tsUpHorzHot, tsUpHorzPressed, tsUpHorzDisabled,
244     tsDownHorzNormal, tsDownHorzHot, tsDownHorzPressed, tsDownHorzDisabled
245   );
246 
247   // 'StartPanel' theme data
248   TThemedStartPanel = (
249     tspStartPanelDontCare,
250     tspStartPanelRoot,
251     tspUserPane,
252     tspMorePrograms,
253     tspMoreProgramsArrowNormal, tspMoreProgramsArrowHot, tspMoreProgramsArrowPressed,
254     tspProgList,
255     tspProgListSeparator,
256     tspPlacesList,
257     tspPlacesListSeparator,
258     tspLogOff,
259     tspLogOffButtonsNormal, tspLogOffButtonsHot, tspLogOffButtonsPressed,
260     tspUserPicture,
261     tspPreview
262   );
263 
264   // 'Status' theme data
265   TThemedStatus = (
266     tsStatusDontCare,
267     tsStatusRoot,
268     tsPane,
269     tsGripperPane,
270     tsGripper
271   );
272 
273   // 'Tab' theme data
274   TThemedTab = (
275     ttTabDontCare,
276     ttTabRoot,
277     ttTabItemNormal, ttTabItemHot, ttTabItemSelected, ttTabItemDisabled, ttTabItemFocused,
278     ttTabItemLeftEdgeNormal, ttTabItemLeftEdgeHot, ttTabItemLeftEdgeSelected, ttTabItemLeftEdgeDisabled, ttTabItemLeftEdgeFocused,
279     ttTabItemRightEdgeNormal, ttTabItemRightEdgeHot, ttTabItemRightEdgeSelected, ttTabItemRightEdgeDisabled, ttTabItemRightEdgeFocused,
280     ttTabItemBothEdgeNormal, ttTabItemBothEdgeHot, ttTabItemBothEdgeSelected, ttTabItemBothEdgeDisabled, ttTabItemBothEdgeFocused,
281     ttTopTabItemNormal, ttTopTabItemHot, ttTopTabItemSelected, ttTopTabItemDisabled, ttTopTabItemFocused,
282     ttTopTabItemLeftEdgeNormal, ttTopTabItemLeftEdgeHot, ttTopTabItemLeftEdgeSelected, ttTopTabItemLeftEdgeDisabled, ttTopTabItemLeftEdgeFocused,
283     ttTopTabItemRightEdgeNormal, ttTopTabItemRightEdgeHot, ttTopTabItemRightEdgeSelected, ttTopTabItemRightEdgeDisabled, ttTopTabItemRightEdgeFocused,
284     ttTopTabItemBothEdgeNormal, ttTopTabItemBothEdgeHot, ttTopTabItemBothEdgeSelected, ttTopTabItemBothEdgeDisabled, ttTopTabItemBothEdgeFocused,
285     ttPane,
286     ttBody
287   );
288 
289   // 'TaskBand' theme data
290   TThemedTaskBand = (
291     ttbTaskBandDontCare,
292     ttbTaskBandRoot,
293     ttbGroupCount,
294     ttbFlashButton,
295     ttpFlashButtonGroupMenu
296   );
297 
298   // 'TaskBar' theme data
299   TThemedTaskBar = (
300     ttTaskBarDontCare,
301     ttTaskBarRoot,
302     ttbTimeNormal
303   );
304 
305   // 'ToolBar' theme data
306   TThemedToolBar = (
307     ttbToolBarDontCare,
308     ttbToolBarRoot,
309     ttbButtonNormal, ttbButtonHot, ttbButtonPressed, ttbButtonDisabled, ttbButtonChecked, ttbButtonCheckedHot,
310     ttbDropDownButtonNormal, ttbDropDownButtonHot, ttbDropDownButtonPressed, ttbDropDownButtonDisabled, ttbDropDownButtonChecked, ttbDropDownButtonCheckedHot,
311     ttbSplitButtonNormal, ttbSplitButtonHot, ttbSplitButtonPressed, ttbSplitButtonDisabled, ttbSplitButtonChecked, ttbSplitButtonCheckedHot,
312     ttbSplitButtonDropDownNormal, ttbSplitButtonDropDownHot, ttbSplitButtonDropDownPressed, ttbSplitButtonDropDownDisabled, ttbSplitButtonDropDownChecked, ttbSplitButtonDropDownCheckedHot,
313     ttbSeparatorNormal, ttbSeparatorHot, ttbSeparatorPressed, ttbSeparatorDisabled, ttbSeparatorChecked, ttbSeparatorCheckedHot,
314     ttbSeparatorVertNormal, ttbSeparatorVertHot, ttbSeparatorVertPressed, ttbSeparatorVertDisabled, ttbSeparatorVertChecked, ttbSeparatorVertCheckedHot
315   );
316 
317   // 'ToolTip' theme data
318   TThemedToolTip = (
319     tttToolTipDontCare,
320     tttToolTipRoot,
321     tttStandardNormal, tttStandardLink,
322     tttStandardTitleNormal, tttStandardTitleLink,
323     tttBaloonNormal, tttBaloonLink,
324     tttBaloonTitleNormal, tttBaloonTitleLink,
325     tttCloseNormal, tttCloseHot, tttClosePressed
326   );
327 
328   // 'TrackBar' theme data
329   TThemedTrackBar = (
330     ttbTrackBarDontCare,
331     ttbTrackBarRoot,
332     ttbTrack,
333     ttbTrackVert,
334     ttbThumbNormal, ttbThumbHot, ttbThumbPressed, ttbThumbFocused, ttbThumbDisabled,
335     ttbThumbBottomNormal, ttbThumbBottomHot, ttbThumbBottomPressed, ttbThumbBottomFocused, ttbThumbBottomDisabled,
336     ttbThumbTopNormal, ttbThumbTopHot, ttbThumbTopPressed, ttbThumbTopFocused, ttbThumbTopDisabled,
337     ttbThumbVertNormal, ttbThumbVertHot, ttbThumbVertPressed, ttbThumbVertFocused, ttbThumbVertDisabled,
338     ttbThumbLeftNormal, ttbThumbLeftHot, ttbThumbLeftPressed, ttbThumbLeftFocused, ttbThumbLeftDisabled,
339     ttbThumbRightNormal, ttbThumbRightHot, ttbThumbRightPressed, ttbThumbRightFocused, ttbThumbRightDisabled,
340     ttbThumbTics,
341     ttbThumbTicsVert
342   );
343 
344   // 'TrayNotify' theme data
345   TThemedTrayNotify = (
346     ttnTrayNotifyDontCare,
347     ttnTrayNotifyRoot,
348     ttnBackground,
349     ttnAnimBackground
350   );
351 
352   // 'Treeview' theme data
353   TThemedTreeview = (
354     ttTreeviewDontCare,
355     ttTreeviewRoot,
356     ttItemNormal, ttItemHot, ttItemSelected, ttItemDisabled, ttItemSelectedNotFocus,
357     ttGlyphClosed, ttGlyphOpened,
358     ttBranch,
359     ttHotGlyphClosed, ttHotGlyphOpened
360   );
361 
362   // 'Window' theme data
363   TThemedWindow = (
364     twWindowDontCare,
365     twWindowRoot,
366     twCaptionActive, twCaptionInactive, twCaptionDisabled,
367     twSmallCaptionActive, twSmallCaptionInactive, twSmallCaptionDisabled,
368     twMinCaptionActive, twMinCaptionInactive, twMinCaptionDisabled,
369     twSmallMinCaptionActive, twSmallMinCaptionInactive, twSmallMinCaptionDisabled,
370     twMaxCaptionActive, twMaxCaptionInactive, twMaxCaptionDisabled,
371     twSmallMaxCaptionActive, twSmallMaxCaptionInactive, twSmallMaxCaptionDisabled,
372 
373     twFrameLeftActive, twFrameLeftInactive,
374     twFrameRightActive, twFrameRightInactive,
375     twFrameBottomActive, twFrameBottomInactive,
376     twSmallFrameLeftActive, twSmallFrameLeftInactive,
377     twSmallFrameRightActive, twSmallFrameRightInactive,
378     twSmallFrameBottomActive, twSmallFrameBottomInactive,
379 
380     twSysButtonNormal, twSysButtonHot, twSysButtonPushed, twSysButtonDisabled, twSysButtonInactive,
381     twMDISysButtonNormal, twMDISysButtonHot, twMDISysButtonPushed, twMDISysButtonDisabled, twMDISysButtonInactive,
382     twMinButtonNormal, twMinButtonHot, twMinButtonPushed, twMinButtonDisabled, twMinButtonInactive,
383     twMDIMinButtonNormal, twMDIMinButtonHot, twMDIMinButtonPushed, twMDIMinButtonDisabled, twMDIMinButtonInactive,
384     twMaxButtonNormal, twMaxButtonHot, twMaxButtonPushed, twMaxButtonDisabled, twMaxButtonInactive,
385     twCloseButtonNormal, twCloseButtonHot, twCloseButtonPushed, twCloseButtonDisabled, twCloseButtonInactive,
386     twSmallCloseButtonNormal, twSmallCloseButtonHot, twSmallCloseButtonPushed, twSmallCloseButtonDisabled, twSmallCloseButtonInactive,
387     twMDICloseButtonNormal, twMDICloseButtonHot, twMDICloseButtonPushed, twMDICloseButtonDisabled, twMDICloseButtonInactive,
388     twRestoreButtonNormal, twRestoreButtonHot, twRestoreButtonPushed, twRestoreButtonDisabled, twRestoreButtonInactive,
389     twMDIRestoreButtonNormal, twMDIRestoreButtonHot, twMDIRestoreButtonPushed, twMDIRestoreButtonDisabled, twMDIRestoreButtonInactive,
390     twHelpButtonNormal, twHelpButtonHot, twHelpButtonPushed, twHelpButtonDisabled, twHelpButtonInactive,
391     twMDIHelpButtonNormal, twMDIHelpButtonHot, twMDIHelpButtonPushed, twMDIHelpButtonDisabled, twMDIHelpButtonInactive,
392 
393     twHorzScrollNormal, twHorzScrollHot, twHorzScrollPushed, twHorzScrollDisabled,
394     twHorzThumbNormal, twHorzThumbHot, twHorzThumbPushed, twHorzThumbDisabled,
395     twVertScrollNormal, twVertScrollHot, twVertScrollPushed, twVertScrollDisabled,
396     twVertThumbNormal, twVertThumbHot, twVertThumbPushed, twVertThumbDisabled,
397 
398     twDialog,
399     twCaptionSizingTemplate,
400     twSmallCaptionSizingTemplate,
401     twFrameLeftSizingTemplate,
402     twSmallFrameLeftSizingTemplate,
403     twFrameRightSizingTemplate,
404     twSmallFrameRightSizingTemplate,
405     twFrameBottomSizingTemplate,
406     twSmallFrameBottomSizingTemplate
407   );
408 
409   PThemedElementDetails = ^TThemedElementDetails;
410   TThemedElementDetails = record
411     Element: TThemedElement;
412     Part,
413     State: Integer;
414   end;
415 
416   TThemeOption = (
417     toShowButtonImages, // show images on buttons
418     toShowMenuImages,   // show images on menus
419     toUseGlyphEffects   // use hot/down effects on (button) glyphs
420   );
421 
422   // TThemeServices is a small foot print class to provide the user with pure
423   // Windows XP theme related abilities like painting elements and text or
424   // retrieving certain info.
425   TThemeServices = class(TObject)
426   private
427     FThemesAvailable,
428     FUseThemes,
429     FThemedControlsEnabled: Boolean;
430     FOnThemeChange: TNotifyEvent;      // Called when the current window theme has changed.
431     FDottedBrush: HBrush;
432 
433     function GetThemesEnabled: Boolean;
434     function GetDottedBrush: HBrush;
435   protected
436     function InitThemes: Boolean; virtual;
437     procedure UnloadThemeData; virtual;
438     function UseThemes: Boolean; virtual;
439     function ThemedControlsEnabled: Boolean; virtual;
440 
441     function InternalColorToRGB(Details: TThemedElementDetails; Color: LongInt): COLORREF; virtual;
442     procedure InternalDrawParentBackground(Window: HWND; Target: HDC; Bounds: PRect); virtual;
443   public
444     constructor Create;
445     destructor Destroy; override;
446     procedure IntfDoOnThemeChange; virtual;
447 
448     // state helpers
449     function IsDisabled(Details: TThemedElementDetails): Boolean;
450     function IsPushed(Details: TThemedElementDetails): Boolean;
451     function IsHot(Details: TThemedElementDetails): Boolean;
452     function IsChecked(Details: TThemedElementDetails): Boolean;
453     function IsMixed(Details: TThemedElementDetails): Boolean;
454 
455     function GetElementDetails(Detail: TThemedButton): TThemedElementDetails; overload;
456     function GetElementDetails(Detail: TThemedClock): TThemedElementDetails; overload;
457     function GetElementDetails(Detail: TThemedComboBox): TThemedElementDetails; overload;
458     function GetElementDetails(Detail: TThemedEdit): TThemedElementDetails; overload;
459     function GetElementDetails(Detail: TThemedExplorerBar): TThemedElementDetails; overload;
460     function GetElementDetails(Detail: TThemedHeader): TThemedElementDetails; overload;
461     function GetElementDetails(Detail: TThemedListView): TThemedElementDetails; overload;
462     function GetElementDetails(Detail: TThemedMenu): TThemedElementDetails; overload;
463     function GetElementDetails(Detail: TThemedPage): TThemedElementDetails; overload;
464     function GetElementDetails(Detail: TThemedProgress): TThemedElementDetails; overload;
465     function GetElementDetails(Detail: TThemedRebar): TThemedElementDetails; overload;
466     function GetElementDetails(Detail: TThemedScrollBar): TThemedElementDetails; overload;
467     function GetElementDetails(Detail: TThemedSpin): TThemedElementDetails; overload;
468     function GetElementDetails(Detail: TThemedStartPanel): TThemedElementDetails; overload;
469     function GetElementDetails(Detail: TThemedStatus): TThemedElementDetails; overload;
470     function GetElementDetails(Detail: TThemedTab): TThemedElementDetails; overload;
471     function GetElementDetails(Detail: TThemedTaskBand): TThemedElementDetails; overload;
472     function GetElementDetails(Detail: TThemedTaskBar): TThemedElementDetails; overload;
473     function GetElementDetails(Detail: TThemedToolBar): TThemedElementDetails; overload;
474     function GetElementDetails(Detail: TThemedToolTip): TThemedElementDetails; overload;
475     function GetElementDetails(Detail: TThemedTrackBar): TThemedElementDetails; overload;
476     function GetElementDetails(Detail: TThemedTrayNotify): TThemedElementDetails; overload;
477     function GetElementDetails(Detail: TThemedTreeview): TThemedElementDetails; overload;
478     function GetElementDetails(Detail: TThemedWindow): TThemedElementDetails; overload;
479 
480     function GetDetailSize(Details: TThemedElementDetails): TSize; virtual;
481     function GetDetailRegion(DC: HDC; Details: TThemedElementDetails; const R: TRect): HRGN; virtual;
482     function GetStockImage(StockID: LongInt; out Image, Mask: HBitmap): Boolean; virtual;
483     function GetOption(AOption: TThemeOption): Integer; virtual;
484     function GetTextExtent(DC: HDC; Details: TThemedElementDetails; const S: String; Flags: Cardinal; BoundingRect: PRect): TRect; virtual;
485 
486     function ColorToRGB(Color: LongInt; Details: PThemedElementDetails = nil): COLORREF;
487     function ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect; virtual;
488     procedure DrawEdge(DC: HDC; Details: TThemedElementDetails; const R: TRect; Edge, Flags: Cardinal;
489       AContentRect: PRect = nil); virtual;
490     procedure DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect = nil); virtual;
491     procedure DrawIcon(DC: HDC; Details: TThemedElementDetails; const R: TRect; himl: HIMAGELIST; Index: Integer); virtual; overload;
492     procedure DrawIcon(ACanvas: TPersistent; Details: TThemedElementDetails; const P: TPoint; AImageList: TPersistent; Index: Integer;
493       AImageWidth: Integer = 0; ARefControl: TPersistent = nil); virtual; overload;
494     procedure DrawParentBackground(Window: HWND; Target: HDC; Details: PThemedElementDetails; OnlyIfTransparent: Boolean;
495       Bounds: PRect = nil);
496     procedure DrawText(DC: HDC; Details: TThemedElementDetails; const S: String; R: TRect; Flags, Flags2: Cardinal); virtual; overload;
497     procedure DrawText(ACanvas: TPersistent; Details: TThemedElementDetails; const S: String; R: TRect; Flags, Flags2: Cardinal); virtual; overload;
498 
499     function HasTransparentParts(Details: TThemedElementDetails): Boolean; virtual;
500     procedure PaintBorder(Control: TObject; EraseLRCorner: Boolean); virtual;
501     procedure UpdateThemes;
502 
503     property DottedBrush: HBRUSH read GetDottedBrush;
504     property ThemesAvailable: Boolean read FThemesAvailable;
505     property ThemesEnabled: Boolean read GetThemesEnabled;
506 
507     property OnThemeChange: TNotifyEvent read FOnThemeChange write FOnThemeChange;
508   end;
509 
510 function ThemeServices: TThemeServices;
511 function ThemedElementDetailsEqual(const D1, D2: TThemedElementDetails): Boolean;
512 //----------------------------------------------------------------------------------------------------------------------
513 
514 const
515   // Do not modify the copyright in any way! Usage of this unit is prohibited without the copyright notice
516   // in the compiled binary file.
517   ThemeManagerCopyright: string = 'Theme manager © 2001-2005 Mike Lischke';
518 type
519   TThemesImageDrawEvent = procedure(AImageList: TPersistent; ACanvas: TPersistent;
520                      AX, AY, AIndex: Integer; ADrawEffect: TGraphicsDrawEffect;
521                      AImageWidth: Integer; ARefControl: TPersistent);
522 var
523   ThemesImageDrawEvent: TThemesImageDrawEvent = nil; // set by unit ImgList if used
524 
525 implementation
526 
527 uses
528   InterfaceBase, LCLIntf;
529 
530 //----------------------------------------------------------------------------------------------------------------------
531 
532 function ThemeServices: TThemeServices;
533 begin
534   Result := WidgetSet.ThemeServices;
535 end;
536 
537 function ThemedElementDetailsEqual(const D1, D2: TThemedElementDetails): Boolean;
538 begin
539   Result := CompareMem(@D1, @D2, SizeOf(TThemedElementDetails));
540 end;
541 
542 //----------------- TThemeServices -------------------------------------------------------------------------------------
543 
544 constructor TThemeServices.Create;
545 begin
546   FDottedBrush := 0;
547 
548   FThemesAvailable := InitThemes;
549   UpdateThemes;
550 end;
551 
552 //----------------------------------------------------------------------------------------------------------------------
553 
554 destructor TThemeServices.Destroy;
555 begin
556   UnloadThemeData;
557 
558   if FDottedBrush <> 0 then
559     DeleteObject(FDottedBrush);
560 
561   inherited;
562 end;
563 
564 //----------------------------------------------------------------------------------------------------------------------
565 
GetThemesEnablednull566 function TThemeServices.GetThemesEnabled: Boolean;
567 begin
568   Result := FThemesAvailable and FUseThemes and FThemedControlsEnabled;
569 end;
570 
GetDottedBrushnull571 function TThemeServices.GetDottedBrush: HBrush;
572 const
573   LineBitsDotted: array[0..7] of Word = ($55, $AA, $55, $AA, $55, $AA, $55, $AA);
574 var
575   DottedBitmap: HBitmap;
576 begin
577   if FDottedBrush = 0 then
578   begin
579     DottedBitmap := CreateBitmap(8, 8, 1, 1, @LineBitsDotted);
580     if DottedBitmap <> 0 then
581     begin
582       FDottedBrush := CreatePatternBrush(DottedBitmap);
583       DeleteObject(DottedBitmap);
584     end;
585   end;
586   Result := FDottedBrush;
587 end;
588 
589 //----------------------------------------------------------------------------------------------------------------------
590 
591 procedure TThemeServices.IntfDoOnThemeChange;
592 begin
593   if Assigned(FOnThemeChange) then
594     FOnThemeChange(Self);
595 end;
596 
597 //----------------------------------------------------------------------------------------------------------------------
598 
GetElementDetailsnull599 function TThemeServices.GetElementDetails(Detail: TThemedButton): TThemedElementDetails;
600 var
601   Base: Integer;
602 begin
603   Result.Element := teButton;
604   with Result do
605   begin
606     case Detail of
607       tbPushButtonNormal..tbPushButtonDefaulted:
608         begin
609           Part := BP_PUSHBUTTON;
610           Base := Ord(tbPushButtonNormal);
611         end;
612       tbRadioButtonUncheckedNormal..tbRadioButtonCheckedDisabled:
613         begin
614           Part := BP_RADIOBUTTON;
615           Base := Ord(tbRadioButtonUncheckedNormal);
616         end;
617       tbCheckBoxUncheckedNormal..tbCheckBoxMixedDisabled:
618         begin
619           Part := BP_CHECKBOX;
620           Base := Ord(tbCheckBoxUncheckedNormal);
621         end;
622       tbGroupBoxNormal..tbGroupBoxDisabled:
623         begin
624           Part := BP_GROUPBOX;
625           Base := Ord(tbGroupBoxNormal);
626         end;
627       tbUserButton:
628         begin
629           Part := BP_USERBUTTON;
630           Base := Ord(tbUserButton);
631         end;
632     else
633       Part := 0;
634       Base := 0;
635     end;
636     State := Ord(Detail) - Base + 1;
637   end;
638 end;
639 
640 //----------------------------------------------------------------------------------------------------------------------
641 
GetElementDetailsnull642 function TThemeServices.GetElementDetails(Detail: TThemedClock): TThemedElementDetails;
643 var
644   Base: Integer;
645 begin
646   Result.Element := teClock;
647   with Result do
648   begin
649     case Detail of
650       tcTimeNormal:
651         begin
652           Part := CLP_TIME;
653           Base := Ord(tcTimeNormal);
654         end;
655     else
656       Part := 0;
657       Base := 0;
658     end;
659     State := Ord(Detail) - Base + 1;
660   end;
661 end;
662 
663 //----------------------------------------------------------------------------------------------------------------------
664 
GetElementDetailsnull665 function TThemeServices.GetElementDetails(Detail: TThemedComboBox): TThemedElementDetails;
666 var
667   Base: Integer;
668 begin
669   Result.Element := teComboBox;
670   with Result do
671   begin
672     case Detail of
673       tcDropDownButtonNormal..tcDropDownButtonDisabled:
674         begin
675           Part := CP_DROPDOWNBUTTON;
676           Base := Ord(tcDropDownButtonNormal);
677         end;
678     else
679       Part := 0;
680       Base := 0;
681     end;
682     State := Ord(Detail) - Base + 1;
683   end;
684 end;
685 
686 //----------------------------------------------------------------------------------------------------------------------
687 
GetElementDetailsnull688 function TThemeServices.GetElementDetails(Detail: TThemedEdit): TThemedElementDetails;
689 var
690   Base: Integer;
691 begin
692   Result.Element := teEdit;
693   with Result do
694   begin
695     case Detail of
696       teEditTextNormal..teEditTextAssist:
697         begin
698           Part := EP_EDITTEXT;
699           Base := Ord(teEditTextNormal);
700         end;
701       teEditCaret:
702         begin
703           Part := EP_CARET;
704           Base := Ord(teEditCaret);
705         end;
706     else
707       Part := 0;
708       Base := 0;
709     end;
710     State := Ord(Detail) - Base + 1;
711   end;
712 end;
713 
714 //----------------------------------------------------------------------------------------------------------------------
715 
GetElementDetailsnull716 function TThemeServices.GetElementDetails(Detail: TThemedExplorerBar): TThemedElementDetails;
717 var
718   Base: Integer;
719 begin
720   Result.Element := teExplorerBar;
721   with Result do
722   begin
723     case Detail of
724       tebHeaderBackgroundNormal..tebHeaderBackgroundPressed:
725         begin
726           Part := EBP_HEADERBACKGROUND;
727           Base := Ord(tebHeaderBackgroundNormal);
728         end;
729       tebHeaderCloseNormal..tebHeaderClosePressed:
730         begin
731           Part := EBP_HEADERCLOSE;
732           Base := Ord(tebHeaderCloseNormal);
733         end;
734       tebHeaderPinNormal..tebHeaderPinSelectedPressed:
735         begin
736           Part := EBP_HEADERPIN;
737           Base := Ord(tebHeaderPinSelectedNormal);
738         end;
739       tebIEBarMenuNormal..tebIEBarMenuPressed:
740         begin
741           Part := EBP_IEBARMENU;
742           Base := Ord(tebIEBarMenuNormal);
743         end;
744       tebNormalGroupBackground:
745         begin
746           Part := EBP_NORMALGROUPBACKGROUND;
747           Base := Ord(tebNormalGroupBackground);
748         end;
749       tebNormalGroupCollapseNormal..tebNormalGroupCollapsePressed:
750         begin
751           Part := EBP_NORMALGROUPCOLLAPSE;
752           Base := Ord(tebNormalGroupCollapseNormal);
753         end;
754       tebNormalGroupExpandNormal..tebNormalGroupExpandPressed:
755         begin
756           Part := EBP_NORMALGROUPEXPAND;
757           Base := Ord(tebNormalGroupExpandNormal);
758         end;
759       tebNormalGroupHead:
760         begin
761           Part := EBP_NORMALGROUPHEAD;
762           Base := Ord(tebNormalGroupHead);
763         end;
764       tebSpecialGroupBackground:
765         begin
766           Part := EBP_SPECIALGROUPBACKGROUND;
767           Base := Ord(tebSpecialGroupBackground);
768         end;
769       tebSpecialGroupCollapseSpecial..tebSpecialGroupCollapsePressed:
770         begin
771           Part := EBP_SPECIALGROUPCOLLAPSE;
772           Base := Ord(tebSpecialGroupCollapseSpecial);
773         end;
774       tebSpecialGroupExpandSpecial..tebSpecialGroupExpandPressed:
775         begin
776           Part := EBP_SPECIALGROUPEXPAND;
777           Base := Ord(tebSpecialGroupExpandSpecial);
778         end;
779       tebSpecialGroupHead:
780         begin
781           Part := EBP_SPECIALGROUPHEAD;
782           Base := Ord(tebSpecialGroupHead);
783         end;
784     else
785       Part := 0;
786       Base := 0;
787     end;
788     State := Ord(Detail) - Base + 1;
789   end;
790 end;
791 
792 //----------------------------------------------------------------------------------------------------------------------
793 
GetElementDetailsnull794 function TThemeServices.GetElementDetails(Detail: TThemedHeader): TThemedElementDetails;
795 var
796   Base: Integer;
797 begin
798   Result.Element := teHeader;
799   with Result do
800   begin
801     case Detail of
802       thHeaderItemNormal..thHeaderItemPressed:
803         begin
804           Part := HP_HEADERITEM;
805           Base := Ord(thHeaderItemNormal);
806         end;
807       thHeaderItemLeftNormal..thHeaderItemLeftPressed:
808         begin
809           Part := HP_HEADERITEMLEFT;
810           Base := Ord(thHeaderItemLeftNormal);
811         end;
812       thHeaderItemRightNormal..thHeaderItemRightPressed:
813         begin
814           Part := HP_HEADERITEMRIGHT;
815           Base := Ord(thHeaderItemRightNormal);
816         end;
817       thHeaderSortArrowSortedUp..thHeaderSortArrowSortedDown:
818         begin
819           Part := HP_HEADERSORTARROW;
820           Base := Ord(thHeaderSortArrowSortedUp);
821         end;
822     else
823       Part := 0;
824       Base := 0;
825     end;
826     State := Ord(Detail) - Base + 1;
827   end;
828 end;
829 
830 //----------------------------------------------------------------------------------------------------------------------
831 
GetElementDetailsnull832 function TThemeServices.GetElementDetails(Detail: TThemedListView
833   ): TThemedElementDetails;
834 var
835   Base: Integer;
836 begin
837   Result.Element := teListView;
838   with Result do
839   begin
840     case Detail of
841       tlListItemNormal..tlListItemSelectedNotFocus:
842         begin
843           Part := LVP_LISTITEM;
844           Base := Ord(tlListItemNormal);
845         end;
846       tlListGroup:
847         begin
848           Part := LVP_LISTGROUP;
849           Base := Ord(tlListGroup);
850         end;
851       tlListDetail:
852         begin
853           Part := LVP_LISTDETAIL;
854           Base := Ord(tlListDetail);
855         end;
856       tlListSortDetail:
857         begin
858           Part := LVP_LISTSORTEDDETAIL;
859           Base := Ord(tlListSortDetail);
860         end;
861       tlEmptyText:
862         begin
863           Part := LVP_EMPTYTEXT;
864           Base := Ord(tlEmptyText);
865         end;
866     else
867       Part := 0;
868       Base := 0;
869     end;
870     State := Ord(Detail) - Base + 1;
871   end;
872 end;
873 
874 //----------------------------------------------------------------------------------------------------------------------
875 
GetElementDetailsnull876 function TThemeServices.GetElementDetails(Detail: TThemedMenu): TThemedElementDetails;
877 var
878   Base: Integer;
879 begin
880   Result.Element := teMenu;
881   with Result do
882   begin
883     case Detail of
884       tmMenuItemNormal..tmMenuItemDemoted:
885         begin
886           Part := MENU_MENUITEM_TMSCHEMA;
887           Base := Ord(tmMenuItemNormal);
888         end;
889       tmMenuDropDown:
890         begin
891           Part := MENU_MENUDROPDOWN_TMSCHEMA;
892           Base := Ord(tmMenuDropDown);
893         end;
894       tmMenuBarItem:
895         begin
896           Part := MENU_MENUBARITEM_TMSCHEMA;
897           Base := Ord(tmMenuBarItem);
898         end;
899       tmMenuBarDropDown:
900         begin
901           Part := MENU_MENUBARDROPDOWN_TMSCHEMA;
902           Base := Ord(tmMenuBarDropDown);
903         end;
904       tmChevron:
905         begin
906           Part := MENU_CHEVRON_TMSCHEMA;
907           Base := Ord(tmChevron);
908         end;
909       tmSeparator:
910         begin
911           Part := MENU_SEPARATOR_TMSCHEMA;
912           Base := Ord(tmSeparator);
913         end;
914       tmBarBackgroundActive..tmBarBackgroundInactive:
915         begin
916           Part := MENU_BARBACKGROUND;
917           Base := Ord(tmBarBackgroundActive);
918         end;
919       tmBarItemNormal..tmBarItemDisabledPushed:
920         begin
921           Part := MENU_BARITEM;
922           Base := Ord(tmBarItemNormal);
923         end;
924       tmPopupBackground:
925         begin
926           Part := MENU_POPUPBACKGROUND;
927           Base := Ord(tmPopupBackground);
928         end;
929       tmPopupBorders:
930         begin
931           Part := MENU_POPUPBORDERS;
932           Base := Ord(tmPopupBorders);
933         end;
934       tmPopupCheckMarkNormal..tmPopupBulletDisabled:
935         begin
936           Part := MENU_POPUPCHECK;
937           Base := Ord(tmPopupCheckMarkNormal);
938         end;
939       tmPopupCheckBackgroundDisabled..tmPopupCheckBackgroundBitmap:
940         begin
941           Part := MENU_POPUPCHECKBACKGROUND;
942           Base := Ord(tmPopupCheckBackgroundDisabled);
943         end;
944       tmPopupGutter:
945         begin
946           Part := MENU_POPUPGUTTER;
947           Base := Ord(tmPopupGutter);
948         end;
949       tmPopupItemNormal..tmPopupItemDisabledHot:
950         begin
951           Part := MENU_POPUPITEM;
952           Base := Ord(tmPopupItemNormal);
953         end;
954       tmPopupSeparator:
955         begin
956           Part := MENU_POPUPSEPARATOR;
957           Base := Ord(tmPopupSeparator);
958         end;
959       tmPopupSubmenuNormal..tmPopupSubmenuDisabled:
960         begin
961           Part := MENU_POPUPSUBMENU;
962           Base := Ord(tmPopupSubmenuNormal);
963         end;
964       tmSystemCloseNormal..tmSystemCloseDisabled:
965         begin
966           Part := MENU_SYSTEMCLOSE;
967           Base := Ord(tmSystemCloseNormal);
968         end;
969       tmSystemMaximizeNormal..tmSystemMaximizeDisabled:
970         begin
971           Part := MENU_SYSTEMMAXIMIZE;
972           Base := Ord(tmSystemMaximizeNormal);
973         end;
974       tmSystemMinimizeNormal..tmSystemMinimizeDisabled:
975         begin
976           Part := MENU_SYSTEMMINIMIZE;
977           Base := Ord(tmSystemMinimizeNormal);
978         end;
979       tmSystemRestoreNormal..tmSystemRestoreDisabled:
980         begin
981           Part := MENU_SYSTEMRESTORE;
982           Base := Ord(tmSystemRestoreNormal);
983         end;
984     else
985       Part := 0;
986       Base := 0;
987     end;
988     State := Ord(Detail) - Base + 1;
989   end;
990 end;
991 
992 //----------------------------------------------------------------------------------------------------------------------
993 
GetElementDetailsnull994 function TThemeServices.GetElementDetails(Detail: TThemedPage): TThemedElementDetails;
995 var
996   Base: Integer;
997 begin
998   Result.Element := tePage;
999   with Result do
1000   begin
1001     case Detail of
1002       tpUpNormal..tpUpDisabled:
1003         begin
1004           Part := PGRP_UP;
1005           Base := Ord(tpUpNormal);
1006         end;
1007       tpDownNormal..tpDownDisabled:
1008         begin
1009           Part := PGRP_DOWN;
1010           Base := Ord(tpDownNormal);
1011         end;
1012       tpUpHorzNormal..tpUpHorzDisabled:
1013         begin
1014           Part := PGRP_UPHORZ;
1015           Base := Ord(tpUpHorzNormal);
1016         end;
1017       tpDownHorzNormal..tpDownHorzDisabled:
1018         begin
1019           Part := PGRP_DOWNHORZ;
1020           Base := Ord(tpDownHorzNormal);
1021         end;
1022     else
1023       Part := 0;
1024       Base := 0;
1025     end;
1026     State := Ord(Detail) - Base + 1;
1027   end;
1028 end;
1029 
1030 //----------------------------------------------------------------------------------------------------------------------
1031 
GetElementDetailsnull1032 function TThemeServices.GetElementDetails(Detail: TThemedProgress): TThemedElementDetails;
1033 var
1034   Base: Integer;
1035 begin
1036   Result.Element := teProgress;
1037   with Result do
1038   begin
1039     case Detail of
1040       tpBar:
1041         begin
1042           Part := PP_BAR;
1043           Base := Ord(tpBar);
1044         end;
1045       tpBarVert:
1046         begin
1047           Part := PP_BARVERT;
1048           Base := Ord(tpBarVert);
1049         end;
1050       tpChunk:
1051         begin
1052           Part := PP_CHUNK;
1053           Base := Ord(tpChunk);
1054         end;
1055       tpChunkVert:
1056         begin
1057           Part := PP_CHUNKVERT;
1058           Base := Ord(tpChunkVert);
1059         end;
1060     else
1061       Part := 0;
1062       Base := 0;
1063     end;
1064     State := Ord(Detail) - Base + 1;
1065   end;
1066 end;
1067 
1068 //----------------------------------------------------------------------------------------------------------------------
1069 
GetElementDetailsnull1070 function TThemeServices.GetElementDetails(Detail: TThemedRebar): TThemedElementDetails;
1071 var
1072   Base: Integer;
1073 begin
1074   Result.Element := teRebar;
1075   with Result do
1076   begin
1077     case Detail of
1078       trGripper:
1079         begin
1080           Part := RP_GRIPPER;
1081           Base := Ord(trGripper);
1082         end;
1083       trGripperVert:
1084         begin
1085           Part := RP_GRIPPERVERT;
1086           Base := Ord(trGripperVert);
1087         end;
1088       trBandNormal..trBandHotChecked:
1089         begin
1090           Part := RP_BAND;
1091           Base := Ord(trBandNormal);
1092         end;
1093       trChevronNormal..trChevronDisabled:
1094         begin
1095           Part := RP_CHEVRON;
1096           Base := Ord(trChevronNormal);
1097         end;
1098       trChevronVertNormal..trChevronVertDisabled:
1099         begin
1100           Part := RP_CHEVRONVERT;
1101           Base := Ord(trChevronVertNormal);
1102         end;
1103     else
1104       Part := 0;
1105       Base := 0;
1106     end;
1107     State := Ord(Detail) - Base + 1;
1108   end;
1109 end;
1110 
1111 //----------------------------------------------------------------------------------------------------------------------
1112 
GetElementDetailsnull1113 function TThemeServices.GetElementDetails(Detail: TThemedScrollBar): TThemedElementDetails;
1114 var
1115   Base: Integer;
1116 begin
1117   Result.Element := teScrollBar;
1118   with Result do
1119   begin
1120     case Detail of
1121       tsArrowBtnUpNormal..tsArrowBtnRightDisabled:
1122         begin
1123           Part := SBP_ARROWBTN;
1124           Base := Ord(tsArrowBtnUpNormal);
1125         end;
1126       tsThumbBtnHorzNormal..tsThumbBtnHorzDisabled:
1127         begin
1128           Part := SBP_THUMBBTNHORZ;
1129           Base := Ord(tsThumbBtnHorzNormal);
1130         end;
1131       tsThumbBtnVertNormal..tsThumbBtnVertDisabled:
1132         begin
1133           Part := SBP_THUMBBTNVERT;
1134           Base := Ord(tsThumbBtnVertNormal);
1135         end;
1136       tsLowerTrackHorzNormal..tsLowerTrackHorzDisabled:
1137         begin
1138           Part := SBP_LOWERTRACKHORZ;
1139           Base := Ord(tsLowerTrackHorzNormal);
1140         end;
1141       tsUpperTrackHorzNormal..tsUpperTrackHorzDisabled:
1142         begin
1143           Part := SBP_UPPERTRACKHORZ;
1144           Base := Ord(tsUpperTrackHorzNormal);
1145         end;
1146       tsLowerTrackVertNormal..tsLowerTrackVertDisabled:
1147         begin
1148           Part := SBP_LOWERTRACKVERT;
1149           Base := Ord(tsLowerTrackVertNormal);
1150         end;
1151       tsUpperTrackVertNormal..tsUpperTrackVertDisabled:
1152         begin
1153           Part := SBP_UPPERTRACKVERT;
1154           Base := Ord(tsUpperTrackVertNormal);
1155         end;
1156       tsGripperHorzNormal..tsGripperHorzDisabled:
1157         begin
1158           Part := SBP_GRIPPERHORZ;
1159           Base := Ord(tsGripperHorzNormal);
1160         end;
1161       tsGripperVertNormal..tsGripperVertDisabled:
1162         begin
1163           Part := SBP_GRIPPERVERT;
1164           Base := Ord(tsGripperVertNormal);
1165         end;
1166       tsSizeBoxRightAlign..tsSizeBoxLeftAlign:
1167         begin
1168           Part := SBP_SIZEBOX;
1169           Base := Ord(tsSizeBoxRightAlign);
1170         end;
1171     else
1172       Part := 0;
1173       Base := 0;
1174     end;
1175     State := Ord(Detail) - Base + 1;
1176   end;
1177 end;
1178 
1179 //----------------------------------------------------------------------------------------------------------------------
1180 
GetElementDetailsnull1181 function TThemeServices.GetElementDetails(Detail: TThemedSpin): TThemedElementDetails;
1182 var
1183   Base: Integer;
1184 begin
1185   Result.Element := teSpin;
1186   with Result do
1187   begin
1188     case Detail of
1189       tsUpNormal..tsUpDisabled:
1190         begin
1191           Part := SPNP_UP;
1192           Base := Ord(tsUpNormal);
1193         end;
1194       tsDownNormal..tsDownDisabled:
1195         begin
1196           Part := SPNP_DOWN;
1197           Base := Ord(tsDownNormal);
1198         end;
1199       tsUpHorzNormal..tsUpHorzDisabled:
1200         begin
1201           Part := SPNP_UPHORZ;
1202           Base := Ord(tsUpHorzNormal);
1203         end;
1204       tsDownHorzNormal..tsDownHorzDisabled:
1205         begin
1206           Part := SPNP_DOWNHORZ;
1207           Base := Ord(tsDownHorzNormal);
1208         end;
1209     else
1210       Part := 0;
1211       Base := 0;
1212     end;
1213     State := Ord(Detail) - Base + 1;
1214   end;
1215 end;
1216 
1217 //----------------------------------------------------------------------------------------------------------------------
1218 
GetElementDetailsnull1219 function TThemeServices.GetElementDetails(Detail: TThemedStartPanel): TThemedElementDetails;
1220 var
1221   Base: Integer;
1222 begin
1223   Result.Element := teStartPanel;
1224   with Result do
1225   begin
1226     case Detail of
1227       tspUserPane:
1228         begin
1229           Part := SPP_USERPANE;
1230           Base := Ord(tspUserPane);
1231         end;
1232       tspMorePrograms:
1233         begin
1234           Part := SPP_MOREPROGRAMS;
1235           Base := Ord(tspMorePrograms);
1236         end;
1237       tspMoreProgramsArrowNormal..tspMoreProgramsArrowPressed:
1238         begin
1239           Part := SPP_MOREPROGRAMSARROW;
1240           Base := Ord(tspMoreProgramsArrowNormal);
1241         end;
1242       tspProgList:
1243         begin
1244           Part := SPP_PROGLIST;
1245           Base := Ord(tspProgList);
1246         end;
1247       tspProgListSeparator:
1248         begin
1249           Part := SPP_PROGLISTSEPARATOR;
1250           Base := Ord(tspProgListSeparator);
1251         end;
1252       tspPlacesList:
1253         begin
1254           Part := SPP_PLACESLIST;
1255           Base := Ord(tspPlacesList);
1256         end;
1257       tspPlacesListSeparator:
1258         begin
1259           Part := SPP_PLACESLISTSEPARATOR;
1260           Base := Ord(tspPlacesListSeparator);
1261         end;
1262       tspLogOff:
1263         begin
1264           Part := SPP_LOGOFF;
1265           Base := Ord(tspLogOff);
1266         end;
1267       tspLogOffButtonsNormal..tspLogOffButtonsPressed:
1268         begin
1269           Part := SPP_LOGOFFBUTTONS;
1270           Base := Ord(tspLogOffButtonsNormal);
1271         end;
1272       tspUserPicture:
1273         begin
1274           Part := SPP_USERPICTURE;
1275           Base := Ord(tspUserPicture);
1276         end;
1277       tspPreview:
1278         begin
1279           Part := SPP_PREVIEW;
1280           Base := Ord(tspPreview);
1281         end;
1282     else
1283       Part := 0;
1284       Base := 0;
1285     end;
1286     State := Ord(Detail) - Base + 1;
1287   end;
1288 end;
1289 
1290 //----------------------------------------------------------------------------------------------------------------------
1291 
GetElementDetailsnull1292 function TThemeServices.GetElementDetails(Detail: TThemedStatus): TThemedElementDetails;
1293 var
1294   Base: Integer;
1295 begin
1296   Result.Element := teStatus;
1297   with Result do
1298   begin
1299     case Detail of
1300       tsPane:
1301         begin
1302           Part := SP_PANE;
1303           Base := Ord(tsPane);
1304         end;
1305       tsGripperPane:
1306         begin
1307           Part := SP_GRIPPERPANE;
1308           Base := Ord(tsGripperPane);
1309         end;
1310       tsGripper:
1311         begin
1312           Part := SP_GRIPPER;
1313           Base := Ord(tsGripper);
1314         end;
1315     else
1316       Part := 0;
1317       Base := 0;
1318     end;
1319     State := Ord(Detail) - Base + 1;
1320   end;
1321 end;
1322 
1323 //----------------------------------------------------------------------------------------------------------------------
1324 
GetElementDetailsnull1325 function TThemeServices.GetElementDetails(Detail: TThemedTab): TThemedElementDetails;
1326 var
1327   Base: Integer;
1328 begin
1329   Result.Element := teTab;
1330   with Result do
1331   begin
1332     case Detail of
1333       ttTabItemNormal..ttTabItemFocused:
1334         begin
1335           Part := TABP_TABITEM;
1336           Base := Ord(ttTabItemNormal);
1337         end;
1338       ttTabItemLeftEdgeNormal..ttTabItemLeftEdgeFocused:
1339         begin
1340           Part := TABP_TABITEMLEFTEDGE;
1341           Base := Ord(ttTabItemLeftEdgeNormal);
1342         end;
1343       ttTabItemRightEdgeNormal..ttTabItemRightEdgeFocused:
1344         begin
1345           Part := TABP_TABITEMRIGHTEDGE;
1346           Base := Ord(ttTabItemRightEdgeNormal);
1347         end;
1348       ttTabItemBothEdgeNormal..ttTabItemBothEdgeFocused:
1349         begin
1350           Part := TABP_TABITEMBOTHEDGE;
1351           Base := Ord(ttTabItemBothEdgeNormal);
1352         end;
1353       ttTopTabItemNormal..ttTopTabItemFocused:
1354         begin
1355           Part := TABP_TOPTABITEM;
1356           Base := Ord(ttTopTabItemNormal);
1357         end;
1358       ttTopTabItemLeftEdgeNormal..ttTopTabItemLeftEdgeFocused:
1359         begin
1360           Part := TABP_TOPTABITEMLEFTEDGE;
1361           Base := Ord(ttTopTabItemLeftEdgeNormal);
1362         end;
1363       ttTopTabItemRightEdgeNormal..ttTopTabItemRightEdgeFocused:
1364         begin
1365           Part := TABP_TOPTABITEMRIGHTEDGE;
1366           Base := Ord(ttTopTabItemRightEdgeNormal);
1367         end;
1368       ttTopTabItemBothEdgeNormal..ttTopTabItemBothEdgeFocused:
1369         begin
1370           Part := TABP_TOPTABITEMBOTHEDGE;
1371           Base := Ord(ttTopTabItemBothEdgeNormal);
1372         end;
1373       ttPane:
1374         begin
1375           Part := TABP_PANE;
1376           Base := Ord(ttPane);
1377         end;
1378       ttBody:
1379         begin
1380           Part := TABP_BODY;
1381           Base := Ord(ttBody);
1382         end;
1383     else
1384       Part := 0;
1385       Base := 0;
1386     end;
1387     State := Ord(Detail) - Base + 1;
1388   end;
1389 end;
1390 
1391 //----------------------------------------------------------------------------------------------------------------------
1392 
GetElementDetailsnull1393 function TThemeServices.GetElementDetails(Detail: TThemedTaskBand): TThemedElementDetails;
1394 var
1395   Base: Integer;
1396 begin
1397   Result.Element := teTaskBand;
1398   with Result do
1399   begin
1400     case Detail of
1401       ttbGroupCount:
1402         begin
1403           Part := TDP_GROUPCOUNT;
1404           Base := Ord(ttbGroupCount);
1405         end;
1406       ttbFlashButton:
1407         begin
1408           Part := TDP_FLASHBUTTON;
1409           Base := Ord(ttbFlashButton);
1410         end;
1411       ttpFlashButtonGroupMenu:
1412         begin
1413           Part := TDP_FLASHBUTTONGROUPMENU;
1414           Base := Ord(ttpFlashButtonGroupMenu);
1415         end;
1416     else
1417       Part := 0;
1418       Base := 0;
1419     end;
1420     State := Ord(Detail) - Base + 1;
1421   end;
1422 end;
1423 
1424 //----------------------------------------------------------------------------------------------------------------------
1425 
GetElementDetailsnull1426 function TThemeServices.GetElementDetails(Detail: TThemedTaskBar): TThemedElementDetails;
1427 var
1428   Base: Integer;
1429 begin
1430   Result.Element := teTaskBar;
1431   with Result do
1432   begin
1433     case Detail of
1434       ttbTimeNormal:
1435         begin
1436           Part := CLP_TIME;
1437           Base := Ord(ttbTimeNormal);
1438         end;
1439     else
1440       Part := 0;
1441       Base := 0;
1442     end;
1443     State := Ord(Detail) - Base + 1;
1444   end;
1445 end;
1446 
1447 //----------------------------------------------------------------------------------------------------------------------
1448 
GetElementDetailsnull1449 function TThemeServices.GetElementDetails(Detail: TThemedToolBar): TThemedElementDetails;
1450 var
1451   Base: Integer;
1452 begin
1453   Result.Element := teToolBar;
1454   with Result do
1455   begin
1456     case Detail of
1457       ttbButtonNormal..ttbButtonCheckedHot:
1458         begin
1459           Part := TP_BUTTON;
1460           Base := Ord(ttbButtonNormal);
1461         end;
1462       ttbDropDownButtonNormal..ttbDropDownButtonCheckedHot:
1463         begin
1464           Part := TP_DROPDOWNBUTTON;
1465           Base := Ord(ttbDropDownButtonNormal);
1466         end;
1467       ttbSplitButtonNormal..ttbSplitButtonCheckedHot:
1468         begin
1469           Part := TP_SPLITBUTTON;
1470           Base := Ord(ttbSplitButtonNormal);
1471         end;
1472       ttbSplitButtonDropDownNormal..ttbSplitButtonDropDownCheckedHot:
1473         begin
1474           Part := TP_SPLITBUTTONDROPDOWN;
1475           Base := Ord(ttbSplitButtonDropDownNormal);
1476         end;
1477       ttbSeparatorNormal..ttbSeparatorCheckedHot:
1478         begin
1479           Part := TP_SEPARATOR;
1480           Base := Ord(ttbSeparatorNormal);
1481         end;
1482       ttbSeparatorVertNormal..ttbSeparatorVertCheckedHot:
1483         begin
1484           Part := TP_SEPARATORVERT;
1485           Base := Ord(ttbSeparatorVertNormal);
1486         end;
1487     else
1488       Part := 0;
1489       Base := 0;
1490     end;
1491     State := Ord(Detail) - Base + 1;
1492   end;
1493 end;
1494 
1495 //----------------------------------------------------------------------------------------------------------------------
1496 
GetElementDetailsnull1497 function TThemeServices.GetElementDetails(Detail: TThemedToolTip): TThemedElementDetails;
1498 var
1499   Base: Integer;
1500 begin
1501   Result.Element := teToolTip;
1502   with Result do
1503   begin
1504     case Detail of
1505       tttStandardNormal..tttStandardLink:
1506         begin
1507           Part := TTP_STANDARD;
1508           Base := Ord(tttStandardNormal);
1509         end;
1510       tttStandardTitleNormal..tttStandardTitleLink:
1511         begin
1512           Part := TTP_STANDARDTITLE;
1513           Base := Ord(tttStandardTitleNormal);
1514         end;
1515       tttBaloonNormal..tttBaloonLink:
1516         begin
1517           Part := TTP_BALLOON;
1518           Base := Ord(tttBaloonNormal);
1519         end;
1520       tttBaloonTitleNormal..tttBaloonTitleLink:
1521         begin
1522           Part := TTP_BALLOONTITLE;
1523           Base := Ord(tttBaloonTitleNormal);
1524         end;
1525       tttCloseNormal..tttClosePressed:
1526         begin
1527           Part := TTP_CLOSE;
1528           Base := Ord(tttCloseNormal);
1529         end;
1530     else
1531       Part := 0;
1532       Base := 0;
1533     end;
1534     State := Ord(Detail) - Base + 1;
1535   end;
1536 end;
1537 
1538 //----------------------------------------------------------------------------------------------------------------------
1539 
GetElementDetailsnull1540 function TThemeServices.GetElementDetails(Detail: TThemedTrackBar): TThemedElementDetails;
1541 var
1542   Base: Integer;
1543 begin
1544   Result.Element := teTrackBar;
1545   with Result do
1546   begin
1547     case Detail of
1548       ttbTrack:
1549         begin
1550           Part := TKP_TRACK;
1551           Base := Ord(ttbTrack);
1552         end;
1553       ttbTrackVert:
1554         begin
1555           Part := TKP_TRACKVERT;
1556           Base := Ord(ttbTrackVert);
1557         end;
1558       ttbThumbNormal..ttbThumbDisabled:
1559         begin
1560           Part := TKP_THUMB;
1561           Base := Ord(ttbThumbNormal);
1562         end;
1563       ttbThumbBottomNormal..ttbThumbBottomDisabled:
1564         begin
1565           Part := TKP_THUMBBOTTOM;
1566           Base := Ord(ttbThumbBottomNormal);
1567         end;
1568       ttbThumbTopNormal..ttbThumbTopDisabled:
1569         begin
1570           Part := TKP_THUMBTOP;
1571           Base := Ord(ttbThumbTopNormal);
1572         end;
1573       ttbThumbVertNormal..ttbThumbVertDisabled:
1574         begin
1575           Part := TKP_THUMBVERT;
1576           Base := Ord(ttbThumbVertNormal);
1577         end;
1578       ttbThumbLeftNormal..ttbThumbLeftDisabled:
1579         begin
1580           Part := TKP_THUMBLEFT;
1581           Base := Ord(ttbThumbLeftNormal);
1582         end;
1583       ttbThumbRightNormal..ttbThumbRightDisabled:
1584         begin
1585           Part := TKP_THUMBRIGHT;
1586           Base := Ord(ttbThumbRightNormal);
1587         end;
1588       ttbThumbTics:
1589         begin
1590           Part := TKP_TICS;
1591           Base := Ord(ttbThumbTics);
1592         end;
1593       ttbThumbTicsVert:
1594         begin
1595           Part := TKP_TICSVERT;
1596           Base := Ord(ttbThumbTicsVert);
1597         end;
1598     else
1599       Part := 0;
1600       Base := 0;
1601     end;
1602     State := Ord(Detail) - Base + 1;
1603   end;
1604 end;
1605 
1606 //----------------------------------------------------------------------------------------------------------------------
1607 
GetElementDetailsnull1608 function TThemeServices.GetElementDetails(Detail: TThemedTrayNotify): TThemedElementDetails;
1609 var
1610   Base: Integer;
1611 begin
1612   Result.Element := teTrayNotify;
1613   with Result do
1614   begin
1615     case Detail of
1616       ttnBackground:
1617         begin
1618           Part := TNP_BACKGROUND;
1619           Base := Ord(ttnBackground);
1620         end;
1621       ttnAnimBackground:
1622         begin
1623           Part := TNP_ANIMBACKGROUND;
1624           Base := Ord(ttnAnimBackground);
1625         end;
1626     else
1627       Part := 0;
1628       Base := 0;
1629     end;
1630     State := Ord(Detail) - Base + 1;
1631   end;
1632 end;
1633 
1634 //----------------------------------------------------------------------------------------------------------------------
1635 
GetElementDetailsnull1636 function TThemeServices.GetElementDetails(Detail: TThemedTreeview): TThemedElementDetails;
1637 var
1638   Base: Integer;
1639 begin
1640   Result.Element := teTreeView;
1641   with Result do
1642   begin
1643     case Detail of
1644       ttItemNormal..ttItemSelectedNotFocus:
1645         begin
1646           Part := TVP_TREEITEM;
1647           Base := Ord(ttItemNormal);
1648         end;
1649       ttGlyphClosed..ttGlyphOpened:
1650         begin
1651           Part := TVP_GLYPH;
1652           Base := Ord(ttGlyphClosed);
1653         end;
1654       ttBranch:
1655         begin
1656           Part := TVP_BRANCH;
1657           Base := Ord(ttBranch);
1658         end;
1659       ttHotGlyphClosed..ttHotGlyphOpened:
1660         begin
1661           Part := TVP_HOTGLYPH;
1662           Base := Ord(ttHotGlyphClosed);
1663         end;
1664     else
1665       Part := 0;
1666       Base := 0;
1667     end;
1668     State := Ord(Detail) - Base + 1;
1669   end;
1670 end;
1671 
1672 //----------------------------------------------------------------------------------------------------------------------
1673 
GetElementDetailsnull1674 function TThemeServices.GetElementDetails(Detail: TThemedWindow): TThemedElementDetails;
1675 var
1676   Base: Integer;
1677 begin
1678   Result.Element := teWindow;
1679   with Result do
1680   begin
1681     case Detail of
1682       twCaptionActive..twCaptionDisabled:
1683         begin
1684           Part := WP_CAPTION;
1685           Base := Ord(twCaptionActive);
1686         end;
1687       twSmallCaptionActive..twSmallCaptionDisabled:
1688         begin
1689           Part := WP_SMALLCAPTION;
1690           Base := Ord(twSmallCaptionActive);
1691         end;
1692       twMinCaptionActive..twMinCaptionDisabled:
1693         begin
1694           Part := WP_MINCAPTION;
1695           Base := Ord(twMinCaptionActive);
1696         end;
1697       twSmallMinCaptionActive..twSmallMinCaptionDisabled:
1698         begin
1699           Part := WP_SMALLMINCAPTION;
1700           Base := Ord(twSmallMinCaptionActive);
1701         end;
1702       twMaxCaptionActive..twMaxCaptionDisabled:
1703         begin
1704           Part := WP_MAXCAPTION;
1705           Base := Ord(twMaxCaptionActive);
1706         end;
1707       twSmallMaxCaptionActive..twSmallMaxCaptionDisabled:
1708         begin
1709           Part := WP_SMALLMAXCAPTION;
1710           Base := Ord(twSmallMaxCaptionActive);
1711         end;
1712       twFrameLeftActive..twFrameLeftInactive:
1713         begin
1714           Part := WP_FRAMELEFT;
1715           Base := Ord(twFrameLeftActive);
1716         end;
1717       twFrameRightActive..twFrameRightInactive:
1718         begin
1719           Part := WP_FRAMERIGHT;
1720           Base := Ord(twFrameRightActive);
1721         end;
1722       twFrameBottomActive..twFrameBottomInactive:
1723         begin
1724           Part := WP_FRAMEBOTTOM;
1725           Base := Ord(twFrameBottomActive);
1726         end;
1727       twSmallFrameLeftActive..twSmallFrameLeftInactive:
1728         begin
1729           Part := WP_SMALLFRAMELEFT;
1730           Base := Ord(twSmallFrameLeftActive);
1731         end;
1732       twSmallFrameRightActive..twSmallFrameRightInactive:
1733         begin
1734           Part := WP_SMALLFRAMERIGHT;
1735           Base := Ord(twSmallFrameRightActive);
1736         end;
1737       twSmallFrameBottomActive..twSmallFrameBottomInactive:
1738         begin
1739           Part := WP_SMALLFRAMEBOTTOM;
1740           Base := Ord(twSmallFrameBottomActive);
1741         end;
1742       twSysButtonNormal..twSysButtonInactive:
1743         begin
1744           Part := WP_SYSBUTTON;
1745           Base := Ord(twSysButtonNormal);
1746         end;
1747       twMDISysButtonNormal..twMDISysButtonInactive:
1748         begin
1749           Part := WP_MDISYSBUTTON;
1750           Base := Ord(twMDISysButtonNormal);
1751         end;
1752       twMinButtonNormal..twMinButtonInactive:
1753         begin
1754           Part := WP_MINBUTTON;
1755           Base := Ord(twMinButtonNormal);
1756         end;
1757       twMDIMinButtonNormal..twMDIMinButtonInactive:
1758         begin
1759           Part := WP_MDIMINBUTTON;
1760           Base := Ord(twMDIMinButtonNormal);
1761         end;
1762       twMaxButtonNormal..twMaxButtonInactive:
1763         begin
1764           Part := WP_MAXBUTTON;
1765           Base := Ord(twMaxButtonNormal);
1766         end;
1767       twCloseButtonNormal..twCloseButtonInactive:
1768         begin
1769           Part := WP_CLOSEBUTTON;
1770           Base := Ord(twCloseButtonNormal);
1771         end;
1772       twSmallCloseButtonNormal..twSmallCloseButtonInactive:
1773         begin
1774           Part := WP_SMALLCLOSEBUTTON;
1775           Base := Ord(twSmallCloseButtonNormal);
1776         end;
1777       twMDICloseButtonNormal..twMDICloseButtonInactive:
1778         begin
1779           Part := WP_MDICLOSEBUTTON;
1780           Base := Ord(twMDICloseButtonNormal);
1781         end;
1782       twRestoreButtonNormal..twRestoreButtonInactive:
1783         begin
1784           Part := WP_RESTOREBUTTON;
1785           Base := Ord(twRestoreButtonNormal);
1786         end;
1787       twMDIRestoreButtonNormal..twMDIRestoreButtonInactive:
1788         begin
1789           Part := WP_MDIRESTOREBUTTON;
1790           Base := Ord(twMDIRestoreButtonNormal);
1791         end;
1792       twHelpButtonNormal..twHelpButtonInactive:
1793         begin
1794           Part := WP_HELPBUTTON;
1795           Base := Ord(twHelpButtonNormal);
1796         end;
1797       twMDIHelpButtonNormal..twMDIHelpButtonInactive:
1798         begin
1799           Part := WP_MDIHELPBUTTON;
1800           Base := Ord(twMDIHelpButtonNormal);
1801         end;
1802       twHorzScrollNormal..twHorzScrollDisabled:
1803         begin
1804           Part := WP_HORZSCROLL;
1805           Base := Ord(twHorzScrollNormal);
1806         end;
1807       twHorzThumbNormal..twHorzThumbDisabled:
1808         begin
1809           Part := WP_HORZTHUMB;
1810           Base := Ord(twHorzThumbNormal);
1811         end;
1812       twVertScrollNormal..twVertScrollDisabled:
1813         begin
1814           Part := WP_VERTSCROLL;
1815           Base := Ord(twVertScrollNormal);
1816         end;
1817       twVertThumbNormal..twVertThumbDisabled:
1818         begin
1819           Part := WP_VERTTHUMB;
1820           Base := Ord(twVertThumbNormal);
1821         end;
1822       twDialog:
1823         begin
1824           Part := WP_DIALOG;
1825           Base := Ord(twDialog);
1826         end;
1827       twCaptionSizingTemplate:
1828         begin
1829           Part := WP_CAPTIONSIZINGTEMPLATE;
1830           Base := Ord(twCaptionSizingTemplate);
1831         end;
1832       twSmallCaptionSizingTemplate:
1833         begin
1834           Part := WP_SMALLCAPTIONSIZINGTEMPLATE;
1835           Base := Ord(twSmallCaptionSizingTemplate);
1836         end;
1837       twFrameLeftSizingTemplate:
1838         begin
1839           Part := WP_FRAMELEFTSIZINGTEMPLATE;
1840           Base := Ord(twFrameLeftSizingTemplate);
1841         end;
1842       twSmallFrameLeftSizingTemplate:
1843         begin
1844           Part := WP_SMALLFRAMELEFTSIZINGTEMPLATE;
1845           Base := Ord(twSmallFrameLeftSizingTemplate);
1846         end;
1847       twFrameRightSizingTemplate:
1848         begin
1849           Part := WP_FRAMERIGHTSIZINGTEMPLATE;
1850           Base := Ord(twFrameRightSizingTemplate);
1851         end;
1852       twSmallFrameRightSizingTemplate:
1853         begin
1854           Part := WP_SMALLFRAMERIGHTSIZINGTEMPLATE;
1855           Base := Ord(twSmallFrameRightSizingTemplate);
1856         end;
1857       twFrameBottomSizingTemplate:
1858         begin
1859           Part := WP_FRAMEBOTTOMSIZINGTEMPLATE;
1860           Base := Ord(twFrameBottomSizingTemplate);
1861         end;
1862       twSmallFrameBottomSizingTemplate:
1863         begin
1864           Part := WP_SMALLFRAMEBOTTOMSIZINGTEMPLATE;
1865           Base := Ord(twSmallFrameBottomSizingTemplate);
1866         end;
1867     else
1868       Part := 0;
1869       Base := 0;
1870     end;
1871     State := Ord(Detail) - Base + 1;
1872   end;
1873 end;
1874 
GetDetailSizenull1875 function TThemeServices.GetDetailSize(Details: TThemedElementDetails): TSize;
1876 begin
1877   // default values here
1878   // -1 mean that we do not know size of detail
1879   Result := Size(-1, -1);
1880   case Details.Element of
1881     teButton:
1882       if Details.Part in [BP_RADIOBUTTON, BP_CHECKBOX] then
1883         Result := Size(13, 13)
1884       else
1885       if Details.Part = BP_PUSHBUTTON then
1886         Result := Size(75, 23);
1887     teRebar:
1888       if Details.Part = RP_GRIPPER then
1889         Result.cy := 30
1890       else
1891       if Details.Part = RP_GRIPPERVERT then
1892         Result.cx := 30;
1893     teToolBar:
1894       if Details.Part in [TP_SPLITBUTTONDROPDOWN, TP_DROPDOWNBUTTON] then
1895         Result.cx := 12;
1896     teTreeView:
1897       if Details.Part in [TVP_GLYPH, TVP_HOTGLYPH] then
1898         Result := Size(9, 9);
1899     teWindow:
1900       if Details.Part in [WP_SMALLCLOSEBUTTON, WP_MDICLOSEBUTTON, WP_MDIHELPBUTTON, WP_MDIMINBUTTON, WP_MDIRESTOREBUTTON, WP_MDISYSBUTTON] then
1901         Result := Size(9, 9);
1902     teHeader:
1903       if Details.Part in [HP_HEADERSORTARROW] then
1904         Result := Size(8, 5);
1905   end;
1906   if (Result.cx>0) then
1907     Result.cx := MulDiv(Result.cx, ScreenInfo.PixelsPerInchX, 96);
1908   if (Result.cy>0) then
1909     Result.cy := MulDiv(Result.cy, ScreenInfo.PixelsPerInchY, 96);
1910 end;
1911 
GetDetailRegionnull1912 function TThemeServices.GetDetailRegion(DC: HDC;
1913   Details: TThemedElementDetails; const R: TRect): HRGN;
1914 begin
1915   Result := 0;
1916 end;
1917 
GetStockImagenull1918 function TThemeServices.GetStockImage(StockID: LongInt; out Image, Mask: HBitmap): Boolean;
1919 begin
1920   Result := False;
1921 end;
1922 
GetOptionnull1923 function TThemeServices.GetOption(AOption: TThemeOption): Integer;
1924 begin
1925   case AOption of
1926     toShowButtonImages: Result := 1;
1927     toShowMenuImages: Result := 1;
1928     toUseGlyphEffects:
1929     begin
1930       // toUseGlyphEffects seems to be OS-dependent.
1931       //   Linux: yes
1932       //   Win, OSX: no
1933       {$IFDEF LINUX}
1934       Result := 1;
1935       {$ELSE}
1936       Result := 0;
1937       {$ENDIF}
1938     end;
1939   else
1940     Result := 0;
1941   end;
1942 end;
1943 
GetTextExtentnull1944 function TThemeServices.GetTextExtent(DC: HDC; Details: TThemedElementDetails;
1945   const S: String; Flags: Cardinal; BoundingRect: PRect): TRect;
1946 begin
1947   if Assigned(BoundingRect) then
1948     Result := BoundingRect^
1949   else
1950     Result := Rect(0, 0, 0, 0);
1951   LCLIntf.DrawText(DC, PChar(S), Length(S), Result, DT_CALCRECT or Flags);
1952 end;
1953 
1954 //----------------------------------------------------------------------------------------------------------------------
1955 
ColorToRGBnull1956 function TThemeServices.ColorToRGB(Color: LongInt; Details: PThemedElementDetails = nil): COLORREF;
1957 begin
1958   if (Color and $80000000 = 0) then
1959     Result := Color
1960   else
1961   if Details = nil then
1962     Result := Graphics.ColorToRGB(Color)
1963   else
1964     Result := InternalColorToRGB(Details^, Color);
1965 end;
1966 
1967 //----------------------------------------------------------------------------------------------------------------------
1968 
ContentRectnull1969 function TThemeServices.ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect;
1970 begin
1971   Result := BoundingRect;
1972   if Details.Element in [teHeader, teButton] then
1973     InflateRect(Result, -2, -2)
1974   else
1975     InflateRect(Result, -1, -1);
1976 end;
1977 
1978 //----------------------------------------------------------------------------------------------------------------------
1979 
1980 procedure TThemeServices.DrawEdge(DC: HDC; Details: TThemedElementDetails; const R: TRect; Edge, Flags: Cardinal;
1981   AContentRect: PRect = nil);
1982 var
1983   ARect: TRect;
1984 begin
1985   // deafult painting
1986   ARect := R;
1987   WidgetSet.DrawEdge(DC, ARect, Edge, Flags);
1988   if (Flags and DFCS_ADJUSTRECT <> 0) and (AContentRect <> nil) then
1989     AContentRect^ := R;
1990 end;
1991 
1992 //----------------------------------------------------------------------------------------------------------------------
1993 
1994 procedure TThemeServices.DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect = nil);
1995 
1996   procedure DrawDropDownArrow(const DropDownButtonRect: TRect);
1997   const
1998     cArrowWidth = 10;
1999   var
2000     ArrowRect: TRect;
2001     Points: array[1..3] of TPoint;
2002     OldBrush, Brush: HBrush;
2003   begin
2004     ArrowRect := DropDownButtonRect;
2005     ArrowRect.Left := (DropDownButtonRect.Left+DropDownButtonRect.Right-cArrowWidth-1) div 2;
2006     ArrowRect.Right := ArrowRect.Left+cArrowWidth;
2007     ArrowRect.Left := ArrowRect.Left + 3;
2008     ArrowRect.Right := Max(ArrowRect.Right - 3, ArrowRect.Left);
2009     ArrowRect.Top := (DropDownButtonRect.Top + DropDownButtonRect.Bottom +
2010                       ArrowRect.Left - ArrowRect.Right) div 2;
2011     ArrowRect.Bottom := ArrowRect.Top + Min(2, ArrowRect.Right - ArrowRect.Left);
2012     Points[1] := Point(ArrowRect.Left, ArrowRect.Top);
2013     Points[2] := Point((ArrowRect.Left + ArrowRect.Right) div 2, ArrowRect.Bottom);
2014     Points[3] := Point(ArrowRect.Right, ArrowRect.Top);
2015     Brush := CreateSolidBrush(clBlack);
2016     OldBrush := SelectObject(DC, Brush);
2017     Polygon(Dc, @Points[1], 3, False);
2018     DeleteObject(SelectObject(DC, OldBrush));
2019   end;
2020 
2021   procedure DrawVLine(ARect: TRect);
2022   begin
2023     ARect.Left := ((ARect.Left + ARect.Right) div 2) - 1;
2024     ARect.Right := ARect.Left + 2;
2025     inc(ARect.Top, 2);
2026     inc(ARect.Bottom, 2);
2027     LCLIntf.DrawEdge(DC, ARect, EDGE_ETCHED, BF_LEFT);
2028   end;
2029 
2030   procedure DrawHLine(ARect: TRect);
2031   begin
2032     ARect.Top := ((ARect.Top + ARect.Bottom) div 2) - 1;
2033     ARect.Bottom := ARect.Top + 2;
2034     inc(ARect.Left, 2);
2035     inc(ARect.Right, 2);
2036     LCLIntf.DrawEdge(DC, ARect, EDGE_ETCHED, BF_LEFT);
2037   end;
2038 
2039   procedure FillWithColor(ARect: TRect; AColor: TColor);
2040   var
2041     Brush: HBrush;
2042   begin
2043     Brush := CreateSolidBrush(ColorToRGB(AColor));
2044     FillRect(DC, ARect, Brush);
2045     DeleteObject(Brush);
2046   end;
2047 
2048   procedure FillWithDottedBrush(ARect: TRect; Color1, Color2: TColor);
2049   var
2050     OldColor1, OldColor2: TColorRef;
2051   begin
2052     OldColor1 := SetBkColor(DC, ColorToRGB(Color1));
2053     OldColor2 := SetTextColor(DC, ColorToRGB(Color2));
2054     FillRect(DC, ARect, DottedBrush);
2055     SetBkColor(DC, OldColor1);
2056     SetTextColor(DC, OldColor2);
2057   end;
2058 
2059   procedure DrawTriangle(ADown: Boolean);
2060   var
2061     P: array[0..2] of TPoint;
2062     Brush: HBRUSH;
2063     OldBrush, OldPen: HGDIOBJ;
2064     Pen: HPEN;
2065   begin
2066     if ADown then
2067     begin
2068       P[0].x:=R.Left; P[0].y:=R.Top;
2069       P[1].x:=R.Left+(R.Right-1-R.Left) div 2; P[1].y:= R.Bottom-1;
2070       P[2].x:=R.Right-1; P[2].y:= R.Top;
2071     end else
2072     begin
2073       P[0].x:=R.Right-1; P[0].y:= R.Bottom-1;
2074       P[1].x:=R.Left+(R.Right-1-R.Left) div 2; P[1].y:= R.Top-1;
2075       P[2].x:=R.Left-1; P[2].y:=R.Bottom-1;
2076     end;
2077 
2078     Pen := CreatePen(PS_NULL, 0, 0);
2079     OldPen := SelectObject(DC, Pen);
2080     Brush := CreateSolidBrush(ColorToRGB(clBtnText));
2081     OldBrush := SelectObject(DC, Brush);
2082     Polygon(DC, @P[0], 3, False);
2083     DeleteObject(SelectObject(DC, OldBrush));
2084     DeleteObject(SelectObject(DC, OldPen));
2085   end;
2086 
2087 var
2088   ADrawFlags: DWord;
2089   Bevel: TGraphicsBevelCut;
2090   ARect: TRect;
2091   Tmp: Integer;
2092 begin
2093   // default painting
2094   ARect := R; // in order to pass by reference
2095   case Details.Element of
2096     teButton:
2097       begin
2098         ADrawFlags := DFCS_BUTTONPUSH;
2099         if Details.Element = teButton then
2100         begin
2101           case Details.Part of
2102             BP_RADIOBUTTON: ADrawFlags := DFCS_BUTTONRADIO;
2103             BP_CHECKBOX:
2104               if IsMixed(Details) then
2105                 ADrawFlags := DFCS_BUTTON3STATE
2106               else
2107                 ADrawFlags := DFCS_BUTTONCHECK;
2108           end;
2109         end;
2110 
2111         if IsDisabled(Details) then
2112           ADrawFlags := ADrawFlags or DFCS_INACTIVE else
2113         if IsPushed(Details) then
2114           ADrawFlags := ADrawFlags or DFCS_PUSHED else
2115         if IsHot(Details) then
2116           ADrawFlags := ADrawFlags or DFCS_HOT;
2117         if IsChecked(Details) or IsMixed(Details) then
2118           ADrawFlags := ADrawFlags or DFCS_CHECKED;
2119 
2120         WidgetSet.DrawFrameControl(DC, ARect, DFC_BUTTON, ADrawFlags);
2121       end;
2122     teHeader:
2123       begin
2124         if Details.Part = HP_HEADERSORTARROW then
2125           DrawTriangle(Details.State = HSAS_SORTEDDOWN)
2126         else
2127         begin
2128           ADrawFlags := DFCS_BUTTONPUSH;
2129           if IsDisabled(Details) then
2130             ADrawFlags := ADrawFlags or DFCS_INACTIVE else
2131           if IsPushed(Details) then
2132             ADrawFlags := ADrawFlags or DFCS_PUSHED else
2133           if IsHot(Details) then
2134             ADrawFlags := ADrawFlags or DFCS_HOT;
2135 
2136           WidgetSet.DrawFrameControl(DC, ARect, DFC_BUTTON, ADrawFlags);
2137         end;
2138       end;
2139     teToolBar:
2140       begin
2141         case Details.Part of
2142           TP_BUTTON,
2143           TP_DROPDOWNBUTTON,
2144           TP_SPLITBUTTON:
2145             begin
2146               if IsPushed(Details) or IsChecked(Details) then
2147                 Bevel := bvLowered
2148               else
2149               if IsHot(Details) then
2150                 Bevel := bvRaised
2151               else
2152                 Bevel := bvNone;
2153 
2154               Frame3D(DC, ARect, 1, Bevel);
2155 
2156               if IsChecked(Details) and not IsHot(Details) then
2157               begin
2158                 InflateRect(ARect, -2, -2);
2159                 FillWithDottedBrush(ARect, clBtnHighlight, clBtnFace)
2160               end;
2161             end;
2162           TP_SPLITBUTTONDROPDOWN:
2163             begin
2164               if IsPushed(Details) or IsChecked(Details) then
2165                 Bevel := bvLowered
2166               else
2167               if IsHot(Details) then
2168                 Bevel := bvRaised
2169               else
2170                 Bevel := bvNone;
2171 
2172               Frame3D(DC, ARect, 1, Bevel);
2173               ARect:=R;
2174               InflateRect(ARect, -1, -1);
2175               DrawDropDownArrow(ARect);
2176             end;
2177           TP_SEPARATOR:
2178             DrawVline(ARect);
2179           TP_SEPARATORVERT:
2180             DrawHline(ARect);
2181         end;
2182       end;
2183     teWindow:
2184       begin
2185         case Details.Part of
2186           WP_MINBUTTON,
2187           WP_MDIMINBUTTON    : ADrawFlags := DFCS_CAPTIONMIN;
2188           WP_MAXBUTTON       : ADrawFlags := DFCS_CAPTIONMAX;
2189           WP_CLOSEBUTTON,
2190           WP_SMALLCLOSEBUTTON,
2191           WP_MDICLOSEBUTTON  : ADrawFlags := DFCS_CAPTIONCLOSE;
2192           WP_RESTOREBUTTON,
2193           WP_MDIRESTOREBUTTON: ADrawFlags := DFCS_CAPTIONRESTORE;
2194           WP_HELPBUTTON,
2195           WP_MDIHELPBUTTON   : ADrawFlags := DFCS_CAPTIONHELP;
2196         else
2197           ADrawFlags := 0;
2198         end;
2199 
2200         if Details.Part in [WP_MDIMINBUTTON, WP_MDIRESTOREBUTTON, WP_MDICLOSEBUTTON] then
2201           ADrawFlags := ADrawFlags or DFCS_FLAT;
2202 
2203         if IsDisabled(Details) then
2204           ADrawFlags := ADrawFlags or DFCS_INACTIVE else
2205         if IsPushed(Details) then
2206           ADrawFlags := ADrawFlags or DFCS_PUSHED else
2207         if IsHot(Details) then
2208           ADrawFlags := ADrawFlags or DFCS_HOT;
2209 
2210         WidgetSet.DrawFrameControl(DC, ARect, DFC_CAPTION, ADrawFlags);
2211       end;
2212     teTab:
2213       begin
2214         if Details.Part in [TABP_PANE, TABP_BODY] then
2215           FillWithColor(ARect, clBackground);
2216       end;
2217     teTreeView:
2218       begin
2219         if Details.Part in [TVP_GLYPH, TVP_HOTGLYPH] then
2220         begin
2221           with ARect do
2222           begin
2223             if not odd(Right - Left) then
2224               Dec(Right);
2225             if not odd(Bottom - Top) then
2226               Dec(Bottom);
2227           end;
2228           Rectangle(DC, ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
2229           Tmp := Integer((ARect.Bottom + ARect.Top) shr 1);
2230           MoveToEx(DC, ARect.Left + 2, Tmp, nil);
2231           LineTo(DC, ARect.Right - 2, Tmp);
2232           if Details.State = GLPS_CLOSED then
2233           begin
2234             Tmp := (ARect.Left + ARect.Right) shr 1;
2235             MoveToEx(DC, Tmp, ARect.Top + 2, nil);
2236             LineTo(DC, Tmp, ARect.Bottom - 2);
2237           end;
2238         end
2239         else
2240         if Details.Part = TVP_TREEITEM then
2241         begin
2242           case Details.State of
2243             TREIS_NORMAL: FillWithColor(ARect, clWindow);
2244             TREIS_HOT: FillWithColor(ARect, clHotLight);
2245             TREIS_SELECTED: FillWithColor(ARect, clHighlight);
2246             TREIS_DISABLED: FillWithColor(ARect, clWindow);
2247             TREIS_SELECTEDNOTFOCUS: FillWithColor(ARect, clBtnFace);
2248             TREIS_HOTSELECTED: FillWithColor(ARect, clHighlight);
2249           end;
2250         end;
2251       end;
2252     teToolTip:
2253       begin
2254         if Details.Part = TTP_STANDARD then
2255         begin
2256           FillWithColor(ARect, clInfoBk);
2257           LCLIntf.DrawEdge(DC, ARect, BDR_RAISEDOUTER, BF_RECT);
2258         end;
2259       end;
2260   end;
2261 end;
2262 
2263 //----------------------------------------------------------------------------------------------------------------------
2264 
2265 procedure TThemeServices.DrawIcon(DC: HDC; Details: TThemedElementDetails; const R: TRect; himl: HIMAGELIST;
2266   Index: Integer);
2267 begin
2268   // overrided in TWin32ThemeServices (for compatability with Delphi)
2269 end;
2270 
2271 procedure TThemeServices.DrawIcon(ACanvas: TPersistent;
2272   Details: TThemedElementDetails; const P: TPoint; AImageList: TPersistent;
2273   Index: Integer; AImageWidth: Integer; ARefControl: TPersistent);
2274 var
2275   AEffect: TGraphicsDrawEffect;
2276 begin
2277   if not Assigned(ThemesImageDrawEvent) then exit;
2278   if IsDisabled(Details) then
2279     AEffect := gdeDisabled
2280   else
2281   if IsPushed(Details) then
2282     AEffect := gdeShadowed
2283   else
2284   if IsHot(Details) then
2285     AEffect := gdeHighlighted
2286   else
2287     AEffect := gdeNormal;
2288   ThemesImageDrawEvent(AImageList, ACanvas, P.X, P.Y, Index, AEffect, AImageWidth, ARefControl);
2289 end;
2290 
2291 //----------------------------------------------------------------------------------------------------------------------
2292 
2293 procedure TThemeServices.DrawParentBackground(Window: HWND; Target: HDC; Details: PThemedElementDetails;
2294   OnlyIfTransparent: Boolean; Bounds: PRect = nil);
2295 var
2296   DoDraw: Boolean;
2297 begin
2298   if OnlyIfTransparent and Assigned(Details) then
2299     DoDraw := HasTransparentParts(Details^)
2300   else
2301     DoDraw := True;
2302 
2303   if DoDraw then
2304     InternalDrawParentBackground(Window, Target, Bounds);
2305 end;
2306 
2307 //----------------------------------------------------------------------------------------------------------------------
2308 
2309 procedure TThemeServices.DrawText(DC: HDC; Details: TThemedElementDetails; const S: String; R: TRect; Flags,
2310   Flags2: Cardinal);
2311 begin
2312   // overrided in TWin32ThemeServices (for compatability with Delphi)
2313 end;
2314 
IsDisablednull2315 function TThemeServices.IsDisabled(Details: TThemedElementDetails): Boolean;
2316 begin
2317   // teHeader should not be here, it has no disabled state
2318 
2319   Result := False;
2320   if (Details.Element in [teButton, teToolBar, teComboBox, teEdit]) or
2321      ((Details.Element = teRebar) and (Details.Part >= RP_BAND)) or
2322      ((Details.Element = teWindow) and (Details.Part >= WP_SYSBUTTON) and
2323      (Details.Part <= WP_MDIHELPBUTTON)) then
2324     Result := (Details.State mod 4) = 0; // usual disabled = 4 / 8 / 12
2325 end;
2326 
IsPushednull2327 function TThemeServices.IsPushed(Details: TThemedElementDetails): Boolean;
2328 begin
2329   Result := False;
2330   if (Details.Element in [teButton, teToolBar, teHeader, teComboBox]) or
2331      ((Details.Element = teRebar) and (Details.Part >= RP_BAND)) or
2332      ((Details.Element = teWindow) and (Details.Part >= WP_SYSBUTTON) and
2333      (Details.Part <= WP_MDIHELPBUTTON)) then
2334     Result := Details.State in [3, 7, 11];
2335 end;
2336 
IsHotnull2337 function TThemeServices.IsHot(Details: TThemedElementDetails): Boolean;
2338 begin
2339   Result := False;
2340   if (Details.Element in [teButton, teToolBar, teHeader, teComboBox]) or
2341      ((Details.Element = teRebar) and (Details.Part >= RP_BAND)) or
2342      ((Details.Element = teWindow) and (Details.Part >= WP_SYSBUTTON) and
2343      (Details.Part <= WP_MDIHELPBUTTON)) then
2344     Result := Details.State in [2, 6, 10]
2345   else
2346   if (Details.Element = teTreeview) and (Details.Part = TVP_HOTGLYPH) then
2347     Result := True;
2348 end;
2349 
IsCheckednull2350 function TThemeServices.IsChecked(Details: TThemedElementDetails): Boolean;
2351 begin
2352   Result := False;
2353   if (Details.Element in [teButton]) then
2354     Result := (Details.State > 4) and (Details.State < 9)
2355   else
2356   if (Details.Element in [teToolBar]) then
2357     Result := (Details.State > 4);
2358 end;
2359 
IsMixednull2360 function TThemeServices.IsMixed(Details: TThemedElementDetails): Boolean;
2361 begin
2362   Result := False;
2363   if (Details.Element in [teButton]) then
2364     Result := Details.State > 8;
2365 end;
2366 
InitThemesnull2367 function TThemeServices.InitThemes: Boolean;
2368 begin
2369   Result := False;
2370 end;
2371 
2372 procedure TThemeServices.UnloadThemeData;
2373 begin
2374 end;
2375 
UseThemesnull2376 function TThemeServices.UseThemes: Boolean;
2377 begin
2378   Result := False;
2379 end;
2380 
ThemedControlsEnablednull2381 function TThemeServices.ThemedControlsEnabled: Boolean;
2382 begin
2383   Result := False;
2384 end;
2385 
InternalColorToRGBnull2386 function TThemeServices.InternalColorToRGB(Details: TThemedElementDetails;
2387   Color: LongInt): COLORREF;
2388 begin
2389   Result := Graphics.ColorToRGB(Color);
2390 end;
2391 
2392 procedure TThemeServices.InternalDrawParentBackground(Window: HWND;
2393   Target: HDC; Bounds: PRect);
2394 begin
2395   // default painting
2396 end;
2397 
2398 procedure TThemeServices.DrawText(ACanvas: TPersistent;
2399   Details: TThemedElementDetails; const S: String; R: TRect; Flags,
2400   Flags2: Cardinal);
2401 var
2402   Canvas: TCanvas absolute ACanvas;
2403   TXTStyle: TTextStyle;
2404   OldColor: TColor;
2405 begin
2406   TXTStyle := Canvas.TextStyle;
2407   TXTStyle.Opaque := False;
2408   TXTStyle.Clipping := (Flags and DT_NOCLIP) = 0;
2409   TXTStyle.ShowPrefix := (Flags and DT_NOPREFIX) = 0;
2410   TXTStyle.SingleLine := (Flags and DT_SINGLELINE) <> 0;
2411 
2412   if (Flags and DT_CENTER) <> 0 then
2413     TXTStyle.Alignment := taCenter
2414   else
2415   if (Flags and DT_RIGHT) <> 0 then
2416     TXTStyle.Alignment := taRightJustify
2417   else
2418     TXTStyle.Alignment := taLeftJustify;
2419 
2420   if (Flags and DT_VCENTER) <> 0 then
2421     TXTStyle.Layout := tlCenter
2422   else
2423   if (Flags and DT_BOTTOM) <> 0 then
2424     TXTStyle.Layout := tlBottom
2425   else
2426     TXTStyle.Layout := tlTop;
2427   TXTStyle.RightToLeft := (Flags and DT_RTLREADING) <> 0;
2428     // set color here, otherwise SystemFont is wrong if the button was disabled before
2429   TXTStyle.SystemFont := Canvas.Font.IsDefault;//Match System Default Style
2430 
2431   TXTStyle.Wordbreak := (Flags and DT_WORDBREAK) <> 0;
2432   if not TXTStyle.Wordbreak then
2433     TXTStyle.EndEllipsis := (Flags and DT_END_ELLIPSIS) <> 0
2434   else
2435     TXTStyle.EndEllipsis := False;
2436 
2437   OldColor := Canvas.Font.Color;
2438   if IsDisabled(Details) then
2439     if ThemesEnabled then
2440       Canvas.Font.Color := clGrayText
2441     else
2442     begin
2443       Canvas.Font.Color := clBtnHighlight;
2444       OffsetRect(R, 1, 1);
2445       Canvas.TextRect(R, R.Left, R.Top, S, TXTStyle);
2446       Canvas.Font.Color := clBtnShadow;
2447       OffsetRect(R, -1, -1);
2448     end;
2449   if (Details.Element = teTreeview) and (Details.Part = TVP_TREEITEM) then
2450   begin
2451     case Details.State of
2452       TREIS_SELECTED,
2453       TREIS_HOTSELECTED: Canvas.Font.Color := clHighlightText;
2454       TREIS_DISABLED: Canvas.Font.Color := clGrayText;
2455       TREIS_SELECTEDNOTFOCUS: Canvas.Font.Color := clBtnText;
2456     else
2457       Canvas.Font.Color := clWindowText;
2458     end;
2459   end;
2460   Canvas.TextRect(R, R.Left, R.Top, S, TXTStyle);
2461   Canvas.Font.Color := OldColor;
2462 end;
2463 
2464 //----------------------------------------------------------------------------------------------------------------------
2465 
HasTransparentPartsnull2466 function TThemeServices.HasTransparentParts(Details: TThemedElementDetails): Boolean;
2467 begin
2468   Result := True;
2469 end;
2470 
2471 //----------------------------------------------------------------------------------------------------------------------
2472 
2473 procedure TThemeServices.PaintBorder(Control: TObject; EraseLRCorner: Boolean);
2474 begin
2475   // default painting
2476 end;
2477 
2478 //----------------------------------------------------------------------------------------------------------------------
2479 
2480 procedure TThemeServices.UpdateThemes;
2481 begin
2482   if FUseThemes then
2483     UnloadThemeData;
2484   FUseThemes := UseThemes;
2485 
2486   if FUseThemes then
2487     FThemedControlsEnabled := ThemedControlsEnabled
2488   else
2489     FThemedControlsEnabled := False;
2490 end;
2491 
2492 //----------------------------------------------------------------------------------------------------------------------
2493 
2494 end.
2495