]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/dataviewrenderer.tex
allow to optionally use vendor name component in standard paths (slightly modified...
[wxWidgets.git] / docs / latex / wx / dataviewrenderer.tex
1
2 \section{\class{wxDataViewRenderer}}\label{wxdataviewrenderer}
3
4
5 This class is used by \helpref{wxDataViewCtrl}{wxdataviewctrl} to
6 render the individual cells. One instance of a renderer class is
7 owned by \helpref{wxDataViewColumn}{wxdataviewcolumn}. There is
8 a number of ready-to-use renderers provided:
9 \helpref{wxDataViewTextRenderer}{wxdataviewtextrenderer},
10 \helpref{wxDataViewIconTextRenderer}{wxdataviewicontextrenderer},
11 \helpref{wxDataViewToggleRenderer}{wxdataviewtogglerenderer},
12 \helpref{wxDataViewProgressRenderer}{wxdataviewprogressrenderer},
13 \helpref{wxDataViewBitmapRenderer}{wxdataviewbitmaprenderer},
14 \helpref{wxDataViewDateRenderer}{wxdataviewdaterenderer}.
15 \helpref{wxDataViewSpinRenderer}{wxdataviewspinrenderer}.
16
17 Additionally, the user can write own renderers by deriving from
18 \helpref{wxDataViewCustomRenderer}{wxdataviewcustomrenderer}.
19
20 The {\it wxDataViewCellMode} flag controls, what actions
21 the cell data allows. {\it wxDATAVIEW\_CELL\_ACTIVATABLE}
22 indicates that the user can double click the cell and
23 something will happen (e.g. a window for editing a date
24 will pop up). {\it wxDATAVIEW\_CELL\_EDITABLE} indicates
25 that the user can edit the data in-place, i.e. an control
26 will show up after a slow click on the cell. This behaviour
27 is best known from changing the filename in most file
28 managers etc.
29
30
31
32 {\small
33 \begin{verbatim}
34 enum wxDataViewCellMode
35 {
36 wxDATAVIEW_CELL_INERT,
37 wxDATAVIEW_CELL_ACTIVATABLE,
38 wxDATAVIEW_CELL_EDITABLE
39 };
40 \end{verbatim}
41 }
42
43 The {\it wxDataViewCellRenderState} flag controls how the
44 the renderer should display its contents in a cell:
45
46 {\small
47 \begin{verbatim}
48 enum 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
67 \wxheading{Library}
68
69 \helpref{wxAdv}{librarieslist}
70
71
72
73 \latexignore{\rtfignore{\wxheading{Members}}}
74
75 \membersection{wxDataViewRenderer::wxDataViewRenderer}\label{wxdataviewrendererwxdataviewrenderer}
76
77 \func{}{wxDataViewRenderer}{\param{const wxString\& }{varianttype}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{alignment = wxALIGN\_LEFT|wxALIGN\_CENTRE\_VERTICAL}}
78
79 Constructor.
80
81 \membersection{wxDataViewRenderer::GetMode}\label{wxdataviewrenderergetmode}
82
83 \func{virtual wxDataViewCellMode}{GetMode}{\void}
84
85 Returns the cell mode.
86
87 \membersection{wxDataViewRenderer::GetOwner}\label{wxdataviewrenderergetowner}
88
89 \func{virtual wxDataViewColumn*}{GetOwner}{\void}
90
91 Returns pointer to the owning \helpref{wxDataViewColumn}{wxdataviewcolumn}.
92
93 \membersection{wxDataViewRenderer::GetValue}\label{wxdataviewrenderergetvalue}
94
95 \func{virtual bool}{GetValue}{\param{wxVariant\& }{value}}
96
97 This methods retrieves the value from the renderer in order to
98 transfer the value back to the data model. Returns {\it false}
99 on failure.
100
101 \membersection{wxDataViewRenderer::GetVariantType}\label{wxdataviewrenderergetvarianttype}
102
103 \func{virtual wxString}{GetVariantType}{\void}
104
105 Returns a string with the type of the \helpref{wxVariant}{wxvariant}
106 supported by this renderer.
107
108 \membersection{wxDataViewRenderer::SetOwner}\label{wxdataviewrenderersetowner}
109
110 \func{virtual void}{SetOwner}{\param{wxDataViewColumn* }{owner}}
111
112 Sets the owning \helpref{wxDataViewColumn}{wxdataviewcolumn}. This
113 is usually called from within wxDataViewColumn.
114
115 \membersection{wxDataViewRenderer::SetValue}\label{wxdataviewrenderersetvalue}
116
117 \func{virtual bool}{SetValue}{\param{const wxVariant\& }{value}}
118
119 Set the value of the renderer (and thus its cell) to {\it value}.
120 The 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
127 Before data is committed to the data model, it is passed to this
128 method where it can be checked for validity. This can also be
129 used for checking a valid range or limiting the user input in
130 a certain aspect (e.g. max number of characters or only alphanumeric
131 input, ASCII only etc.). Return {\it false} if the value is
132 not valid.
133
134 Please note that due to implementation limitations, this validation
135 is done after the editing control already is destroyed and the
136 editing process finished.
137
138
139 \section{\class{wxDataViewTextRenderer}}\label{wxdataviewtextrenderer}
140
141 wxDataViewTextRenderer is used for rendering text. It supports
142 in-place editing if desired.
143
144
145 \wxheading{Derived from}
146
147 \helpref{wxDataViewRenderer}{wxdataviewrenderer}\\
148 \helpref{wxObject}{wxobject}
149
150 \wxheading{Include files}
151
152 <wx/dataview.h>
153
154 \wxheading{Library}
155
156 \helpref{wxAdv}{librarieslist}
157
158
159 \latexignore{\rtfignore{\wxheading{Members}}}
160
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
169 wxDataViewProgressRenderer
170
171
172 \wxheading{Derived from}
173
174 \helpref{wxDataViewRenderer}{wxdataviewrenderer}\\
175 \helpref{wxObject}{wxobject}
176
177 \wxheading{Include files}
178
179 <wx/dataview.h>
180
181 \wxheading{Library}
182
183 \helpref{wxAdv}{librarieslist}
184
185
186 \latexignore{\rtfignore{\wxheading{Members}}}
187
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
193 \section{\class{wxDataViewIconText}}\label{wxdataviewicontext}
194
195 wxDataViewIconText is used by
196 \helpref{wxDataViewIconTextRenderer}{wxdataviewicontextrenderer}
197 for data transfer. This class can be converted to a from
198 a \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
214 Constructor.
215
216 \membersection{wxDataViewIconText::GetIcon}\label{wxdataviewicontextgeticon}
217
218 \constfunc{const wxIcon\&}{GetIcon}{\void}
219
220 Gets the icon.
221
222 \membersection{wxDataViewIconText::GetText}\label{wxdataviewicontextgettext}
223
224 \constfunc{wxString}{GetText}{\void}
225
226 Gets the text.
227
228 \membersection{wxDataViewIconText::SetIcon}\label{wxdataviewicontextseticon}
229
230 \func{void}{SetIcon}{\param{const wxIcon\& }{icon}}
231
232 Set the icon.
233
234 \membersection{wxDataViewIconText::SetText}\label{wxdataviewicontextsettext}
235
236 \func{void}{SetText}{\param{const wxString\& }{text}}
237
238 Set the text.
239
240 \section{\class{wxDataViewIconTextRenderer}}\label{wxdataviewicontextrenderer}
241
242 The wxDataViewIconTextRenderer class is used to display text with
243 a small icon next to it as it is typically done in a file manager.
244 This classes uses the \helpref{wxDataViewIconText}{wxdataviewicontext}
245 helper class to store its data. wxDataViewIonText can be converted
246 to a from a \helpref{wxVariant}{wxvariant} using the left shift
247 operator.
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
269
270 \section{\class{wxDataViewToggleRenderer}}\label{wxdataviewtogglerenderer}
271
272 wxDataViewToggleRenderer
273
274 \wxheading{Derived from}
275
276 \helpref{wxDataViewRenderer}{wxdataviewrenderer}\\
277 \helpref{wxObject}{wxobject}
278
279 \wxheading{Include files}
280
281 <wx/dataview.h>
282
283 \wxheading{Library}
284
285 \helpref{wxAdv}{librarieslist}
286
287
288 \latexignore{\rtfignore{\wxheading{Members}}}
289
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
297 wxDataViewBitmapRenderer
298
299 \wxheading{Derived from}
300
301 \helpref{wxDataViewRenderer}{wxdataviewrenderer}\\
302 \helpref{wxObject}{wxobject}
303
304 \wxheading{Include files}
305
306 <wx/dataview.h>
307
308 \wxheading{Library}
309
310 \helpref{wxAdv}{librarieslist}
311
312
313 \latexignore{\rtfignore{\wxheading{Members}}}
314
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
322 wxDataViewDateRenderer
323
324
325 \wxheading{Derived from}
326
327 \helpref{wxDataViewRenderer}{wxdataviewrenderer}\\
328 \helpref{wxObject}{wxobject}
329
330 \wxheading{Include files}
331
332 <wx/dataview.h>
333
334 \wxheading{Library}
335
336 \helpref{wxAdv}{librarieslist}
337
338
339 \latexignore{\rtfignore{\wxheading{Members}}}
340
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
348 You need to derive a new class from wxDataViewCustomRenderer in
349 order to write a new renderer. You need to override at least
350 \helpref{SetValue}{wxdataviewrenderersetvalue},
351 \helpref{GetValue}{wxdataviewrenderergetvalue},
352 \helpref{GetSize}{wxdataviewcustomrenderergetsize}
353 and \helpref{Render}{wxdataviewcustomrendererrender}.
354
355 If you want your renderer to support in-place editing then you
356 also need to override
357 \helpref{HasEditorCtrl}{wxdataviewcustomrendererhaseditorctrl},
358 \helpref{CreateEditorCtrl}{wxdataviewcustomrenderercreateeditorctrl}
359 and \helpref{GetValueFromEditorCtrl}{wxdataviewcustomrenderergetvaluefromeditorctrl}.
360 Note that a special event handler will be pushed onto that
361 editor control which handles <ENTER> and focus out events
362 in order to end the editing.
363
364 \wxheading{Derived from}
365
366 \helpref{wxDataViewRenderer}{wxdataviewrenderer}\\
367 \helpref{wxObject}{wxobject}
368
369 \wxheading{Include files}
370
371 <wx/dataview.h>
372
373 \wxheading{Library}
374
375 \helpref{wxAdv}{librarieslist}
376
377
378 \latexignore{\rtfignore{\wxheading{Members}}}
379
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
384 Constructor.
385
386 \membersection{wxDataViewCustomRenderer::\destruct{wxDataViewCustomRenderer}}\label{wxdataviewcustomrendererdtor}
387
388 \func{}{\destruct{wxDataViewCustomRenderer}}{\void}
389
390 Destructor.
391
392
393 \membersection{wxDataViewCustomRenderer::HasEditorCtrl}\label{wxdataviewcustomrendererhaseditorctrl}
394
395 \func{virtual bool}{HasEditorCtrl}{\void}
396
397 Override this and make it return {\it true} in order to
398 indicate that this renderer supports in-place editing.
399
400 \membersection{wxDataViewCustomRenderer::CreateEditorCtrl}\label{wxdataviewcustomrenderercreateeditorctrl}
401
402 \func{virtual wxControl*}{CreateEditorCtrl}{\param{wxWindow *}{parent}, \param{wxRect }{labelRect}, \param{const wxVariant \& }{value}}
403
404 Override this to create the actual editor control once editing
405 is about to start. {\it parent} is the parent of the editor
406 control, {\it labelRect} indicates the position and
407 size 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
421 \func{virtual bool}{GetValueFromEditorCtrl}{\param{wxControl* }{editor}, \param{wxVariant \& }{value}}
422
423 Overrride this so that the renderer can get the value
424 from 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
437 \membersection{wxDataViewCustomRenderer::Activate}\label{wxdataviewcustomrendereractivate}
438
439 \func{virtual bool}{Activate}{\param{wxRect }{cell}, \param{wxDataViewModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
440
441 Override this to react to double clicks or <ENTER>.
442
443 \membersection{wxDataViewCustomRenderer::GetDC}\label{wxdataviewcustomrenderergetdc}
444
445 \func{virtual wxDC*}{GetDC}{\void}
446
447 Create DC on request. Internal.
448
449
450 \membersection{wxDataViewCustomRenderer::GetSize}\label{wxdataviewcustomrenderergetsize}
451
452 \func{virtual wxSize}{GetSize}{\void}
453
454 Return size required to show content.
455
456
457 \membersection{wxDataViewCustomRenderer::LeftClick}\label{wxdataviewcustomrendererleftclick}
458
459 \func{virtual bool}{LeftClick}{\param{wxPoint }{cursor}, \param{wxRect }{cell}, \param{wxDataViewModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
460
461 Overrride 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
467 Override this to render the cell. Before this is called,
468 \helpref{SetValue}{wxdataviewrenderersetvalue} was called
469 so that this instance knows what to render.
470
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
475 This method should be called from within \helpref{Render}{wxdataviewcustomrendererrender}
476 whenever you need to render simple text. This will ensure that the
477 correct colour, font and vertical alignment will be chosen so the
478 text will look the same as text drawn by native renderers.
479
480 \membersection{wxDataViewCustomRenderer::RightClick}\label{wxdataviewcustomrendererrightclick}
481
482 \func{virtual bool}{RightClick}{\param{wxPoint }{cursor}, \param{wxRect }{cell}, \param{wxDataViewModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
483
484 Overrride this to react to a right click.
485
486 \membersection{wxDataViewCustomRenderer::StartDrag}\label{wxdataviewcustomrendererstartdrag}
487
488 \func{virtual bool}{StartDrag}{\param{wxPoint }{cursor}, \param{wxRect }{cell}, \param{wxDataViewModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
489
490 Overrride this to start a drag operation.
491
492
493 \section{\class{wxDataViewSpinRenderer}}\label{wxdataviewspinrenderer}
494
495 This is a specialized renderer for rendering integer values. It
496 supports modifying the values in-place by using a wxSpinCtrl.
497 The 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
516 Constructor. {\it min} and {\it max} indicate the minimum und
517 maximum values of for the wxSpinCtrl.
518