]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/dataviewrenderer.tex
added a script to automaitcally fix 'Derived from' doc sections; updated the 'Library...
[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
a7af285d
VZ
65\wxheading{Library}
66
67\helpref{wxAdv}{librarieslist}
68
b6b9d556
RR
69
70\membersection{wxDataViewRenderer::wxDataViewRenderer}\label{wxdataviewrendererwxdataviewrenderer}
71
72\func{}{wxDataViewRenderer}{\param{const wxString\& }{varianttype}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}}
73
74Constructor.
75
76\membersection{wxDataViewRenderer::GetMode}\label{wxdataviewrenderergetmode}
77
78\func{virtual wxDataViewCellMode}{GetMode}{\void}
79
80Returns the cell mode.
81
82\membersection{wxDataViewRenderer::GetOwner}\label{wxdataviewrenderergetowner}
83
84\func{virtual wxDataViewColumn*}{GetOwner}{\void}
85
86Returns pointer to the owning \helpref{wxDataViewColumn}{wxdataviewcolumn}.
87
88\membersection{wxDataViewRenderer::GetValue}\label{wxdataviewrenderergetvalue}
89
90\func{virtual bool}{GetValue}{\param{wxVariant\& }{value}}
91
92This methods retrieves the value from the renderer in order to
93transfer the value back to the data model. Returns {\it false}
94on failure.
95
96\membersection{wxDataViewRenderer::GetVariantType}\label{wxdataviewrenderergetvarianttype}
97
98\func{virtual wxString}{GetVariantType}{\void}
99
100Returns a string with the type of the \helpref{wxVariant}{wxvariant}
101supported by this renderer.
102
103\membersection{wxDataViewRenderer::SetOwner}\label{wxdataviewrenderersetowner}
104
105\func{virtual void}{SetOwner}{\param{wxDataViewColumn* }{owner}}
106
107Sets the owning \helpref{wxDataViewColumn}{wxdataviewcolumn}. This
108is usually called from within wxDataViewColumn.
109
110\membersection{wxDataViewRenderer::SetValue}\label{wxdataviewrenderersetvalue}
111
112\func{virtual bool}{SetValue}{\param{const wxVariant\& }{value}}
113
114Set the value of the renderer (and thus its cell) to {\it value}.
115The internal code will then render this cell with this data.
116
117
118\membersection{wxDataViewRenderer::Validate}\label{wxdataviewrenderervalidate}
119
120\func{virtual bool}{Validate}{\param{wxVariant\& }{value}}
121
305c49a1
RR
122Before data is committed to the data model, it is passed to this
123method where it can be checked for validity. This can also be
124used for checking a valid range or limiting the user input in
125a certain aspect (e.g. max number of characters or only alphanumeric
126input, ASCII only etc.). Return {\it false} if the value is
127not valid.
128
129Please note that due to implementation limitations, this validation
130is done after the editing control already is destroyed and the
131editing process finished.
b6b9d556
RR
132
133
134\section{\class{wxDataViewTextRenderer}}\label{wxdataviewtextrenderer}
135
305c49a1
RR
136wxDataViewTextRenderer is used for rendering text. It supports
137in-place editing if desired.
b6b9d556
RR
138
139
140\wxheading{Derived from}
141
142\helpref{wxDataViewRenderer}{wxdataviewrenderer}
143
144\wxheading{Include files}
145
146<wx/dataview.h>
147
a7af285d
VZ
148\wxheading{Library}
149
150\helpref{wxAdv}{librarieslist}
151
b6b9d556
RR
152
153\membersection{wxDataViewTextRenderer::wxDataViewTextRenderer}\label{wxdataviewtextrendererwxdataviewtextrenderer}
154
155\func{}{wxDataViewTextRenderer}{\param{const wxString\& }{varianttype = wxT("string")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}}
156
157
158
159\section{\class{wxDataViewProgressRenderer}}\label{wxdataviewprogressrenderer}
160
161wxDataViewProgressRenderer
162
163
164\wxheading{Derived from}
165
166\helpref{wxDataViewRenderer}{wxdataviewrenderer}
167
168\wxheading{Include files}
169
170<wx/dataview.h>
171
a7af285d
VZ
172\wxheading{Library}
173
174\helpref{wxAdv}{librarieslist}
175
b6b9d556
RR
176
177\membersection{wxDataViewProgressRenderer::wxDataViewProgressRenderer}\label{wxdataviewprogressrendererwxdataviewprogressrenderer}
178
179\func{}{wxDataViewProgressRenderer}{\param{const wxString\& }{label = wxEmptyString}, \param{const wxString\& }{varianttype = wxT("long")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}}
180
181
182
183\section{\class{wxDataViewToggleRenderer}}\label{wxdataviewtogglerenderer}
184
185wxDataViewToggleRenderer
186
187\wxheading{Derived from}
188
189\helpref{wxDataViewRenderer}{wxdataviewrenderer}
190
191\wxheading{Include files}
192
193<wx/dataview.h>
194
a7af285d
VZ
195\wxheading{Library}
196
197\helpref{wxAdv}{librarieslist}
198
b6b9d556
RR
199
200\membersection{wxDataViewToggleRenderer::wxDataViewToggleRenderer}\label{wxdataviewtogglerendererwxdataviewtogglerenderer}
201
202\func{}{wxDataViewToggleRenderer}{\param{const wxString\& }{varianttype = wxT("bool")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}}
203
204
205\section{\class{wxDataViewBitmapRenderer}}\label{wxdataviewbitmaprenderer}
206
207wxDataViewBitmapRenderer
208
209\wxheading{Derived from}
210
211\helpref{wxDataViewRenderer}{wxdataviewrenderer}
212
213\wxheading{Include files}
214
215<wx/dataview.h>
216
a7af285d
VZ
217\wxheading{Library}
218
219\helpref{wxAdv}{librarieslist}
220
b6b9d556
RR
221
222\membersection{wxDataViewBitmapRenderer::wxDataViewBitmapRenderer}\label{wxdataviewbitmaprendererwxdataviewbitmaprenderer}
223
224\func{}{wxDataViewBitmapRenderer}{\param{const wxString\& }{varianttype = wxT("wxBitmap")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}}
225
226
227\section{\class{wxDataViewDateRenderer}}\label{wxdataviewdaterenderer}
228
229wxDataViewDateRenderer
230
231
232\wxheading{Derived from}
233
234\helpref{wxDataViewRenderer}{wxdataviewrenderer}
235
236\wxheading{Include files}
237
238<wx/dataview.h>
239
a7af285d
VZ
240\wxheading{Library}
241
242\helpref{wxAdv}{librarieslist}
243
b6b9d556
RR
244\membersection{wxDataViewDateRenderer::wxDataViewDateRenderer}\label{wxdataviewdaterendererwxdataviewdaterenderer}
245
246\func{}{wxDataViewDateRenderer}{\param{const wxString\& }{varianttype = wxT("datetime")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_ACTIVATABLE}}
247
248
249\section{\class{wxDataViewCustomRenderer}}\label{wxdataviewcustomrenderer}
250
81a22037
RR
251You need to derive a new class from wxDataViewCustomRenderer in
252order to write a new renderer. You need to override at least
253\helpref{SetValue}{wxdataviewrenderersetvalue},
305c49a1
RR
254\helpref{GetValue}{wxdataviewrenderergetvalue},
255\helpref{GetSize}{wxdataviewcustomrenderergetsize}
256and \helpref{Render}{wxdataviewcustomrendererrender}.
257
81a22037
RR
258If you want your renderer to support in-place editing then you
259also need to override
305c49a1
RR
260\helpref{HasEditorCtrl}{wxdataviewcustomrendererhaseditorctrl},
261\helpref{CreateEditorCtrl}{wxdataviewcustomrenderercreateeditorctrl}
262and \helpref{GetValueFromEditorCtrl}{wxdataviewcustomrenderergetvaluefromeditorctrl}.
263Note that a special event handler will be pushed onto that
264editor control which handles <ENTER> and focus out events
265in order to end the editing.
b6b9d556
RR
266
267\wxheading{Derived from}
268
269\helpref{wxDataViewRenderer}{wxdataviewrenderer}
270
271\wxheading{Include files}
272
273<wx/dataview.h>
274
a7af285d
VZ
275\wxheading{Library}
276
277\helpref{wxAdv}{librarieslist}
278
b6b9d556
RR
279\membersection{wxDataViewCustomRenderer::wxDataViewCustomRenderer}\label{wxdataviewcustomrendererwxdataviewcustomrenderer}
280
281\func{}{wxDataViewCustomRenderer}{\param{const wxString\& }{varianttype = wxT("string")}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{bool }{no\_init = false}}
282
283Constructor.
284
285\membersection{wxDataViewCustomRenderer::\destruct{wxDataViewCustomRenderer}}\label{wxdataviewcustomrendererdtor}
286
287\func{}{\destruct{wxDataViewCustomRenderer}}{\void}
288
289Destructor.
290
305c49a1
RR
291
292\membersection{wxDataViewCustomRenderer::HasEditorCtrl}\label{wxdataviewcustomrendererhaseditorctrl}
293
294\func{virtual bool}{HasEditorCtrl}{\void}
295
296Override this and make it return {\it true} in order to
297indicate that this renderer supports in-place editing.
298
299\membersection{wxDataViewCustomRenderer::CreateEditorCtrl}\label{wxdataviewcustomrenderercreateeditorctrl}
300
befba9e4 301\func{virtual wxControl*}{CreateEditorCtrl}{\param{wxWindow *}{parent}, \param{wxRect }{labelRect}, \param{const wxVariant \& }{value}}
305c49a1
RR
302
303Override this to create the actual editor control once editing
304is about to start. {\it parent} is the parent of the editor
305control, {\it labelRect} indicates the position and
306size of the editor control and {\it value} is its initial value:
307
308{\small
309\begin{verbatim}
310{
311 long l = value;
312 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
313 labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l );
314}
315\end{verbatim}
316}
317
318\membersection{wxDataViewCustomRenderer::GetValueFromEditorCtrl}\label{wxdataviewcustomrenderergetvaluefromeditorctrl}
319
7a4523c8 320\func{virtual bool}{GetValueFromEditorCtrl}{\param{wxControl* }{editor}, \param{wxVariant \& }{value}}
305c49a1
RR
321
322Overrride this so that the renderer can get the value
323from the editor control (pointed to by {\it editor}):
324
325{\small
326\begin{verbatim}
327{
328 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
329 long l = sc->GetValue();
330 value = l;
331 return true;
332}
333\end{verbatim}
334}
335
b6b9d556
RR
336\membersection{wxDataViewCustomRenderer::Activate}\label{wxdataviewcustomrendereractivate}
337
338\func{virtual bool}{Activate}{\param{wxRect }{cell}, \param{wxDataViewListModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
339
340Override this to react to double clicks or <ENTER>.
341
342\membersection{wxDataViewCustomRenderer::GetDC}\label{wxdataviewcustomrenderergetdc}
343
344\func{virtual wxDC*}{GetDC}{\void}
345
346Create DC on request. Internal.
347
348
349\membersection{wxDataViewCustomRenderer::GetSize}\label{wxdataviewcustomrenderergetsize}
350
351\func{virtual wxSize}{GetSize}{\void}
352
353Return size required to show content.
354
355
356\membersection{wxDataViewCustomRenderer::LeftClick}\label{wxdataviewcustomrendererleftclick}
357
358\func{virtual bool}{LeftClick}{\param{wxPoint }{cursor}, \param{wxRect }{cell}, \param{wxDataViewListModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
359
360Overrride this to react to a left click.
361
362\membersection{wxDataViewCustomRenderer::Render}\label{wxdataviewcustomrendererrender}
363
364\func{virtual bool}{Render}{\param{wxRect }{cell}, \param{wxDC* }{dc}, \param{int }{state}}
365
366Override this to render the cell. Before this is called,
367\helpref{SetValue}{wxdataviewrenderersetvalue} was called
368so that this instance knows what to render.
369
370\membersection{wxDataViewCustomRenderer::RightClick}\label{wxdataviewcustomrendererrightclick}
371
372\func{virtual bool}{RightClick}{\param{wxPoint }{cursor}, \param{wxRect }{cell}, \param{wxDataViewListModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
373
374Overrride this to react to a right click.
375
376\membersection{wxDataViewCustomRenderer::StartDrag}\label{wxdataviewcustomrendererstartdrag}
377
378\func{virtual bool}{StartDrag}{\param{wxPoint }{cursor}, \param{wxRect }{cell}, \param{wxDataViewListModel* }{model}, \param{unsigned int }{col}, \param{unsigned int }{row}}
379
380Overrride this to start a drag operation.
381
382
383