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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
18 #pragma interface "theme.h"
21 // ----------------------------------------------------------------------------
23 // ----------------------------------------------------------------------------
25 class WXDLLEXPORT wxRenderer
;
26 class WXDLLEXPORT wxColourScheme
;
27 class WXDLLEXPORT wxInputHandler
;
28 class WXDLLEXPORT wxArtProvider
;
29 struct WXDLLEXPORT wxThemeInfo
;
31 class WXDLLEXPORT wxTheme
37 // create the default theme
38 static bool CreateDefault();
40 // create the theme by name (will return NULL if not found)
41 static wxTheme
*Create(const wxString
& name
);
43 // change the current scheme
44 static wxTheme
*Set(wxTheme
*theme
);
46 // get the current theme (never NULL)
47 static wxTheme
*Get() { return ms_theme
; }
52 // get the renderer implementing all the control-drawing operations in
54 virtual wxRenderer
*GetRenderer() = 0;
56 // get the art provider to be used together with this theme
57 virtual wxArtProvider
*GetArtProvider() = 0;
59 // get the input handler of the given type
60 virtual wxInputHandler
*GetInputHandler(const wxString
& handlerType
) = 0;
62 // get the colour scheme for the control with this name
63 virtual wxColourScheme
*GetColourScheme() = 0;
65 // implementation only from now on
66 // -------------------------------
71 // the list of descriptions of all known themes
72 static wxThemeInfo
*ms_allThemes
;
75 static wxTheme
*ms_theme
;
76 friend struct WXDLLEXPORT wxThemeInfo
;
79 // ----------------------------------------------------------------------------
80 // dynamic theme creation helpers
81 // ----------------------------------------------------------------------------
83 struct WXDLLEXPORT wxThemeInfo
85 typedef wxTheme
*(*Constructor
)();
87 // theme name and (user readable) description
90 // the function to create a theme object
93 // next node in the linked list or NULL
96 // constructor for the struct itself
97 wxThemeInfo(Constructor ctor
, const wxChar
*name
, const wxChar
*desc
);
100 // ----------------------------------------------------------------------------
102 // ----------------------------------------------------------------------------
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) \
108 WXDLLEXPORT_DATA(extern bool) wxThemeUse##themename; \
109 static struct wxThemeUserFor##themename \
111 wxThemeUserFor##themename() { wxThemeUse##themename = TRUE; } \
112 } wxThemeDoUse##themename
114 // to declare a new theme, this macro must be used in the class declaration
115 #define WX_DECLARE_THEME(themename) \
117 static wxThemeInfo ms_info##themename; \
119 const wxThemeInfo *GetThemeInfo() const \
120 { return &ms_info##themename; }
122 // and this one must be inserted in the source file
123 #define WX_IMPLEMENT_THEME(classname, themename, themedesc) \
124 WXDLLEXPORT_DATA(bool) wxThemeUse##themename = TRUE; \
125 wxTheme *wxCtorFor##themename() { return new classname; } \
126 wxThemeInfo classname::ms_info##themename(wxCtorFor##themename, \
127 wxT( #themename ), themedesc)
129 #endif // _WX_UNIV_THEME_H_