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
}
70 \membersection{wxDataViewRenderer::wxDataViewRenderer
}\label{wxdataviewrendererwxdataviewrenderer
}
72 \func{}{wxDataViewRenderer
}{\param{const wxString\&
}{varianttype
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
76 \membersection{wxDataViewRenderer::GetMode
}\label{wxdataviewrenderergetmode
}
78 \func{virtual wxDataViewCellMode
}{GetMode
}{\void}
80 Returns the cell mode.
82 \membersection{wxDataViewRenderer::GetOwner
}\label{wxdataviewrenderergetowner
}
84 \func{virtual wxDataViewColumn*
}{GetOwner
}{\void}
86 Returns pointer to the owning
\helpref{wxDataViewColumn
}{wxdataviewcolumn
}.
88 \membersection{wxDataViewRenderer::GetValue
}\label{wxdataviewrenderergetvalue
}
90 \func{virtual bool
}{GetValue
}{\param{wxVariant\&
}{value
}}
92 This methods retrieves the value from the renderer in order to
93 transfer the value back to the data model. Returns
{\it false
}
96 \membersection{wxDataViewRenderer::GetVariantType
}\label{wxdataviewrenderergetvarianttype
}
98 \func{virtual wxString
}{GetVariantType
}{\void}
100 Returns a string with the type of the
\helpref{wxVariant
}{wxvariant
}
101 supported by this renderer.
103 \membersection{wxDataViewRenderer::SetOwner
}\label{wxdataviewrenderersetowner
}
105 \func{virtual void
}{SetOwner
}{\param{wxDataViewColumn*
}{owner
}}
107 Sets the owning
\helpref{wxDataViewColumn
}{wxdataviewcolumn
}. This
108 is usually called from within wxDataViewColumn.
110 \membersection{wxDataViewRenderer::SetValue
}\label{wxdataviewrenderersetvalue
}
112 \func{virtual bool
}{SetValue
}{\param{const wxVariant\&
}{value
}}
114 Set the value of the renderer (and thus its cell) to
{\it value
}.
115 The internal code will then render this cell with this data.
118 \membersection{wxDataViewRenderer::Validate
}\label{wxdataviewrenderervalidate
}
120 \func{virtual bool
}{Validate
}{\param{wxVariant\&
}{value
}}
122 Before data is committed to the data model, it is passed to this
123 method where it can be checked for validity. This can also be
124 used for checking a valid range or limiting the user input in
125 a certain aspect (e.g. max number of characters or only alphanumeric
126 input, ASCII only etc.). Return
{\it false
} if the value is
129 Please note that due to implementation limitations, this validation
130 is done after the editing control already is destroyed and the
131 editing process finished.
134 \section{\class{wxDataViewTextRenderer
}}\label{wxdataviewtextrenderer
}
136 wxDataViewTextRenderer is used for rendering text. It supports
137 in-place editing if desired.
140 \wxheading{Derived from
}
142 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}\\
143 \helpref{wxObject
}{wxobject
}
145 \wxheading{Include files
}
151 \helpref{wxAdv
}{librarieslist
}
154 \membersection{wxDataViewTextRenderer::wxDataViewTextRenderer
}\label{wxdataviewtextrendererwxdataviewtextrenderer
}
156 \func{}{wxDataViewTextRenderer
}{\param{const wxString\&
}{varianttype = wxT("string")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
160 \section{\class{wxDataViewProgressRenderer
}}\label{wxdataviewprogressrenderer
}
162 wxDataViewProgressRenderer
165 \wxheading{Derived from
}
167 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}\\
168 \helpref{wxObject
}{wxobject
}
170 \wxheading{Include files
}
176 \helpref{wxAdv
}{librarieslist
}
179 \membersection{wxDataViewProgressRenderer::wxDataViewProgressRenderer
}\label{wxdataviewprogressrendererwxdataviewprogressrenderer
}
181 \func{}{wxDataViewProgressRenderer
}{\param{const wxString\&
}{label = wxEmptyString
},
\param{const wxString\&
}{varianttype = wxT("long")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
185 \section{\class{wxDataViewToggleRenderer
}}\label{wxdataviewtogglerenderer
}
187 wxDataViewToggleRenderer
189 \wxheading{Derived from
}
191 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}\\
192 \helpref{wxObject
}{wxobject
}
194 \wxheading{Include files
}
200 \helpref{wxAdv
}{librarieslist
}
203 \membersection{wxDataViewToggleRenderer::wxDataViewToggleRenderer
}\label{wxdataviewtogglerendererwxdataviewtogglerenderer
}
205 \func{}{wxDataViewToggleRenderer
}{\param{const wxString\&
}{varianttype = wxT("bool")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
208 \section{\class{wxDataViewBitmapRenderer
}}\label{wxdataviewbitmaprenderer
}
210 wxDataViewBitmapRenderer
212 \wxheading{Derived from
}
214 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}\\
215 \helpref{wxObject
}{wxobject
}
217 \wxheading{Include files
}
223 \helpref{wxAdv
}{librarieslist
}
226 \membersection{wxDataViewBitmapRenderer::wxDataViewBitmapRenderer
}\label{wxdataviewbitmaprendererwxdataviewbitmaprenderer
}
228 \func{}{wxDataViewBitmapRenderer
}{\param{const wxString\&
}{varianttype = wxT("wxBitmap")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
231 \section{\class{wxDataViewDateRenderer
}}\label{wxdataviewdaterenderer
}
233 wxDataViewDateRenderer
236 \wxheading{Derived from
}
238 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}\\
239 \helpref{wxObject
}{wxobject
}
241 \wxheading{Include files
}
247 \helpref{wxAdv
}{librarieslist
}
249 \membersection{wxDataViewDateRenderer::wxDataViewDateRenderer
}\label{wxdataviewdaterendererwxdataviewdaterenderer
}
251 \func{}{wxDataViewDateRenderer
}{\param{const wxString\&
}{varianttype = wxT("datetime")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_ACTIVATABLE}}
254 \section{\class{wxDataViewCustomRenderer
}}\label{wxdataviewcustomrenderer
}
256 You need to derive a new class from wxDataViewCustomRenderer in
257 order to write a new renderer. You need to override at least
258 \helpref{SetValue
}{wxdataviewrenderersetvalue
},
259 \helpref{GetValue
}{wxdataviewrenderergetvalue
},
260 \helpref{GetSize
}{wxdataviewcustomrenderergetsize
}
261 and
\helpref{Render
}{wxdataviewcustomrendererrender
}.
263 If you want your renderer to support in-place editing then you
264 also need to override
265 \helpref{HasEditorCtrl
}{wxdataviewcustomrendererhaseditorctrl
},
266 \helpref{CreateEditorCtrl
}{wxdataviewcustomrenderercreateeditorctrl
}
267 and
\helpref{GetValueFromEditorCtrl
}{wxdataviewcustomrenderergetvaluefromeditorctrl
}.
268 Note that a special event handler will be pushed onto that
269 editor control which handles <ENTER> and focus out events
270 in order to end the editing.
272 \wxheading{Derived from
}
274 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}\\
275 \helpref{wxObject
}{wxobject
}
277 \wxheading{Include files
}
283 \helpref{wxAdv
}{librarieslist
}
285 \membersection{wxDataViewCustomRenderer::wxDataViewCustomRenderer
}\label{wxdataviewcustomrendererwxdataviewcustomrenderer
}
287 \func{}{wxDataViewCustomRenderer
}{\param{const wxString\&
}{varianttype = wxT("string")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT},
\param{bool
}{no
\_init = false
}}
291 \membersection{wxDataViewCustomRenderer::
\destruct{wxDataViewCustomRenderer
}}\label{wxdataviewcustomrendererdtor
}
293 \func{}{\destruct{wxDataViewCustomRenderer
}}{\void}
298 \membersection{wxDataViewCustomRenderer::HasEditorCtrl
}\label{wxdataviewcustomrendererhaseditorctrl
}
300 \func{virtual bool
}{HasEditorCtrl
}{\void}
302 Override this and make it return
{\it true
} in order to
303 indicate that this renderer supports in-place editing.
305 \membersection{wxDataViewCustomRenderer::CreateEditorCtrl
}\label{wxdataviewcustomrenderercreateeditorctrl
}
307 \func{virtual wxControl*
}{CreateEditorCtrl
}{\param{wxWindow *
}{parent
},
\param{wxRect
}{labelRect
},
\param{const wxVariant \&
}{value
}}
309 Override this to create the actual editor control once editing
310 is about to start.
{\it parent
} is the parent of the editor
311 control,
{\it labelRect
} indicates the position and
312 size of the editor control and
{\it value
} is its initial value:
318 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
319 labelRect.GetTopLeft(), labelRect.GetSize(),
0,
0,
100, l );
324 \membersection{wxDataViewCustomRenderer::GetValueFromEditorCtrl
}\label{wxdataviewcustomrenderergetvaluefromeditorctrl
}
326 \func{virtual bool
}{GetValueFromEditorCtrl
}{\param{wxControl*
}{editor
},
\param{wxVariant \&
}{value
}}
328 Overrride this so that the renderer can get the value
329 from the editor control (pointed to by
{\it editor
}):
334 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
335 long l = sc->GetValue();
342 \membersection{wxDataViewCustomRenderer::Activate
}\label{wxdataviewcustomrendereractivate
}
344 \func{virtual bool
}{Activate
}{\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
346 Override this to react to double clicks or <ENTER>.
348 \membersection{wxDataViewCustomRenderer::GetDC
}\label{wxdataviewcustomrenderergetdc
}
350 \func{virtual wxDC*
}{GetDC
}{\void}
352 Create DC on request. Internal.
355 \membersection{wxDataViewCustomRenderer::GetSize
}\label{wxdataviewcustomrenderergetsize
}
357 \func{virtual wxSize
}{GetSize
}{\void}
359 Return size required to show content.
362 \membersection{wxDataViewCustomRenderer::LeftClick
}\label{wxdataviewcustomrendererleftclick
}
364 \func{virtual bool
}{LeftClick
}{\param{wxPoint
}{cursor
},
\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
366 Overrride this to react to a left click.
368 \membersection{wxDataViewCustomRenderer::Render
}\label{wxdataviewcustomrendererrender
}
370 \func{virtual bool
}{Render
}{\param{wxRect
}{cell
},
\param{wxDC*
}{dc
},
\param{int
}{state
}}
372 Override this to render the cell. Before this is called,
373 \helpref{SetValue
}{wxdataviewrenderersetvalue
} was called
374 so that this instance knows what to render.
376 \membersection{wxDataViewCustomRenderer::RightClick
}\label{wxdataviewcustomrendererrightclick
}
378 \func{virtual bool
}{RightClick
}{\param{wxPoint
}{cursor
},
\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
380 Overrride this to react to a right click.
382 \membersection{wxDataViewCustomRenderer::StartDrag
}\label{wxdataviewcustomrendererstartdrag
}
384 \func{virtual bool
}{StartDrag
}{\param{wxPoint
}{cursor
},
\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
386 Overrride this to start a drag operation.