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