2 \section{\class{wxDataViewRenderer
}}\label{wxdataviewrenderer
}
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{wxDataViewToggleRenderer
}{wxdataviewtogglerenderer
},
11 \helpref{wxDataViewProgressRenderer
}{wxdataviewprogressrenderer
},
12 \helpref{wxDataViewBitmapRenderer
}{wxdataviewbitmaprenderer
},
13 \helpref{wxDataViewDateRenderer
}{wxdataviewdaterenderer
}.
15 Additionally, the user can write own renderers by deriving from
16 \helpref{wxDataViewCustomRenderer
}{wxdataviewcustomrenderer
}.
18 The
{\it wxDataViewCellMode
} flag controls, what actions
19 the cell data allows.
{\it wxDATAVIEW
\_CELL\_ACTIVATABLE}
20 indicates that the user can double click the cell and
21 something will happen (e.g. a window for editing a date
22 will pop up).
{\it wxDATAVIEW
\_CELL\_EDITABLE} indicates
23 that the user can edit the data in-place, i.e. an control
24 will show up after a slow click on the cell. This behaviour
25 is best known from changing the filename in most file
32 enum wxDataViewCellMode
34 wxDATAVIEW_CELL_INERT,
35 wxDATAVIEW_CELL_ACTIVATABLE,
36 wxDATAVIEW_CELL_EDITABLE
41 The
{\it wxDataViewCellRenderState
} flag controls how the
42 the renderer should display its contents in a cell:
46 enum wxDataViewCellRenderState
48 wxDATAVIEW_CELL_SELECTED =
1,
49 wxDATAVIEW_CELL_PRELIT =
2,
50 wxDATAVIEW_CELL_INSENSITIVE =
4,
51 wxDATAVIEW_CELL_FOCUSED =
8
57 \wxheading{Derived from
}
59 \helpref{wxObject
}{wxobject
}
61 \wxheading{Include files
}
67 \helpref{wxAdv
}{librarieslist
}
71 \latexignore{\rtfignore{\wxheading{Members
}}}
73 \membersection{wxDataViewRenderer::wxDataViewRenderer
}\label{wxdataviewrendererwxdataviewrenderer
}
75 \func{}{wxDataViewRenderer
}{\param{const wxString\&
}{varianttype
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
79 \membersection{wxDataViewRenderer::GetMode
}\label{wxdataviewrenderergetmode
}
81 \func{virtual wxDataViewCellMode
}{GetMode
}{\void}
83 Returns the cell mode.
85 \membersection{wxDataViewRenderer::GetOwner
}\label{wxdataviewrenderergetowner
}
87 \func{virtual wxDataViewColumn*
}{GetOwner
}{\void}
89 Returns pointer to the owning
\helpref{wxDataViewColumn
}{wxdataviewcolumn
}.
91 \membersection{wxDataViewRenderer::GetValue
}\label{wxdataviewrenderergetvalue
}
93 \func{virtual bool
}{GetValue
}{\param{wxVariant\&
}{value
}}
95 This methods retrieves the value from the renderer in order to
96 transfer the value back to the data model. Returns
{\it false
}
99 \membersection{wxDataViewRenderer::GetVariantType
}\label{wxdataviewrenderergetvarianttype
}
101 \func{virtual wxString
}{GetVariantType
}{\void}
103 Returns a string with the type of the
\helpref{wxVariant
}{wxvariant
}
104 supported by this renderer.
106 \membersection{wxDataViewRenderer::SetOwner
}\label{wxdataviewrenderersetowner
}
108 \func{virtual void
}{SetOwner
}{\param{wxDataViewColumn*
}{owner
}}
110 Sets the owning
\helpref{wxDataViewColumn
}{wxdataviewcolumn
}. This
111 is usually called from within wxDataViewColumn.
113 \membersection{wxDataViewRenderer::SetValue
}\label{wxdataviewrenderersetvalue
}
115 \func{virtual bool
}{SetValue
}{\param{const wxVariant\&
}{value
}}
117 Set the value of the renderer (and thus its cell) to
{\it value
}.
118 The internal code will then render this cell with this data.
121 \membersection{wxDataViewRenderer::Validate
}\label{wxdataviewrenderervalidate
}
123 \func{virtual bool
}{Validate
}{\param{wxVariant\&
}{value
}}
125 Before data is committed to the data model, it is passed to this
126 method where it can be checked for validity. This can also be
127 used for checking a valid range or limiting the user input in
128 a certain aspect (e.g. max number of characters or only alphanumeric
129 input, ASCII only etc.). Return
{\it false
} if the value is
132 Please note that due to implementation limitations, this validation
133 is done after the editing control already is destroyed and the
134 editing process finished.
137 \section{\class{wxDataViewTextRenderer
}}\label{wxdataviewtextrenderer
}
139 wxDataViewTextRenderer is used for rendering text. It supports
140 in-place editing if desired.
143 \wxheading{Derived from
}
145 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}\\
146 \helpref{wxObject
}{wxobject
}
148 \wxheading{Include files
}
154 \helpref{wxAdv
}{librarieslist
}
157 \latexignore{\rtfignore{\wxheading{Members
}}}
159 \membersection{wxDataViewTextRenderer::wxDataViewTextRenderer
}\label{wxdataviewtextrendererwxdataviewtextrenderer
}
161 \func{}{wxDataViewTextRenderer
}{\param{const wxString\&
}{varianttype = wxT("string")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
165 \section{\class{wxDataViewProgressRenderer
}}\label{wxdataviewprogressrenderer
}
167 wxDataViewProgressRenderer
170 \wxheading{Derived from
}
172 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}\\
173 \helpref{wxObject
}{wxobject
}
175 \wxheading{Include files
}
181 \helpref{wxAdv
}{librarieslist
}
184 \latexignore{\rtfignore{\wxheading{Members
}}}
186 \membersection{wxDataViewProgressRenderer::wxDataViewProgressRenderer
}\label{wxdataviewprogressrendererwxdataviewprogressrenderer
}
188 \func{}{wxDataViewProgressRenderer
}{\param{const wxString\&
}{label = wxEmptyString
},
\param{const wxString\&
}{varianttype = wxT("long")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
192 \section{\class{wxDataViewToggleRenderer
}}\label{wxdataviewtogglerenderer
}
194 wxDataViewToggleRenderer
196 \wxheading{Derived from
}
198 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}\\
199 \helpref{wxObject
}{wxobject
}
201 \wxheading{Include files
}
207 \helpref{wxAdv
}{librarieslist
}
210 \latexignore{\rtfignore{\wxheading{Members
}}}
212 \membersection{wxDataViewToggleRenderer::wxDataViewToggleRenderer
}\label{wxdataviewtogglerendererwxdataviewtogglerenderer
}
214 \func{}{wxDataViewToggleRenderer
}{\param{const wxString\&
}{varianttype = wxT("bool")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
217 \section{\class{wxDataViewBitmapRenderer
}}\label{wxdataviewbitmaprenderer
}
219 wxDataViewBitmapRenderer
221 \wxheading{Derived from
}
223 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}\\
224 \helpref{wxObject
}{wxobject
}
226 \wxheading{Include files
}
232 \helpref{wxAdv
}{librarieslist
}
235 \latexignore{\rtfignore{\wxheading{Members
}}}
237 \membersection{wxDataViewBitmapRenderer::wxDataViewBitmapRenderer
}\label{wxdataviewbitmaprendererwxdataviewbitmaprenderer
}
239 \func{}{wxDataViewBitmapRenderer
}{\param{const wxString\&
}{varianttype = wxT("wxBitmap")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
242 \section{\class{wxDataViewDateRenderer
}}\label{wxdataviewdaterenderer
}
244 wxDataViewDateRenderer
247 \wxheading{Derived from
}
249 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}\\
250 \helpref{wxObject
}{wxobject
}
252 \wxheading{Include files
}
258 \helpref{wxAdv
}{librarieslist
}
261 \latexignore{\rtfignore{\wxheading{Members
}}}
263 \membersection{wxDataViewDateRenderer::wxDataViewDateRenderer
}\label{wxdataviewdaterendererwxdataviewdaterenderer
}
265 \func{}{wxDataViewDateRenderer
}{\param{const wxString\&
}{varianttype = wxT("datetime")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_ACTIVATABLE}}
268 \section{\class{wxDataViewCustomRenderer
}}\label{wxdataviewcustomrenderer
}
270 You need to derive a new class from wxDataViewCustomRenderer in
271 order to write a new renderer. You need to override at least
272 \helpref{SetValue
}{wxdataviewrenderersetvalue
},
273 \helpref{GetValue
}{wxdataviewrenderergetvalue
},
274 \helpref{GetSize
}{wxdataviewcustomrenderergetsize
}
275 and
\helpref{Render
}{wxdataviewcustomrendererrender
}.
277 If you want your renderer to support in-place editing then you
278 also need to override
279 \helpref{HasEditorCtrl
}{wxdataviewcustomrendererhaseditorctrl
},
280 \helpref{CreateEditorCtrl
}{wxdataviewcustomrenderercreateeditorctrl
}
281 and
\helpref{GetValueFromEditorCtrl
}{wxdataviewcustomrenderergetvaluefromeditorctrl
}.
282 Note that a special event handler will be pushed onto that
283 editor control which handles <ENTER> and focus out events
284 in order to end the editing.
286 \wxheading{Derived from
}
288 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}\\
289 \helpref{wxObject
}{wxobject
}
291 \wxheading{Include files
}
297 \helpref{wxAdv
}{librarieslist
}
300 \latexignore{\rtfignore{\wxheading{Members
}}}
302 \membersection{wxDataViewCustomRenderer::wxDataViewCustomRenderer
}\label{wxdataviewcustomrendererwxdataviewcustomrenderer
}
304 \func{}{wxDataViewCustomRenderer
}{\param{const wxString\&
}{varianttype = wxT("string")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT},
\param{bool
}{no
\_init = false
}}
308 \membersection{wxDataViewCustomRenderer::
\destruct{wxDataViewCustomRenderer
}}\label{wxdataviewcustomrendererdtor
}
310 \func{}{\destruct{wxDataViewCustomRenderer
}}{\void}
315 \membersection{wxDataViewCustomRenderer::HasEditorCtrl
}\label{wxdataviewcustomrendererhaseditorctrl
}
317 \func{virtual bool
}{HasEditorCtrl
}{\void}
319 Override this and make it return
{\it true
} in order to
320 indicate that this renderer supports in-place editing.
322 \membersection{wxDataViewCustomRenderer::CreateEditorCtrl
}\label{wxdataviewcustomrenderercreateeditorctrl
}
324 \func{virtual wxControl*
}{CreateEditorCtrl
}{\param{wxWindow *
}{parent
},
\param{wxRect
}{labelRect
},
\param{const wxVariant \&
}{value
}}
326 Override this to create the actual editor control once editing
327 is about to start.
{\it parent
} is the parent of the editor
328 control,
{\it labelRect
} indicates the position and
329 size of the editor control and
{\it value
} is its initial value:
335 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
336 labelRect.GetTopLeft(), labelRect.GetSize(),
0,
0,
100, l );
341 \membersection{wxDataViewCustomRenderer::GetValueFromEditorCtrl
}\label{wxdataviewcustomrenderergetvaluefromeditorctrl
}
343 \func{virtual bool
}{GetValueFromEditorCtrl
}{\param{wxControl*
}{editor
},
\param{wxVariant \&
}{value
}}
345 Overrride this so that the renderer can get the value
346 from the editor control (pointed to by
{\it editor
}):
351 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
352 long l = sc->GetValue();
359 \membersection{wxDataViewCustomRenderer::Activate
}\label{wxdataviewcustomrendereractivate
}
361 \func{virtual bool
}{Activate
}{\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
363 Override this to react to double clicks or <ENTER>.
365 \membersection{wxDataViewCustomRenderer::GetDC
}\label{wxdataviewcustomrenderergetdc
}
367 \func{virtual wxDC*
}{GetDC
}{\void}
369 Create DC on request. Internal.
372 \membersection{wxDataViewCustomRenderer::GetSize
}\label{wxdataviewcustomrenderergetsize
}
374 \func{virtual wxSize
}{GetSize
}{\void}
376 Return size required to show content.
379 \membersection{wxDataViewCustomRenderer::LeftClick
}\label{wxdataviewcustomrendererleftclick
}
381 \func{virtual bool
}{LeftClick
}{\param{wxPoint
}{cursor
},
\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
383 Overrride this to react to a left click.
385 \membersection{wxDataViewCustomRenderer::Render
}\label{wxdataviewcustomrendererrender
}
387 \func{virtual bool
}{Render
}{\param{wxRect
}{cell
},
\param{wxDC*
}{dc
},
\param{int
}{state
}}
389 Override this to render the cell. Before this is called,
390 \helpref{SetValue
}{wxdataviewrenderersetvalue
} was called
391 so that this instance knows what to render.
393 \membersection{wxDataViewCustomRenderer::RightClick
}\label{wxdataviewcustomrendererrightclick
}
395 \func{virtual bool
}{RightClick
}{\param{wxPoint
}{cursor
},
\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
397 Overrride this to react to a right click.
399 \membersection{wxDataViewCustomRenderer::StartDrag
}\label{wxdataviewcustomrendererstartdrag
}
401 \func{virtual bool
}{StartDrag
}{\param{wxPoint
}{cursor
},
\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
403 Overrride this to start a drag operation.