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
10 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
11 // Licence: wxWindows licence
12 ///////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_UNIV_THEME_H_
15 #define _WX_UNIV_THEME_H_
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
21 class WXDLLEXPORT wxArtProvider
;
22 class WXDLLEXPORT wxColourScheme
;
23 class WXDLLEXPORT wxInputConsumer
;
24 class WXDLLEXPORT wxInputHandler
;
25 class WXDLLEXPORT wxRenderer
;
26 struct WXDLLEXPORT wxThemeInfo
;
28 class WXDLLEXPORT wxTheme
34 // create the default theme
35 static bool CreateDefault();
37 // create the theme by name (will return NULL if not found)
38 static wxTheme
*Create(const wxString
& name
);
40 // change the current scheme
41 static wxTheme
*Set(wxTheme
*theme
);
43 // get the current theme (never NULL)
44 static wxTheme
*Get() { return ms_theme
; }
49 // get the renderer implementing all the control-drawing operations in
51 virtual wxRenderer
*GetRenderer() = 0;
53 // get the art provider to be used together with this theme
54 virtual wxArtProvider
*GetArtProvider() = 0;
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;
60 // get the colour scheme for the control with this name
61 virtual wxColourScheme
*GetColourScheme() = 0;
63 // implementation only from now on
64 // -------------------------------
69 // the list of descriptions of all known themes
70 static wxThemeInfo
*ms_allThemes
;
73 static wxTheme
*ms_theme
;
74 friend struct WXDLLEXPORT wxThemeInfo
;
77 // ----------------------------------------------------------------------------
78 // dynamic theme creation helpers
79 // ----------------------------------------------------------------------------
81 struct WXDLLEXPORT wxThemeInfo
83 typedef wxTheme
*(*Constructor
)();
85 // theme name and (user readable) description
88 // the function to create a theme object
91 // next node in the linked list or NULL
94 // constructor for the struct itself
95 wxThemeInfo(Constructor ctor
, const wxChar
*name
, const wxChar
*desc
);
98 // ----------------------------------------------------------------------------
100 // ----------------------------------------------------------------------------
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)
109 #define WX_USE_THEME_IMPL(themename) \
110 extern WXDLLEXPORT_DATA(bool) wxThemeUse##themename; \
111 static struct wxThemeUserFor##themename \
113 wxThemeUserFor##themename() { wxThemeUse##themename = true; } \
114 } wxThemeDoUse##themename
116 // to declare a new theme, this macro must be used in the class declaration
117 #define WX_DECLARE_THEME(themename) \
119 static wxThemeInfo ms_info##themename; \
121 const wxThemeInfo *GetThemeInfo() const \
122 { return &ms_info##themename; }
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)
131 // ----------------------------------------------------------------------------
132 // determine default theme
133 // ----------------------------------------------------------------------------
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
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
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
165 // If nothing matches, no themes are compiled and the app must provide
167 // (note that wxUSE_THEME_METAL depends on win32 theme, so we don't have to
170 #endif // !wxUNIV_DEFAULT_THEME
172 #endif // _WX_UNIV_THEME_H_