1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: include/wx/msw/uxtheme.h
3 // Purpose: wxUxThemeEngine class: support for XP themes
4 // Author: John Platts, Vadim Zeitlin
8 // Copyright: (c) 2003 John Platts, Vadim Zeitlin
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"
23 typedef void* WXHTHEME
;
24 typedef long WXUHRESULT
;
25 typedef WXHTHEME (__stdcall
*PFNWXUOPENTHEMEDATA
)(WXHWND
, const wchar_t *);
26 typedef WXUHRESULT (__stdcall
*PFNWXUCLOSETHEMEDATA
)(WXHTHEME
);
27 typedef WXUHRESULT (__stdcall
*PFNWXUDRAWTHEMEBACKGROUND
)(WXHTHEME
, WXHDC
,
28 int, int, const RECT
*, const RECT
*);
29 #define WXU_DTT_GRAYED 0x1
30 typedef WXUHRESULT (__stdcall
*PFNWXUDRAWTHEMETEXT
)(WXHTHEME
, WXHDC
, int,
31 int, const wchar_t *, int, DWORD
,
33 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEBACKGROUNDCONTENTRECT
)(WXHTHEME
, WXHDC
,
34 int, int, const RECT
*, RECT
*);
35 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEBACKGROUNDEXTENT
)(WXHTHEME
, WXHDC
, int, int,
36 const RECT
*, RECT
*);
45 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEPARTSIZE
)(WXHTHEME
, WXHDC
, int, int, const RECT
*,
46 enum WXUTHEMESIZE
, SIZE
*);
47 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMETEXTEXTENT
)(WXHTHEME
, WXHDC
, int, int, const wchar_t *,
48 int, WXDWORD
, const RECT
*, RECT
*);
49 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMETEXTMETRICS
)(WXHTHEME
, WXHDC
,
50 int, int, TEXTMETRIC
*);
51 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEBACKGROUNDREGION
)(WXHTHEME
, WXHDC
,
52 int, int, const RECT
*, WXHRGN
*);
54 #define WXU_HTTB_BACKGROUNDSEG 0x0000
55 #define WXU_HTTB_FIXEDBORDER 0x0002
56 #define WXU_HTTB_CAPTION 0x0004
57 #define WXU_HTTB_RESIZINGBORDER_LEFT 0x0010
58 #define WXU_HTTB_RESIZINGBORDER_TOP 0x0020
59 #define WXU_HTTB_RESIZINGBORDER_RIGHT 0x0040
60 #define WXU_HTTB_RESIZINGBORDER_BOTTOM 0x0080
61 #define WXU_HTTB_RESIZINGBORDER 0x00F0
62 #define WXU_HTTB_SIZINGTEMPLATE 0x0100
63 #define WXU_HTTB_SYSTEMSIZINGMARGINS 0x0200
65 typedef WXUHRESULT (__stdcall
*PFNWXUHITTESTTHEMEBACKGROUND
)(WXHTHEME
, WXHDC
, int,
66 int, WXDWORD
, const RECT
*, WXHRGN
,
67 POINT
, unsigned short *);
68 typedef WXUHRESULT (__stdcall
*PFNWXUDRAWTHEMEEDGE
)(WXHTHEME
, WXHDC
, int, int,
69 const RECT
*, unsigned int, unsigned int, RECT
*);
70 typedef WXUHRESULT (__stdcall
*PFNWXUDRAWTHEMEICON
)(WXHTHEME
, WXHDC
, int, int,
71 const RECT
*, WXHIMAGELIST
, int);
72 typedef BOOL (__stdcall
*PFNWXUISTHEMEPARTDEFINED
)(WXHTHEME
, int, int);
73 typedef BOOL (__stdcall
*PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT
)(WXHTHEME
, int, int);
74 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMECOLOR
)(WXHTHEME
, int, int, int, WXCOLORREF
*);
75 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEMETRIC
)(WXHTHEME
, WXHDC
, int,
77 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMESTRING
)(WXHTHEME
, int,
78 int, int, wchar_t *, int);
79 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEBOOL
)(WXHTHEME
, int, int, int, BOOL
*);
80 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEINT
)(WXHTHEME
, int, int, int, int *);
81 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEENUMVALUE
)(WXHTHEME
, int, int, int, int *);
82 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEPOSITION
)(WXHTHEME
, int, int, int, POINT
*);
83 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEFONT
)(WXHTHEME
, WXHDC
, int, int, int, LOGFONT
*);
84 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMERECT
)(WXHTHEME
, int, int, int, RECT
*);
85 typedef struct _WXUMARGINS
91 } WXUMARGINS
, *PWXUMARGINS
;
92 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEMARGINS
)(WXHTHEME
, WXHDC
, int,
93 int, int, RECT
*, WXUMARGINS
*);
95 #define WXU_MAX_INTLIST_COUNT 10
96 typedef struct _WXUINTLIST
99 int iValues
[WXU_MAX_INTLIST_COUNT
];
100 } WXUINTLIST
, *PWXUINTLIST
;
101 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEINTLIST
)(WXHTHEME
, int,
102 int, int, WXUINTLIST
*);
104 enum WXUPROPERTYORIGIN
113 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEPROPERTYORIGIN
)(WXHTHEME
, int,
114 int, int, enum WXUPROPERTYORIGIN
*);
115 typedef WXUHRESULT (__stdcall
*PFNWXUSETWINDOWTHEME
)(WXHWND
, const wchar_t*, const wchar_t *);
116 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEFILENAME
)(WXHTHEME
, int, int, int, wchar_t *, int);
117 typedef WXCOLORREF (__stdcall
*PFNWXUGETTHEMESYSCOLOR
)(WXHTHEME
, int);
118 typedef WXHBRUSH (__stdcall
*PFNWXUGETTHEMESYSCOLORBRUSH
)(WXHTHEME
, int);
119 typedef BOOL (__stdcall
*PFNWXUGETTHEMESYSBOOL
)(WXHTHEME
, int);
120 typedef int (__stdcall
*PFNWXUGETTHEMESYSSIZE
)(WXHTHEME
, int);
121 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMESYSFONT
)(WXHTHEME
, int, LOGFONT
*);
122 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMESYSSTRING
)(WXHTHEME
, int, wchar_t *, int);
123 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMESYSINT
)(WXHTHEME
, int, int *);
124 typedef BOOL (__stdcall
*PFNWXUISTHEMEACTIVE
)();
125 typedef BOOL (__stdcall
*PFNWXUISAPPTHEMED
)();
126 typedef WXHTHEME (__stdcall
*PFNWXUGETWINDOWTHEME
)(WXHWND
);
128 #define WXU_ETDT_DISABLE 0x00000001
129 #define WXU_ETDT_ENABLE 0x00000002
130 #define WXU_ETDT_USETABTEXTURE 0x00000004
131 #define WXU_ETDT_ENABLETAB 0x00000006
133 typedef WXUHRESULT (__stdcall
*PFNWXUENABLETHEMEDIALOGTEXTURE
)(WXHWND
, WXDWORD
);
134 typedef BOOL (__stdcall
*PFNWXUISTHEMEDIALOGTEXTUREENABLED
)(WXHWND
);
136 #define WXU_STAP_ALLOW_NONCLIENT 1
137 #define WXU_STAP_ALLOW_CONTROLS 2
138 #define WXU_STAP_ALLOW_WEBCONTENT 4
140 typedef WXDWORD (__stdcall
*PFNWXUGETTHEMEAPPPROPERTIES
)();
141 typedef void (__stdcall
*PFNWXUSETTHEMEAPPPROPERTIES
)(WXDWORD
);
142 typedef WXUHRESULT (__stdcall
*PFNWXUGETCURRENTTHEMENAME
)(wchar_t *, int,
143 wchar_t *, int, wchar_t *, int);
145 #define WXU_SZ_THDOCPROP_DISPLAYNAME L"DisplayName"
146 #define WXU_SZ_THDOCPROP_CANONICALNAME L"ThemeName"
147 #define WXU_SZ_THDOCPROP_TOOLTIP L"ToolTip"
148 #define WXU_SZ_THDOCPROP_AUTHOR L"author"
150 typedef WXUHRESULT (__stdcall
*PFNWXUGETTHEMEDOCUMENTATIONPROPERTY
)(const wchar_t *,
151 const wchar_t *, wchar_t *, int);
152 typedef WXUHRESULT (__stdcall
*PFNWXUDRAWTHEMEPARENTBACKGROUND
)(WXHWND
, WXHDC
, RECT
*);
153 typedef WXUHRESULT (__stdcall
*PFNWXUENABLETHEMING
)(BOOL
);
155 // ----------------------------------------------------------------------------
156 // wxUxThemeEngine: provides all theme functions from uxtheme.dll
157 // ----------------------------------------------------------------------------
159 // we always define this class, even if wxUSE_UXTHEME == 0, but we just make it
160 // empty in this case -- this allows to use it elsewhere without any #ifdefs
162 #include "wx/dynload.h"
164 #define wxUX_THEME_DECLARE(type, func) type func;
166 #define wxUX_THEME_DECLARE(type, func) type func(...) { return 0; }
169 class WXDLLEXPORT wxUxThemeEngine
172 // get the theme engine or NULL if themes are not available
173 static wxUxThemeEngine
*Get();
175 // get the theme enging or NULL if themes are not available or not used for
177 static wxUxThemeEngine
*GetIfActive();
179 // all uxtheme.dll functions
180 wxUX_THEME_DECLARE(PFNWXUOPENTHEMEDATA
, OpenThemeData
)
181 wxUX_THEME_DECLARE(PFNWXUCLOSETHEMEDATA
, CloseThemeData
)
182 wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEBACKGROUND
, DrawThemeBackground
)
183 wxUX_THEME_DECLARE(PFNWXUDRAWTHEMETEXT
, DrawThemeText
)
184 wxUX_THEME_DECLARE(PFNWXUGETTHEMEBACKGROUNDCONTENTRECT
, GetThemeBackgroundContentRect
)
185 wxUX_THEME_DECLARE(PFNWXUGETTHEMEBACKGROUNDEXTENT
, GetThemeBackgroundExtent
)
186 wxUX_THEME_DECLARE(PFNWXUGETTHEMEPARTSIZE
, GetThemePartSize
)
187 wxUX_THEME_DECLARE(PFNWXUGETTHEMETEXTEXTENT
, GetThemeTextExtent
)
188 wxUX_THEME_DECLARE(PFNWXUGETTHEMETEXTMETRICS
, GetThemeTextMetrics
)
189 wxUX_THEME_DECLARE(PFNWXUGETTHEMEBACKGROUNDREGION
, GetThemeBackgroundRegion
)
190 wxUX_THEME_DECLARE(PFNWXUHITTESTTHEMEBACKGROUND
, HitTestThemeBackground
)
191 wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEEDGE
, DrawThemeEdge
)
192 wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEICON
, DrawThemeIcon
)
193 wxUX_THEME_DECLARE(PFNWXUISTHEMEPARTDEFINED
, IsThemePartDefined
)
194 wxUX_THEME_DECLARE(PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT
, IsThemeBackgroundPartiallyTransparent
)
195 wxUX_THEME_DECLARE(PFNWXUGETTHEMECOLOR
, GetThemeColor
)
196 wxUX_THEME_DECLARE(PFNWXUGETTHEMEMETRIC
, GetThemeMetric
)
197 wxUX_THEME_DECLARE(PFNWXUGETTHEMESTRING
, GetThemeString
)
198 wxUX_THEME_DECLARE(PFNWXUGETTHEMEBOOL
, GetThemeBool
)
199 wxUX_THEME_DECLARE(PFNWXUGETTHEMEINT
, GetThemeInt
)
200 wxUX_THEME_DECLARE(PFNWXUGETTHEMEENUMVALUE
, GetThemeEnumValue
)
201 wxUX_THEME_DECLARE(PFNWXUGETTHEMEPOSITION
, GetThemePosition
)
202 wxUX_THEME_DECLARE(PFNWXUGETTHEMEFONT
, GetThemeFont
)
203 wxUX_THEME_DECLARE(PFNWXUGETTHEMERECT
, GetThemeRect
)
204 wxUX_THEME_DECLARE(PFNWXUGETTHEMEMARGINS
, GetThemeMargins
)
205 wxUX_THEME_DECLARE(PFNWXUGETTHEMEINTLIST
, GetThemeIntList
)
206 wxUX_THEME_DECLARE(PFNWXUGETTHEMEPROPERTYORIGIN
, GetThemePropertyOrigin
)
207 wxUX_THEME_DECLARE(PFNWXUSETWINDOWTHEME
, SetWindowTheme
)
208 wxUX_THEME_DECLARE(PFNWXUGETTHEMEFILENAME
, GetThemeFilename
)
209 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSCOLOR
, GetThemeSysColor
)
210 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSCOLORBRUSH
, GetThemeSysColorBrush
)
211 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSBOOL
, GetThemeSysBool
)
212 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSSIZE
, GetThemeSysSize
)
213 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSFONT
, GetThemeSysFont
)
214 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSSTRING
, GetThemeSysString
)
215 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSINT
, GetThemeSysInt
)
216 wxUX_THEME_DECLARE(PFNWXUISTHEMEACTIVE
, IsThemeActive
)
217 wxUX_THEME_DECLARE(PFNWXUISAPPTHEMED
, IsAppThemed
)
218 wxUX_THEME_DECLARE(PFNWXUGETWINDOWTHEME
, GetWindowTheme
)
219 wxUX_THEME_DECLARE(PFNWXUENABLETHEMEDIALOGTEXTURE
, EnableThemeDialogTexture
)
220 wxUX_THEME_DECLARE(PFNWXUISTHEMEDIALOGTEXTUREENABLED
, IsThemeDialogTextureEnabled
)
221 wxUX_THEME_DECLARE(PFNWXUGETTHEMEAPPPROPERTIES
, GetThemeAppProperties
)
222 wxUX_THEME_DECLARE(PFNWXUSETTHEMEAPPPROPERTIES
, SetThemeAppProperties
)
223 wxUX_THEME_DECLARE(PFNWXUGETCURRENTTHEMENAME
, GetCurrentThemeName
)
224 wxUX_THEME_DECLARE(PFNWXUGETTHEMEDOCUMENTATIONPROPERTY
, GetThemeDocumentationProperty
)
225 wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEPARENTBACKGROUND
, DrawThemeParentBackground
)
226 wxUX_THEME_DECLARE(PFNWXUENABLETHEMING
, EnableTheming
)
229 // construcor is private as only Get() can create us and is also trivial as
230 // everything really happens in Initialize()
231 wxUxThemeEngine() { }
233 // destructor is private as only Get() and wxUxThemeModule delete us, it is
234 // not virtual as we're not supposed to be derived from
235 ~wxUxThemeEngine() { }
238 // initialize the theme engine: load the DLL, resolve the functions
240 // return true if we can be used, false if themes are not available
245 wxDynamicLibrary m_dllUxTheme
;
248 // the one and only theme engine, initially NULL
249 static wxUxThemeEngine
*ms_themeEngine
;
251 // this is a bool which initially has the value -1 meaning "unknown"
252 static int ms_isThemeEngineAvailable
;
254 // it must be able to delete us
255 friend class wxUxThemeModule
;
256 #endif // wxUSE_UXTHEME
258 DECLARE_NO_COPY_CLASS(wxUxThemeEngine
)
263 /* static */ inline wxUxThemeEngine
*wxUxThemeEngine::GetIfActive()
265 wxUxThemeEngine
*engine
= Get();
266 return engine
&& engine
->IsAppThemed() && engine
->IsThemeActive()
271 #else // !wxUSE_UXTHEME
273 /* static */ inline wxUxThemeEngine
*wxUxThemeEngine::Get()
278 /* static */ inline wxUxThemeEngine
*wxUxThemeEngine::GetIfActive()
283 #endif // wxUSE_UXTHEME/!wxUSE_UXTHEME
285 // ----------------------------------------------------------------------------
286 // wxUxThemeHandle: encapsulates ::Open/CloseThemeData()
287 // ----------------------------------------------------------------------------
289 class wxUxThemeHandle
292 wxUxThemeHandle(wxWindow
*win
, const wchar_t *classes
)
294 wxUxThemeEngine
*engine
= wxUxThemeEngine::Get();
297 engine
? (WXHTHEME
)engine
->OpenThemeData(win
->GetHWND(), classes
)
301 operator WXHTHEME() const { return m_hTheme
; }
307 wxUxThemeEngine::Get()->CloseThemeData(m_hTheme
);
314 DECLARE_NO_COPY_CLASS(wxUxThemeHandle
)
317 #endif // _WX_UXTHEME_H_