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 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
11 // Licence: wxWindows license
12 ///////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_UNIV_THEME_H_
15 #define _WX_UNIV_THEME_H_
18 #pragma interface "theme.h"
21 // ----------------------------------------------------------------------------
23 // ----------------------------------------------------------------------------
25 class WXDLLEXPORT wxRenderer
;
26 class WXDLLEXPORT wxColourScheme
;
27 class WXDLLEXPORT wxInputHandler
;
28 struct WXDLLEXPORT wxThemeInfo
;
30 class WXDLLEXPORT wxTheme
36 // create the default theme
37 static bool CreateDefault();
39 // create the theme by name (will return NULL if not found)
40 static wxTheme
*Create(const wxString
& name
);
42 // change the current scheme
43 static wxTheme
*Set(wxTheme
*theme
);
45 // get the current theme (never NULL)
46 static wxTheme
*Get() { return ms_theme
; }
51 // get the renderer implementing all the control-drawing operations in
53 virtual wxRenderer
*GetRenderer() = 0;
55 // get the input handler of the given type
56 virtual wxInputHandler
*GetInputHandler(const wxString
& handlerType
) = 0;
58 // get the colour scheme for the control with this name
59 virtual wxColourScheme
*GetColourScheme() = 0;
61 // implementation only from now on
62 // -------------------------------
67 // the list of descriptions of all known themes
68 static wxThemeInfo
*ms_allThemes
;
71 static wxTheme
*ms_theme
;
76 // ----------------------------------------------------------------------------
77 // dynamic theme creation helpers
78 // ----------------------------------------------------------------------------
80 struct WXDLLEXPORT wxThemeInfo
82 typedef wxTheme
*(*Constructor
)();
84 // theme name and (user readable) description
87 // the function to create a theme object
90 // next node in the linked list or NULL
93 // constructor for the struct itself
94 wxThemeInfo(Constructor ctor
, const wxChar
*name
, const wxChar
*desc
);
97 // ----------------------------------------------------------------------------
99 // ----------------------------------------------------------------------------
101 // to use a standard theme insert this macro into one of the application files:
102 // without it, an over optimizing linker may discard the object module
103 // containing the theme implementation entirely
104 #define WX_USE_THEME(themename) \
105 extern bool wxThemeUse##themename; \
106 static struct wxThemeUserFor##themename \
108 wxThemeUserFor##themename() { wxThemeUse##themename = TRUE; } \
109 } wxThemeDoUse##themename
111 // to declare a new theme, this macro must be used in the class declaration
112 #define WX_DECLARE_THEME(themename) \
114 static wxThemeInfo ms_info##themename; \
116 const wxThemeInfo *GetThemeInfo() const \
117 { return &ms_info##themename; }
119 // and this one must be inserted in the source file
120 #define WX_IMPLEMENT_THEME(classname, themename, themedesc) \
121 bool wxThemeUse##themename = TRUE; \
122 wxTheme *wxCtorFor##themename() { return new classname; } \
123 wxThemeInfo classname::ms_info##themename(wxCtorFor##themename, \
124 #themename, themedesc)
126 #endif // _WX_UNIV_THEME_H_