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
}
66 \membersection{wxDataViewRenderer::wxDataViewRenderer
}\label{wxdataviewrendererwxdataviewrenderer
}
68 \func{}{wxDataViewRenderer
}{\param{const wxString\&
}{varianttype
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
72 \membersection{wxDataViewRenderer::GetMode
}\label{wxdataviewrenderergetmode
}
74 \func{virtual wxDataViewCellMode
}{GetMode
}{\void}
76 Returns the cell mode.
78 \membersection{wxDataViewRenderer::GetOwner
}\label{wxdataviewrenderergetowner
}
80 \func{virtual wxDataViewColumn*
}{GetOwner
}{\void}
82 Returns pointer to the owning
\helpref{wxDataViewColumn
}{wxdataviewcolumn
}.
84 \membersection{wxDataViewRenderer::GetValue
}\label{wxdataviewrenderergetvalue
}
86 \func{virtual bool
}{GetValue
}{\param{wxVariant\&
}{value
}}
88 This methods retrieves the value from the renderer in order to
89 transfer the value back to the data model. Returns
{\it false
}
92 \membersection{wxDataViewRenderer::GetVariantType
}\label{wxdataviewrenderergetvarianttype
}
94 \func{virtual wxString
}{GetVariantType
}{\void}
96 Returns a string with the type of the
\helpref{wxVariant
}{wxvariant
}
97 supported by this renderer.
99 \membersection{wxDataViewRenderer::SetOwner
}\label{wxdataviewrenderersetowner
}
101 \func{virtual void
}{SetOwner
}{\param{wxDataViewColumn*
}{owner
}}
103 Sets the owning
\helpref{wxDataViewColumn
}{wxdataviewcolumn
}. This
104 is usually called from within wxDataViewColumn.
106 \membersection{wxDataViewRenderer::SetValue
}\label{wxdataviewrenderersetvalue
}
108 \func{virtual bool
}{SetValue
}{\param{const wxVariant\&
}{value
}}
110 Set the value of the renderer (and thus its cell) to
{\it value
}.
111 The internal code will then render this cell with this data.
114 \membersection{wxDataViewRenderer::Validate
}\label{wxdataviewrenderervalidate
}
116 \func{virtual bool
}{Validate
}{\param{wxVariant\&
}{value
}}
118 Before data is committed to the data model, it is passed to this
119 method where it can be checked for validity. This can also be
120 used for checking a valid range or limiting the user input in
121 a certain aspect (e.g. max number of characters or only alphanumeric
122 input, ASCII only etc.). Return
{\it false
} if the value is
125 Please note that due to implementation limitations, this validation
126 is done after the editing control already is destroyed and the
127 editing process finished.
130 \section{\class{wxDataViewTextRenderer
}}\label{wxdataviewtextrenderer
}
132 wxDataViewTextRenderer is used for rendering text. It supports
133 in-place editing if desired.
136 \wxheading{Derived from
}
138 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}
140 \wxheading{Include files
}
145 \membersection{wxDataViewTextRenderer::wxDataViewTextRenderer
}\label{wxdataviewtextrendererwxdataviewtextrenderer
}
147 \func{}{wxDataViewTextRenderer
}{\param{const wxString\&
}{varianttype = wxT("string")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
151 \section{\class{wxDataViewProgressRenderer
}}\label{wxdataviewprogressrenderer
}
153 wxDataViewProgressRenderer
156 \wxheading{Derived from
}
158 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}
160 \wxheading{Include files
}
165 \membersection{wxDataViewProgressRenderer::wxDataViewProgressRenderer
}\label{wxdataviewprogressrendererwxdataviewprogressrenderer
}
167 \func{}{wxDataViewProgressRenderer
}{\param{const wxString\&
}{label = wxEmptyString
},
\param{const wxString\&
}{varianttype = wxT("long")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
171 \section{\class{wxDataViewToggleRenderer
}}\label{wxdataviewtogglerenderer
}
173 wxDataViewToggleRenderer
175 \wxheading{Derived from
}
177 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}
179 \wxheading{Include files
}
184 \membersection{wxDataViewToggleRenderer::wxDataViewToggleRenderer
}\label{wxdataviewtogglerendererwxdataviewtogglerenderer
}
186 \func{}{wxDataViewToggleRenderer
}{\param{const wxString\&
}{varianttype = wxT("bool")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
189 \section{\class{wxDataViewBitmapRenderer
}}\label{wxdataviewbitmaprenderer
}
191 wxDataViewBitmapRenderer
193 \wxheading{Derived from
}
195 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}
197 \wxheading{Include files
}
202 \membersection{wxDataViewBitmapRenderer::wxDataViewBitmapRenderer
}\label{wxdataviewbitmaprendererwxdataviewbitmaprenderer
}
204 \func{}{wxDataViewBitmapRenderer
}{\param{const wxString\&
}{varianttype = wxT("wxBitmap")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
207 \section{\class{wxDataViewDateRenderer
}}\label{wxdataviewdaterenderer
}
209 wxDataViewDateRenderer
212 \wxheading{Derived from
}
214 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}
216 \wxheading{Include files
}
220 \membersection{wxDataViewDateRenderer::wxDataViewDateRenderer
}\label{wxdataviewdaterendererwxdataviewdaterenderer
}
222 \func{}{wxDataViewDateRenderer
}{\param{const wxString\&
}{varianttype = wxT("datetime")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_ACTIVATABLE}}
225 \section{\class{wxDataViewCustomRenderer
}}\label{wxdataviewcustomrenderer
}
227 You need to derive a new class from wxDataViewCustomRenderer in
228 order to write a new renderer. You need to override at least
229 \helpref{SetValue
}{wxdataviewrenderersetvalue
},
230 \helpref{GetValue
}{wxdataviewrenderergetvalue
},
231 \helpref{GetSize
}{wxdataviewcustomrenderergetsize
}
232 and
\helpref{Render
}{wxdataviewcustomrendererrender
}.
234 If you want your renderer to support in-place editing then you
235 also need to override
236 \helpref{HasEditorCtrl
}{wxdataviewcustomrendererhaseditorctrl
},
237 \helpref{CreateEditorCtrl
}{wxdataviewcustomrenderercreateeditorctrl
}
238 and
\helpref{GetValueFromEditorCtrl
}{wxdataviewcustomrenderergetvaluefromeditorctrl
}.
239 Note that a special event handler will be pushed onto that
240 editor control which handles <ENTER> and focus out events
241 in order to end the editing.
243 \wxheading{Derived from
}
245 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}
247 \wxheading{Include files
}
251 \membersection{wxDataViewCustomRenderer::wxDataViewCustomRenderer
}\label{wxdataviewcustomrendererwxdataviewcustomrenderer
}
253 \func{}{wxDataViewCustomRenderer
}{\param{const wxString\&
}{varianttype = wxT("string")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT},
\param{bool
}{no
\_init = false
}}
257 \membersection{wxDataViewCustomRenderer::
\destruct{wxDataViewCustomRenderer
}}\label{wxdataviewcustomrendererdtor
}
259 \func{}{\destruct{wxDataViewCustomRenderer
}}{\void}
264 \membersection{wxDataViewCustomRenderer::HasEditorCtrl
}\label{wxdataviewcustomrendererhaseditorctrl
}
266 \func{virtual bool
}{HasEditorCtrl
}{\void}
268 Override this and make it return
{\it true
} in order to
269 indicate that this renderer supports in-place editing.
271 \membersection{wxDataViewCustomRenderer::CreateEditorCtrl
}\label{wxdataviewcustomrenderercreateeditorctrl
}
273 \func{virtual wxControl*
}{CreateEditorCtrl
}{\param{wxWindow *
}{parent
},
\param{wxRect
}{labelRect
},
\param{const wxVariant \&
}{value
}}
275 Override this to create the actual editor control once editing
276 is about to start.
{\it parent
} is the parent of the editor
277 control,
{\it labelRect
} indicates the position and
278 size of the editor control and
{\it value
} is its initial value:
284 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
285 labelRect.GetTopLeft(), labelRect.GetSize(),
0,
0,
100, l );
290 \membersection{wxDataViewCustomRenderer::GetValueFromEditorCtrl
}\label{wxdataviewcustomrenderergetvaluefromeditorctrl
}
292 \func{virtual bool
}{GetValueFromEditorCtrl
}{\param{wxControl*
}{editor
},
\param{wxVariant \&
}{value
}}
294 Overrride this so that the renderer can get the value
295 from the editor control (pointed to by
{\it editor
}):
300 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
301 long l = sc->GetValue();
308 \membersection{wxDataViewCustomRenderer::Activate
}\label{wxdataviewcustomrendereractivate
}
310 \func{virtual bool
}{Activate
}{\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
312 Override this to react to double clicks or <ENTER>.
314 \membersection{wxDataViewCustomRenderer::GetDC
}\label{wxdataviewcustomrenderergetdc
}
316 \func{virtual wxDC*
}{GetDC
}{\void}
318 Create DC on request. Internal.
321 \membersection{wxDataViewCustomRenderer::GetSize
}\label{wxdataviewcustomrenderergetsize
}
323 \func{virtual wxSize
}{GetSize
}{\void}
325 Return size required to show content.
328 \membersection{wxDataViewCustomRenderer::LeftClick
}\label{wxdataviewcustomrendererleftclick
}
330 \func{virtual bool
}{LeftClick
}{\param{wxPoint
}{cursor
},
\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
332 Overrride this to react to a left click.
334 \membersection{wxDataViewCustomRenderer::Render
}\label{wxdataviewcustomrendererrender
}
336 \func{virtual bool
}{Render
}{\param{wxRect
}{cell
},
\param{wxDC*
}{dc
},
\param{int
}{state
}}
338 Override this to render the cell. Before this is called,
339 \helpref{SetValue
}{wxdataviewrenderersetvalue
} was called
340 so that this instance knows what to render.
342 \membersection{wxDataViewCustomRenderer::RightClick
}\label{wxdataviewcustomrendererrightclick
}
344 \func{virtual bool
}{RightClick
}{\param{wxPoint
}{cursor
},
\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
346 Overrride this to react to a right click.
348 \membersection{wxDataViewCustomRenderer::StartDrag
}\label{wxdataviewcustomrendererstartdrag
}
350 \func{virtual bool
}{StartDrag
}{\param{wxPoint
}{cursor
},
\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
352 Overrride this to start a drag operation.