]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/dataviewrenderer.tex
Moved desktop margin options to a more sensible place
[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},
b15666a6 10\helpref{wxDataViewIconTextRenderer}{wxdataviewicontextrenderer},
b6b9d556
RR
11\helpref{wxDataViewToggleRenderer}{wxdataviewtogglerenderer},
12\helpref{wxDataViewProgressRenderer}{wxdataviewprogressrenderer},
13\helpref{wxDataViewBitmapRenderer}{wxdataviewbitmaprenderer},
14\helpref{wxDataViewDateRenderer}{wxdataviewdaterenderer}.
52e750fc 15\helpref{wxDataViewSpinRenderer}{wxdataviewspinrenderer}.
b6b9d556 16
b6b9d556
RR
17Additionally, the user can write own renderers by deriving from
18\helpref{wxDataViewCustomRenderer}{wxdataviewcustomrenderer}.
19
305c49a1 20The {\it wxDataViewCellMode} flag controls, what actions
befba9e4 21the cell data allows. {\it wxDATAVIEW\_CELL\_ACTIVATABLE}
305c49a1
RR
22indicates that the user can double click the cell and
23something will happen (e.g. a window for editing a date
befba9e4 24will pop up). {\it wxDATAVIEW\_CELL\_EDITABLE} indicates
305c49a1
RR
25that the user can edit the data in-place, i.e. an control
26will show up after a slow click on the cell. This behaviour
27is best known from changing the filename in most file
28managers etc.
29
30
b6b9d556
RR
31
32{\small
33\begin{verbatim}
34enum wxDataViewCellMode
35{
36 wxDATAVIEW_CELL_INERT,
37 wxDATAVIEW_CELL_ACTIVATABLE,
38 wxDATAVIEW_CELL_EDITABLE
39};
305c49a1
RR
40\end{verbatim}
41}
42
43The {\it wxDataViewCellRenderState} flag controls how the
44the renderer should display its contents in a cell:
b6b9d556 45
305c49a1
RR
46{\small
47\begin{verbatim}
b6b9d556
RR
48enum wxDataViewCellRenderState
49{
50 wxDATAVIEW_CELL_SELECTED = 1,
51 wxDATAVIEW_CELL_PRELIT = 2,
52 wxDATAVIEW_CELL_INSENSITIVE = 4,
53 wxDATAVIEW_CELL_FOCUSED = 8
54};
55\end{verbatim}
56}
57
58
59\wxheading{Derived from}
60
61\helpref{wxObject}{wxobject}
62
63\wxheading{Include files}
64
65<wx/dataview.h>
66
a7af285d
VZ
67\wxheading{Library}
68
69\helpref{wxAdv}{librarieslist}
70
b6b9d556 71
809e21b5
FM
72
73\latexignore{\rtfignore{\wxheading{Members}}}
74
b6b9d556
RR
75\membersection{wxDataViewRenderer::wxDataViewRenderer}\label{wxdataviewrendererwxdataviewrenderer}
76
c7c5a619 77\func{}{wxDataViewRenderer}{\param{const wxString\& }{varianttype}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{alignment = wxALIGN\_LEFT|wxALIGN\_CENTRE\_VERTICAL}}
b6b9d556
RR
78
79Constructor.
80
81\membersection{wxDataViewRenderer::GetMode}\label{wxdataviewrenderergetmode}
82
83\func{virtual wxDataViewCellMode}{GetMode}{\void}
84
85Returns the cell mode.
86
87\membersection{wxDataViewRenderer::GetOwner}\label{wxdataviewrenderergetowner}
88
89\func{virtual wxDataViewColumn*}{GetOwner}{\void}
90
91Returns pointer to the owning \helpref{wxDataViewColumn}{wxdataviewcolumn}.
92
93\membersection{wxDataViewRenderer::GetValue}\label{wxdataviewrenderergetvalue}
94
95\func{virtual bool}{GetValue}{\param{wxVariant\& }{value}}
96
97This methods retrieves the value from the renderer in order to
98transfer the value back to the data model. Returns {\it false}
99on failure.
100
101\membersection{wxDataViewRenderer::GetVariantType}\label{wxdataviewrenderergetvarianttype}
102
103\func{virtual wxString}{GetVariantType}{\void}
104
105Returns a string with the type of the \helpref{wxVariant}{wxvariant}
106supported by this renderer.
107
108\membersection{wxDataViewRenderer::SetOwner}\label{wxdataviewrenderersetowner}
109
110\func{virtual void}{SetOwner}{\param{wxDataViewColumn* }{owner}}
111
112Sets the owning \helpref{wxDataViewColumn}{wxdataviewcolumn}. This
113is usually called from within wxDataViewColumn.
114
115\membersection{wxDataViewRenderer::SetValue}\label{wxdataviewrenderersetvalue}
116
117\func{virtual bool}{SetValue}{\param{const wxVariant\& }{value}}
118
119Set the value of the renderer (and thus its cell) to {\it value}.
120The internal code will then render this cell with this data.
121
122
123\membersection{wxDataViewRenderer::Validate}\label{wxdataviewrenderervalidate}
124
125\func{virtual bool}{Validate}{\param{wxVariant\& }{value}}
126
305c49a1
RR
127Before data is committed to the data model, it is passed to this
128method where it can be checked for validity. This can also be
129used for checking a valid range or limiting the user input in
130a certain aspect (e.g. max number of characters or only alphanumeric
131input, ASCII only etc.). Return {\it false} if the value is
132not valid.
133
134Please note that due to implementation limitations, this validation
135is done after the editing control already is destroyed and the
136editing process finished.
b6b9d556
RR
137
138
139\section{\class{wxDataViewTextRenderer}}\label{wxdataviewtextrenderer}
140
305c49a1
RR
141wxDataViewTextRenderer is used for rendering text. It supports
142in-place editing if desired.
b6b9d556
RR
143
144
145\wxheading{Derived from}
146
7376079d
VZ
147\helpref{wxDataViewRenderer}{wxdataviewrenderer}\\
148\helpref{wxObject}{wxobject}
b6b9d556
RR
149
150\wxheading{Include files}
151
152<wx/dataview.h>
153
a7af285d
VZ
154\wxheading{Library}
155
156\helpref{wxAdv}{librarieslist}
157
b6b9d556 158
809e21b5
FM
159\latexignore{\rtfignore{\wxheading{Members}}}
160
b6b9d556
RR
161\membersection{wxDataViewTextRenderer::wxDataViewTextRenderer}\label{wxdataviewtextrendererwxdataviewtextrenderer}
162
163\func{}{wxDataViewTextRenderer}{\param{const wxString\& }{varianttype = wxT("string")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}}
164
165
166
167\section{\class{wxDataViewProgressRenderer}}\label{wxdataviewprogressrenderer}
168
169wxDataViewProgressRenderer
170
171
172\wxheading{Derived from}
173
7376079d
VZ
174\helpref{wxDataViewRenderer}{wxdataviewrenderer}\\
175\helpref{wxObject}{wxobject}
b6b9d556
RR
176
177\wxheading{Include files}
178
179<wx/dataview.h>
180
a7af285d
VZ
181\wxheading{Library}
182
183\helpref{wxAdv}{librarieslist}
184
b6b9d556 185
809e21b5
FM
186\latexignore{\rtfignore{\wxheading{Members}}}
187
b6b9d556
RR
188\membersection{wxDataViewProgressRenderer::wxDataViewProgressRenderer}\label{wxdataviewprogressrendererwxdataviewprogressrenderer}
189
190\func{}{wxDataViewProgressRenderer}{\param{const wxString\& }{label = wxEmptyString}, \param{const wxString\& }{varianttype = wxT("long")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}}
191
192
c1e17d4c
RR
193\section{\class{wxDataViewIconText}}\label{wxdataviewicontext}
194
195wxDataViewIconText is used by
196\helpref{wxDataViewIconTextRenderer}{wxdataviewicontextrenderer}
197for data transfer. This class can be converted to a from
198a \helpref{wxVariant}{wxvariant}.
199
200\wxheading{Derived from}
201
202\helpref{wxObject}{wxobject}
203
204\wxheading{Include files}
205
206<dataview.h>
207
208\membersection{wxDataViewIconText::wxDataViewIconText}\label{wxdataviewicontextwxdataviewicontext}
209
210\func{}{wxDataViewIconText}{\param{const wxString\& }{text = wxEmptyString}, \param{const wxIcon\& }{icon = wxNullIcon}}
211
212\func{}{wxDataViewIconText}{\param{const wxDataViewIconText\& }{other}}
213
214Constructor.
215
216\membersection{wxDataViewIconText::GetIcon}\label{wxdataviewicontextgeticon}
217
218\constfunc{const wxIcon\&}{GetIcon}{\void}
219
220Gets the icon.
221
222\membersection{wxDataViewIconText::GetText}\label{wxdataviewicontextgettext}
223
224\constfunc{wxString}{GetText}{\void}
225
226Gets the text.
227
228\membersection{wxDataViewIconText::SetIcon}\label{wxdataviewicontextseticon}
229
230\func{void}{SetIcon}{\param{const wxIcon\& }{icon}}
231
232Set the icon.
233
234\membersection{wxDataViewIconText::SetText}\label{wxdataviewicontextsettext}
235
236\func{void}{SetText}{\param{const wxString\& }{text}}
237
238Set the text.
239
240\section{\class{wxDataViewIconTextRenderer}}\label{wxdataviewicontextrenderer}
241
242The wxDataViewIconTextRenderer class is used to display text with
243a small icon next to it as it is typically done in a file manager.
244This classes uses the \helpref{wxDataViewIconText}{wxdataviewicontext}
245helper class to store its data. wxDataViewIonText can be converted
246to a from a \helpref{wxVariant}{wxvariant} using the left shift
247operator.
248
249\wxheading{Derived from}
250
251\helpref{wxDataViewRenderer}{wxdataviewrenderer}\\
252\helpref{wxObject}{wxobject}
253
254\wxheading{Include files}
255
256<wx/dataview.h>
257
258\wxheading{Library}
259
260\helpref{wxAdv}{librarieslist}
261
262
263\latexignore{\rtfignore{\wxheading{Members}}}
264
265\membersection{wxDataViewIconTextRenderer::wxDataViewIconTextRenderer}\label{wxdataviewtogglerendererwxdataviewicontextrenderer}
266
267\func{}{wxDataViewIconTextRenderer}{\param{const wxString\& }{varianttype = wxT("wxDataViewIconText")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}}
268
b6b9d556
RR
269
270\section{\class{wxDataViewToggleRenderer}}\label{wxdataviewtogglerenderer}
271
272wxDataViewToggleRenderer
273
274\wxheading{Derived from}
275
7376079d
VZ
276\helpref{wxDataViewRenderer}{wxdataviewrenderer}\\
277\helpref{wxObject}{wxobject}
b6b9d556
RR
278
279\wxheading{Include files}
280
281<wx/dataview.h>
282
a7af285d
VZ
283\wxheading{Library}
284
285\helpref{wxAdv}{librarieslist}
286
b6b9d556 287
809e21b5
FM
288\latexignore{\rtfignore{\wxheading{Members}}}
289
b6b9d556
RR
290\membersection{wxDataViewToggleRenderer::wxDataViewToggleRenderer}\label{wxdataviewtogglerendererwxdataviewtogglerenderer}
291
292\func{}{wxDataViewToggleRenderer}{\param{const wxString\& }{varianttype = wxT("bool")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}}
293
294
295\section{\class{wxDataViewBitmapRenderer}}\label{wxdataviewbitmaprenderer}
296
297wxDataViewBitmapRenderer
298
299\wxheading{Derived from}
300
7376079d
VZ
301\helpref{wxDataViewRenderer}{wxdataviewrenderer}\\
302\helpref{wxObject}{wxobject}
b6b9d556
RR
303
304\wxheading{Include files}
305
306<wx/dataview.h>
307
a7af285d
VZ
308\wxheading{Library}
309
310\helpref{wxAdv}{librarieslist}
311
b6b9d556 312
809e21b5
FM
313\latexignore{\rtfignore{\wxheading{Members}}}
314
b6b9d556
RR
315\membersection{wxDataViewBitmapRenderer::wxDataViewBitmapRenderer}\label{wxdataviewbitmaprendererwxdataviewbitmaprenderer}
316
317\func{}{wxDataViewBitmapRenderer}{\param{const wxString\& }{varianttype = wxT("wxBitmap")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}}
318
319
320\section{\class{wxDataViewDateRenderer}}\label{wxdataviewdaterenderer}
321
322wxDataViewDateRenderer
323
324
325\wxheading{Derived from}
326
7376079d
VZ
327\helpref{wxDataViewRenderer}{wxdataviewrenderer}\\
328\helpref{wxObject}{wxobject}
b6b9d556
RR
329
330\wxheading{Include files}
331
332<wx/dataview.h>
333
a7af285d
VZ
334\wxheading{Library}
335
336\helpref{wxAdv}{librarieslist}
337
809e21b5
FM
338
339\latexignore{\rtfignore{\wxheading{Members}}}
340
b6b9d556
RR
341\membersection{wxDataViewDateRenderer::wxDataViewDateRenderer}\label{wxdataviewdaterendererwxdataviewdaterenderer}
342
343\func{}{wxDataViewDateRenderer}{\param{const wxString\& }{varianttype = wxT("datetime")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_ACTIVATABLE}}
344
345
346\section{\class{wxDataViewCustomRenderer}}\label{wxdataviewcustomrenderer}
347
81a22037
RR
348You need to derive a new class from wxDataViewCustomRenderer in
349order to write a new renderer. You need to override at least
350\helpref{SetValue}{wxdataviewrenderersetvalue},
305c49a1
RR
351\helpref{GetValue}{wxdataviewrenderergetvalue},
352\helpref{GetSize}{wxdataviewcustomrenderergetsize}
353and \helpref{Render}{wxdataviewcustomrendererrender}.
354
81a22037
RR
355If you want your renderer to support in-place editing then you
356also need to override
305c49a1
RR
357\helpref{HasEditorCtrl}{wxdataviewcustomrendererhaseditorctrl},
358\helpref{CreateEditorCtrl}{wxdataviewcustomrenderercreateeditorctrl}
359and \helpref{GetValueFromEditorCtrl}{wxdataviewcustomrenderergetvaluefromeditorctrl}.
360Note that a special event handler will be pushed onto that
361editor control which handles <ENTER> and focus out events
362in order to end the editing.
b6b9d556
RR
363
364\wxheading{Derived from}
365
7376079d
VZ
366\helpref{wxDataViewRenderer}{wxdataviewrenderer}\\
367\helpref{wxObject}{wxobject}
b6b9d556
RR
368
369\wxheading{Include files}
370
371<wx/dataview.h>
372
a7af285d
VZ
373\wxheading{Library}
374
375\helpref{wxAdv}{librarieslist}
376
809e21b5
FM
377
378\latexignore{\rtfignore{\wxheading{Members}}}
379
b6b9d556
RR
380\membersection{wxDataViewCustomRenderer::wxDataViewCustomRenderer}\label{wxdataviewcustomrendererwxdataviewcustomrenderer}
381
382\func{}{wxDataViewCustomRenderer}{\param{const wxString\& }{varianttype = wxT("string")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{bool }{no\_init = false}}
383
384Constructor.
385
386\membersection{wxDataViewCustomRenderer::\destruct{wxDataViewCustomRenderer}}\label{wxdataviewcustomrendererdtor}
387
388\func{}{\destruct{wxDataViewCustomRenderer}}{\void}
389
390Destructor.
391
305c49a1
RR
392
393\membersection{wxDataViewCustomRenderer::HasEditorCtrl}\label{wxdataviewcustomrendererhaseditorctrl}
394
395\func{virtual bool}{HasEditorCtrl}{\void}
396
397Override this and make it return {\it true} in order to
398indicate that this renderer supports in-place editing.
399
400\membersection{wxDataViewCustomRenderer::CreateEditorCtrl}\label{wxdataviewcustomrenderercreateeditorctrl}
401
befba9e4 402\func{virtual wxControl*}{CreateEditorCtrl}{\param{wxWindow *}{parent}, \param{wxRect }{labelRect}, \param{const wxVariant \& }{value}}
305c49a1
RR
403
404Override this to create the actual editor control once editing
405is about to start. {\it parent} is the parent of the editor
406control, {\it labelRect} indicates the position and
407size of the editor control and {\it value} is its initial value:
408
409{\small
410\begin{verbatim}
411{
412 long l = value;
413 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
414 labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l );
415}
416\end{verbatim}
417}
418
419\membersection{wxDataViewCustomRenderer::GetValueFromEditorCtrl}\label{wxdataviewcustomrenderergetvaluefromeditorctrl}
420
7a4523c8 421\func{virtual bool}{GetValueFromEditorCtrl}{\param{wxControl* }{editor}, \param{wxVariant \& }{value}}
305c49a1
RR
422
423Overrride this so that the renderer can get the value
424from the editor control (pointed to by {\it editor}):
425
426{\small
427\begin{verbatim}
428{
429 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
430 long l = sc->GetValue();
431 value = l;
432 return true;
433}
434\end{verbatim}
435}
436
b6b9d556
RR
437\membersection{wxDataViewCustomRenderer::Activate}\label{wxdataviewcustomrendereractivate}
438
d0b67421 439\func{virtual bool}{Activate}{\param{wxRect }{cell}, \param{wxDataViewModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
b6b9d556
RR
440
441Override this to react to double clicks or <ENTER>.
442
443\membersection{wxDataViewCustomRenderer::GetDC}\label{wxdataviewcustomrenderergetdc}
444
445\func{virtual wxDC*}{GetDC}{\void}
446
447Create DC on request. Internal.
448
449
450\membersection{wxDataViewCustomRenderer::GetSize}\label{wxdataviewcustomrenderergetsize}
451
452\func{virtual wxSize}{GetSize}{\void}
453
454Return size required to show content.
455
456
457\membersection{wxDataViewCustomRenderer::LeftClick}\label{wxdataviewcustomrendererleftclick}
458
d0b67421 459\func{virtual bool}{LeftClick}{\param{wxPoint }{cursor}, \param{wxRect }{cell}, \param{wxDataViewModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
b6b9d556
RR
460
461Overrride this to react to a left click.
462
463\membersection{wxDataViewCustomRenderer::Render}\label{wxdataviewcustomrendererrender}
464
465\func{virtual bool}{Render}{\param{wxRect }{cell}, \param{wxDC* }{dc}, \param{int }{state}}
466
467Override this to render the cell. Before this is called,
468\helpref{SetValue}{wxdataviewrenderersetvalue} was called
469so that this instance knows what to render.
470
52e750fc
RR
471\membersection{wxDataViewCustomRenderer::RenderText}\label{wxdataviewcustomrendererrender}
472
473\func{bool}{RenderText}{\param{const wxString\& }{text}, \param{int }{xoffset}, \param{wxRect }{cell}, \param{wxDC* }{dc}, \param{int }{state}}
474
475This method should be called from within \helpref{Render}{wxdataviewcustomrendererrender}
476whenever you need to render simple text. This will ensure that the
477correct colour, font and vertical alignment will be chosen so the
478text will look the same as text drawn by native renderers.
479
b6b9d556
RR
480\membersection{wxDataViewCustomRenderer::RightClick}\label{wxdataviewcustomrendererrightclick}
481
d0b67421 482\func{virtual bool}{RightClick}{\param{wxPoint }{cursor}, \param{wxRect }{cell}, \param{wxDataViewModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
b6b9d556
RR
483
484Overrride this to react to a right click.
485
486\membersection{wxDataViewCustomRenderer::StartDrag}\label{wxdataviewcustomrendererstartdrag}
487
d0b67421 488\func{virtual bool}{StartDrag}{\param{wxPoint }{cursor}, \param{wxRect }{cell}, \param{wxDataViewModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
b6b9d556
RR
489
490Overrride this to start a drag operation.
491
492
52e750fc
RR
493\section{\class{wxDataViewSpinRenderer}}\label{wxdataviewspinrenderer}
494
495This is a specialized renderer for rendering integer values. It
496supports modifying the values in-place by using a wxSpinCtrl.
497The renderer only support variants of type {\it long}.
498
499\wxheading{Derived from}
500
501\helpref{wxDataViewCustomRenderer}{wxdataviewcustomrenderer}
502
503\wxheading{Include files}
504
505<dataview.h>
506
507\wxheading{Data structures}
508
509\latexignore{\rtfignore{\wxheading{Members}}}
510
511
512\membersection{wxDataViewSpinRenderer::wxDataViewSpinRenderer}\label{wxdataviewspinrendererwxdataviewspinrenderer}
513
514\func{}{wxDataViewSpinRenderer}{\param{int }{min}, \param{int }{max}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_EDITABLE}, \param{int }{alignment = wxDVR\_DEFAULT\_ALIGNMENT}}
515
516Constructor. {\it min} and {\it max} indicate the minimum und
517maximum values of for the wxSpinCtrl.
b6b9d556 518