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