]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/theme.h
refactored common parts of DrawItem() in the base class; implemented GetTextTotal...
[wxWidgets.git] / include / wx / univ / theme.h
CommitLineData
1e6feb95
VZ
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$
442b35b5 10// Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
65571936 11// Licence: wxWindows licence
1e6feb95
VZ
12///////////////////////////////////////////////////////////////////////////////
13
14#ifndef _WX_UNIV_THEME_H_
15#define _WX_UNIV_THEME_H_
16
1e6feb95
VZ
17// ----------------------------------------------------------------------------
18// wxTheme
19// ----------------------------------------------------------------------------
20
9467bdb7 21class WXDLLEXPORT wxArtProvider;
1e6feb95 22class WXDLLEXPORT wxColourScheme;
9467bdb7 23class WXDLLEXPORT wxInputConsumer;
1e6feb95 24class WXDLLEXPORT wxInputHandler;
9467bdb7 25class WXDLLEXPORT wxRenderer;
1e6feb95
VZ
26struct WXDLLEXPORT wxThemeInfo;
27
28class WXDLLEXPORT wxTheme
29{
30public:
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;
ef359b43 52
536b70ac
VS
53 // get the art provider to be used together with this theme
54 virtual wxArtProvider *GetArtProvider() = 0;
1e6feb95 55
9467bdb7
VZ
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;
1e6feb95
VZ
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
68private:
69 // the list of descriptions of all known themes
70 static wxThemeInfo *ms_allThemes;
71
72 // the current theme
73 static wxTheme *ms_theme;
3ad252c9 74 friend struct WXDLLEXPORT wxThemeInfo;
1e6feb95
VZ
75};
76
77// ----------------------------------------------------------------------------
78// dynamic theme creation helpers
79// ----------------------------------------------------------------------------
80
81struct 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) \
ef359b43 106 extern WXDLLEXPORT_DATA(bool) wxThemeUse##themename; \
1e6feb95
VZ
107 static struct wxThemeUserFor##themename \
108 { \
a290fa5a 109 wxThemeUserFor##themename() { wxThemeUse##themename = true; } \
1e6feb95
VZ
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) \
a290fa5a 122 WXDLLEXPORT_DATA(bool) wxThemeUse##themename = true; \
1e6feb95
VZ
123 wxTheme *wxCtorFor##themename() { return new classname; } \
124 wxThemeInfo classname::ms_info##themename(wxCtorFor##themename, \
f63e248e 125 wxT( #themename ), themedesc)
1e6feb95
VZ
126
127#endif // _WX_UNIV_THEME_H_
128