1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxRenderer and wxRendererNative documentation
4 %% Author: Vadim Zeitlin
8 %% Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxRendererNative
}}\label{wxrenderernative
}
14 First, a brief introduction to wxRenderer and why it is needed.
16 Usually wxWidgets uses the underlying low level GUI system to draw all the
17 controls - this is what we mean when we say that it is a ``native'' framework.
18 However not all controls exist under all (or even any) platforms and in this
19 case wxWidgets provides a default, generic, implementation of them written in
22 These controls don't have the native appearance if only the standard
23 line drawing and other graphics primitives are used, because the native
24 appearance is different under different platforms while the lines are always
25 drawn in the same way.
27 This is why we have renderers: wxRenderer is a class which virtualizes the
28 drawing, i.e. it abstracts the drawing operations and allows you to draw say, a
29 button, without caring about exactly how this is done. Of course, as we
30 can draw the button differently in different renderers, this also allows us to
31 emulate the native look and feel.
33 So the renderers work by exposing a large set of high-level drawing functions
34 which are used by the generic controls. There is always a default global
35 renderer but it may be changed or extended by the user, see
36 \helpref{Render sample
}{samplerender
}.
38 All drawing functions take some standard parameters:
40 \item \arg{win
} is the window being drawn. It is normally not used and when
41 it 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
44 function may be reused for drawing different kinds of control.
45 \item \arg{dc
} is the
\helpref{wxDC
}{wxdc
} to draw on. Only this device
46 context should be used for drawing. It is not necessary to restore
47 pens and brushes for it on function exit but, on the other hand, you
48 shouldn't assume that it is in any specific state on function entry:
49 the 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
52 combination of the
\texttt{wxCONTROL
\_XXX} constants below.
57 The following rendering flags are defined:
62 wxCONTROL_DISABLED =
0x00000001, // control is disabled
63 wxCONTROL_FOCUSED =
0x00000002, // currently has keyboard focus
64 wxCONTROL_PRESSED =
0x00000004, // (button) is pressed
65 wxCONTROL_ISDEFAULT =
0x00000008, // only applies to the buttons
66 wxCONTROL_ISSUBMENU = wxCONTROL_ISDEFAULT, // only for menu items
67 wxCONTROL_EXPANDED = wxCONTROL_ISDEFAULT, // only for the tree items
68 wxCONTROL_CURRENT =
0x00000010, // mouse is currently over the control
69 wxCONTROL_SELECTED =
0x00000020, // selected item in e.g. listbox
70 wxCONTROL_CHECKED =
0x00000040, // (check/radio button) is checked
71 wxCONTROL_CHECKABLE =
0x00000080, // (menu) item can be checked
72 wxCONTROL_UNDETERMINED = wxCONTROL_CHECKABLE // (check) undetermined state
76 \wxheading{Derived from
}
80 \wxheading{Include files
}
85 \latexignore{\rtfignore{\wxheading{Members
}}}
88 \membersection{wxRendererNative::
\destruct{wxRendererNative
}}\label{wxrenderernativedtor
}
90 \func{}{\destruct{wxRendererNative
}}{\void}
92 Virtual destructor as for any base class.
95 \membersection{wxRendererNative::DrawCheckButton
}\label{wxrenderernativedrawcheckbutton
}
97 \func{void
}{DrawCheckButton
}{\param{wxWindow *
}{win
},
\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{int
}{flags
}}
99 Draw a check box (used by wxDataViewCtrl).
101 \arg{flags
} may have the
\texttt{wxCONTROL
\_CHECKED},
\texttt{wxCONTROL
\_CURRENT} or
102 \texttt{wxCONTROL
\_UNDETERMINED} bit set.
105 \membersection{wxRendererNative::DrawComboBoxDropButton
}\label{wxrenderernativedrawcomboboxdropbutton
}
107 \func{void
}{DrawComboBoxDropButton
}{\param{wxWindow *
}{win
},
\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{int
}{flags
}}
109 Draw a button like the one used by
\helpref{wxComboBox
}{wxcombobox
} to show a
110 drop down window. The usual appearance is a downwards pointing arrow.
112 \arg{flags
} may have the
\texttt{wxCONTROL
\_PRESSED} or
\texttt{wxCONTROL
\_CURRENT} bit set.
115 \membersection{wxRendererNative::DrawDropArrow
}\label{wxrenderernativedrawdroparrow
}
117 \func{void
}{DrawDropArrow
}{\param{wxWindow *
}{win
},
\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{int
}{flags
}}
119 Draw a drop down arrow that is suitable for use outside a combo box. Arrow will have
120 transparent background.
122 \arg{rect
} is not entirely filled by the arrow. Instead, you should use bounding
123 rectangle of a drop down button which arrow matches the size you need.
124 \arg{flags
} may have the
\texttt{wxCONTROL
\_PRESSED} or
\texttt{wxCONTROL
\_CURRENT} bit set.
127 \membersection{wxRendererNative::DrawHeaderButton
}\label{wxrenderernativedrawheaderbutton
}
129 \func{void
}{DrawHeaderButton
}{\param{wxWindow*
}{win
},
\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{int
}{flags =
0}}
131 Draw the header control button (used by
\helpref{wxListCtrl
}{wxlistctrl
}).
134 \membersection{wxRendererNative::DrawPushButton
}\label{wxrenderernativedrawpushbutton
}
136 \func{void
}{DrawPushButton
}{\param{wxWindow *
}{win
},
\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{int
}{flags
}}
138 Draw a blank push button that looks very similar to
\helpref{wxButton
}{wxbutton
}.
140 \arg{flags
} may have the
\texttt{wxCONTROL
\_PRESSED},
\texttt{wxCONTROL
\_CURRENT} or
141 \texttt{wxCONTROL
\_ISDEFAULT} bit set.
144 \membersection{wxRendererNative::DrawSplitterBorder
}\label{wxrenderernativedrawsplitterborder
}
146 \func{void
}{DrawSplitterBorder
}{\param{wxWindow*
}{win
},
\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{int
}{flags =
0}}
148 Draw the border for sash window: this border must be such that the sash
149 drawn by
\helpref{DrawSash
}{wxrenderernativedrawsplittersash
} blends into it
153 \membersection{wxRendererNative::DrawSplitterSash
}\label{wxrenderernativedrawsplittersash
}
155 \func{void
}{DrawSplitterSash
}{\param{wxWindow*
}{win
},
\param{wxDC\&
}{dc
},
\param{const wxSize\&
}{size
},
\param{wxCoord
}{position
},
\param{wxOrientation
}{orient
},
\param{int
}{flags =
0}}
157 Draw a sash. The
\arg{orient
} parameter defines whether the sash should be
158 vertical or horizontal and how the
\arg{position
} should be interpreted.
161 \membersection{wxRendererNative::DrawTreeItemButton
}\label{wxrenderernativedrawtreeitembutton
}
163 \func{void
}{DrawTreeItemButton
}{\param{wxWindow*
}{win
},
\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{int
}{flags =
0}}
165 Draw the expanded/collapsed icon for a tree control item. To draw an expanded
166 button the
\arg{flags
} parameter must contain
{\tt wxCONTROL
\_EXPANDED} bit.
169 \membersection{wxRendererNative::Get
}\label{wxrenderernativeget
}
171 \func{wxRendererNative\&
}{Get
}{\void}
173 Return the currently used renderer.
176 \membersection{wxRendererNative::GetDefault
}\label{wxrenderernativegetdefault
}
178 \func{wxRendererNative\&
}{GetDefault
}{\void}
180 Return the default (native) implementation for this platform -- this is also
181 the one used by default but this may be changed by calling
182 \helpref{Set
}{wxrenderernativeset
} in which case the return value of this
183 method may be different from the return value of
\helpref{Get
}{wxrenderernativeget
}.
186 \membersection{wxRendererNative::GetGeneric
}\label{wxrenderernativegetgeneric
}
188 \func{wxRendererNative\&
}{GetGeneric
}{\void}
190 Return the generic implementation of the renderer. Under some platforms, this
191 is the default renderer implementation, others have platform-specific default
192 renderer which can be retrieved by calling
\helpref{GetDefault
}{wxrenderernativegetdefault
}.
195 \membersection{wxRendererNative::GetSplitterParams
}\label{wxrenderernativegetsplitterparams
}
197 \func{wxSplitterRenderParams
}{GetSplitterParams
}{\param{const wxWindow*
}{win
}}
199 Get the splitter parameters, see
200 \helpref{wxSplitterRenderParams
}{wxsplitterrenderparams
}.
203 \membersection{wxRendererNative::GetVersion
}\label{wxrenderernativegetversion
}
205 \constfunc{wxRendererVersion
}{GetVersion
}{\void}
207 This function is used for version checking:
\helpref{Load
}{wxrenderernativeload
}
208 refuses to load any shared libraries implementing an older or incompatible
211 The implementation of this method is always the same in all renderers (simply
212 construct
\helpref{wxRendererVersion
}{wxrendererversion
} using the
213 {\tt wxRendererVersion::Current
\_XXX} values), but it has to be in the derived,
214 not base, class, to detect mismatches between the renderers versions and so you
215 have to implement it anew in all renderers.
218 \membersection{wxRendererNative::Load
}\label{wxrenderernativeload
}
220 \func{wxRendererNative*
}{Load
}{\param{const wxString\&
}{name
}}
222 Load the renderer from the specified DLL, the returned pointer must be
223 deleted by caller if not
{\tt NULL
} when it is not used any more.
225 The
\arg{name
} should be just the base name of the renderer and not the full
226 name of the DLL file which is constructed differently (using
227 \helpref{wxDynamicLibrary::CanonicalizePluginName
}{wxdynamiclibrarycanonicalizepluginname
})
228 on different systems.
231 \membersection{wxRendererNative::Set
}\label{wxrenderernativeset
}
233 \func{wxRendererNative*
}{Set
}{\param{wxRendererNative*
}{renderer
}}
235 Set the renderer to use, passing
{\tt NULL
} reverts to using the default
236 renderer (the global renderer must always exist).
238 Return the previous renderer used with Set() or
{\tt NULL
} if none.