]> git.saurik.com Git - wxWidgets.git/blame - src/msw/uxtheme.cpp
Set missing Language: headers in PO files.
[wxWidgets.git] / src / msw / uxtheme.cpp
CommitLineData
2d9c0e97
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/msw/uxtheme.cpp
3// Purpose: implements wxUxThemeEngine class: support for XP themes
0ea1cce3 4// Author: John Platts, Vadim Zeitlin
2d9c0e97
VZ
5// Modified by:
6// Created: 2003
0ea1cce3 7// Copyright: (c) 2003 John Platts, Vadim Zeitlin
526954c5 8// Licence: wxWindows licence
2d9c0e97
VZ
9///////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
0d1cb8cb 14
2d9c0e97
VZ
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
85b43fbf
JS
19// For compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
2d9c0e97
VZ
26#if wxUSE_UXTHEME
27
85b43fbf
JS
28#ifndef WX_PRECOMP
29 #include "wx/app.h"
30 #include "wx/toplevel.h"
31 #include "wx/string.h"
32 #include "wx/log.h"
02761f6c 33 #include "wx/module.h"
85b43fbf
JS
34#endif //WX_PRECOMP
35
0d1cb8cb 36#include "wx/msw/uxtheme.h"
0d1cb8cb 37
2d9c0e97
VZ
38// ============================================================================
39// wxUxThemeModule
40// ============================================================================
0d1cb8cb 41
2d9c0e97 42// this module is responsable for deleting the theme engine
0d1cb8cb
JS
43class wxUxThemeModule : public wxModule
44{
0d1cb8cb 45public:
27d2dbbc
WS
46 virtual bool OnInit() { return true; }
47 virtual void OnExit()
48 {
49 if ( wxUxThemeEngine::ms_themeEngine )
50 {
2d9c0e97
VZ
51 // this is probably not necessary right now but try to be careful
52 // and avoid the problems which we might have if someone ever
53 // decides to show a message box using the theme engine from
54 // wxUxThemeEngine dtor (e.g. from wxDynamicLibrary dtor...) or
55 // something like this
56 wxUxThemeEngine *themeEngine = wxUxThemeEngine::ms_themeEngine;
57 wxUxThemeEngine::ms_themeEngine = NULL;
58 wxUxThemeEngine::ms_isThemeEngineAvailable = false;
59
27d2dbbc
WS
60 delete themeEngine;
61 }
62 }
0d1cb8cb 63
0d1cb8cb 64
27d2dbbc 65 DECLARE_DYNAMIC_CLASS(wxUxThemeModule)
0d1cb8cb
JS
66};
67
68IMPLEMENT_DYNAMIC_CLASS(wxUxThemeModule, wxModule)
0d1cb8cb 69
2d9c0e97
VZ
70// ============================================================================
71// wxUxThemeEngine implementation
72// ============================================================================
0d1cb8cb 73
2d9c0e97
VZ
74wxUxThemeEngine *wxUxThemeEngine::ms_themeEngine = NULL;
75int wxUxThemeEngine::ms_isThemeEngineAvailable = -1; // unknown
0d1cb8cb 76
2d9c0e97 77wxUxThemeEngine* wxUxThemeEngine::Get()
0d1cb8cb 78{
2d9c0e97
VZ
79 // we assume that themes are only used in the main thread hence no need for
80 // critical section here
81 if ( ms_isThemeEngineAvailable == -1 )
0d1cb8cb 82 {
2d9c0e97
VZ
83 // we're called or the first time, check if the themes are available
84 ms_themeEngine = new wxUxThemeEngine;
85 if ( !ms_themeEngine->Initialize() )
86 {
87 // can't use themes, probably because the system doesn't support
88 // them, don't do it again
89 delete ms_themeEngine;
90 ms_themeEngine = NULL;
91
92 ms_isThemeEngineAvailable = false;
93 }
94 else // initialized ok
95 {
96 ms_isThemeEngineAvailable = true;
97 }
0d1cb8cb 98 }
0d1cb8cb 99
2d9c0e97 100 return ms_themeEngine;
0d1cb8cb
JS
101}
102
2d9c0e97 103bool wxUxThemeEngine::Initialize()
0d1cb8cb 104{
2a1f999f 105 if ( wxApp::GetComCtl32Version() < 600 )
07e90782
VZ
106 {
107 // not using theme-aware comctl32.dll anyhow, don't even try to use
108 // themes
109 return false;
110 }
27d2dbbc 111
7f9fe789
VZ
112 // we're prepared to handle the errors
113 wxLogNull noLog;
114
9a83f860 115 if ( !m_dllUxTheme.Load(wxT("uxtheme.dll")) )
2d9c0e97
VZ
116 return false;
117
118#define RESOLVE_UXTHEME_FUNCTION(type, funcname) \
9a83f860 119 funcname = (type)m_dllUxTheme.GetSymbol(wxT(#funcname)); \
2d9c0e97
VZ
120 if ( !funcname ) \
121 return false
122
123 RESOLVE_UXTHEME_FUNCTION(PFNWXUOPENTHEMEDATA, OpenThemeData);
124 RESOLVE_UXTHEME_FUNCTION(PFNWXUCLOSETHEMEDATA, CloseThemeData);
125 RESOLVE_UXTHEME_FUNCTION(PFNWXUDRAWTHEMEBACKGROUND, DrawThemeBackground);
126 RESOLVE_UXTHEME_FUNCTION(PFNWXUDRAWTHEMETEXT, DrawThemeText);
127 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEBACKGROUNDCONTENTRECT, GetThemeBackgroundContentRect);
128 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEBACKGROUNDEXTENT, GetThemeBackgroundExtent);
129 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEPARTSIZE, GetThemePartSize);
130 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMETEXTEXTENT, GetThemeTextExtent);
131 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMETEXTMETRICS, GetThemeTextMetrics);
132 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEBACKGROUNDREGION, GetThemeBackgroundRegion);
133 RESOLVE_UXTHEME_FUNCTION(PFNWXUHITTESTTHEMEBACKGROUND, HitTestThemeBackground);
134 RESOLVE_UXTHEME_FUNCTION(PFNWXUDRAWTHEMEEDGE, DrawThemeEdge);
135 RESOLVE_UXTHEME_FUNCTION(PFNWXUDRAWTHEMEICON, DrawThemeIcon);
136 RESOLVE_UXTHEME_FUNCTION(PFNWXUISTHEMEPARTDEFINED, IsThemePartDefined);
137 RESOLVE_UXTHEME_FUNCTION(PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT, IsThemeBackgroundPartiallyTransparent);
138 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMECOLOR, GetThemeColor);
139 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEMETRIC, GetThemeMetric);
140 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESTRING, GetThemeString);
141 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEBOOL, GetThemeBool);
142 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEINT, GetThemeInt);
143 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEENUMVALUE, GetThemeEnumValue);
144 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEPOSITION, GetThemePosition);
145 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEFONT, GetThemeFont);
146 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMERECT, GetThemeRect);
147 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEMARGINS, GetThemeMargins);
148 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEINTLIST, GetThemeIntList);
149 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEPROPERTYORIGIN, GetThemePropertyOrigin);
150 RESOLVE_UXTHEME_FUNCTION(PFNWXUSETWINDOWTHEME, SetWindowTheme);
151 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEFILENAME, GetThemeFilename);
152 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESYSCOLOR, GetThemeSysColor);
153 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESYSCOLORBRUSH, GetThemeSysColorBrush);
154 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESYSBOOL, GetThemeSysBool);
155 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESYSSIZE, GetThemeSysSize);
156 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESYSFONT, GetThemeSysFont);
157 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESYSSTRING, GetThemeSysString);
158 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESYSINT, GetThemeSysInt);
159 RESOLVE_UXTHEME_FUNCTION(PFNWXUISTHEMEACTIVE, IsThemeActive);
160 RESOLVE_UXTHEME_FUNCTION(PFNWXUISAPPTHEMED, IsAppThemed);
161 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETWINDOWTHEME, GetWindowTheme);
162 RESOLVE_UXTHEME_FUNCTION(PFNWXUENABLETHEMEDIALOGTEXTURE, EnableThemeDialogTexture);
163 RESOLVE_UXTHEME_FUNCTION(PFNWXUISTHEMEDIALOGTEXTUREENABLED, IsThemeDialogTextureEnabled);
164 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEAPPPROPERTIES, GetThemeAppProperties);
165 RESOLVE_UXTHEME_FUNCTION(PFNWXUSETTHEMEAPPPROPERTIES, SetThemeAppProperties);
166 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETCURRENTTHEMENAME, GetCurrentThemeName);
167 RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEDOCUMENTATIONPROPERTY, GetThemeDocumentationProperty);
168 RESOLVE_UXTHEME_FUNCTION(PFNWXUDRAWTHEMEPARENTBACKGROUND, DrawThemeParentBackground);
169 RESOLVE_UXTHEME_FUNCTION(PFNWXUENABLETHEMING, EnableTheming);
170
171#undef RESOLVE_UXTHEME_FUNCTION
172
173 return true;
0d1cb8cb
JS
174}
175
2d9c0e97 176#endif // wxUSE_UXTHEME