2 * wxuxthem.h : wxWindows support for Microsoft Windows XP Theme library
4 * Modified to work with almost all Win32 compilers
5 * Compiler must support Unicode, the __cdecl calling convention, and the
6 * __stdcall calling convention
10 #pragma implementation "uxtheme.h"
13 // For compilers that support precompilation, includes "wx.h".
14 #include "wx/wxprec.h"
22 #include "wx/toplevel.h"
23 #include "wx/string.h"
27 #include "wx/module.h"
33 #include "wx/msw/winundef.h"
34 #include "wx/msw/uxtheme.h"
35 #include "wx/msw/private.h"
36 #include "wx/app.h" // for GetComCtl32Version
38 wxUxThemeEngine
* g_pThemeEngine
= ((wxUxThemeEngine
*)NULL
) ;
40 BOOL
wxCanUseInitThemeEngine()
42 WXUOSVERSIONINFOEX wxuosex
;
43 memset((void*)&wxuosex
, 0, sizeof(WXUOSVERSIONINFOEX
)) ;
44 wxuosex
.dwOSVersionInfoSize
= sizeof(WXUOSVERSIONINFOEX
) ;
45 if(!GetVersionEx((LPOSVERSIONINFO
)&wxuosex
))
47 wxuosex
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
) ;
48 if(!GetVersionEx((LPOSVERSIONINFO
)&wxuosex
))
53 if ((wxuosex
.dwMajorVersion
== 5) && (wxuosex
.dwMinorVersion
> 0))
55 return (wxTheApp
->GetComCtl32Version() >= 600) ;
63 wxUxThemeEngine
* wxUxThemeEngine::wxInitUxThemeEngine()
65 wxUxThemeEngine
* pThemeEngine
= new wxUxThemeEngine
;
69 wxUxThemeEngine
* wxUxThemeEngine::Get()
71 return g_pThemeEngine
;
74 #ifdef WXU_USE_WXMODULE
75 class wxUxThemeModule
: public wxModule
77 DECLARE_DYNAMIC_CLASS(wxUxThemeModule
)
81 if((wxCanUseInitThemeEngine()) && (g_pThemeEngine
))
83 delete g_pThemeEngine
;
84 g_pThemeEngine
= ((wxUxThemeEngine
*)NULL
) ;
90 if(!wxCanUseInitThemeEngine())
92 g_pThemeEngine
= ((wxUxThemeEngine
*)NULL
) ;
95 g_pThemeEngine
= wxUxThemeEngine::wxInitUxThemeEngine() ;
100 else if(!g_pThemeEngine
->IsInitialized())
110 IMPLEMENT_DYNAMIC_CLASS(wxUxThemeModule
, wxModule
)
112 static void __cdecl
wxUxThemeEngineOnExit()
116 delete g_pThemeEngine
;
117 g_pThemeEngine
= ((wxUxThemeEngine
*)NULL
) ;
121 BOOL
wxUxInitThemeEngine()
123 if(!wxCanUseInitThemeEngine())
127 g_pThemeEngine
= wxUxThemeEngine::wxInitUxThemeEngine() ;
132 else if(!g_pThemeEngine
->IsInitialized())
134 wxUxThemeEngineOnExit() ;
138 if(atexit(wxUxThemeEngineOnExit
) != 0)
140 wxUxThemeEngineOnExit() ;
148 #define WXU_GET_FN_PTR(hmod, type, pfunc, funcname) if(hmod != ((HINSTANCE)NULL)) { \
149 pfunc = (type)::GetProcAddress(hmod, funcname) ; \
150 if(pfunc == ((type)NULL)) \
152 ::FreeLibrary(hmod) ; \
153 hmod = ((HINSTANCE)NULL) ; \
157 wxUxThemeEngine::wxUxThemeEngine()
159 m_hInstUXThemeDLL
= ::LoadLibraryA("uxtheme.dll") ;
160 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUOPENTHEMEDATA
, m_pfnOpenThemeData
, "OpenThemeData")
161 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUCLOSETHEMEDATA
, m_pfnCloseThemeData
, "CloseThemeData")
162 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUDRAWTHEMEBACKGROUND
, m_pfnDrawThemeBackground
, "DrawThemeBackground")
163 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUDRAWTHEMETEXT
, m_pfnDrawThemeText
, "DrawThemeText")
164 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEBACKGROUNDCONTENTRECT
, m_pfnGetThemeBackgroundContentRect
, "GetThemeBackgroundContentRect")
165 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEBACKGROUNDEXTENT
, m_pfnGetThemeBackgroundExtent
, "GetThemeBackgroundExtent")
166 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEPARTSIZE
, m_pfnGetThemePartSize
, "GetThemePartSize")
167 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMETEXTEXTENT
, m_pfnGetThemeTextExtent
, "GetThemeTextExtent")
168 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMETEXTMETRICS
, m_pfnGetThemeTextMetrics
, "GetThemeTextMetrics")
169 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEBACKGROUNDREGION
, m_pfnGetThemeBackgroundRegion
, "GetThemeBackgroundRegion")
170 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUHITTESTTHEMEBACKGROUND
, m_pfnHitTestThemeBackground
, "HitTestThemeBackground")
171 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUDRAWTHEMEEDGE
, m_pfnDrawThemeEdge
, "DrawThemeEdge")
172 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUDRAWTHEMEICON
, m_pfnDrawThemeIcon
, "DrawThemeIcon")
173 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUISTHEMEPARTDEFINED
, m_pfnIsThemePartDefined
, "IsThemePartDefined")
174 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT
, m_pfnIsThemeBackgroundPartiallyTransparent
, "IsThemeBackgroundPartiallyTransparent")
175 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMECOLOR
, m_pfnGetThemeColor
, "GetThemeColor")
176 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEMETRIC
, m_pfnGetThemeMetric
, "GetThemeMetric")
177 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESTRING
, m_pfnGetThemeString
, "GetThemeString")
178 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEBOOL
, m_pfnGetThemeBool
, "GetThemeBool")
179 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEINT
, m_pfnGetThemeInt
, "GetThemeInt")
180 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEENUMVALUE
, m_pfnGetThemeEnumValue
, "GetThemeEnumValue")
181 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEPOSITION
, m_pfnGetThemePosition
, "GetThemePosition")
182 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEFONT
, m_pfnGetThemeFont
, "GetThemeFont")
183 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMERECT
, m_pfnGetThemeRect
, "GetThemeRect")
184 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEMARGINS
, m_pfnGetThemeMargins
, "GetThemeMargins")
185 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEINTLIST
, m_pfnGetThemeIntList
, "GetThemeIntList")
186 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEPROPERTYORIGIN
, m_pfnGetThemePropertyOrigin
, "GetThemePropertyOrigin")
187 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUSETWINDOWTHEME
, m_pfnSetWindowTheme
, "SetWindowTheme")
188 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEFILENAME
, m_pfnGetThemeFilename
, "GetThemeFilename")
189 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESYSCOLOR
, m_pfnGetThemeSysColor
, "GetThemeSysColor")
190 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESYSCOLORBRUSH
, m_pfnGetThemeSysColorBrush
, "GetThemeSysColorBrush")
191 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESYSBOOL
, m_pfnGetThemeSysBool
, "GetThemeSysBool")
192 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESYSSIZE
, m_pfnGetThemeSysSize
, "GetThemeSysSize")
193 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESYSFONT
, m_pfnGetThemeSysFont
, "GetThemeSysFont")
194 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESYSSTRING
, m_pfnGetThemeSysString
, "GetThemeSysString")
195 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESYSINT
, m_pfnGetThemeSysInt
, "GetThemeSysInt")
196 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUISTHEMEACTIVE
, m_pfnIsThemeActive
, "IsThemeActive")
197 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUISAPPTHEMED
, m_pfnIsAppThemed
, "IsAppThemed")
198 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETWINDOWTHEME
, m_pfnGetWindowTheme
, "GetWindowTheme")
199 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUENABLETHEMEDIALOGTEXTURE
, m_pfnEnableThemeDialogTexture
, "EnableThemeDialogTexture")
200 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUISTHEMEDIALOGTEXTUREENABLED
, m_pfnIsThemeDialogTextureEnabled
, "IsThemeDialogTextureEnabled")
201 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEAPPPROPERTIES
, m_pfnGetThemeAppProperties
, "GetThemeAppProperties")
202 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUSETTHEMEAPPPROPERTIES
, m_pfnSetThemeAppProperties
, "SetThemeAppProperties")
203 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETCURRENTTHEMENAME
, m_pfnGetCurrentThemeName
, "GetCurrentThemeName")
204 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEDOCUMENTATIONPROPERTY
, m_pfnGetThemeDocumentationProperty
, "GetThemeDocumentationProperty")
205 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUDRAWTHEMEPARENTBACKGROUND
, m_pfnDrawThemeParentBackground
, "DrawThemeParentBackground")
206 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUENABLETHEMING
, m_pfnEnableTheming
, "EnableTheming")
207 m_bIsInitialized
= (m_hInstUXThemeDLL
!= ((HINSTANCE
)NULL
)) ;
208 if(!m_bIsInitialized
)
210 ResetFunctionPointers() ;
214 void wxUxThemeEngine::ResetFunctionPointers()
216 m_pfnOpenThemeData
= ((PFNWXUOPENTHEMEDATA
)NULL
) ;
217 m_pfnCloseThemeData
= ((PFNWXUCLOSETHEMEDATA
)NULL
) ;
218 m_pfnDrawThemeBackground
= ((PFNWXUDRAWTHEMEBACKGROUND
)NULL
) ;
219 m_pfnDrawThemeText
= ((PFNWXUDRAWTHEMETEXT
)NULL
) ;
220 m_pfnGetThemeBackgroundContentRect
= ((PFNWXUGETTHEMEBACKGROUNDCONTENTRECT
)NULL
) ;
221 m_pfnGetThemeBackgroundExtent
= ((PFNWXUGETTHEMEBACKGROUNDEXTENT
)NULL
) ;
222 m_pfnGetThemePartSize
= ((PFNWXUGETTHEMEPARTSIZE
)NULL
) ;
223 m_pfnGetThemeTextExtent
= ((PFNWXUGETTHEMETEXTEXTENT
)NULL
) ;
224 m_pfnGetThemeTextMetrics
= ((PFNWXUGETTHEMETEXTMETRICS
)NULL
) ;
225 m_pfnGetThemeBackgroundRegion
= ((PFNWXUGETTHEMEBACKGROUNDREGION
)NULL
) ;
226 m_pfnHitTestThemeBackground
= ((PFNWXUHITTESTTHEMEBACKGROUND
)NULL
) ;
227 m_pfnDrawThemeEdge
= ((PFNWXUDRAWTHEMEEDGE
)NULL
) ;
228 m_pfnDrawThemeIcon
= ((PFNWXUDRAWTHEMEICON
)NULL
) ;
229 m_pfnIsThemePartDefined
= ((PFNWXUISTHEMEPARTDEFINED
)NULL
) ;
230 m_pfnIsThemeBackgroundPartiallyTransparent
= ((PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT
)NULL
) ;
231 m_pfnGetThemeColor
= ((PFNWXUGETTHEMECOLOR
)NULL
) ;
232 m_pfnGetThemeMetric
= ((PFNWXUGETTHEMEMETRIC
)NULL
) ;
233 m_pfnGetThemeString
= ((PFNWXUGETTHEMESTRING
)NULL
) ;
234 m_pfnGetThemeBool
= ((PFNWXUGETTHEMEBOOL
)NULL
) ;
235 m_pfnGetThemeInt
= ((PFNWXUGETTHEMEINT
)NULL
) ;
236 m_pfnGetThemeEnumValue
= ((PFNWXUGETTHEMEENUMVALUE
)NULL
) ;
237 m_pfnGetThemePosition
= ((PFNWXUGETTHEMEPOSITION
)NULL
) ;
238 m_pfnGetThemeFont
= ((PFNWXUGETTHEMEFONT
)NULL
) ;
239 m_pfnGetThemeRect
= ((PFNWXUGETTHEMERECT
)NULL
) ;
240 m_pfnGetThemeMargins
= ((PFNWXUGETTHEMEMARGINS
)NULL
) ;
241 m_pfnGetThemeIntList
= ((PFNWXUGETTHEMEINTLIST
)NULL
) ;
242 m_pfnGetThemePropertyOrigin
= ((PFNWXUGETTHEMEPROPERTYORIGIN
)NULL
) ;
243 m_pfnSetWindowTheme
= ((PFNWXUSETWINDOWTHEME
)NULL
) ;
244 m_pfnGetThemeFilename
= ((PFNWXUGETTHEMEFILENAME
)NULL
) ;
245 m_pfnGetThemeSysColor
= ((PFNWXUGETTHEMESYSCOLOR
)NULL
) ;
246 m_pfnGetThemeSysColorBrush
= ((PFNWXUGETTHEMESYSCOLORBRUSH
)NULL
) ;
247 m_pfnGetThemeSysBool
= ((PFNWXUGETTHEMESYSBOOL
)NULL
) ;
248 m_pfnGetThemeSysSize
= ((PFNWXUGETTHEMESYSSIZE
)NULL
) ;
249 m_pfnGetThemeSysFont
= ((PFNWXUGETTHEMESYSFONT
)NULL
) ;
250 m_pfnGetThemeSysString
= ((PFNWXUGETTHEMESYSSTRING
)NULL
) ;
251 m_pfnGetThemeSysInt
= ((PFNWXUGETTHEMESYSINT
)NULL
) ;
252 m_pfnIsThemeActive
= ((PFNWXUISTHEMEACTIVE
)NULL
) ;
253 m_pfnIsAppThemed
= ((PFNWXUISAPPTHEMED
)NULL
) ;
254 m_pfnGetWindowTheme
= ((PFNWXUGETWINDOWTHEME
)NULL
) ;
255 m_pfnEnableThemeDialogTexture
= ((PFNWXUENABLETHEMEDIALOGTEXTURE
)NULL
) ;
256 m_pfnIsThemeDialogTextureEnabled
= ((PFNWXUISTHEMEDIALOGTEXTUREENABLED
)NULL
) ;
257 m_pfnGetThemeAppProperties
= ((PFNWXUGETTHEMEAPPPROPERTIES
)NULL
) ;
258 m_pfnSetThemeAppProperties
= ((PFNWXUSETTHEMEAPPPROPERTIES
)NULL
) ;
259 m_pfnGetCurrentThemeName
= ((PFNWXUGETCURRENTTHEMENAME
)NULL
) ;
260 m_pfnGetThemeDocumentationProperty
= ((PFNWXUGETTHEMEDOCUMENTATIONPROPERTY
)NULL
) ;
261 m_pfnDrawThemeParentBackground
= ((PFNWXUDRAWTHEMEPARENTBACKGROUND
)NULL
) ;
262 m_pfnEnableTheming
= ((PFNWXUENABLETHEMING
)NULL
) ;
265 wxUxThemeEngine::~wxUxThemeEngine()
267 if(m_hInstUXThemeDLL
!= ((HINSTANCE
)NULL
))
269 ::FreeLibrary(m_hInstUXThemeDLL
) ;
271 ResetFunctionPointers() ;