]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/theme.h
use a virtual function instead of wxDynamicCast(wxMDIParentFrame) in wxFrame code...
[wxWidgets.git] / include / wx / univ / theme.h
CommitLineData
1e6feb95
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/univ/theme.h
3// Purpose: wxTheme class manages all configurable aspects of the
4// application including the look (wxRenderer), feel
5// (wxInputHandler) and the colours (wxColourScheme)
6// Author: Vadim Zeitlin
7// Modified by:
8// Created: 06.08.00
9// RCS-ID: $Id$
442b35b5 10// Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
65571936 11// Licence: wxWindows licence
1e6feb95
VZ
12///////////////////////////////////////////////////////////////////////////////
13
14#ifndef _WX_UNIV_THEME_H_
15#define _WX_UNIV_THEME_H_
16
3d5f724f
WS
17#include "wx/string.h"
18
1e6feb95
VZ
19// ----------------------------------------------------------------------------
20// wxTheme
21// ----------------------------------------------------------------------------
22
b5dbe15d
VS
23class WXDLLIMPEXP_FWD_CORE wxArtProvider;
24class WXDLLIMPEXP_FWD_CORE wxColourScheme;
25class WXDLLIMPEXP_FWD_CORE wxInputConsumer;
26class WXDLLIMPEXP_FWD_CORE wxInputHandler;
27class WXDLLIMPEXP_FWD_CORE wxRenderer;
28struct WXDLLIMPEXP_FWD_CORE wxThemeInfo;
1e6feb95 29
53a2db12 30class WXDLLIMPEXP_CORE wxTheme
1e6feb95
VZ
31{
32public:
33 // static methods
34 // --------------
35
36 // create the default theme
37 static bool CreateDefault();
38
39 // create the theme by name (will return NULL if not found)
40 static wxTheme *Create(const wxString& name);
41
42 // change the current scheme
43 static wxTheme *Set(wxTheme *theme);
44
45 // get the current theme (never NULL)
46 static wxTheme *Get() { return ms_theme; }
47
48 // the theme methods
49 // -----------------
50
51 // get the renderer implementing all the control-drawing operations in
52 // this theme
53 virtual wxRenderer *GetRenderer() = 0;
ef359b43 54
536b70ac
VS
55 // get the art provider to be used together with this theme
56 virtual wxArtProvider *GetArtProvider() = 0;
1e6feb95 57
9467bdb7
VZ
58 // get the input handler of the given type, forward to the standard one
59 virtual wxInputHandler *GetInputHandler(const wxString& handlerType,
60 wxInputConsumer *consumer) = 0;
1e6feb95
VZ
61
62 // get the colour scheme for the control with this name
63 virtual wxColourScheme *GetColourScheme() = 0;
64
65 // implementation only from now on
66 // -------------------------------
67
68 virtual ~wxTheme();
69
70private:
71 // the list of descriptions of all known themes
72 static wxThemeInfo *ms_allThemes;
73
74 // the current theme
75 static wxTheme *ms_theme;
b5dbe15d 76 friend struct wxThemeInfo;
1e6feb95
VZ
77};
78
eef1a0cc
VS
79// ----------------------------------------------------------------------------
80// wxDelegateTheme: it is impossible to inherit from any of standard
81// themes as their declarations are in private code, but you can use this
82// class to override only some of their functions - all the other ones
83// will be left to the original theme
84// ----------------------------------------------------------------------------
85
86class wxDelegateTheme : public wxTheme
87{
88public:
c2e45372 89 wxDelegateTheme(const wxString& theme);
eef1a0cc
VS
90 virtual ~wxDelegateTheme();
91
92 virtual wxRenderer *GetRenderer();
93 virtual wxArtProvider *GetArtProvider();
94 virtual wxInputHandler *GetInputHandler(const wxString& control,
95 wxInputConsumer *consumer);
96 virtual wxColourScheme *GetColourScheme();
97
98protected:
99 // gets or creates theme and sets m_theme to point to it,
100 // returns true on success
101 bool GetOrCreateTheme();
102
103 wxString m_themeName;
104 wxTheme *m_theme;
105};
106
1e6feb95
VZ
107// ----------------------------------------------------------------------------
108// dynamic theme creation helpers
109// ----------------------------------------------------------------------------
110
53a2db12 111struct WXDLLIMPEXP_CORE wxThemeInfo
1e6feb95
VZ
112{
113 typedef wxTheme *(*Constructor)();
114
115 // theme name and (user readable) description
116 wxString name, desc;
117
118 // the function to create a theme object
119 Constructor ctor;
120
121 // next node in the linked list or NULL
122 wxThemeInfo *next;
123
124 // constructor for the struct itself
c2e45372 125 wxThemeInfo(Constructor ctor, const wxString& name, const wxString& desc);
1e6feb95
VZ
126};
127
128// ----------------------------------------------------------------------------
129// macros
130// ----------------------------------------------------------------------------
131
132// to use a standard theme insert this macro into one of the application files:
133// without it, an over optimizing linker may discard the object module
134// containing the theme implementation entirely
135#define WX_USE_THEME(themename) \
ee92941a
VS
136 /* this indirection makes it possible to pass macro as the argument */ \
137 WX_USE_THEME_IMPL(themename)
138
139#define WX_USE_THEME_IMPL(themename) \
53a2db12 140 extern WXDLLIMPEXP_DATA_CORE(bool) wxThemeUse##themename; \
1e6feb95
VZ
141 static struct wxThemeUserFor##themename \
142 { \
a290fa5a 143 wxThemeUserFor##themename() { wxThemeUse##themename = true; } \
1e6feb95
VZ
144 } wxThemeDoUse##themename
145
146// to declare a new theme, this macro must be used in the class declaration
147#define WX_DECLARE_THEME(themename) \
148 private: \
149 static wxThemeInfo ms_info##themename; \
150 public: \
151 const wxThemeInfo *GetThemeInfo() const \
152 { return &ms_info##themename; }
153
154// and this one must be inserted in the source file
155#define WX_IMPLEMENT_THEME(classname, themename, themedesc) \
53a2db12 156 WXDLLIMPEXP_DATA_CORE(bool) wxThemeUse##themename = true; \
1e6feb95
VZ
157 wxTheme *wxCtorFor##themename() { return new classname; } \
158 wxThemeInfo classname::ms_info##themename(wxCtorFor##themename, \
f63e248e 159 wxT( #themename ), themedesc)
1e6feb95 160
ee92941a
VS
161// ----------------------------------------------------------------------------
162// determine default theme
163// ----------------------------------------------------------------------------
164
165#if wxUSE_ALL_THEMES
13f6c470 166 #undef wxUSE_THEME_WIN32
ee92941a 167 #define wxUSE_THEME_WIN32 1
13f6c470 168 #undef wxUSE_THEME_GTK
ee92941a 169 #define wxUSE_THEME_GTK 1
13f6c470 170 #undef wxUSE_THEME_MONO
ee92941a 171 #define wxUSE_THEME_MONO 1
13f6c470 172 #undef wxUSE_THEME_METAL
ee92941a
VS
173 #define wxUSE_THEME_METAL 1
174#endif // wxUSE_ALL_THEMES
175
176// determine the default theme to use:
177#if defined(__WXGTK__) && wxUSE_THEME_GTK
178 #define wxUNIV_DEFAULT_THEME gtk
179#elif defined(__WXDFB__) && wxUSE_THEME_MONO
180 // use mono theme for DirectFB port because it cannot correctly
181 // render neither win32 nor gtk themes yet:
182 #define wxUNIV_DEFAULT_THEME mono
183#endif
184
185// if no theme was picked, get any theme compiled in (sorted by
186// quality/completeness of the theme):
187#ifndef wxUNIV_DEFAULT_THEME
188 #if wxUSE_THEME_WIN32
189 #define wxUNIV_DEFAULT_THEME win32
190 #elif wxUSE_THEME_GTK
191 #define wxUNIV_DEFAULT_THEME gtk
192 #elif wxUSE_THEME_MONO
193 #define wxUNIV_DEFAULT_THEME mono
194 #endif
195 // If nothing matches, no themes are compiled and the app must provide
196 // some theme itself
197 // (note that wxUSE_THEME_METAL depends on win32 theme, so we don't have to
198 // try it)
199 //
200#endif // !wxUNIV_DEFAULT_THEME
1e6feb95 201
ee92941a 202#endif // _WX_UNIV_THEME_H_