1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxSplitterRenderParams class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxSplitterRenderParams
13 This is just a simple @c struct used as a return value of
14 wxRendererNative::GetSplitterParams.
16 It doesn't have any methods and all of its fields are constant and so can be
17 only examined but not modified.
22 class wxSplitterRenderParams
27 The width of the border drawn by the splitter inside it, may be 0.
32 const bool isHotSensitive
33 @true if the sash changes appearance when the mouse passes over it, @false
39 const wxCoord widthSash
40 The width of the splitter sash.
46 @class wxDelegateRendererNative
49 wxDelegateRendererNative allows reuse of renderers code by forwarding all the
50 wxRendererNative methods to the given object and
51 thus allowing you to only modify some of its methods -- without having to
52 reimplement all of them.
54 Note that the "normal'', inheritance-based approach, doesn't work with the
55 renderers as it is impossible to derive from a class unknown at compile-time
56 and the renderer is only chosen at run-time. So suppose that you want to only
57 add something to the drawing of the tree control buttons but leave all the
58 other methods unchanged -- the only way to do it, considering that the renderer
59 class which you want to customize might not even be written yet when you write
60 your code (it could be written later and loaded from a DLL during run-time), is
63 Except for the constructor, it has exactly the same methods as
64 wxRendererNative and their implementation is
65 trivial: they are simply forwarded to the real renderer. Note that the "real''
66 renderer may, in turn, be a wxDelegateRendererNative as well and that there may
67 be arbitrarily many levels like this -- but at the end of the chain there must
68 be a real renderer which does the drawing.
73 class wxDelegateRendererNative
: public wxRendererNative
78 The default constructor does the same thing as the other one except that it
79 uses the @ref wxRendererNative::getgeneric "generic renderer" instead of the
80 user-specified @e rendererNative.
81 In any case, this sets up the delegate renderer object to follow all calls to
82 the specified real renderer.
83 Note that this object does not take ownership of (i.e. won't delete)
86 wxDelegateRendererNative();
87 wxDelegateRendererNative(wxRendererNative
& rendererNative
);
91 This class also provides all the virtual methods of
92 wxRendererNative, please refer to that class
93 documentation for the details.
100 @class wxRendererNative
101 @wxheader{renderer.h}
103 First, a brief introduction to wxRenderer and why it is needed.
105 Usually wxWidgets uses the underlying low level GUI system to draw all the
106 controls - this is what we mean when we say that it is a "native'' framework.
107 However not all controls exist under all (or even any) platforms and in this
108 case wxWidgets provides a default, generic, implementation of them written in
111 These controls don't have the native appearance if only the standard
112 line drawing and other graphics primitives are used, because the native
113 appearance is different under different platforms while the lines are always
114 drawn in the same way.
116 This is why we have renderers: wxRenderer is a class which virtualizes the
117 drawing, i.e. it abstracts the drawing operations and allows you to draw say, a
118 button, without caring about exactly how this is done. Of course, as we
119 can draw the button differently in different renderers, this also allows us to
120 emulate the native look and feel.
122 So the renderers work by exposing a large set of high-level drawing functions
123 which are used by the generic controls. There is always a default global
124 renderer but it may be changed or extended by the user, see
125 @ref overview_samplerender "Render sample".
127 All drawing functions take some standard parameters:
129 @e win is the window being drawn. It is normally not used and when
130 it is it should only be used as a generic wxWindow
131 (in order to get its low level handle, for example), but you should
132 not assume that it is of some given type as the same renderer
133 function may be reused for drawing different kinds of control.
134 @e dc is the wxDC to draw on. Only this device
135 context should be used for drawing. It is not necessary to restore
136 pens and brushes for it on function exit but, on the other hand, you
137 shouldn't assume that it is in any specific state on function entry:
138 the rendering functions should always prepare it.
139 @e rect the bounding rectangle for the element to be drawn.
140 @e flags the optional flags (none by default) which can be a
141 combination of the @c wxCONTROL_XXX constants below.
143 Note that each drawing function restores the wxDC attributes if
144 it changes them, so it is safe to assume that the same pen, brush and colours
145 that were active before the call to this function are still in effect after it.
150 class wxRendererNative
154 Virtual destructor as for any base class.
159 Draw a check box (used by wxDataViewCtrl).
160 @a flags may have the @c wxCONTROL_CHECKED, @c wxCONTROL_CURRENT or
161 @c wxCONTROL_UNDETERMINED bit set.
163 void DrawCheckBox(wxWindow
* win
, wxDC
& dc
, const wxRect
& rect
,
167 Draw a button like the one used by wxComboBox to show a
168 drop down window. The usual appearance is a downwards pointing arrow.
169 @a flags may have the @c wxCONTROL_PRESSED or @c wxCONTROL_CURRENT bit set.
171 void DrawComboBoxDropButton(wxWindow
* win
, wxDC
& dc
,
176 Draw a drop down arrow that is suitable for use outside a combo box. Arrow will
178 transparent background.
179 @a rect is not entirely filled by the arrow. Instead, you should use bounding
180 rectangle of a drop down button which arrow matches the size you need.
181 @a flags may have the @c wxCONTROL_PRESSED or @c wxCONTROL_CURRENT bit set.
183 void DrawDropArrow(wxWindow
* win
, wxDC
& dc
, const wxRect
& rect
,
187 Draw a focus rectangle using the specified rectangle.
188 wxListCtrl. The only supported flags is
189 @c wxCONTROL_SELECTED for items which are selected.
191 void DrawFocusRect(wxWindow
* win
, wxDC
& dc
, const wxRect
& rect
,
195 Draw the header control button (used, for example, by
196 wxListCtrl). Depending on platforms the
197 @a flags parameter may support the @c wxCONTROL_SELECTED
198 @c wxCONTROL_DISABLED and @c wxCONTROL_CURRENT bits.
199 The @a sortArrow parameter can be one of
200 @c wxHDR_SORT_ICON_NONE, @c wxHDR_SORT_ICON_UP, or
201 @c wxHDR_SORT_ICON_DOWN. Additional values controlling the
202 drawing of a text or bitmap label can be passed in @e params. The
203 value returned is the optimal width to contain the the unabreviated
204 label text or bitmap, the sort arrow if present, and internal margins.
206 int DrawHeaderButton(wxWindow
* win
, wxDC
& dc
, const wxRect
& rect
,
208 wxHeaderSortIconType sortArrow
= wxHDR_SORT_ICON_NONE
,
209 wxHeaderButtonParams
* params
= NULL
);
212 Draw a selection rectangle underneath the text as used e.g. in a
213 wxListCtrl. The supported @a flags are
214 @c wxCONTROL_SELECTED for items which are selected (e.g. often a blue
215 rectangle) and @c wxCONTROL_CURRENT for the item that has the focus
216 (often a dotted line around the item's text). @c wxCONTROL_FOCUSED may
217 be used to indicate if the control has the focus (othewise the the selection
218 rectangle is e.g. often grey and not blue). This may be ignored by the renderer
219 or deduced by the code directly from the @e win.
221 void DrawItemSelectionRect(wxWindow
* win
, wxDC
& dc
,
226 Draw a blank push button that looks very similar to wxButton.
227 @a flags may have the @c wxCONTROL_PRESSED, @c wxCONTROL_CURRENT or
228 @c wxCONTROL_ISDEFAULT bit set.
230 void DrawPushButton(wxWindow
* win
, wxDC
& dc
, const wxRect
& rect
,
234 Draw the border for sash window: this border must be such that the sash
235 drawn by @ref drawsplittersash() DrawSash blends into it
238 void DrawSplitterBorder(wxWindow
* win
, wxDC
& dc
,
243 Draw a sash. The @a orient parameter defines whether the sash should be
244 vertical or horizontal and how the @a position should be interpreted.
246 void DrawSplitterSash(wxWindow
* win
, wxDC
& dc
,
249 wxOrientation orient
,
253 Draw the expanded/collapsed icon for a tree control item. To draw an expanded
254 button the @a flags parameter must contain @c wxCONTROL_EXPANDED bit.
256 void DrawTreeItemButton(wxWindow
* win
, wxDC
& dc
,
261 Return the currently used renderer.
263 wxRendererNative
Get();
266 Return the default (native) implementation for this platform -- this is also
267 the one used by default but this may be changed by calling
268 Set() in which case the return value of this
269 method may be different from the return value of Get().
271 wxRendererNative
GetDefault();
274 Return the generic implementation of the renderer. Under some platforms, this
275 is the default renderer implementation, others have platform-specific default
276 renderer which can be retrieved by calling GetDefault().
278 wxRendererNative
GetGeneric();
281 Returns the height of a header button, either a fixed platform height if
283 generic height based on the window's font.
285 int GetHeaderButtonHeight(const wxWindow
* win
);
288 Get the splitter parameters, see
289 wxSplitterRenderParams.
291 wxSplitterRenderParams
GetSplitterParams(const wxWindow
* win
);
294 This function is used for version checking: Load()
295 refuses to load any shared libraries implementing an older or incompatible
297 The implementation of this method is always the same in all renderers (simply
298 construct wxRendererVersion using the
299 @c wxRendererVersion::Current_XXX values), but it has to be in the derived,
300 not base, class, to detect mismatches between the renderers versions and so you
301 have to implement it anew in all renderers.
303 wxRendererVersion
GetVersion() const;
306 Load the renderer from the specified DLL, the returned pointer must be
307 deleted by caller if not @NULL when it is not used any more.
308 The @a name should be just the base name of the renderer and not the full
309 name of the DLL file which is constructed differently (using
310 wxDynamicLibrary::CanonicalizePluginName)
311 on different systems.
313 wxRendererNative
* Load(const wxString
& name
);
316 Set the renderer to use, passing @NULL reverts to using the default
317 renderer (the global renderer must always exist).
318 Return the previous renderer used with Set() or @NULL if none.
320 wxRendererNative
* Set(wxRendererNative
* renderer
);
325 @class wxRendererVersion
326 @wxheader{renderer.h}
328 This simple struct represents the wxRendererNative
329 interface version and is only used as the return value of
330 wxRendererNative::GetVersion.
332 The version has two components: the version itself and the age. If the main
333 program and the renderer have different versions they are never compatible with
334 each other because the version is only changed when an existing virtual
335 function is modified or removed. The age, on the other hand, is incremented
336 each time a new virtual method is added and so, at least for the compilers
337 using a common C++ object model, the calling program is compatible with any
338 renderer which has the age greater or equal to its age. This verification is
339 done by IsCompatible method.
344 class wxRendererVersion
348 Checks if the main program is compatible with the renderer having the version
349 @e ver, returns @true if it is and @false otherwise.
350 This method is used by
351 wxRendererNative::Load to determine whether a
352 renderer can be used.
354 static bool IsCompatible(const wxRendererVersion
& ver
);
364 The version component.