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"
31 #include "wx/msw/wrapwin.h"
33 #include "wx/msw/uxtheme.h"
34 #include "wx/msw/private.h"
35 #include "wx/app.h" // for GetComCtl32Version
37 wxUxThemeEngine
* g_pThemeEngine
= ((wxUxThemeEngine
*)NULL
) ;
39 BOOL
wxCanUseInitThemeEngine()
41 WXUOSVERSIONINFOEX wxuosex
;
42 memset((void*)&wxuosex
, 0, sizeof(WXUOSVERSIONINFOEX
)) ;
43 wxuosex
.dwOSVersionInfoSize
= sizeof(WXUOSVERSIONINFOEX
) ;
44 if(!GetVersionEx((LPOSVERSIONINFO
)&wxuosex
))
46 wxuosex
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
) ;
47 if(!GetVersionEx((LPOSVERSIONINFO
)&wxuosex
))
52 if ((wxuosex
.dwMajorVersion
== 5) && (wxuosex
.dwMinorVersion
> 0))
54 return (wxTheApp
->GetComCtl32Version() >= 600) ;
62 wxUxThemeEngine
* wxUxThemeEngine::wxInitUxThemeEngine()
64 wxUxThemeEngine
* pThemeEngine
= new wxUxThemeEngine
;
68 wxUxThemeEngine
* wxUxThemeEngine::Get()
70 return g_pThemeEngine
;
73 #ifdef WXU_USE_WXMODULE
74 class wxUxThemeModule
: public wxModule
76 DECLARE_DYNAMIC_CLASS(wxUxThemeModule
)
80 if((wxCanUseInitThemeEngine()) && (g_pThemeEngine
))
82 delete g_pThemeEngine
;
83 g_pThemeEngine
= ((wxUxThemeEngine
*)NULL
) ;
89 if(!wxCanUseInitThemeEngine())
91 g_pThemeEngine
= ((wxUxThemeEngine
*)NULL
) ;
94 g_pThemeEngine
= wxUxThemeEngine::wxInitUxThemeEngine() ;
99 else if(!g_pThemeEngine
->IsInitialized())
109 IMPLEMENT_DYNAMIC_CLASS(wxUxThemeModule
, wxModule
)
111 static void __cdecl
wxUxThemeEngineOnExit()
115 delete g_pThemeEngine
;
116 g_pThemeEngine
= ((wxUxThemeEngine
*)NULL
) ;
120 BOOL
wxUxInitThemeEngine()
122 if(!wxCanUseInitThemeEngine())
126 g_pThemeEngine
= wxUxThemeEngine::wxInitUxThemeEngine() ;
131 else if(!g_pThemeEngine
->IsInitialized())
133 wxUxThemeEngineOnExit() ;
137 if(atexit(wxUxThemeEngineOnExit
) != 0)
139 wxUxThemeEngineOnExit() ;
147 #define WXU_GET_FN_PTR(hmod, type, pfunc, funcname) if(hmod != ((HINSTANCE)NULL)) { \
148 pfunc = (type)::GetProcAddress(hmod, funcname) ; \
149 if(pfunc == ((type)NULL)) \
151 ::FreeLibrary(hmod) ; \
152 hmod = ((HINSTANCE)NULL) ; \
156 wxUxThemeEngine::wxUxThemeEngine()
158 m_hInstUXThemeDLL
= ::LoadLibraryA("uxtheme.dll") ;
159 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUOPENTHEMEDATA
, m_pfnOpenThemeData
, "OpenThemeData")
160 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUCLOSETHEMEDATA
, m_pfnCloseThemeData
, "CloseThemeData")
161 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUDRAWTHEMEBACKGROUND
, m_pfnDrawThemeBackground
, "DrawThemeBackground")
162 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUDRAWTHEMETEXT
, m_pfnDrawThemeText
, "DrawThemeText")
163 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEBACKGROUNDCONTENTRECT
, m_pfnGetThemeBackgroundContentRect
, "GetThemeBackgroundContentRect")
164 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEBACKGROUNDEXTENT
, m_pfnGetThemeBackgroundExtent
, "GetThemeBackgroundExtent")
165 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEPARTSIZE
, m_pfnGetThemePartSize
, "GetThemePartSize")
166 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMETEXTEXTENT
, m_pfnGetThemeTextExtent
, "GetThemeTextExtent")
167 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMETEXTMETRICS
, m_pfnGetThemeTextMetrics
, "GetThemeTextMetrics")
168 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEBACKGROUNDREGION
, m_pfnGetThemeBackgroundRegion
, "GetThemeBackgroundRegion")
169 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUHITTESTTHEMEBACKGROUND
, m_pfnHitTestThemeBackground
, "HitTestThemeBackground")
170 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUDRAWTHEMEEDGE
, m_pfnDrawThemeEdge
, "DrawThemeEdge")
171 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUDRAWTHEMEICON
, m_pfnDrawThemeIcon
, "DrawThemeIcon")
172 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUISTHEMEPARTDEFINED
, m_pfnIsThemePartDefined
, "IsThemePartDefined")
173 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT
, m_pfnIsThemeBackgroundPartiallyTransparent
, "IsThemeBackgroundPartiallyTransparent")
174 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMECOLOR
, m_pfnGetThemeColor
, "GetThemeColor")
175 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEMETRIC
, m_pfnGetThemeMetric
, "GetThemeMetric")
176 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESTRING
, m_pfnGetThemeString
, "GetThemeString")
177 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEBOOL
, m_pfnGetThemeBool
, "GetThemeBool")
178 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEINT
, m_pfnGetThemeInt
, "GetThemeInt")
179 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEENUMVALUE
, m_pfnGetThemeEnumValue
, "GetThemeEnumValue")
180 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEPOSITION
, m_pfnGetThemePosition
, "GetThemePosition")
181 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEFONT
, m_pfnGetThemeFont
, "GetThemeFont")
182 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMERECT
, m_pfnGetThemeRect
, "GetThemeRect")
183 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEMARGINS
, m_pfnGetThemeMargins
, "GetThemeMargins")
184 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEINTLIST
, m_pfnGetThemeIntList
, "GetThemeIntList")
185 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEPROPERTYORIGIN
, m_pfnGetThemePropertyOrigin
, "GetThemePropertyOrigin")
186 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUSETWINDOWTHEME
, m_pfnSetWindowTheme
, "SetWindowTheme")
187 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEFILENAME
, m_pfnGetThemeFilename
, "GetThemeFilename")
188 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESYSCOLOR
, m_pfnGetThemeSysColor
, "GetThemeSysColor")
189 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESYSCOLORBRUSH
, m_pfnGetThemeSysColorBrush
, "GetThemeSysColorBrush")
190 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESYSBOOL
, m_pfnGetThemeSysBool
, "GetThemeSysBool")
191 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESYSSIZE
, m_pfnGetThemeSysSize
, "GetThemeSysSize")
192 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESYSFONT
, m_pfnGetThemeSysFont
, "GetThemeSysFont")
193 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESYSSTRING
, m_pfnGetThemeSysString
, "GetThemeSysString")
194 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMESYSINT
, m_pfnGetThemeSysInt
, "GetThemeSysInt")
195 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUISTHEMEACTIVE
, m_pfnIsThemeActive
, "IsThemeActive")
196 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUISAPPTHEMED
, m_pfnIsAppThemed
, "IsAppThemed")
197 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETWINDOWTHEME
, m_pfnGetWindowTheme
, "GetWindowTheme")
198 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUENABLETHEMEDIALOGTEXTURE
, m_pfnEnableThemeDialogTexture
, "EnableThemeDialogTexture")
199 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUISTHEMEDIALOGTEXTUREENABLED
, m_pfnIsThemeDialogTextureEnabled
, "IsThemeDialogTextureEnabled")
200 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEAPPPROPERTIES
, m_pfnGetThemeAppProperties
, "GetThemeAppProperties")
201 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUSETTHEMEAPPPROPERTIES
, m_pfnSetThemeAppProperties
, "SetThemeAppProperties")
202 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETCURRENTTHEMENAME
, m_pfnGetCurrentThemeName
, "GetCurrentThemeName")
203 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUGETTHEMEDOCUMENTATIONPROPERTY
, m_pfnGetThemeDocumentationProperty
, "GetThemeDocumentationProperty")
204 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUDRAWTHEMEPARENTBACKGROUND
, m_pfnDrawThemeParentBackground
, "DrawThemeParentBackground")
205 WXU_GET_FN_PTR (m_hInstUXThemeDLL
, PFNWXUENABLETHEMING
, m_pfnEnableTheming
, "EnableTheming")
206 m_bIsInitialized
= (m_hInstUXThemeDLL
!= ((HINSTANCE
)NULL
)) ;
207 if(!m_bIsInitialized
)
209 ResetFunctionPointers() ;
213 void wxUxThemeEngine::ResetFunctionPointers()
215 m_pfnOpenThemeData
= ((PFNWXUOPENTHEMEDATA
)NULL
) ;
216 m_pfnCloseThemeData
= ((PFNWXUCLOSETHEMEDATA
)NULL
) ;
217 m_pfnDrawThemeBackground
= ((PFNWXUDRAWTHEMEBACKGROUND
)NULL
) ;
218 m_pfnDrawThemeText
= ((PFNWXUDRAWTHEMETEXT
)NULL
) ;
219 m_pfnGetThemeBackgroundContentRect
= ((PFNWXUGETTHEMEBACKGROUNDCONTENTRECT
)NULL
) ;
220 m_pfnGetThemeBackgroundExtent
= ((PFNWXUGETTHEMEBACKGROUNDEXTENT
)NULL
) ;
221 m_pfnGetThemePartSize
= ((PFNWXUGETTHEMEPARTSIZE
)NULL
) ;
222 m_pfnGetThemeTextExtent
= ((PFNWXUGETTHEMETEXTEXTENT
)NULL
) ;
223 m_pfnGetThemeTextMetrics
= ((PFNWXUGETTHEMETEXTMETRICS
)NULL
) ;
224 m_pfnGetThemeBackgroundRegion
= ((PFNWXUGETTHEMEBACKGROUNDREGION
)NULL
) ;
225 m_pfnHitTestThemeBackground
= ((PFNWXUHITTESTTHEMEBACKGROUND
)NULL
) ;
226 m_pfnDrawThemeEdge
= ((PFNWXUDRAWTHEMEEDGE
)NULL
) ;
227 m_pfnDrawThemeIcon
= ((PFNWXUDRAWTHEMEICON
)NULL
) ;
228 m_pfnIsThemePartDefined
= ((PFNWXUISTHEMEPARTDEFINED
)NULL
) ;
229 m_pfnIsThemeBackgroundPartiallyTransparent
= ((PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT
)NULL
) ;
230 m_pfnGetThemeColor
= ((PFNWXUGETTHEMECOLOR
)NULL
) ;
231 m_pfnGetThemeMetric
= ((PFNWXUGETTHEMEMETRIC
)NULL
) ;
232 m_pfnGetThemeString
= ((PFNWXUGETTHEMESTRING
)NULL
) ;
233 m_pfnGetThemeBool
= ((PFNWXUGETTHEMEBOOL
)NULL
) ;
234 m_pfnGetThemeInt
= ((PFNWXUGETTHEMEINT
)NULL
) ;
235 m_pfnGetThemeEnumValue
= ((PFNWXUGETTHEMEENUMVALUE
)NULL
) ;
236 m_pfnGetThemePosition
= ((PFNWXUGETTHEMEPOSITION
)NULL
) ;
237 m_pfnGetThemeFont
= ((PFNWXUGETTHEMEFONT
)NULL
) ;
238 m_pfnGetThemeRect
= ((PFNWXUGETTHEMERECT
)NULL
) ;
239 m_pfnGetThemeMargins
= ((PFNWXUGETTHEMEMARGINS
)NULL
) ;
240 m_pfnGetThemeIntList
= ((PFNWXUGETTHEMEINTLIST
)NULL
) ;
241 m_pfnGetThemePropertyOrigin
= ((PFNWXUGETTHEMEPROPERTYORIGIN
)NULL
) ;
242 m_pfnSetWindowTheme
= ((PFNWXUSETWINDOWTHEME
)NULL
) ;
243 m_pfnGetThemeFilename
= ((PFNWXUGETTHEMEFILENAME
)NULL
) ;
244 m_pfnGetThemeSysColor
= ((PFNWXUGETTHEMESYSCOLOR
)NULL
) ;
245 m_pfnGetThemeSysColorBrush
= ((PFNWXUGETTHEMESYSCOLORBRUSH
)NULL
) ;
246 m_pfnGetThemeSysBool
= ((PFNWXUGETTHEMESYSBOOL
)NULL
) ;
247 m_pfnGetThemeSysSize
= ((PFNWXUGETTHEMESYSSIZE
)NULL
) ;
248 m_pfnGetThemeSysFont
= ((PFNWXUGETTHEMESYSFONT
)NULL
) ;
249 m_pfnGetThemeSysString
= ((PFNWXUGETTHEMESYSSTRING
)NULL
) ;
250 m_pfnGetThemeSysInt
= ((PFNWXUGETTHEMESYSINT
)NULL
) ;
251 m_pfnIsThemeActive
= ((PFNWXUISTHEMEACTIVE
)NULL
) ;
252 m_pfnIsAppThemed
= ((PFNWXUISAPPTHEMED
)NULL
) ;
253 m_pfnGetWindowTheme
= ((PFNWXUGETWINDOWTHEME
)NULL
) ;
254 m_pfnEnableThemeDialogTexture
= ((PFNWXUENABLETHEMEDIALOGTEXTURE
)NULL
) ;
255 m_pfnIsThemeDialogTextureEnabled
= ((PFNWXUISTHEMEDIALOGTEXTUREENABLED
)NULL
) ;
256 m_pfnGetThemeAppProperties
= ((PFNWXUGETTHEMEAPPPROPERTIES
)NULL
) ;
257 m_pfnSetThemeAppProperties
= ((PFNWXUSETTHEMEAPPPROPERTIES
)NULL
) ;
258 m_pfnGetCurrentThemeName
= ((PFNWXUGETCURRENTTHEMENAME
)NULL
) ;
259 m_pfnGetThemeDocumentationProperty
= ((PFNWXUGETTHEMEDOCUMENTATIONPROPERTY
)NULL
) ;
260 m_pfnDrawThemeParentBackground
= ((PFNWXUDRAWTHEMEPARENTBACKGROUND
)NULL
) ;
261 m_pfnEnableTheming
= ((PFNWXUENABLETHEMING
)NULL
) ;
264 wxUxThemeEngine::~wxUxThemeEngine()
266 if(m_hInstUXThemeDLL
!= ((HINSTANCE
)NULL
))
268 ::FreeLibrary(m_hInstUXThemeDLL
) ;
270 ResetFunctionPointers() ;