]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/renderer.tex
sorting support for generic version (patch 1765087 from Bo)
[wxWidgets.git] / docs / latex / wx / renderer.tex
CommitLineData
3e6c2880
VZ
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%% Name: renderer.tex
3%% Purpose: wxRenderer and wxRendererNative documentation
4%% Author: Vadim Zeitlin
5%% Modified by:
6%% Created: 06.08.03
7%% RCS-ID: $Id$
8%% Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
8795498c 9%% License: wxWindows license
3e6c2880
VZ
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
bc51e42e 12\section{\class{wxRendererNative}}\label{wxrenderernative}
3e6c2880 13
684761db 14First, a brief introduction to wxRenderer and why it is needed.
3e6c2880 15
fc2171bd 16Usually wxWidgets uses the underlying low level GUI system to draw all the
dceb1c09 17controls - this is what we mean when we say that it is a ``native'' framework.
3e6c2880 18However not all controls exist under all (or even any) platforms and in this
fc2171bd
JS
19case wxWidgets provides a default, generic, implementation of them written in
20wxWidgets itself.
3e6c2880 21
93558403 22These controls don't have the native appearance if only the standard
684761db 23line drawing and other graphics primitives are used, because the native
3e6c2880
VZ
24appearance is different under different platforms while the lines are always
25drawn in the same way.
26
27This is why we have renderers: wxRenderer is a class which virtualizes the
684761db
JS
28drawing, i.e. it abstracts the drawing operations and allows you to draw say, a
29button, without caring about exactly how this is done. Of course, as we
3e6c2880
VZ
30can draw the button differently in different renderers, this also allows us to
31emulate the native look and feel.
32
684761db 33So the renderers work by exposing a large set of high-level drawing functions
3e6c2880
VZ
34which are used by the generic controls. There is always a default global
35renderer but it may be changed or extended by the user, see
36\helpref{Render sample}{samplerender}.
37
bc51e42e
VZ
38All drawing functions take some standard parameters:
39\begin{itemize}
d2c2afc9
JS
40\item \arg{win} is the window being drawn. It is normally not used and when
41it is it should only be used as a generic \helpref{wxWindow}{wxwindow}
42(in order to get its low level handle, for example), but you should
43\emph{not} assume that it is of some given type as the same renderer
44function may be reused for drawing different kinds of control.
45\item \arg{dc} is the \helpref{wxDC}{wxdc} to draw on. Only this device
46context should be used for drawing. It is not necessary to restore
47pens and brushes for it on function exit but, on the other hand, you
48shouldn't assume that it is in any specific state on function entry:
49the rendering functions should always prepare it.
50\item \arg{rect} the bounding rectangle for the element to be drawn.
51\item \arg{flags} the optional flags (none by default) which can be a
52combination of the \texttt{wxCONTROL\_XXX} constants below.
bc51e42e
VZ
53\end{itemize}
54
8fa8d158
VZ
55Note that each drawing function restores the \helpref{wxDC}{wxdc} attributes if
56it changes them, so it is safe to assume that the same pen, brush and colours
57that were active before the call to this function are still in effect after it.
58
59
bc51e42e
VZ
60\wxheading{Constants}
61
62The following rendering flags are defined:
d2c2afc9 63
bc51e42e
VZ
64\begin{verbatim}
65enum
66{
67 wxCONTROL_DISABLED = 0x00000001, // control is disabled
68 wxCONTROL_FOCUSED = 0x00000002, // currently has keyboard focus
69 wxCONTROL_PRESSED = 0x00000004, // (button) is pressed
8a461249
VZ
70 wxCONTROL_SPECIAL = 0x00000008, // control-specific bit:
71 wxCONTROL_ISDEFAULT = wxCONTROL_SPECIAL, // only for the buttons
72 wxCONTROL_ISSUBMENU = wxCONTROL_SPECIAL, // only for the menu items
73 wxCONTROL_EXPANDED = wxCONTROL_SPECIAL, // only for the tree items
74 wxCONTROL_SIZEGRIP = wxCONTROL_SPECIAL, // only for the status bar panes
75 wxCONTROL_FLAT = wxCONTROL_SPECIAL, // checkboxes only: flat border
bc51e42e
VZ
76 wxCONTROL_CURRENT = 0x00000010, // mouse is currently over the control
77 wxCONTROL_SELECTED = 0x00000020, // selected item in e.g. listbox
78 wxCONTROL_CHECKED = 0x00000040, // (check/radio button) is checked
2209baae
RR
79 wxCONTROL_CHECKABLE = 0x00000080, // (menu) item can be checked
80 wxCONTROL_UNDETERMINED = wxCONTROL_CHECKABLE // (check) undetermined state
bc51e42e
VZ
81};
82\end{verbatim}
83
bc51e42e
VZ
84\wxheading{Derived from}
85
86No base class
87
88\wxheading{Include files}
89
90<wx/renderer.h>
91
a7af285d
VZ
92\wxheading{Library}
93
94\helpref{wxCore}{librarieslist}
95
bc51e42e
VZ
96
97\latexignore{\rtfignore{\wxheading{Members}}}
98
99
100\membersection{wxRendererNative::\destruct{wxRendererNative}}\label{wxrenderernativedtor}
101
102\func{}{\destruct{wxRendererNative}}{\void}
103
104Virtual destructor as for any base class.
105
106
90b903c2 107\membersection{wxRendererNative::DrawCheckBox}\label{wxrenderernativedrawcheckbox}
2209baae 108
90b903c2 109\func{void}{DrawCheckBox}{\param{wxWindow *}{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags}}
2209baae
RR
110
111Draw a check box (used by wxDataViewCtrl).
112
113\arg{flags} may have the \texttt{wxCONTROL\_CHECKED}, \texttt{wxCONTROL\_CURRENT} or
114\texttt{wxCONTROL\_UNDETERMINED} bit set.
115
116
5e091b2b 117\membersection{wxRendererNative::DrawComboBoxDropButton}\label{wxrenderernativedrawcomboboxdropbutton}
f33cef9f
VZ
118
119\func{void}{DrawComboBoxDropButton}{\param{wxWindow *}{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags}}
120
121Draw a button like the one used by \helpref{wxComboBox}{wxcombobox} to show a
122drop down window. The usual appearance is a downwards pointing arrow.
123
4c85ab75
VZ
124\arg{flags} may have the \texttt{wxCONTROL\_PRESSED} or \texttt{wxCONTROL\_CURRENT} bit set.
125
126
127\membersection{wxRendererNative::DrawDropArrow}\label{wxrenderernativedrawdroparrow}
128
129\func{void}{DrawDropArrow}{\param{wxWindow *}{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags}}
130
131Draw a drop down arrow that is suitable for use outside a combo box. Arrow will have
132transparent background.
133
134\arg{rect} is not entirely filled by the arrow. Instead, you should use bounding
135rectangle of a drop down button which arrow matches the size you need.
136\arg{flags} may have the \texttt{wxCONTROL\_PRESSED} or \texttt{wxCONTROL\_CURRENT} bit set.
f33cef9f
VZ
137
138
bc51e42e
VZ
139\membersection{wxRendererNative::DrawHeaderButton}\label{wxrenderernativedrawheaderbutton}
140
c97c9952 141\func{int}{DrawHeaderButton}{\param{wxWindow* }{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags = 0}, \param{wxHeaderSortIconType }{sortArrow = wxHDR\_SORT\_ICON\_NONE}, \param{wxHeaderButtonParams* }{params = NULL}}
bc51e42e 142
80752b57
RD
143Draw the header control button (used, for example, by
144\helpref{wxListCtrl}{wxlistctrl}). Depending on platforms the
145\arg{flags} parameter may support the \texttt{wxCONTROL\_SELECTED}
146\texttt{wxCONTROL\_DISABLED} and \texttt{wxCONTROL\_CURRENT} bits.
147The \arg{sortArrow} parameter can be one of
c97c9952 148\texttt{wxHDR\_SORT\_ICON\_NONE}, \texttt{wxHDR\_SORT\_ICON\_UP}, or
80752b57 149\texttt{wxHDR\_SORT\_ICON\_DOWN}. Additional values controlling the
c97c9952
RD
150drawing of a text or bitmap label can be passed in \arg{params}. The
151value returned is the optimal width to contain the the unabreviated
152label text or bitmap, the sort arrow if present, and internal margins.
153
bc51e42e
VZ
154
155
05d97538
RR
156\membersection{wxRendererNative::DrawItemSelectionRect}\label{wxrenderernativedrawitemselectionrect}
157
158\func{void}{DrawItemSelectionRect}{\param{wxWindow* }{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags = 0}}
159
c6a372b6
VZ
160Draw a selection rectangle underneath the text as used e.g. in a
161\helpref{wxListCtrl}{wxlistctrl}. The supported \arg{flags} are
162\texttt{wxCONTROL\_SELECTED} for items which are selected (e.g. often a blue
163rectangle) and \texttt{wxCONTROL\_CURRENT} for the item that has the focus
164(often a dotted line around the item's text). \texttt{wxCONTROL\_FOCUSED} may
165be used to indicate if the control has the focus (othewise the the selection
166rectangle is e.g. often grey and not blue). This may be ignored by the renderer
167or deduced by the code directly from the \arg{win}.
168
05d97538 169
2209baae
RR
170\membersection{wxRendererNative::DrawPushButton}\label{wxrenderernativedrawpushbutton}
171
172\func{void}{DrawPushButton}{\param{wxWindow *}{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags}}
173
174Draw a blank push button that looks very similar to \helpref{wxButton}{wxbutton}.
175
176\arg{flags} may have the \texttt{wxCONTROL\_PRESSED}, \texttt{wxCONTROL\_CURRENT} or
177\texttt{wxCONTROL\_ISDEFAULT} bit set.
178
179
bc51e42e
VZ
180\membersection{wxRendererNative::DrawSplitterBorder}\label{wxrenderernativedrawsplitterborder}
181
182\func{void}{DrawSplitterBorder}{\param{wxWindow* }{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags = 0}}
183
184Draw the border for sash window: this border must be such that the sash
185drawn by \helpref{DrawSash}{wxrenderernativedrawsplittersash} blends into it
186well.
187
188
189\membersection{wxRendererNative::DrawSplitterSash}\label{wxrenderernativedrawsplittersash}
190
191\func{void}{DrawSplitterSash}{\param{wxWindow* }{win}, \param{wxDC\& }{dc}, \param{const wxSize\& }{size}, \param{wxCoord }{position}, \param{wxOrientation }{orient}, \param{int }{flags = 0}}
192
193Draw a sash. The \arg{orient} parameter defines whether the sash should be
43e8916f 194vertical or horizontal and how the \arg{position} should be interpreted.
bc51e42e
VZ
195
196
197\membersection{wxRendererNative::DrawTreeItemButton}\label{wxrenderernativedrawtreeitembutton}
198
199\func{void}{DrawTreeItemButton}{\param{wxWindow* }{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags = 0}}
200
201Draw the expanded/collapsed icon for a tree control item. To draw an expanded
202button the \arg{flags} parameter must contain {\tt wxCONTROL\_EXPANDED} bit.
203
204
205\membersection{wxRendererNative::Get}\label{wxrenderernativeget}
206
207\func{wxRendererNative\&}{Get}{\void}
208
209Return the currently used renderer.
210
211
212\membersection{wxRendererNative::GetDefault}\label{wxrenderernativegetdefault}
213
214\func{wxRendererNative\&}{GetDefault}{\void}
215
216Return the default (native) implementation for this platform -- this is also
217the one used by default but this may be changed by calling
218\helpref{Set}{wxrenderernativeset} in which case the return value of this
219method may be different from the return value of \helpref{Get}{wxrenderernativeget}.
220
221
222\membersection{wxRendererNative::GetGeneric}\label{wxrenderernativegetgeneric}
223
224\func{wxRendererNative\&}{GetGeneric}{\void}
225
226Return the generic implementation of the renderer. Under some platforms, this
227is the default renderer implementation, others have platform-specific default
228renderer which can be retrieved by calling \helpref{GetDefault}{wxrenderernativegetdefault}.
229
230
6e872f5c
RD
231\membersection{wxRendererNative::GetHeaderButtonHeight}\label{wxrenderernativegetheaderbuttonheight}
232
233\func{int}{GetHeaderButtonHeight}{\param{const wxWindow* }{win}}
234
235Returns the height of a header button, either a fixed platform height if available, or a
236generic height based on the window's font.
237
238
bc51e42e
VZ
239\membersection{wxRendererNative::GetSplitterParams}\label{wxrenderernativegetsplitterparams}
240
241\func{wxSplitterRenderParams}{GetSplitterParams}{\param{const wxWindow* }{win}}
242
243Get the splitter parameters, see
244\helpref{wxSplitterRenderParams}{wxsplitterrenderparams}.
245
246
247\membersection{wxRendererNative::GetVersion}\label{wxrenderernativegetversion}
248
249\constfunc{wxRendererVersion}{GetVersion}{\void}
250
251This function is used for version checking: \helpref{Load}{wxrenderernativeload}
252refuses to load any shared libraries implementing an older or incompatible
253version.
254
255The implementation of this method is always the same in all renderers (simply
256construct \helpref{wxRendererVersion}{wxrendererversion} using the
257{\tt wxRendererVersion::Current\_XXX} values), but it has to be in the derived,
258not base, class, to detect mismatches between the renderers versions and so you
259have to implement it anew in all renderers.
260
261
262\membersection{wxRendererNative::Load}\label{wxrenderernativeload}
263
264\func{wxRendererNative*}{Load}{\param{const wxString\& }{name}}
265
266Load the renderer from the specified DLL, the returned pointer must be
267deleted by caller if not {\tt NULL} when it is not used any more.
268
269The \arg{name} should be just the base name of the renderer and not the full
270name of the DLL file which is constructed differently (using
271\helpref{wxDynamicLibrary::CanonicalizePluginName}{wxdynamiclibrarycanonicalizepluginname})
272on different systems.
273
274
275\membersection{wxRendererNative::Set}\label{wxrenderernativeset}
276
277\func{wxRendererNative*}{Set}{\param{wxRendererNative* }{renderer}}
278
279Set the renderer to use, passing {\tt NULL} reverts to using the default
280renderer (the global renderer must always exist).
281
282Return the previous renderer used with Set() or {\tt NULL} if none.
b67a86d5 283