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
}
144 \wxheading{Include files
}
150 \helpref{wxAdv
}{librarieslist
}
153 \membersection{wxDataViewTextRenderer::wxDataViewTextRenderer
}\label{wxdataviewtextrendererwxdataviewtextrenderer
}
155 \func{}{wxDataViewTextRenderer
}{\param{const wxString\&
}{varianttype = wxT("string")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
159 \section{\class{wxDataViewProgressRenderer
}}\label{wxdataviewprogressrenderer
}
161 wxDataViewProgressRenderer
164 \wxheading{Derived from
}
166 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}
168 \wxheading{Include files
}
174 \helpref{wxAdv
}{librarieslist
}
177 \membersection{wxDataViewProgressRenderer::wxDataViewProgressRenderer
}\label{wxdataviewprogressrendererwxdataviewprogressrenderer
}
179 \func{}{wxDataViewProgressRenderer
}{\param{const wxString\&
}{label = wxEmptyString
},
\param{const wxString\&
}{varianttype = wxT("long")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
183 \section{\class{wxDataViewToggleRenderer
}}\label{wxdataviewtogglerenderer
}
185 wxDataViewToggleRenderer
187 \wxheading{Derived from
}
189 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}
191 \wxheading{Include files
}
197 \helpref{wxAdv
}{librarieslist
}
200 \membersection{wxDataViewToggleRenderer::wxDataViewToggleRenderer
}\label{wxdataviewtogglerendererwxdataviewtogglerenderer
}
202 \func{}{wxDataViewToggleRenderer
}{\param{const wxString\&
}{varianttype = wxT("bool")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
205 \section{\class{wxDataViewBitmapRenderer
}}\label{wxdataviewbitmaprenderer
}
207 wxDataViewBitmapRenderer
209 \wxheading{Derived from
}
211 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}
213 \wxheading{Include files
}
219 \helpref{wxAdv
}{librarieslist
}
222 \membersection{wxDataViewBitmapRenderer::wxDataViewBitmapRenderer
}\label{wxdataviewbitmaprendererwxdataviewbitmaprenderer
}
224 \func{}{wxDataViewBitmapRenderer
}{\param{const wxString\&
}{varianttype = wxT("wxBitmap")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT}}
227 \section{\class{wxDataViewDateRenderer
}}\label{wxdataviewdaterenderer
}
229 wxDataViewDateRenderer
232 \wxheading{Derived from
}
234 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}
236 \wxheading{Include files
}
242 \helpref{wxAdv
}{librarieslist
}
244 \membersection{wxDataViewDateRenderer::wxDataViewDateRenderer
}\label{wxdataviewdaterendererwxdataviewdaterenderer
}
246 \func{}{wxDataViewDateRenderer
}{\param{const wxString\&
}{varianttype = wxT("datetime")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_ACTIVATABLE}}
249 \section{\class{wxDataViewCustomRenderer
}}\label{wxdataviewcustomrenderer
}
251 You need to derive a new class from wxDataViewCustomRenderer in
252 order to write a new renderer. You need to override at least
253 \helpref{SetValue
}{wxdataviewrenderersetvalue
},
254 \helpref{GetValue
}{wxdataviewrenderergetvalue
},
255 \helpref{GetSize
}{wxdataviewcustomrenderergetsize
}
256 and
\helpref{Render
}{wxdataviewcustomrendererrender
}.
258 If you want your renderer to support in-place editing then you
259 also need to override
260 \helpref{HasEditorCtrl
}{wxdataviewcustomrendererhaseditorctrl
},
261 \helpref{CreateEditorCtrl
}{wxdataviewcustomrenderercreateeditorctrl
}
262 and
\helpref{GetValueFromEditorCtrl
}{wxdataviewcustomrenderergetvaluefromeditorctrl
}.
263 Note that a special event handler will be pushed onto that
264 editor control which handles <ENTER> and focus out events
265 in order to end the editing.
267 \wxheading{Derived from
}
269 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
}
271 \wxheading{Include files
}
277 \helpref{wxAdv
}{librarieslist
}
279 \membersection{wxDataViewCustomRenderer::wxDataViewCustomRenderer
}\label{wxdataviewcustomrendererwxdataviewcustomrenderer
}
281 \func{}{wxDataViewCustomRenderer
}{\param{const wxString\&
}{varianttype = wxT("string")
},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT},
\param{bool
}{no
\_init = false
}}
285 \membersection{wxDataViewCustomRenderer::
\destruct{wxDataViewCustomRenderer
}}\label{wxdataviewcustomrendererdtor
}
287 \func{}{\destruct{wxDataViewCustomRenderer
}}{\void}
292 \membersection{wxDataViewCustomRenderer::HasEditorCtrl
}\label{wxdataviewcustomrendererhaseditorctrl
}
294 \func{virtual bool
}{HasEditorCtrl
}{\void}
296 Override this and make it return
{\it true
} in order to
297 indicate that this renderer supports in-place editing.
299 \membersection{wxDataViewCustomRenderer::CreateEditorCtrl
}\label{wxdataviewcustomrenderercreateeditorctrl
}
301 \func{virtual wxControl*
}{CreateEditorCtrl
}{\param{wxWindow *
}{parent
},
\param{wxRect
}{labelRect
},
\param{const wxVariant \&
}{value
}}
303 Override this to create the actual editor control once editing
304 is about to start.
{\it parent
} is the parent of the editor
305 control,
{\it labelRect
} indicates the position and
306 size of the editor control and
{\it value
} is its initial value:
312 return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString,
313 labelRect.GetTopLeft(), labelRect.GetSize(),
0,
0,
100, l );
318 \membersection{wxDataViewCustomRenderer::GetValueFromEditorCtrl
}\label{wxdataviewcustomrenderergetvaluefromeditorctrl
}
320 \func{virtual bool
}{GetValueFromEditorCtrl
}{\param{wxControl*
}{editor
},
\param{wxVariant \&
}{value
}}
322 Overrride this so that the renderer can get the value
323 from the editor control (pointed to by
{\it editor
}):
328 wxSpinCtrl *sc = (wxSpinCtrl*) editor;
329 long l = sc->GetValue();
336 \membersection{wxDataViewCustomRenderer::Activate
}\label{wxdataviewcustomrendereractivate
}
338 \func{virtual bool
}{Activate
}{\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
340 Override this to react to double clicks or <ENTER>.
342 \membersection{wxDataViewCustomRenderer::GetDC
}\label{wxdataviewcustomrenderergetdc
}
344 \func{virtual wxDC*
}{GetDC
}{\void}
346 Create DC on request. Internal.
349 \membersection{wxDataViewCustomRenderer::GetSize
}\label{wxdataviewcustomrenderergetsize
}
351 \func{virtual wxSize
}{GetSize
}{\void}
353 Return size required to show content.
356 \membersection{wxDataViewCustomRenderer::LeftClick
}\label{wxdataviewcustomrendererleftclick
}
358 \func{virtual bool
}{LeftClick
}{\param{wxPoint
}{cursor
},
\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
360 Overrride this to react to a left click.
362 \membersection{wxDataViewCustomRenderer::Render
}\label{wxdataviewcustomrendererrender
}
364 \func{virtual bool
}{Render
}{\param{wxRect
}{cell
},
\param{wxDC*
}{dc
},
\param{int
}{state
}}
366 Override this to render the cell. Before this is called,
367 \helpref{SetValue
}{wxdataviewrenderersetvalue
} was called
368 so that this instance knows what to render.
370 \membersection{wxDataViewCustomRenderer::RightClick
}\label{wxdataviewcustomrendererrightclick
}
372 \func{virtual bool
}{RightClick
}{\param{wxPoint
}{cursor
},
\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
374 Overrride this to react to a right click.
376 \membersection{wxDataViewCustomRenderer::StartDrag
}\label{wxdataviewcustomrendererstartdrag
}
378 \func{virtual bool
}{StartDrag
}{\param{wxPoint
}{cursor
},
\param{wxRect
}{cell
},
\param{wxDataViewListModel*
}{model
},
\param{unsigned int
}{col
},
\param{unsigned int
}{row
}}
380 Overrride this to start a drag operation.