]> git.saurik.com Git - wxWidgets.git/blob - interface/renderer.h
adjusted indentation with astyle; added Id keyword
[wxWidgets.git] / interface / renderer.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: renderer.h
3 // Purpose: documentation for wxSplitterRenderParams class
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxSplitterRenderParams
11 @wxheader{renderer.h}
12
13 This is just a simple @c struct used as a return value of
14 wxRendererNative::GetSplitterParams.
15
16 It doesn't have any methods and all of its fields are constant and so can be
17 only examined but not modified.
18
19 @library{wxbase}
20 @category{FIXME}
21 */
22 class wxSplitterRenderParams
23 {
24 public:
25 /**
26 const wxCoord border
27
28 The width of the border drawn by the splitter inside it, may be 0.
29 */
30
31
32 /**
33 const bool isHotSensitive
34
35 @true if the sash changes appearance when the mouse passes over it, @false
36 otherwise.
37 */
38
39
40 /**
41 const wxCoord widthSash
42
43 The width of the splitter sash.
44 */
45 };
46
47
48 /**
49 @class wxDelegateRendererNative
50 @wxheader{renderer.h}
51
52 wxDelegateRendererNative allows reuse of renderers code by forwarding all the
53 wxRendererNative methods to the given object and
54 thus allowing you to only modify some of its methods -- without having to
55 reimplement all of them.
56
57 Note that the "normal'', inheritance-based approach, doesn't work with the
58 renderers as it is impossible to derive from a class unknown at compile-time
59 and the renderer is only chosen at run-time. So suppose that you want to only
60 add something to the drawing of the tree control buttons but leave all the
61 other methods unchanged -- the only way to do it, considering that the renderer
62 class which you want to customize might not even be written yet when you write
63 your code (it could be written later and loaded from a DLL during run-time), is
64 by using this class.
65
66 Except for the constructor, it has exactly the same methods as
67 wxRendererNative and their implementation is
68 trivial: they are simply forwarded to the real renderer. Note that the "real''
69 renderer may, in turn, be a wxDelegateRendererNative as well and that there may
70 be arbitrarily many levels like this -- but at the end of the chain there must
71 be a real renderer which does the drawing.
72
73 @library{wxcore}
74 @category{FIXME}
75 */
76 class wxDelegateRendererNative : public wxRendererNative
77 {
78 public:
79 //@{
80 /**
81 The default constructor does the same thing as the other one except that it
82 uses the @ref wxRendererNative::getgeneric "generic renderer" instead of the
83 user-specified @e rendererNative.
84
85 In any case, this sets up the delegate renderer object to follow all calls to
86 the specified real renderer.
87
88 Note that this object does not take ownership of (i.e. won't delete)
89 @e rendererNative.
90 */
91 wxDelegateRendererNative();
92 wxDelegateRendererNative(wxRendererNative& rendererNative);
93 //@}
94
95 /**
96 This class also provides all the virtual methods of
97 wxRendererNative, please refer to that class
98 documentation for the details.
99 */
100 DrawXXX(...);
101 };
102
103
104 /**
105 @class wxRendererNative
106 @wxheader{renderer.h}
107
108 First, a brief introduction to wxRenderer and why it is needed.
109
110 Usually wxWidgets uses the underlying low level GUI system to draw all the
111 controls - this is what we mean when we say that it is a "native'' framework.
112 However not all controls exist under all (or even any) platforms and in this
113 case wxWidgets provides a default, generic, implementation of them written in
114 wxWidgets itself.
115
116 These controls don't have the native appearance if only the standard
117 line drawing and other graphics primitives are used, because the native
118 appearance is different under different platforms while the lines are always
119 drawn in the same way.
120
121 This is why we have renderers: wxRenderer is a class which virtualizes the
122 drawing, i.e. it abstracts the drawing operations and allows you to draw say, a
123 button, without caring about exactly how this is done. Of course, as we
124 can draw the button differently in different renderers, this also allows us to
125 emulate the native look and feel.
126
127 So the renderers work by exposing a large set of high-level drawing functions
128 which are used by the generic controls. There is always a default global
129 renderer but it may be changed or extended by the user, see
130 @ref overview_samplerender "Render sample".
131
132 All drawing functions take some standard parameters:
133
134 @e win is the window being drawn. It is normally not used and when
135 it is it should only be used as a generic wxWindow
136 (in order to get its low level handle, for example), but you should
137 not assume that it is of some given type as the same renderer
138 function may be reused for drawing different kinds of control.
139 @e dc is the wxDC to draw on. Only this device
140 context should be used for drawing. It is not necessary to restore
141 pens and brushes for it on function exit but, on the other hand, you
142 shouldn't assume that it is in any specific state on function entry:
143 the rendering functions should always prepare it.
144 @e rect the bounding rectangle for the element to be drawn.
145 @e flags the optional flags (none by default) which can be a
146 combination of the @c wxCONTROL_XXX constants below.
147
148 Note that each drawing function restores the wxDC attributes if
149 it changes them, so it is safe to assume that the same pen, brush and colours
150 that were active before the call to this function are still in effect after it.
151
152 @library{wxcore}
153 @category{gdi}
154 */
155 class wxRendererNative
156 {
157 public:
158 /**
159 Virtual destructor as for any base class.
160 */
161 ~wxRendererNative();
162
163 /**
164 Draw a check box (used by wxDataViewCtrl).
165
166 @e flags may have the @c wxCONTROL_CHECKED, @c wxCONTROL_CURRENT or
167 @c wxCONTROL_UNDETERMINED bit set.
168 */
169 void DrawCheckBox(wxWindow * win, wxDC& dc, const wxRect& rect,
170 int flags);
171
172 /**
173 Draw a button like the one used by wxComboBox to show a
174 drop down window. The usual appearance is a downwards pointing arrow.
175
176 @e flags may have the @c wxCONTROL_PRESSED or @c wxCONTROL_CURRENT bit set.
177 */
178 void DrawComboBoxDropButton(wxWindow * win, wxDC& dc,
179 const wxRect& rect,
180 int flags);
181
182 /**
183 Draw a drop down arrow that is suitable for use outside a combo box. Arrow will
184 have
185 transparent background.
186
187 @e rect is not entirely filled by the arrow. Instead, you should use bounding
188 rectangle of a drop down button which arrow matches the size you need.
189 @e flags may have the @c wxCONTROL_PRESSED or @c wxCONTROL_CURRENT bit set.
190 */
191 void DrawDropArrow(wxWindow * win, wxDC& dc, const wxRect& rect,
192 int flags);
193
194 /**
195 Draw a focus rectangle using the specified rectangle.
196 wxListCtrl. The only supported flags is
197 @c wxCONTROL_SELECTED for items which are selected.
198 */
199 void DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect,
200 int flags = 0);
201
202 /**
203 Draw the header control button (used, for example, by
204 wxListCtrl). Depending on platforms the
205 @e flags parameter may support the @c wxCONTROL_SELECTED
206 @c wxCONTROL_DISABLED and @c wxCONTROL_CURRENT bits.
207 The @e sortArrow parameter can be one of
208 @c wxHDR_SORT_ICON_NONE, @c wxHDR_SORT_ICON_UP, or
209 @c wxHDR_SORT_ICON_DOWN. Additional values controlling the
210 drawing of a text or bitmap label can be passed in @e params. The
211 value returned is the optimal width to contain the the unabreviated
212 label text or bitmap, the sort arrow if present, and internal margins.
213 */
214 int DrawHeaderButton(wxWindow* win, wxDC& dc, const wxRect& rect,
215 int flags = 0,
216 wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
217 wxHeaderButtonParams* params = @NULL);
218
219 /**
220 Draw a selection rectangle underneath the text as used e.g. in a
221 wxListCtrl. The supported @e flags are
222 @c wxCONTROL_SELECTED for items which are selected (e.g. often a blue
223 rectangle) and @c wxCONTROL_CURRENT for the item that has the focus
224 (often a dotted line around the item's text). @c wxCONTROL_FOCUSED may
225 be used to indicate if the control has the focus (othewise the the selection
226 rectangle is e.g. often grey and not blue). This may be ignored by the renderer
227 or deduced by the code directly from the @e win.
228 */
229 void DrawItemSelectionRect(wxWindow* win, wxDC& dc,
230 const wxRect& rect,
231 int flags = 0);
232
233 /**
234 Draw a blank push button that looks very similar to wxButton.
235
236 @e flags may have the @c wxCONTROL_PRESSED, @c wxCONTROL_CURRENT or
237 @c wxCONTROL_ISDEFAULT bit set.
238 */
239 void DrawPushButton(wxWindow * win, wxDC& dc, const wxRect& rect,
240 int flags);
241
242 /**
243 Draw the border for sash window: this border must be such that the sash
244 drawn by @ref drawsplittersash() DrawSash blends into it
245 well.
246 */
247 void DrawSplitterBorder(wxWindow* win, wxDC& dc,
248 const wxRect& rect,
249 int flags = 0);
250
251 /**
252 Draw a sash. The @e orient parameter defines whether the sash should be
253 vertical or horizontal and how the @e position should be interpreted.
254 */
255 void DrawSplitterSash(wxWindow* win, wxDC& dc,
256 const wxSize& size,
257 wxCoord position,
258 wxOrientation orient,
259 int flags = 0);
260
261 /**
262 Draw the expanded/collapsed icon for a tree control item. To draw an expanded
263 button the @e flags parameter must contain @c wxCONTROL_EXPANDED bit.
264 */
265 void DrawTreeItemButton(wxWindow* win, wxDC& dc,
266 const wxRect& rect,
267 int flags = 0);
268
269 /**
270 Return the currently used renderer.
271 */
272 #define wxRendererNative Get() /* implementation is private */
273
274 /**
275 Return the default (native) implementation for this platform -- this is also
276 the one used by default but this may be changed by calling
277 Set() in which case the return value of this
278 method may be different from the return value of Get().
279 */
280 wxRendererNative GetDefault();
281
282 /**
283 Return the generic implementation of the renderer. Under some platforms, this
284 is the default renderer implementation, others have platform-specific default
285 renderer which can be retrieved by calling GetDefault().
286 */
287 wxRendererNative GetGeneric();
288
289 /**
290 Returns the height of a header button, either a fixed platform height if
291 available, or a
292 generic height based on the window's font.
293 */
294 int GetHeaderButtonHeight(const wxWindow* win);
295
296 /**
297 Get the splitter parameters, see
298 wxSplitterRenderParams.
299 */
300 wxSplitterRenderParams GetSplitterParams(const wxWindow* win);
301
302 /**
303 This function is used for version checking: Load()
304 refuses to load any shared libraries implementing an older or incompatible
305 version.
306
307 The implementation of this method is always the same in all renderers (simply
308 construct wxRendererVersion using the
309 @c wxRendererVersion::Current_XXX values), but it has to be in the derived,
310 not base, class, to detect mismatches between the renderers versions and so you
311 have to implement it anew in all renderers.
312 */
313 wxRendererVersion GetVersion();
314
315 /**
316 Load the renderer from the specified DLL, the returned pointer must be
317 deleted by caller if not @NULL when it is not used any more.
318
319 The @e name should be just the base name of the renderer and not the full
320 name of the DLL file which is constructed differently (using
321 wxDynamicLibrary::CanonicalizePluginName)
322 on different systems.
323 */
324 wxRendererNative* Load(const wxString& name);
325
326 /**
327 Set the renderer to use, passing @NULL reverts to using the default
328 renderer (the global renderer must always exist).
329
330 Return the previous renderer used with Set() or @NULL if none.
331 */
332 #define wxRendererNative* Set(wxRendererNative* renderer) /* implementation is private */
333 };
334
335
336 /**
337 @class wxRendererVersion
338 @wxheader{renderer.h}
339
340 This simple struct represents the wxRendererNative
341 interface version and is only used as the return value of
342 wxRendererNative::GetVersion.
343
344 The version has two components: the version itself and the age. If the main
345 program and the renderer have different versions they are never compatible with
346 each other because the version is only changed when an existing virtual
347 function is modified or removed. The age, on the other hand, is incremented
348 each time a new virtual method is added and so, at least for the compilers
349 using a common C++ object model, the calling program is compatible with any
350 renderer which has the age greater or equal to its age. This verification is
351 done by IsCompatible method.
352
353 @library{wxbase}
354 @category{FIXME}
355 */
356 class wxRendererVersion
357 {
358 public:
359 /**
360 Checks if the main program is compatible with the renderer having the version
361 @e ver, returns @true if it is and @false otherwise.
362
363 This method is used by
364 wxRendererNative::Load to determine whether a
365 renderer can be used.
366 */
367 static bool IsCompatible(const wxRendererVersion& ver);
368
369 /**
370 const int age
371
372 The age component.
373 */
374
375
376 /**
377 const int version
378
379 The version component.
380 */
381 };