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