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 extern WXDLLEXPORT_DATA(bool) wxThemeUse##themename; \
107 static struct wxThemeUserFor##themename \
109 wxThemeUserFor##themename() { wxThemeUse##themename = true; } \
110 } wxThemeDoUse##themename
112 // to declare a new theme, this macro must be used in the class declaration
113 #define WX_DECLARE_THEME(themename) \
115 static wxThemeInfo ms_info##themename; \
117 const wxThemeInfo *GetThemeInfo() const \
118 { return &ms_info##themename; }
120 // and this one must be inserted in the source file
121 #define WX_IMPLEMENT_THEME(classname, themename, themedesc) \
122 WXDLLEXPORT_DATA(bool) wxThemeUse##themename = true; \
123 wxTheme *wxCtorFor##themename() { return new classname; } \
124 wxThemeInfo classname::ms_info##themename(wxCtorFor##themename, \
125 wxT( #themename ), themedesc)
127 #endif // _WX_UNIV_THEME_H_