]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/dataviewrenderer.tex
removed erroneous spaces from wxTo/FromString() documentation
[wxWidgets.git] / docs / latex / wx / dataviewrenderer.tex
CommitLineData
b6b9d556
RR
1
2\section{\class{wxDataViewRenderer}}\label{wxdataviewrenderer}
3
4
5This class is used by \helpref{wxDataViewCtrl}{wxdataviewctrl} to
6render the individual cells. One instance of a renderer class is
7owned by \helpref{wxDataViewColumn}{wxdataviewcolumn}. There is
8a number of ready-to-use renderers provided:
9\helpref{wxDataViewTextRenderer}{wxdataviewtextrenderer},
10\helpref{wxDataViewToggleRenderer}{wxdataviewtogglerenderer},
11\helpref{wxDataViewProgressRenderer}{wxdataviewprogressrenderer},
12\helpref{wxDataViewBitmapRenderer}{wxdataviewbitmaprenderer},
13\helpref{wxDataViewDateRenderer}{wxdataviewdaterenderer}.
14
b6b9d556
RR
15Additionally, the user can write own renderers by deriving from
16\helpref{wxDataViewCustomRenderer}{wxdataviewcustomrenderer}.
17
305c49a1 18The {\it wxDataViewCellMode} flag controls, what actions
befba9e4 19the cell data allows. {\it wxDATAVIEW\_CELL\_ACTIVATABLE}
305c49a1
RR
20indicates that the user can double click the cell and
21something will happen (e.g. a window for editing a date
befba9e4 22will pop up). {\it wxDATAVIEW\_CELL\_EDITABLE} indicates
305c49a1
RR
23that the user can edit the data in-place, i.e. an control
24will show up after a slow click on the cell. This behaviour
25is best known from changing the filename in most file
26managers etc.
27
28
b6b9d556
RR
29
30{\small
31\begin{verbatim}
32enum wxDataViewCellMode
33{
34 wxDATAVIEW_CELL_INERT,
35 wxDATAVIEW_CELL_ACTIVATABLE,
36 wxDATAVIEW_CELL_EDITABLE
37};
305c49a1
RR
38\end{verbatim}
39}
40
41The {\it wxDataViewCellRenderState} flag controls how the
42the renderer should display its contents in a cell:
b6b9d556 43
305c49a1
RR
44{\small
45\begin{verbatim}
b6b9d556
RR
46enum wxDataViewCellRenderState
47{
48 wxDATAVIEW_CELL_SELECTED = 1,
49 wxDATAVIEW_CELL_PRELIT = 2,
50 wxDATAVIEW_CELL_INSENSITIVE = 4,
51 wxDATAVIEW_CELL_FOCUSED = 8
52};
53\end{verbatim}
54}
55
56
57\wxheading{Derived from}
58
59\helpref{wxObject}{wxobject}
60
61\wxheading{Include files}
62
63<wx/dataview.h>
64
65
66\membersection{wxDataViewRenderer::wxDataViewRenderer}\label{wxdataviewrendererwxdataviewrenderer}
67
68\func{}{wxDataViewRenderer}{\param{const wxString\& }{varianttype}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}}
69
70Constructor.
71
72\membersection{wxDataViewRenderer::GetMode}\label{wxdataviewrenderergetmode}
73
74\func{virtual wxDataViewCellMode}{GetMode}{\void}
75
76Returns the cell mode.
77
78\membersection{wxDataViewRenderer::GetOwner}\label{wxdataviewrenderergetowner}
79
80\func{virtual wxDataViewColumn*}{GetOwner}{\void}
81
82Returns pointer to the owning \helpref{wxDataViewColumn}{wxdataviewcolumn}.
83
84\membersection{wxDataViewRenderer::GetValue}\label{wxdataviewrenderergetvalue}
85
86\func{virtual bool}{GetValue}{\param{wxVariant\& }{value}}
87
88This methods retrieves the value from the renderer in order to
89transfer the value back to the data model. Returns {\it false}
90on failure.
91
92\membersection{wxDataViewRenderer::GetVariantType}\label{wxdataviewrenderergetvarianttype}
93
94\func{virtual wxString}{GetVariantType}{\void}
95
96Returns a string with the type of the \helpref{wxVariant}{wxvariant}
97supported by this renderer.
98
99\membersection{wxDataViewRenderer::SetOwner}\label{wxdataviewrenderersetowner}
100
101\func{virtual void}{SetOwner}{\param{wxDataViewColumn* }{owner}}
102
103Sets the owning \helpref{wxDataViewColumn}{wxdataviewcolumn}. This
104is usually called from within wxDataViewColumn.
105
106\membersection{wxDataViewRenderer::SetValue}\label{wxdataviewrenderersetvalue}
107
108\func{virtual bool}{SetValue}{\param{const wxVariant\& }{value}}
109
110Set the value of the renderer (and thus its cell) to {\it value}.
111The internal code will then render this cell with this data.
112
113
114\membersection{wxDataViewRenderer::Validate}\label{wxdataviewrenderervalidate}
115
116\func{virtual bool}{Validate}{\param{wxVariant\& }{value}}
117
305c49a1
RR
118Before data is committed to the data model, it is passed to this
119method where it can be checked for validity. This can also be
120used for checking a valid range or limiting the user input in
121a certain aspect (e.g. max number of characters or only alphanumeric
122input, ASCII only etc.). Return {\it false} if the value is
123not valid.
124
125Please note that due to implementation limitations, this validation
126is done after the editing control already is destroyed and the
127editing process finished.
b6b9d556
RR
128
129
130\section{\class{wxDataViewTextRenderer}}\label{wxdataviewtextrenderer}
131
305c49a1
RR
132wxDataViewTextRenderer is used for rendering text. It supports
133in-place editing if desired.
b6b9d556
RR
134
135
136\wxheading{Derived from}
137
138\helpref{wxDataViewRenderer}{wxdataviewrenderer}
139
140\wxheading{Include files}
141
142<wx/dataview.h>
143
144
145\membersection{wxDataViewTextRenderer::wxDataViewTextRenderer}\label{wxdataviewtextrendererwxdataviewtextrenderer}
146
147\func{}{wxDataViewTextRenderer}{\param{const wxString\& }{varianttype = wxT("string")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}}
148
149
150
151\section{\class{wxDataViewProgressRenderer}}\label{wxdataviewprogressrenderer}
152
153wxDataViewProgressRenderer
154
155
156\wxheading{Derived from}
157
158\helpref{wxDataViewRenderer}{wxdataviewrenderer}
159
160\wxheading{Include files}
161
162<wx/dataview.h>
163
164
165\membersection{wxDataViewProgressRenderer::wxDataViewProgressRenderer}\label{wxdataviewprogressrendererwxdataviewprogressrenderer}
166
167\func{}{wxDataViewProgressRenderer}{\param{const wxString\& }{label = wxEmptyString}, \param{const wxString\& }{varianttype = wxT("long")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}}
168
169
170
171\section{\class{wxDataViewToggleRenderer}}\label{wxdataviewtogglerenderer}
172
173wxDataViewToggleRenderer
174
175\wxheading{Derived from}
176
177\helpref{wxDataViewRenderer}{wxdataviewrenderer}
178
179\wxheading{Include files}
180
181<wx/dataview.h>
182
183
184\membersection{wxDataViewToggleRenderer::wxDataViewToggleRenderer}\label{wxdataviewtogglerendererwxdataviewtogglerenderer}
185
186\func{}{wxDataViewToggleRenderer}{\param{const wxString\& }{varianttype = wxT("bool")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}}
187
188
189\section{\class{wxDataViewBitmapRenderer}}\label{wxdataviewbitmaprenderer}
190
191wxDataViewBitmapRenderer
192
193\wxheading{Derived from}
194
195\helpref{wxDataViewRenderer}{wxdataviewrenderer}
196
197\wxheading{Include files}
198
199<wx/dataview.h>
200
201
202\membersection{wxDataViewBitmapRenderer::wxDataViewBitmapRenderer}\label{wxdataviewbitmaprendererwxdataviewbitmaprenderer}
203
204\func{}{wxDataViewBitmapRenderer}{\param{const wxString\& }{varianttype = wxT("wxBitmap")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}}
205
206
207\section{\class{wxDataViewDateRenderer}}\label{wxdataviewdaterenderer}
208
209wxDataViewDateRenderer
210
211
212\wxheading{Derived from}
213
214\helpref{wxDataViewRenderer}{wxdataviewrenderer}
215
216\wxheading{Include files}
217
218<wx/dataview.h>
219
220\membersection{wxDataViewDateRenderer::wxDataViewDateRenderer}\label{wxdataviewdaterendererwxdataviewdaterenderer}
221
222\func{}{wxDataViewDateRenderer}{\param{const wxString\& }{varianttype = wxT("datetime")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_ACTIVATABLE}}
223
224
225\section{\class{wxDataViewCustomRenderer}}\label{wxdataviewcustomrenderer}
226
81a22037
RR
227You need to derive a new class from wxDataViewCustomRenderer in
228order to write a new renderer. You need to override at least
229\helpref{SetValue}{wxdataviewrenderersetvalue},
305c49a1
RR
230\helpref{GetValue}{wxdataviewrenderergetvalue},
231\helpref{GetSize}{wxdataviewcustomrenderergetsize}
232and \helpref{Render}{wxdataviewcustomrendererrender}.
233
81a22037
RR
234If you want your renderer to support in-place editing then you
235also need to override
305c49a1
RR
236\helpref{HasEditorCtrl}{wxdataviewcustomrendererhaseditorctrl},
237\helpref{CreateEditorCtrl}{wxdataviewcustomrenderercreateeditorctrl}
238and \helpref{GetValueFromEditorCtrl}{wxdataviewcustomrenderergetvaluefromeditorctrl}.
239Note that a special event handler will be pushed onto that
240editor control which handles <ENTER> and focus out events
241in order to end the editing.
b6b9d556
RR
242
243\wxheading{Derived from}
244
245\helpref{wxDataViewRenderer}{wxdataviewrenderer}
246
247\wxheading{Include files}
248
249<wx/dataview.h>
250
251\membersection{wxDataViewCustomRenderer::wxDataViewCustomRenderer}\label{wxdataviewcustomrendererwxdataviewcustomrenderer}
252
253\func{}{wxDataViewCustomRenderer}{\param{const wxString\& }{varianttype = wxT("string")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{bool }{no\_init = false}}
254
255Constructor.
256
257\membersection{wxDataViewCustomRenderer::\destruct{wxDataViewCustomRenderer}}\label{wxdataviewcustomrendererdtor}
258
259\func{}{\destruct{wxDataViewCustomRenderer}}{\void}
260
261Destructor.
262
305c49a1
RR
263
264\membersection{wxDataViewCustomRenderer::HasEditorCtrl}\label{wxdataviewcustomrendererhaseditorctrl}
265
266\func{virtual bool}{HasEditorCtrl}{\void}
267
268Override this and make it return {\it true} in order to
269indicate that this renderer supports in-place editing.
270
271\membersection{wxDataViewCustomRenderer::CreateEditorCtrl}\label{wxdataviewcustomrenderercreateeditorctrl}
272
befba9e4 273\func{virtual wxControl*}{CreateEditorCtrl}{\param{wxWindow *}{parent}, \param{wxRect }{labelRect}, \param{const wxVariant \& }{value}}
305c49a1
RR
274
275Override this to create the actual editor control once editing
276is about to start. {\it parent} is the parent of the editor
277control, {\it labelRect} indicates the position and
278size of the editor control and {\it value} is its initial value:
279
280{\small
281\begin{verbatim}
282{
283 long l = value;
284 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
285 labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l );
286}
287\end{verbatim}
288}
289
290\membersection{wxDataViewCustomRenderer::GetValueFromEditorCtrl}\label{wxdataviewcustomrenderergetvaluefromeditorctrl}
291
7a4523c8 292\func{virtual bool}{GetValueFromEditorCtrl}{\param{wxControl* }{editor}, \param{wxVariant \& }{value}}
305c49a1
RR
293
294Overrride this so that the renderer can get the value
295from the editor control (pointed to by {\it editor}):
296
297{\small
298\begin{verbatim}
299{
300 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
301 long l = sc->GetValue();
302 value = l;
303 return true;
304}
305\end{verbatim}
306}
307
b6b9d556
RR
308\membersection{wxDataViewCustomRenderer::Activate}\label{wxdataviewcustomrendereractivate}
309
310\func{virtual bool}{Activate}{\param{wxRect }{cell}, \param{wxDataViewListModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
311
312Override this to react to double clicks or <ENTER>.
313
314\membersection{wxDataViewCustomRenderer::GetDC}\label{wxdataviewcustomrenderergetdc}
315
316\func{virtual wxDC*}{GetDC}{\void}
317
318Create DC on request. Internal.
319
320
321\membersection{wxDataViewCustomRenderer::GetSize}\label{wxdataviewcustomrenderergetsize}
322
323\func{virtual wxSize}{GetSize}{\void}
324
325Return size required to show content.
326
327
328\membersection{wxDataViewCustomRenderer::LeftClick}\label{wxdataviewcustomrendererleftclick}
329
330\func{virtual bool}{LeftClick}{\param{wxPoint }{cursor}, \param{wxRect }{cell}, \param{wxDataViewListModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
331
332Overrride this to react to a left click.
333
334\membersection{wxDataViewCustomRenderer::Render}\label{wxdataviewcustomrendererrender}
335
336\func{virtual bool}{Render}{\param{wxRect }{cell}, \param{wxDC* }{dc}, \param{int }{state}}
337
338Override this to render the cell. Before this is called,
339\helpref{SetValue}{wxdataviewrenderersetvalue} was called
340so that this instance knows what to render.
341
342\membersection{wxDataViewCustomRenderer::RightClick}\label{wxdataviewcustomrendererrightclick}
343
344\func{virtual bool}{RightClick}{\param{wxPoint }{cursor}, \param{wxRect }{cell}, \param{wxDataViewListModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
345
346Overrride this to react to a right click.
347
348\membersection{wxDataViewCustomRenderer::StartDrag}\label{wxdataviewcustomrendererstartdrag}
349
350\func{virtual bool}{StartDrag}{\param{wxPoint }{cursor}, \param{wxRect }{cell}, \param{wxDataViewListModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
351
352Overrride this to start a drag operation.
353
354
355