]> git.saurik.com Git - wxWidgets.git/blob - include/wx/renderer.h
added wxVListBox::OnDrawBackground(); fixed warnings
[wxWidgets.git] / include / wx / renderer.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/renderer.h
3 // Purpose: wxRendererNative class declaration
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 20.07.2003
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 /*
13 Renderers are used in wxWindows for two similar but different things:
14 (a) wxUniversal uses them to draw everything, i.e. all the control
15 (b) all the native ports use them to draw generic controls only
16
17 wxUniversal needs more functionality than what is included in the base class
18 as it needs to draw stuff like scrollbars which are never going to be
19 generic. So we put the bare minimum needed by the native ports here and the
20 full wxRenderer class is declared in wx/univ/renderer.h and is only used by
21 wxUniveral (although note that native ports can load wxRenderer objects from
22 theme DLLs and use them as wxRendererNative ones, of course).
23 */
24
25 #ifndef _WX_RENDERER_H_
26 #define _WX_RENDERER_H_
27
28 class WXDLLEXPORT wxDC;
29 class WXDLLEXPORT wxWindow;
30
31 #include "wx/gdicmn.h" // for wxPoint
32
33 // some platforms have their own renderers, others use the generic one
34 #if defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXGTK__)
35 #define wxHAS_NATIVE_RENDERER
36 #else
37 #undef wxHAS_NATIVE_RENDERER
38 #endif
39
40 // ----------------------------------------------------------------------------
41 // constants
42 // ----------------------------------------------------------------------------
43
44 // control state flags used in wxRenderer and wxColourScheme
45 enum
46 {
47 wxCONTROL_DISABLED = 0x00000001, // control is disabled
48 wxCONTROL_FOCUSED = 0x00000002, // currently has keyboard focus
49 wxCONTROL_PRESSED = 0x00000004, // (button) is pressed
50 wxCONTROL_ISDEFAULT = 0x00000008, // only applies to the buttons
51 wxCONTROL_ISSUBMENU = wxCONTROL_ISDEFAULT, // only for menu items
52 wxCONTROL_EXPANDED = wxCONTROL_ISDEFAULT, // only for the tree items
53 wxCONTROL_CURRENT = 0x00000010, // mouse is currently over the control
54 wxCONTROL_SELECTED = 0x00000020, // selected item in e.g. listbox
55 wxCONTROL_CHECKED = 0x00000040, // (check/radio button) is checked
56 wxCONTROL_CHECKABLE = 0x00000080, // (menu) item can be checked
57
58 wxCONTROL_FLAGS_MASK = 0x000000ff,
59
60 // this is a pseudo flag not used directly by wxRenderer but rather by some
61 // controls internally
62 wxCONTROL_DIRTY = 0x80000000
63 };
64
65 // ----------------------------------------------------------------------------
66 // wxRendererNative: abstracts drawing methods needed by the native controls
67 // ----------------------------------------------------------------------------
68
69 class WXDLLEXPORT wxRendererNative
70 {
71 public:
72 virtual ~wxRendererNative() { } // stop GCC warning
73
74 // drawing functions
75 // -----------------
76
77 // draw the header control button (used by wxListCtrl)
78 virtual void DrawHeaderButton(wxWindow *win,
79 wxDC& dc,
80 const wxRect& rect,
81 int flags = 0) = 0;
82
83 // draw the expanded/collapsed icon for a tree control item
84 virtual void DrawTreeItemButton(wxWindow *win,
85 wxDC& dc,
86 const wxRect& rect,
87 int flags = 0) = 0;
88
89 // draw the border for sash window: this border must be such that the sash
90 // drawn by DrawSash() blends into it well
91 virtual void DrawSplitterBorder(wxWindow *win,
92 wxDC& dc,
93 const wxRect& rect) = 0;
94
95 // draw a (vertical) sash
96 virtual void DrawSplitterSash(wxWindow *win,
97 wxDC& dc,
98 const wxSize& size,
99 wxCoord position,
100 wxOrientation orient) = 0;
101
102
103 // geometry functions
104 // ------------------
105
106 // get the splitter parameters: the x field of the returned point is the
107 // sash width and the y field is the border width
108 virtual wxPoint GetSplitterSashAndBorder(const wxWindow *win) = 0;
109
110
111 // pseudo constructors
112 // -------------------
113
114 // return the currently used renderer
115 static wxRendererNative& Get();
116
117 // return the generic implementation of the renderer
118 static wxRendererNative& GetGeneric();
119
120 // return the default (native) implementation for this platform
121 static wxRendererNative& GetDefault();
122 };
123
124 // ----------------------------------------------------------------------------
125 // wxDelegateRendererNative: allows reuse of renderers code
126 // ----------------------------------------------------------------------------
127
128 class WXDLLEXPORT wxDelegateRendererNative : public wxRendererNative
129 {
130 public:
131 wxDelegateRendererNative()
132 : m_rendererNative(GetGeneric()) { }
133
134 wxDelegateRendererNative(wxRendererNative& rendererNative)
135 : m_rendererNative(rendererNative) { }
136
137
138 virtual void DrawHeaderButton(wxWindow *win,
139 wxDC& dc,
140 const wxRect& rect,
141 int flags = 0)
142 { m_rendererNative.DrawHeaderButton(win, dc, rect, flags); }
143
144 virtual void DrawTreeItemButton(wxWindow *win,
145 wxDC& dc,
146 const wxRect& rect,
147 int flags = 0)
148 { m_rendererNative.DrawTreeItemButton(win, dc, rect, flags); }
149
150 virtual void DrawSplitterBorder(wxWindow *win,
151 wxDC& dc,
152 const wxRect& rect)
153 { m_rendererNative.DrawSplitterBorder(win, dc, rect); }
154
155 virtual void DrawSplitterSash(wxWindow *win,
156 wxDC& dc,
157 const wxSize& size,
158 wxCoord position,
159 wxOrientation orient)
160 { m_rendererNative.DrawSplitterSash(win, dc, size, position, orient); }
161
162
163 virtual wxPoint GetSplitterSashAndBorder(const wxWindow *win)
164 { return m_rendererNative.GetSplitterSashAndBorder(win); }
165
166 protected:
167 wxRendererNative& m_rendererNative;
168
169 DECLARE_NO_COPY_CLASS(wxDelegateRendererNative)
170 };
171
172 // ----------------------------------------------------------------------------
173 // inline functions implementation
174 // ----------------------------------------------------------------------------
175
176 #ifndef wxHAS_NATIVE_RENDERER
177
178 // default native renderer is the generic one then
179 /* static */ inline
180 wxRendererNative& wxRendererNative::GetDefault()
181 {
182 return GetGeneric();
183 }
184
185 #endif // !wxHAS_NATIVE_RENDERER
186
187 #endif // _WX_RENDERER_H_
188