]>
Commit | Line | Data |
---|---|---|
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 | ||
9467bdb7 | 23 | class WXDLLEXPORT wxArtProvider; |
1e6feb95 | 24 | class WXDLLEXPORT wxColourScheme; |
9467bdb7 | 25 | class WXDLLEXPORT wxInputConsumer; |
1e6feb95 | 26 | class WXDLLEXPORT wxInputHandler; |
9467bdb7 | 27 | class WXDLLEXPORT wxRenderer; |
1e6feb95 VZ |
28 | struct WXDLLEXPORT wxThemeInfo; |
29 | ||
30 | class WXDLLEXPORT wxTheme | |
31 | { | |
32 | public: | |
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 | ||
70 | private: | |
71 | // the list of descriptions of all known themes | |
72 | static wxThemeInfo *ms_allThemes; | |
73 | ||
74 | // the current theme | |
75 | static wxTheme *ms_theme; | |
3ad252c9 | 76 | friend struct WXDLLEXPORT wxThemeInfo; |
1e6feb95 VZ |
77 | }; |
78 | ||
79 | // ---------------------------------------------------------------------------- | |
80 | // dynamic theme creation helpers | |
81 | // ---------------------------------------------------------------------------- | |
82 | ||
83 | struct WXDLLEXPORT wxThemeInfo | |
84 | { | |
85 | typedef wxTheme *(*Constructor)(); | |
86 | ||
87 | // theme name and (user readable) description | |
88 | wxString name, desc; | |
89 | ||
90 | // the function to create a theme object | |
91 | Constructor ctor; | |
92 | ||
93 | // next node in the linked list or NULL | |
94 | wxThemeInfo *next; | |
95 | ||
96 | // constructor for the struct itself | |
97 | wxThemeInfo(Constructor ctor, const wxChar *name, const wxChar *desc); | |
98 | }; | |
99 | ||
100 | // ---------------------------------------------------------------------------- | |
101 | // macros | |
102 | // ---------------------------------------------------------------------------- | |
103 | ||
104 | // to use a standard theme insert this macro into one of the application files: | |
105 | // without it, an over optimizing linker may discard the object module | |
106 | // containing the theme implementation entirely | |
107 | #define WX_USE_THEME(themename) \ | |
ee92941a VS |
108 | /* this indirection makes it possible to pass macro as the argument */ \ |
109 | WX_USE_THEME_IMPL(themename) | |
110 | ||
111 | #define WX_USE_THEME_IMPL(themename) \ | |
ef359b43 | 112 | extern WXDLLEXPORT_DATA(bool) wxThemeUse##themename; \ |
1e6feb95 VZ |
113 | static struct wxThemeUserFor##themename \ |
114 | { \ | |
a290fa5a | 115 | wxThemeUserFor##themename() { wxThemeUse##themename = true; } \ |
1e6feb95 VZ |
116 | } wxThemeDoUse##themename |
117 | ||
118 | // to declare a new theme, this macro must be used in the class declaration | |
119 | #define WX_DECLARE_THEME(themename) \ | |
120 | private: \ | |
121 | static wxThemeInfo ms_info##themename; \ | |
122 | public: \ | |
123 | const wxThemeInfo *GetThemeInfo() const \ | |
124 | { return &ms_info##themename; } | |
125 | ||
126 | // and this one must be inserted in the source file | |
127 | #define WX_IMPLEMENT_THEME(classname, themename, themedesc) \ | |
a290fa5a | 128 | WXDLLEXPORT_DATA(bool) wxThemeUse##themename = true; \ |
1e6feb95 VZ |
129 | wxTheme *wxCtorFor##themename() { return new classname; } \ |
130 | wxThemeInfo classname::ms_info##themename(wxCtorFor##themename, \ | |
f63e248e | 131 | wxT( #themename ), themedesc) |
1e6feb95 | 132 | |
ee92941a VS |
133 | // ---------------------------------------------------------------------------- |
134 | // determine default theme | |
135 | // ---------------------------------------------------------------------------- | |
136 | ||
137 | #if wxUSE_ALL_THEMES | |
13f6c470 | 138 | #undef wxUSE_THEME_WIN32 |
ee92941a | 139 | #define wxUSE_THEME_WIN32 1 |
13f6c470 | 140 | #undef wxUSE_THEME_GTK |
ee92941a | 141 | #define wxUSE_THEME_GTK 1 |
13f6c470 | 142 | #undef wxUSE_THEME_MONO |
ee92941a | 143 | #define wxUSE_THEME_MONO 1 |
13f6c470 | 144 | #undef wxUSE_THEME_METAL |
ee92941a VS |
145 | #define wxUSE_THEME_METAL 1 |
146 | #endif // wxUSE_ALL_THEMES | |
147 | ||
148 | // determine the default theme to use: | |
149 | #if defined(__WXGTK__) && wxUSE_THEME_GTK | |
150 | #define wxUNIV_DEFAULT_THEME gtk | |
151 | #elif defined(__WXDFB__) && wxUSE_THEME_MONO | |
152 | // use mono theme for DirectFB port because it cannot correctly | |
153 | // render neither win32 nor gtk themes yet: | |
154 | #define wxUNIV_DEFAULT_THEME mono | |
155 | #endif | |
156 | ||
157 | // if no theme was picked, get any theme compiled in (sorted by | |
158 | // quality/completeness of the theme): | |
159 | #ifndef wxUNIV_DEFAULT_THEME | |
160 | #if wxUSE_THEME_WIN32 | |
161 | #define wxUNIV_DEFAULT_THEME win32 | |
162 | #elif wxUSE_THEME_GTK | |
163 | #define wxUNIV_DEFAULT_THEME gtk | |
164 | #elif wxUSE_THEME_MONO | |
165 | #define wxUNIV_DEFAULT_THEME mono | |
166 | #endif | |
167 | // If nothing matches, no themes are compiled and the app must provide | |
168 | // some theme itself | |
169 | // (note that wxUSE_THEME_METAL depends on win32 theme, so we don't have to | |
170 | // try it) | |
171 | // | |
172 | #endif // !wxUNIV_DEFAULT_THEME | |
1e6feb95 | 173 | |
ee92941a | 174 | #endif // _WX_UNIV_THEME_H_ |