1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: include/wx/msw/uxtheme.h
3 // Purpose: wxUxThemeEngine class: support for XP themes
8 // Copyright: (c) 2003 wxWidgets Dev-Team
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UXTHEME_H_
13 #define _WX_UXTHEME_H_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "uxtheme.h"
21 #include "wx/msw/wrapwin.h"
24 typedef struct _WXUOSVERSIONINFOEXW
{
25 WXDWORD dwOSVersionInfoSize
;
26 WXDWORD dwMajorVersion
;
27 WXDWORD dwMinorVersion
;
28 WXDWORD dwBuildNumber
;
30 wchar_t szCSDVersion
[ 128 ]; // Maintenance string for PSS usage
31 unsigned short wServicePackMajor
;
32 unsigned short wServicePackMinor
;
33 unsigned short wSuiteMask
;
34 unsigned char wProductType
;
35 unsigned char wReserved
;
36 } WXUOSVERSIONINFOEXW
, *PWXUOSVERSIONINFOEXW
, *LPWXUOSVERSIONINFOEXW
;
37 #define WXUOSVERSIONINFOEX WXUOSVERSIONINFOEXW
38 #define PWXUOSVERSIONINFOEX PWXUOSVERSIONINFOEXW
39 #define LPWXUOSVERSIONINFOEX LPWXUOSVERSIONINFOEXW
41 typedef struct _WXUOSVERSIONINFOEXA
{
42 WXDWORD dwOSVersionInfoSize
;
43 WXDWORD dwMajorVersion
;
44 WXDWORD dwMinorVersion
;
45 WXDWORD dwBuildNumber
;
47 char szCSDVersion
[128]; // Maintenance string for PSS usage
48 unsigned short wServicePackMajor
;
49 unsigned short wServicePackMinor
;
50 unsigned short wSuiteMask
;
51 unsigned char wProductType
;
52 unsigned char wReserved
;
53 } WXUOSVERSIONINFOEXA
, *PWXUOSVERSIONINFOEXA
, *LPWXUOSVERSIONINFOEXA
;
54 #define WXUOSVERSIONINFOEX WXUOSVERSIONINFOEXA
55 #define PWXUOSVERSIONINFOEX PWXUOSVERSIONINFOEXA
56 #define LPWXUOSVERSIONINFOEX LPWXUOSVERSIONINFOEXA
59 typedef void* WXHTHEME
;
60 typedef long WXUHRESULT
;
61 typedef WXHTHEME (__stdcall
*PFNWXUOPENTHEMEDATA
)(WXHWND
, const wchar_t *);
62 typedef WXUHRESULT (__stdcall
*PFNWXUCLOSETHEMEDATA
)(WXHTHEME
);
63 typedef WXUHRESULT (__stdcall
*PFNWXUDRAWTHEMEBACKGROUND
)(WXHTHEME
, WXHDC
,
64 int, int, const RECT
*, const RECT
*);
65 #define WXU_DTT_GRAYED 0x1
66 typedef WXUHRESULT (__stdcall
*PFNWXUDRAWTHEMETEXT
)(WXHTHEME
, WXHDC
, int,
67 int, const wchar_t *, int, DWORD
,
69 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEBACKGROUNDCONTENTRECT
)(WXHTHEME
, WXHDC
,
70 int, int, const RECT
*, RECT
*);
71 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEBACKGROUNDEXTENT
)(WXHTHEME
, WXHDC
, int, int,
72 const RECT
*, RECT
*);
76 WXU_TS_MIN
, // minimum size
77 WXU_TS_TRUE
, // size without stretching
78 WXU_TS_DRAW
// size that theme mgr will use to draw part
81 typedef struct tagWXUSIZE
87 typedef struct tagWXUTEXTMETRIC
92 long tmInternalLeading
;
93 long tmExternalLeading
;
98 long tmDigitizedAspectX
;
99 long tmDigitizedAspectY
;
102 wchar_t tmDefaultChar
;
104 unsigned char tmItalic
;
105 unsigned char tmUnderlined
;
106 unsigned char tmStruckOut
;
107 unsigned char tmPitchAndFamily
;
108 unsigned char tmCharSet
;
111 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEPARTSIZE
)(WXHTHEME
, WXHDC
, int, int, const RECT
*,
112 enum WXUTHEMESIZE
, WXUSIZE
*);
113 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMETEXTEXTENT
)(WXHTHEME
, WXHDC
, int, int, const wchar_t *,
114 int, WXDWORD
, const RECT
*, RECT
*);
115 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMETEXTMETRICS
)(WXHTHEME
, WXHDC
,
116 int, int, WXUTEXTMETRIC
*);
117 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEBACKGROUNDREGION
)(WXHTHEME
, WXHDC
,
118 int, int, const RECT
*, WXHRGN
*);
120 #define WXU_HTTB_BACKGROUNDSEG 0x0000
121 #define WXU_HTTB_FIXEDBORDER 0x0002
122 #define WXU_HTTB_CAPTION 0x0004
123 #define WXU_HTTB_RESIZINGBORDER_LEFT 0x0010
124 #define WXU_HTTB_RESIZINGBORDER_TOP 0x0020
125 #define WXU_HTTB_RESIZINGBORDER_RIGHT 0x0040
126 #define WXU_HTTB_RESIZINGBORDER_BOTTOM 0x0080
127 #define WXU_HTTB_RESIZINGBORDER 0x00F0
128 #define WXU_HTTB_SIZINGTEMPLATE 0x0100
129 #define WXU_HTTB_SYSTEMSIZINGMARGINS 0x0200
131 typedef struct tagWXUPOINT
137 typedef WXUHRESULT (__stdcall
*PFNWXUHITTESTTHEMEBACKGROUND
)(WXHTHEME
, WXHDC
, int,
138 int, WXDWORD
, const RECT
*, WXHRGN
,
139 WXUPOINT
, unsigned short *);
140 typedef WXUHRESULT (__stdcall
*PFNWXUDRAWTHEMEEDGE
)(WXHTHEME
, WXHDC
, int, int,
141 const RECT
*, unsigned int, unsigned int, RECT
*);
142 typedef WXUHRESULT (__stdcall
*PFNWXUDRAWTHEMEICON
)(WXHTHEME
, WXHDC
, int, int,
143 const RECT
*, WXHIMAGELIST
, int);
144 typedef BOOL (__stdcall
*PFNWXUISTHEMEPARTDEFINED
)(WXHTHEME
, int, int);
145 typedef BOOL (__stdcall
*PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT
)(WXHTHEME
, int, int);
146 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMECOLOR
)(WXHTHEME
, int, int, int, WXCOLORREF
*);
147 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEMETRIC
)(WXHTHEME
, WXHDC
, int,
149 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMESTRING
)(WXHTHEME
, int,
150 int, int, wchar_t *, int);
151 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEBOOL
)(WXHTHEME
, int, int, int, BOOL
*);
152 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEINT
)(WXHTHEME
, int, int, int, int *);
153 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEENUMVALUE
)(WXHTHEME
, int, int, int, int *);
154 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEPOSITION
)(WXHTHEME
, int, int, int, WXUPOINT
*);
155 typedef struct tagWXULOGFONT
162 unsigned char lfItalic
;
163 unsigned char lfUnderline
;
164 unsigned char lfStrikeOut
;
165 unsigned char lfCharSet
;
166 unsigned char lfOutPrecision
;
167 unsigned char lfClipPrecision
;
168 unsigned char lfQuality
;
169 unsigned char lfPitchAndFamily
;
170 wchar_t lfFaceName
[32];
172 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEFONT
)(WXHTHEME
, WXHDC
, int, int, int, WXULOGFONT
*);
173 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMERECT
)(WXHTHEME
, int, int, int, RECT
*);
174 typedef struct _WXUMARGINS
176 int cxLeftWidth
; // width of left border that retains its size
177 int cxRightWidth
; // width of right border that retains its size
178 int cyTopHeight
; // height of top border that retains its size
179 int cyBottomHeight
; // height of bottom border that retains its size
180 } WXUMARGINS
, *PWXUMARGINS
;
181 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEMARGINS
)(WXHTHEME
, WXHDC
, int,
182 int, int, RECT
*, WXUMARGINS
*);
184 #define WXU_MAX_INTLIST_COUNT 10
185 typedef struct _WXUINTLIST
187 int iValueCount
; // number of values in iValues
188 int iValues
[WXU_MAX_INTLIST_COUNT
];
189 } WXUINTLIST
, *PWXUINTLIST
;
190 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEINTLIST
)(WXHTHEME
, int,
191 int, int, WXUINTLIST
*);
193 enum WXUPROPERTYORIGIN
195 WXU_PO_STATE
, // property was found in the state section
196 WXU_PO_PART
, // property was found in the part section
197 WXU_PO_CLASS
, // property was found in the class section
198 WXU_PO_GLOBAL
, // property was found in [globals] section
199 WXU_PO_NOTFOUND
// property was not found
202 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEPROPERTYORIGIN
)(WXHTHEME
, int,
203 int, int, enum WXUPROPERTYORIGIN
*);
204 typedef WXUHRESULT (__stdcall
*PFNWXUSETWINDOWTHEME
)(WXHWND
, const wchar_t*, const wchar_t *);
205 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEFILENAME
)(WXHTHEME
, int, int, int, wchar_t *, int);
206 typedef WXCOLORREF (__stdcall
*PFNWXUGETTHEMESYSCOLOR
)(WXHTHEME
, int);
207 typedef WXHBRUSH (__stdcall
*PFNWXUGETTHEMESYSCOLORBRUSH
)(WXHTHEME
, int);
208 typedef BOOL (__stdcall
*PFNWXUGETTHEMESYSBOOL
)(WXHTHEME
, int);
209 typedef int (__stdcall
*PFNWXUGETTHEMESYSSIZE
)(WXHTHEME
, int);
210 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMESYSFONT
)(WXHTHEME
, int, WXULOGFONT
*);
211 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMESYSSTRING
)(WXHTHEME
, int, wchar_t *, int);
212 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMESYSINT
)(WXHTHEME
, int, int *);
213 typedef BOOL (__stdcall
*PFNWXUISTHEMEACTIVE
)();
214 typedef BOOL (__stdcall
*PFNWXUISAPPTHEMED
)();
215 typedef WXHTHEME (__stdcall
*PFNWXUGETWINDOWTHEME
)(WXHWND
);
217 #define WXU_ETDT_DISABLE 0x00000001
218 #define WXU_ETDT_ENABLE 0x00000002
219 #define WXU_ETDT_USETABTEXTURE 0x00000004
220 #define WXU_ETDT_ENABLETAB 0x00000006
222 typedef WXUHRESULT (__stdcall
*PFNWXUENABLETHEMEDIALOGTEXTURE
)(WXHWND
, WXDWORD
);
223 typedef BOOL (__stdcall
*PFNWXUISTHEMEDIALOGTEXTUREENABLED
)(WXHWND
);
225 #define WXU_STAP_ALLOW_NONCLIENT 1
226 #define WXU_STAP_ALLOW_CONTROLS 2
227 #define WXU_STAP_ALLOW_WEBCONTENT 4
229 typedef WXDWORD (__stdcall
*PFNWXUGETTHEMEAPPPROPERTIES
)();
230 typedef void (__stdcall
*PFNWXUSETTHEMEAPPPROPERTIES
)(WXDWORD
);
231 typedef WXUHRESULT (__stdcall
*PFNWXUGETCURRENTTHEMENAME
)(wchar_t *, int,
232 wchar_t *, int, wchar_t *, int);
234 #define WXU_SZ_THDOCPROP_DISPLAYNAME L"DisplayName"
235 #define WXU_SZ_THDOCPROP_CANONICALNAME L"ThemeName"
236 #define WXU_SZ_THDOCPROP_TOOLTIP L"ToolTip"
237 #define WXU_SZ_THDOCPROP_AUTHOR L"author"
239 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEDOCUMENTATIONPROPERTY
)(const wchar_t *,
240 const wchar_t *, wchar_t *, int);
241 typedef WXUHRESULT (__stdcall
*PFNWXUDRAWTHEMEPARENTBACKGROUND
)(WXHWND
, WXHDC
, RECT
*);
242 typedef WXUHRESULT (__stdcall
*PFNWXUENABLETHEMING
)(BOOL
);
244 // ----------------------------------------------------------------------------
245 // wxUxThemeEngine: provides all theme functions from uxtheme.dll
246 // ----------------------------------------------------------------------------
248 // we always define this class, even if wxUSE_UXTHEME == 0, but we just make it
249 // empty in this case -- this allows to use it elsewhere without any #ifdefs
251 #include "wx/dynload.h"
253 #define wxUX_THEME_DECLARE(type, func) type func;
255 #define wxUX_THEME_DECLARE(type, func) type func(...) { return 0; }
258 class WXDLLEXPORT wxUxThemeEngine
261 // get the theme engine or NULL if themes are not available
262 static wxUxThemeEngine
*Get();
264 // get the theme enging or NULL if themes are not available or not used for
266 static wxUxThemeEngine
*GetIfActive();
268 // all uxtheme.dll functions
269 wxUX_THEME_DECLARE(PFNWXUOPENTHEMEDATA
, OpenThemeData
)
270 wxUX_THEME_DECLARE(PFNWXUCLOSETHEMEDATA
, CloseThemeData
)
271 wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEBACKGROUND
, DrawThemeBackground
)
272 wxUX_THEME_DECLARE(PFNWXUDRAWTHEMETEXT
, DrawThemeText
)
273 wxUX_THEME_DECLARE(PFNWXUGETTHEMEBACKGROUNDCONTENTRECT
, GetThemeBackgroundContentRect
)
274 wxUX_THEME_DECLARE(PFNWXUGETTHEMEBACKGROUNDEXTENT
, GetThemeBackgroundExtent
)
275 wxUX_THEME_DECLARE(PFNWXUGETTHEMEPARTSIZE
, GetThemePartSize
)
276 wxUX_THEME_DECLARE(PFNWXUGETTHEMETEXTEXTENT
, GetThemeTextExtent
)
277 wxUX_THEME_DECLARE(PFNWXUGETTHEMETEXTMETRICS
, GetThemeTextMetrics
)
278 wxUX_THEME_DECLARE(PFNWXUGETTHEMEBACKGROUNDREGION
, GetThemeBackgroundRegion
)
279 wxUX_THEME_DECLARE(PFNWXUHITTESTTHEMEBACKGROUND
, HitTestThemeBackground
)
280 wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEEDGE
, DrawThemeEdge
)
281 wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEICON
, DrawThemeIcon
)
282 wxUX_THEME_DECLARE(PFNWXUISTHEMEPARTDEFINED
, IsThemePartDefined
)
283 wxUX_THEME_DECLARE(PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT
, IsThemeBackgroundPartiallyTransparent
)
284 wxUX_THEME_DECLARE(PFNWXUGETTHEMECOLOR
, GetThemeColor
)
285 wxUX_THEME_DECLARE(PFNWXUGETTHEMEMETRIC
, GetThemeMetric
)
286 wxUX_THEME_DECLARE(PFNWXUGETTHEMESTRING
, GetThemeString
)
287 wxUX_THEME_DECLARE(PFNWXUGETTHEMEBOOL
, GetThemeBool
)
288 wxUX_THEME_DECLARE(PFNWXUGETTHEMEINT
, GetThemeInt
)
289 wxUX_THEME_DECLARE(PFNWXUGETTHEMEENUMVALUE
, GetThemeEnumValue
)
290 wxUX_THEME_DECLARE(PFNWXUGETTHEMEPOSITION
, GetThemePosition
)
291 wxUX_THEME_DECLARE(PFNWXUGETTHEMEFONT
, GetThemeFont
)
292 wxUX_THEME_DECLARE(PFNWXUGETTHEMERECT
, GetThemeRect
)
293 wxUX_THEME_DECLARE(PFNWXUGETTHEMEMARGINS
, GetThemeMargins
)
294 wxUX_THEME_DECLARE(PFNWXUGETTHEMEINTLIST
, GetThemeIntList
)
295 wxUX_THEME_DECLARE(PFNWXUGETTHEMEPROPERTYORIGIN
, GetThemePropertyOrigin
)
296 wxUX_THEME_DECLARE(PFNWXUSETWINDOWTHEME
, SetWindowTheme
)
297 wxUX_THEME_DECLARE(PFNWXUGETTHEMEFILENAME
, GetThemeFilename
)
298 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSCOLOR
, GetThemeSysColor
)
299 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSCOLORBRUSH
, GetThemeSysColorBrush
)
300 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSBOOL
, GetThemeSysBool
)
301 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSSIZE
, GetThemeSysSize
)
302 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSFONT
, GetThemeSysFont
)
303 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSSTRING
, GetThemeSysString
)
304 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSINT
, GetThemeSysInt
)
305 wxUX_THEME_DECLARE(PFNWXUISTHEMEACTIVE
, IsThemeActive
)
306 wxUX_THEME_DECLARE(PFNWXUISAPPTHEMED
, IsAppThemed
)
307 wxUX_THEME_DECLARE(PFNWXUGETWINDOWTHEME
, GetWindowTheme
)
308 wxUX_THEME_DECLARE(PFNWXUENABLETHEMEDIALOGTEXTURE
, EnableThemeDialogTexture
)
309 wxUX_THEME_DECLARE(PFNWXUISTHEMEDIALOGTEXTUREENABLED
, IsThemeDialogTextureEnabled
)
310 wxUX_THEME_DECLARE(PFNWXUGETTHEMEAPPPROPERTIES
, GetThemeAppProperties
)
311 wxUX_THEME_DECLARE(PFNWXUSETTHEMEAPPPROPERTIES
, SetThemeAppProperties
)
312 wxUX_THEME_DECLARE(PFNWXUGETCURRENTTHEMENAME
, GetCurrentThemeName
)
313 wxUX_THEME_DECLARE(PFNWXUGETTHEMEDOCUMENTATIONPROPERTY
, GetThemeDocumentationProperty
)
314 wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEPARENTBACKGROUND
, DrawThemeParentBackground
)
315 wxUX_THEME_DECLARE(PFNWXUENABLETHEMING
, EnableTheming
)
318 // construcor is private as only Get() can create us and is also trivial as
319 // everything really happens in Initialize()
320 wxUxThemeEngine() { }
322 // destructor is private as only Get() and wxUxThemeModule delete us, it is
323 // not virtual as we're not supposed to be derived from
324 ~wxUxThemeEngine() { }
327 // initialize the theme engine: load the DLL, resolve the functions
329 // return true if we can be used, false if themes are not available
334 wxDynamicLibrary m_dllUxTheme
;
337 // the one and only theme engine, initially NULL
338 static wxUxThemeEngine
*ms_themeEngine
;
340 // this is a bool which initially has the value -1 meaning "unknown"
341 static int ms_isThemeEngineAvailable
;
343 // it must be able to delete us
344 friend class wxUxThemeModule
;
345 #endif // wxUSE_UXTHEME
347 DECLARE_NO_COPY_CLASS(wxUxThemeEngine
)
352 /* static */ inline wxUxThemeEngine
*wxUxThemeEngine::GetIfActive()
354 wxUxThemeEngine
*engine
= Get();
355 return engine
&& engine
->IsAppThemed() && engine
->IsThemeActive()
360 #else // !wxUSE_UXTHEME
362 /* static */ inline wxUxThemeEngine
*wxUxThemeEngine::Get()
367 /* static */ inline wxUxThemeEngine
*wxUxThemeEngine::GetIfActive()
372 #endif // wxUSE_UXTHEME/!wxUSE_UXTHEME
374 // ----------------------------------------------------------------------------
375 // wxUxThemeHandle: encapsulates ::Open/CloseThemeData()
376 // ----------------------------------------------------------------------------
378 class wxUxThemeHandle
381 wxUxThemeHandle(wxWindow
*win
, const wchar_t *classes
)
383 wxUxThemeEngine
*engine
= wxUxThemeEngine::Get();
386 engine
? (WXHTHEME
)engine
->OpenThemeData(win
->GetHWND(), classes
)
390 operator WXHTHEME() const { return m_hTheme
; }
396 wxUxThemeEngine::Get()->CloseThemeData(m_hTheme
);
403 DECLARE_NO_COPY_CLASS(wxUxThemeHandle
)
406 #endif // _WX_UXTHEME_H_