]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/theme.h
wrap print headers at top level
[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 extern WXDLLEXPORT_DATA(bool) wxThemeUse##themename; \
107 static struct wxThemeUserFor##themename \
108 { \
109 wxThemeUserFor##themename() { wxThemeUse##themename = true; } \
110 } wxThemeDoUse##themename
111
112 // to declare a new theme, this macro must be used in the class declaration
113 #define WX_DECLARE_THEME(themename) \
114 private: \
115 static wxThemeInfo ms_info##themename; \
116 public: \
117 const wxThemeInfo *GetThemeInfo() const \
118 { return &ms_info##themename; }
119
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)
126
127 #endif // _WX_UNIV_THEME_H_
128