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