]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/uxtheme.h
Fix for function access shown in Tinderbox builds.
[wxWidgets.git] / include / wx / msw / uxtheme.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: include/wx/msw/uxtheme.h
3 // Purpose: wxUxThemeEngine class: support for XP themes
4 // Author: John Platts, Vadim Zeitlin
5 // Modified by:
6 // Created: 2003
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 John Platts, Vadim Zeitlin
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_UXTHEME_H_
13 #define _WX_UXTHEME_H_
14
15 #include "wx/defs.h"
16
17 #include "wx/msw/wrapwin.h"
18 #include "wx/msw/uxthemep.h"
19
20 typedef HTHEME (__stdcall *PFNWXUOPENTHEMEDATA)(HWND, const wchar_t *);
21 typedef HRESULT (__stdcall *PFNWXUCLOSETHEMEDATA)(HTHEME);
22 typedef HRESULT (__stdcall *PFNWXUDRAWTHEMEBACKGROUND)(HTHEME, HDC, int, int, const RECT *, const RECT *);
23 typedef HRESULT (__stdcall *PFNWXUDRAWTHEMETEXT)(HTHEME, HDC, int, int, const wchar_t *, int, DWORD, DWORD, const RECT *);
24 typedef HRESULT (__stdcall *PFNWXUGETTHEMEBACKGROUNDCONTENTRECT)(HTHEME, HDC, int, int, const RECT *, RECT *);
25 typedef HRESULT (__stdcall *PFNWXUGETTHEMEBACKGROUNDEXTENT)(HTHEME, HDC, int, int, const RECT *, RECT *);
26 typedef HRESULT (__stdcall *PFNWXUGETTHEMEPARTSIZE)(HTHEME, HDC, int, int, const RECT *, /* enum */ THEMESIZE, SIZE *);
27 typedef HRESULT (__stdcall *PFNWXUGETTHEMETEXTEXTENT)(HTHEME, HDC, int, int, const wchar_t *, int, DWORD, const RECT *, RECT *);
28 typedef HRESULT (__stdcall *PFNWXUGETTHEMETEXTMETRICS)(HTHEME, HDC, int, int, TEXTMETRIC*);
29 typedef HRESULT (__stdcall *PFNWXUGETTHEMEBACKGROUNDREGION)(HTHEME, HDC, int, int, const RECT *, HRGN *);
30 typedef HRESULT (__stdcall *PFNWXUHITTESTTHEMEBACKGROUND)(HTHEME, HDC, int, int, DWORD, const RECT *, HRGN, POINT, unsigned short *);
31 typedef HRESULT (__stdcall *PFNWXUDRAWTHEMEEDGE)(HTHEME, HDC, int, int, const RECT *, unsigned int, unsigned int, RECT *);
32 typedef HRESULT (__stdcall *PFNWXUDRAWTHEMEICON)(HTHEME, HDC, int, int, const RECT *, HIMAGELIST, int);
33 typedef BOOL (__stdcall *PFNWXUISTHEMEPARTDEFINED)(HTHEME, int, int);
34 typedef BOOL (__stdcall *PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT)(HTHEME, int, int);
35 typedef HRESULT (__stdcall *PFNWXUGETTHEMECOLOR)(HTHEME, int, int, int, COLORREF*);
36 typedef HRESULT (__stdcall *PFNWXUGETTHEMEMETRIC)(HTHEME, HDC, int, int, int, int *);
37 typedef HRESULT (__stdcall *PFNWXUGETTHEMESTRING)(HTHEME, int, int, int, wchar_t *, int);
38 typedef HRESULT (__stdcall *PFNWXUGETTHEMEBOOL)(HTHEME, int, int, int, BOOL *);
39 typedef HRESULT (__stdcall *PFNWXUGETTHEMEINT)(HTHEME, int, int, int, int *);
40 typedef HRESULT (__stdcall *PFNWXUGETTHEMEENUMVALUE)(HTHEME, int, int, int, int *);
41 typedef HRESULT (__stdcall *PFNWXUGETTHEMEPOSITION)(HTHEME, int, int, int, POINT *);
42 typedef HRESULT (__stdcall *PFNWXUGETTHEMEFONT)(HTHEME, HDC, int, int, int, LOGFONT *);
43 typedef HRESULT (__stdcall *PFNWXUGETTHEMERECT)(HTHEME, int, int, int, RECT *);
44 typedef HRESULT (__stdcall *PFNWXUGETTHEMEMARGINS)(HTHEME, HDC, int, int, int, RECT *, MARGINS *);
45 typedef HRESULT (__stdcall *PFNWXUGETTHEMEINTLIST)(HTHEME, int, int, int, INTLIST*);
46 typedef HRESULT (__stdcall *PFNWXUGETTHEMEPROPERTYORIGIN)(HTHEME, int, int, int, /* enum */ PROPERTYORIGIN *);
47 typedef HRESULT (__stdcall *PFNWXUSETWINDOWTHEME)(HWND, const wchar_t*, const wchar_t *);
48 typedef HRESULT (__stdcall *PFNWXUGETTHEMEFILENAME)(HTHEME, int, int, int, wchar_t *, int);
49 typedef COLORREF(__stdcall *PFNWXUGETTHEMESYSCOLOR)(HTHEME, int);
50 typedef HBRUSH (__stdcall *PFNWXUGETTHEMESYSCOLORBRUSH)(HTHEME, int);
51 typedef BOOL (__stdcall *PFNWXUGETTHEMESYSBOOL)(HTHEME, int);
52 typedef int (__stdcall *PFNWXUGETTHEMESYSSIZE)(HTHEME, int);
53 typedef HRESULT (__stdcall *PFNWXUGETTHEMESYSFONT)(HTHEME, int, LOGFONT *);
54 typedef HRESULT (__stdcall *PFNWXUGETTHEMESYSSTRING)(HTHEME, int, wchar_t *, int);
55 typedef HRESULT (__stdcall *PFNWXUGETTHEMESYSINT)(HTHEME, int, int *);
56 typedef BOOL (__stdcall *PFNWXUISTHEMEACTIVE)();
57 typedef BOOL (__stdcall *PFNWXUISAPPTHEMED)();
58 typedef HTHEME (__stdcall *PFNWXUGETWINDOWTHEME)(HWND);
59 typedef HRESULT (__stdcall *PFNWXUENABLETHEMEDIALOGTEXTURE)(HWND, DWORD);
60 typedef BOOL (__stdcall *PFNWXUISTHEMEDIALOGTEXTUREENABLED)(HWND);
61 typedef DWORD (__stdcall *PFNWXUGETTHEMEAPPPROPERTIES)();
62 typedef void (__stdcall *PFNWXUSETTHEMEAPPPROPERTIES)(DWORD);
63 typedef HRESULT (__stdcall *PFNWXUGETCURRENTTHEMENAME)(wchar_t *, int, wchar_t *, int, wchar_t *, int);
64 typedef HRESULT (__stdcall *PFNWXUGETTHEMEDOCUMENTATIONPROPERTY)(const wchar_t *, const wchar_t *, wchar_t *, int);
65 typedef HRESULT (__stdcall *PFNWXUDRAWTHEMEPARENTBACKGROUND)(HWND, HDC, RECT *);
66 typedef HRESULT (__stdcall *PFNWXUENABLETHEMING)(BOOL);
67
68 // ----------------------------------------------------------------------------
69 // wxUxThemeEngine: provides all theme functions from uxtheme.dll
70 // ----------------------------------------------------------------------------
71
72 // we always define this class, even if wxUSE_UXTHEME == 0, but we just make it
73 // empty in this case -- this allows to use it elsewhere without any #ifdefs
74 #if wxUSE_UXTHEME
75 #include "wx/dynlib.h"
76
77 #define wxUX_THEME_DECLARE(type, func) type func;
78 #else
79 #define wxUX_THEME_DECLARE(type, func) type func(...) { return 0; }
80 #endif
81
82 class WXDLLEXPORT wxUxThemeEngine
83 {
84 public:
85 // get the theme engine or NULL if themes are not available
86 static wxUxThemeEngine *Get();
87
88 // get the theme enging or NULL if themes are not available or not used for
89 // this application
90 static wxUxThemeEngine *GetIfActive();
91
92 // all uxtheme.dll functions
93 wxUX_THEME_DECLARE(PFNWXUOPENTHEMEDATA, OpenThemeData)
94 wxUX_THEME_DECLARE(PFNWXUCLOSETHEMEDATA, CloseThemeData)
95 wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEBACKGROUND, DrawThemeBackground)
96 wxUX_THEME_DECLARE(PFNWXUDRAWTHEMETEXT, DrawThemeText)
97 wxUX_THEME_DECLARE(PFNWXUGETTHEMEBACKGROUNDCONTENTRECT, GetThemeBackgroundContentRect)
98 wxUX_THEME_DECLARE(PFNWXUGETTHEMEBACKGROUNDEXTENT, GetThemeBackgroundExtent)
99 wxUX_THEME_DECLARE(PFNWXUGETTHEMEPARTSIZE, GetThemePartSize)
100 wxUX_THEME_DECLARE(PFNWXUGETTHEMETEXTEXTENT, GetThemeTextExtent)
101 wxUX_THEME_DECLARE(PFNWXUGETTHEMETEXTMETRICS, GetThemeTextMetrics)
102 wxUX_THEME_DECLARE(PFNWXUGETTHEMEBACKGROUNDREGION, GetThemeBackgroundRegion)
103 wxUX_THEME_DECLARE(PFNWXUHITTESTTHEMEBACKGROUND, HitTestThemeBackground)
104 wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEEDGE, DrawThemeEdge)
105 wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEICON, DrawThemeIcon)
106 wxUX_THEME_DECLARE(PFNWXUISTHEMEPARTDEFINED, IsThemePartDefined)
107 wxUX_THEME_DECLARE(PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT, IsThemeBackgroundPartiallyTransparent)
108 wxUX_THEME_DECLARE(PFNWXUGETTHEMECOLOR, GetThemeColor)
109 wxUX_THEME_DECLARE(PFNWXUGETTHEMEMETRIC, GetThemeMetric)
110 wxUX_THEME_DECLARE(PFNWXUGETTHEMESTRING, GetThemeString)
111 wxUX_THEME_DECLARE(PFNWXUGETTHEMEBOOL, GetThemeBool)
112 wxUX_THEME_DECLARE(PFNWXUGETTHEMEINT, GetThemeInt)
113 wxUX_THEME_DECLARE(PFNWXUGETTHEMEENUMVALUE, GetThemeEnumValue)
114 wxUX_THEME_DECLARE(PFNWXUGETTHEMEPOSITION, GetThemePosition)
115 wxUX_THEME_DECLARE(PFNWXUGETTHEMEFONT, GetThemeFont)
116 wxUX_THEME_DECLARE(PFNWXUGETTHEMERECT, GetThemeRect)
117 wxUX_THEME_DECLARE(PFNWXUGETTHEMEMARGINS, GetThemeMargins)
118 wxUX_THEME_DECLARE(PFNWXUGETTHEMEINTLIST, GetThemeIntList)
119 wxUX_THEME_DECLARE(PFNWXUGETTHEMEPROPERTYORIGIN, GetThemePropertyOrigin)
120 wxUX_THEME_DECLARE(PFNWXUSETWINDOWTHEME, SetWindowTheme)
121 wxUX_THEME_DECLARE(PFNWXUGETTHEMEFILENAME, GetThemeFilename)
122 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSCOLOR, GetThemeSysColor)
123 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSCOLORBRUSH, GetThemeSysColorBrush)
124 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSBOOL, GetThemeSysBool)
125 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSSIZE, GetThemeSysSize)
126 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSFONT, GetThemeSysFont)
127 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSSTRING, GetThemeSysString)
128 wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSINT, GetThemeSysInt)
129 wxUX_THEME_DECLARE(PFNWXUISTHEMEACTIVE, IsThemeActive)
130 wxUX_THEME_DECLARE(PFNWXUISAPPTHEMED, IsAppThemed)
131 wxUX_THEME_DECLARE(PFNWXUGETWINDOWTHEME, GetWindowTheme)
132 wxUX_THEME_DECLARE(PFNWXUENABLETHEMEDIALOGTEXTURE, EnableThemeDialogTexture)
133 wxUX_THEME_DECLARE(PFNWXUISTHEMEDIALOGTEXTUREENABLED, IsThemeDialogTextureEnabled)
134 wxUX_THEME_DECLARE(PFNWXUGETTHEMEAPPPROPERTIES, GetThemeAppProperties)
135 wxUX_THEME_DECLARE(PFNWXUSETTHEMEAPPPROPERTIES, SetThemeAppProperties)
136 wxUX_THEME_DECLARE(PFNWXUGETCURRENTTHEMENAME, GetCurrentThemeName)
137 wxUX_THEME_DECLARE(PFNWXUGETTHEMEDOCUMENTATIONPROPERTY, GetThemeDocumentationProperty)
138 wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEPARENTBACKGROUND, DrawThemeParentBackground)
139 wxUX_THEME_DECLARE(PFNWXUENABLETHEMING, EnableTheming)
140
141 private:
142 // construcor is private as only Get() can create us and is also trivial as
143 // everything really happens in Initialize()
144 wxUxThemeEngine() { }
145
146 // destructor is private as only Get() and wxUxThemeModule delete us, it is
147 // not virtual as we're not supposed to be derived from
148 ~wxUxThemeEngine() { }
149
150 #if wxUSE_UXTHEME
151 // initialize the theme engine: load the DLL, resolve the functions
152 //
153 // return true if we can be used, false if themes are not available
154 bool Initialize();
155
156
157 // uxtheme.dll
158 wxDynamicLibrary m_dllUxTheme;
159
160
161 // the one and only theme engine, initially NULL
162 static wxUxThemeEngine *ms_themeEngine;
163
164 // this is a bool which initially has the value -1 meaning "unknown"
165 static int ms_isThemeEngineAvailable;
166
167 // it must be able to delete us
168 friend class wxUxThemeModule;
169 #endif // wxUSE_UXTHEME
170
171 DECLARE_NO_COPY_CLASS(wxUxThemeEngine)
172 };
173
174 #if wxUSE_UXTHEME
175
176 /* static */ inline wxUxThemeEngine *wxUxThemeEngine::GetIfActive()
177 {
178 wxUxThemeEngine *engine = Get();
179 return engine && engine->IsAppThemed() && engine->IsThemeActive()
180 ? engine
181 : NULL;
182 }
183
184 #else // !wxUSE_UXTHEME
185
186 /* static */ inline wxUxThemeEngine *wxUxThemeEngine::Get()
187 {
188 return NULL;
189 }
190
191 /* static */ inline wxUxThemeEngine *wxUxThemeEngine::GetIfActive()
192 {
193 return NULL;
194 }
195
196 #endif // wxUSE_UXTHEME/!wxUSE_UXTHEME
197
198 // ----------------------------------------------------------------------------
199 // wxUxThemeHandle: encapsulates ::Open/CloseThemeData()
200 // ----------------------------------------------------------------------------
201
202 class wxUxThemeHandle
203 {
204 public:
205 wxUxThemeHandle(const wxWindow *win, const wchar_t *classes)
206 {
207 wxUxThemeEngine *engine = wxUxThemeEngine::Get();
208
209 m_hTheme = engine ? (HTHEME)engine->OpenThemeData(GetHwndOf(win), classes)
210 : NULL;
211 }
212
213 operator HTHEME() const { return m_hTheme; }
214
215 ~wxUxThemeHandle()
216 {
217 if ( m_hTheme )
218 {
219 wxUxThemeEngine::Get()->CloseThemeData(m_hTheme);
220 }
221 }
222
223 private:
224 HTHEME m_hTheme;
225
226 DECLARE_NO_COPY_CLASS(wxUxThemeHandle)
227 };
228
229 #endif // _WX_UXTHEME_H_
230