]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/renderer.tex
Big wxGL classes refactoring/cleanup:
[wxWidgets.git] / docs / latex / wx / renderer.tex
... / ...
CommitLineData
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>
9%% License: wxWindows license
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
12\section{\class{wxRendererNative}}\label{wxrenderernative}
13
14First, a brief introduction to wxRenderer and why it is needed.
15
16Usually wxWidgets uses the underlying low level GUI system to draw all the
17controls - this is what we mean when we say that it is a ``native'' framework.
18However not all controls exist under all (or even any) platforms and in this
19case wxWidgets provides a default, generic, implementation of them written in
20wxWidgets itself.
21
22These controls don't have the native appearance if only the standard
23line drawing and other graphics primitives are used, because the native
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
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
30can draw the button differently in different renderers, this also allows us to
31emulate the native look and feel.
32
33So the renderers work by exposing a large set of high-level drawing functions
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
38All drawing functions take some standard parameters:
39\begin{itemize}
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.
53\end{itemize}
54
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
60\wxheading{Constants}
61
62The following rendering flags are defined:
63
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
70 wxCONTROL_ISDEFAULT = 0x00000008, // only applies to the buttons
71 wxCONTROL_ISSUBMENU = wxCONTROL_ISDEFAULT, // only for menu items
72 wxCONTROL_EXPANDED = wxCONTROL_ISDEFAULT, // only for the tree items
73 wxCONTROL_CURRENT = 0x00000010, // mouse is currently over the control
74 wxCONTROL_SELECTED = 0x00000020, // selected item in e.g. listbox
75 wxCONTROL_CHECKED = 0x00000040, // (check/radio button) is checked
76 wxCONTROL_CHECKABLE = 0x00000080, // (menu) item can be checked
77 wxCONTROL_UNDETERMINED = wxCONTROL_CHECKABLE // (check) undetermined state
78};
79\end{verbatim}
80
81\wxheading{Derived from}
82
83No base class
84
85\wxheading{Include files}
86
87<wx/renderer.h>
88
89
90\latexignore{\rtfignore{\wxheading{Members}}}
91
92
93\membersection{wxRendererNative::\destruct{wxRendererNative}}\label{wxrenderernativedtor}
94
95\func{}{\destruct{wxRendererNative}}{\void}
96
97Virtual destructor as for any base class.
98
99
100\membersection{wxRendererNative::DrawCheckBox}\label{wxrenderernativedrawcheckbox}
101
102\func{void}{DrawCheckBox}{\param{wxWindow *}{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags}}
103
104Draw a check box (used by wxDataViewCtrl).
105
106\arg{flags} may have the \texttt{wxCONTROL\_CHECKED}, \texttt{wxCONTROL\_CURRENT} or
107\texttt{wxCONTROL\_UNDETERMINED} bit set.
108
109
110\membersection{wxRendererNative::DrawComboBoxDropButton}\label{wxrenderernativedrawcomboboxdropbutton}
111
112\func{void}{DrawComboBoxDropButton}{\param{wxWindow *}{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags}}
113
114Draw a button like the one used by \helpref{wxComboBox}{wxcombobox} to show a
115drop down window. The usual appearance is a downwards pointing arrow.
116
117\arg{flags} may have the \texttt{wxCONTROL\_PRESSED} or \texttt{wxCONTROL\_CURRENT} bit set.
118
119
120\membersection{wxRendererNative::DrawDropArrow}\label{wxrenderernativedrawdroparrow}
121
122\func{void}{DrawDropArrow}{\param{wxWindow *}{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags}}
123
124Draw a drop down arrow that is suitable for use outside a combo box. Arrow will have
125transparent background.
126
127\arg{rect} is not entirely filled by the arrow. Instead, you should use bounding
128rectangle of a drop down button which arrow matches the size you need.
129\arg{flags} may have the \texttt{wxCONTROL\_PRESSED} or \texttt{wxCONTROL\_CURRENT} bit set.
130
131
132\membersection{wxRendererNative::DrawHeaderButton}\label{wxrenderernativedrawheaderbutton}
133
134\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}}
135
136Draw the header control button (used, for example, by
137\helpref{wxListCtrl}{wxlistctrl}). Depending on platforms the
138\arg{flags} parameter may support the \texttt{wxCONTROL\_SELECTED}
139\texttt{wxCONTROL\_DISABLED} and \texttt{wxCONTROL\_CURRENT} bits.
140The \arg{sortArrow} parameter can be one of
141\texttt{wxHDR\_SORT\_ICON\_NONE}, \texttt{wxHDR\_SORT\_ICON\_UP}, or
142\texttt{wxHDR\_SORT\_ICON\_DOWN}. Additional values controlling the
143drawing of a text or bitmap label can be passed in \arg{params}. The
144value returned is the optimal width to contain the the unabreviated
145label text or bitmap, the sort arrow if present, and internal margins.
146
147
148
149\membersection{wxRendererNative::DrawItemSelectionRect}\label{wxrenderernativedrawitemselectionrect}
150
151\func{void}{DrawItemSelectionRect}{\param{wxWindow* }{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags = 0}}
152
153Draw a selection rectangle underneath the text as used e.g. in a
154\helpref{wxListCtrl}{wxlistctrl}. The supported \arg{flags} are
155\texttt{wxCONTROL\_SELECTED} for items which are selected (e.g. often a blue
156rectangle) and \texttt{wxCONTROL\_CURRENT} for the item that has the focus
157(often a dotted line around the item's text). \texttt{wxCONTROL\_FOCUSED} may
158be used to indicate if the control has the focus (othewise the the selection
159rectangle is e.g. often grey and not blue). This may be ignored by the renderer
160or deduced by the code directly from the \arg{win}.
161
162
163\membersection{wxRendererNative::DrawPushButton}\label{wxrenderernativedrawpushbutton}
164
165\func{void}{DrawPushButton}{\param{wxWindow *}{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags}}
166
167Draw a blank push button that looks very similar to \helpref{wxButton}{wxbutton}.
168
169\arg{flags} may have the \texttt{wxCONTROL\_PRESSED}, \texttt{wxCONTROL\_CURRENT} or
170\texttt{wxCONTROL\_ISDEFAULT} bit set.
171
172
173\membersection{wxRendererNative::DrawSplitterBorder}\label{wxrenderernativedrawsplitterborder}
174
175\func{void}{DrawSplitterBorder}{\param{wxWindow* }{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags = 0}}
176
177Draw the border for sash window: this border must be such that the sash
178drawn by \helpref{DrawSash}{wxrenderernativedrawsplittersash} blends into it
179well.
180
181
182\membersection{wxRendererNative::DrawSplitterSash}\label{wxrenderernativedrawsplittersash}
183
184\func{void}{DrawSplitterSash}{\param{wxWindow* }{win}, \param{wxDC\& }{dc}, \param{const wxSize\& }{size}, \param{wxCoord }{position}, \param{wxOrientation }{orient}, \param{int }{flags = 0}}
185
186Draw a sash. The \arg{orient} parameter defines whether the sash should be
187vertical or horizontal and how the \arg{position} should be interpreted.
188
189
190\membersection{wxRendererNative::DrawTreeItemButton}\label{wxrenderernativedrawtreeitembutton}
191
192\func{void}{DrawTreeItemButton}{\param{wxWindow* }{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags = 0}}
193
194Draw the expanded/collapsed icon for a tree control item. To draw an expanded
195button the \arg{flags} parameter must contain {\tt wxCONTROL\_EXPANDED} bit.
196
197
198\membersection{wxRendererNative::Get}\label{wxrenderernativeget}
199
200\func{wxRendererNative\&}{Get}{\void}
201
202Return the currently used renderer.
203
204
205\membersection{wxRendererNative::GetDefault}\label{wxrenderernativegetdefault}
206
207\func{wxRendererNative\&}{GetDefault}{\void}
208
209Return the default (native) implementation for this platform -- this is also
210the one used by default but this may be changed by calling
211\helpref{Set}{wxrenderernativeset} in which case the return value of this
212method may be different from the return value of \helpref{Get}{wxrenderernativeget}.
213
214
215\membersection{wxRendererNative::GetGeneric}\label{wxrenderernativegetgeneric}
216
217\func{wxRendererNative\&}{GetGeneric}{\void}
218
219Return the generic implementation of the renderer. Under some platforms, this
220is the default renderer implementation, others have platform-specific default
221renderer which can be retrieved by calling \helpref{GetDefault}{wxrenderernativegetdefault}.
222
223
224\membersection{wxRendererNative::GetHeaderButtonHeight}\label{wxrenderernativegetheaderbuttonheight}
225
226\func{int}{GetHeaderButtonHeight}{\param{const wxWindow* }{win}}
227
228Returns the height of a header button, either a fixed platform height if available, or a
229generic height based on the window's font.
230
231
232\membersection{wxRendererNative::GetSplitterParams}\label{wxrenderernativegetsplitterparams}
233
234\func{wxSplitterRenderParams}{GetSplitterParams}{\param{const wxWindow* }{win}}
235
236Get the splitter parameters, see
237\helpref{wxSplitterRenderParams}{wxsplitterrenderparams}.
238
239
240\membersection{wxRendererNative::GetVersion}\label{wxrenderernativegetversion}
241
242\constfunc{wxRendererVersion}{GetVersion}{\void}
243
244This function is used for version checking: \helpref{Load}{wxrenderernativeload}
245refuses to load any shared libraries implementing an older or incompatible
246version.
247
248The implementation of this method is always the same in all renderers (simply
249construct \helpref{wxRendererVersion}{wxrendererversion} using the
250{\tt wxRendererVersion::Current\_XXX} values), but it has to be in the derived,
251not base, class, to detect mismatches between the renderers versions and so you
252have to implement it anew in all renderers.
253
254
255\membersection{wxRendererNative::Load}\label{wxrenderernativeload}
256
257\func{wxRendererNative*}{Load}{\param{const wxString\& }{name}}
258
259Load the renderer from the specified DLL, the returned pointer must be
260deleted by caller if not {\tt NULL} when it is not used any more.
261
262The \arg{name} should be just the base name of the renderer and not the full
263name of the DLL file which is constructed differently (using
264\helpref{wxDynamicLibrary::CanonicalizePluginName}{wxdynamiclibrarycanonicalizepluginname})
265on different systems.
266
267
268\membersection{wxRendererNative::Set}\label{wxrenderernativeset}
269
270\func{wxRendererNative*}{Set}{\param{wxRendererNative* }{renderer}}
271
272Set the renderer to use, passing {\tt NULL} reverts to using the default
273renderer (the global renderer must always exist).
274
275Return the previous renderer used with Set() or {\tt NULL} if none.
276