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