1 \section{\class{wxDataViewCtrl
}}\label{wxdataviewctrl
}
3 wxDataViewCtrl is a control to display data either
4 in a tree like fashion or in a tabular form or both.
5 If you only need to display a simple tree structure
6 with an API more like the older wxTreeCtrl class,
7 then the specialized
\helpref{wxDataViewTreeCtrl
}{wxdataviewtreectrl
}
10 A
\helpref{wxDataViewItem
}{wxdataviewitem
} is used
11 to represent a (visible) item in the control.
13 Unlike
\helpref{wxListCtrl
}{wxlistctrl
} wxDataViewCtrl doesn't
14 get its data from the user through virtual functions or by
15 setting it directly. Instead you need to write your own
16 \helpref{wxDataViewModel
}{wxdataviewmodel
} and associate
17 it with this control. Then you need to add a number of
18 \helpref{wxDataViewColumn
}{wxdataviewcolumn
} to this control to
19 define what each column shall display. Each wxDataViewColumn
20 in turn owns
1 instance of a
21 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
} to render its
22 cells. A number of standard renderers for rendering text, dates,
23 images, toggle, a progress bar etc. are provided. Additionally,
24 the user can write custom renderes deriving from
25 \helpref{wxDataViewCustomRenderer
}{wxdataviewcustomrenderer
}
26 for displaying anything.
28 All data transfer from the control to the model and the user
29 code is done through
\helpref{wxVariant
}{wxvariant
} which can
30 be extended to support more data formats as necessary.
31 Accordingly, all type information uses the strings returned
32 from
\helpref{wxVariant::GetType
}{wxvariantgettype
}.
34 \wxheading{Window styles
}
37 \begin{twocollist
}\itemsep=
0pt
38 \twocolitem{\windowstyle{wxDV
\_SINGLE}}{Single selection mode. This is the default.
}
39 \twocolitem{\windowstyle{wxDV
\_MULTIPLE}}{Multiple selection mode.
}
43 \wxheading{Event handling
}
45 To process input from a dataview control, use the following event handler
46 macros to direct input to member functions that take a
47 \helpref{wxDataViewEvent
}{wxdataviewevent
} argument.
50 \begin{twocollist
}\itemsep=
0pt
52 \twocolitem{{\bf EVT
\_DATAVIEW\_SELECTION\_CHANGED(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_SELECTION\_CHANGED event.
}
53 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_ACTIVATED(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_ACTIVATED event.
}
54 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_EDITING\_STARTED(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_EDITING\_STARTED event.
}
55 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_EDITING\_DONE(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_EDITING\_DONE event.
}
56 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_COLLAPSING(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_COLLAPSING event.
}
57 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_COLLAPSED(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_COLLAPSED event.
}
58 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_EXPANDING(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_EXPANDING event.
}
59 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_EXPANDED(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_EXPANDED event.
}
60 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_VALUE\_CHANGED(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_VALUE\_CHANGED event.
}
61 \twocolitem{{\bf EVT
\_DATAVIEW\_COLUMN\_HEADER\_CLICK(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_COLUMN\_HEADER\_CLICKED event.
}
62 \twocolitem{{\bf EVT
\_DATAVIEW\_COLUMN\_HEADER\_RIGHT\_CLICK(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_COLUMN\_HEADER\_RIGHT\_CLICKED event.
}
63 \twocolitem{{\bf EVT
\_DATAVIEW\_COLUMN\_HEADER\_SORTED(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_COLUMN\_HEADER\_SORTED event.
}
68 \wxheading{Derived from
}
70 \helpref{wxControl
}{wxcontrol
}\\
71 \helpref{wxWindow
}{wxwindow
}\\
72 \helpref{wxEvtHandler
}{wxevthandler
}\\
73 \helpref{wxObject
}{wxobject
}
75 \wxheading{Include files
}
81 \helpref{wxAdv
}{librarieslist
}
84 \latexignore{\rtfignore{\wxheading{Members
}}}
86 \membersection{wxDataViewCtrl::wxDataViewCtrl
}\label{wxdataviewctrlwxdataviewctrl
}
88 \func{}{wxDataViewCtrl
}{\void}
90 \func{}{wxDataViewCtrl
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\param{const wxPoint\&
}{pos = wxDefaultPosition
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\param{long
}{style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
}}
92 Constructor. Calls
\helpref{Create
}{wxdataviewctrlcreate
}.
94 \membersection{wxDataViewCtrl::
\destruct{wxDataViewCtrl
}}\label{wxdataviewctrldtor
}
96 \func{}{\destruct{wxDataViewCtrl
}}{\void}
100 \membersection{wxDataViewCtrl::AppendColumn
}\label{wxdataviewctrlappendcolumn
}
102 \func{virtual bool
}{AppendColumn
}{\param{wxDataViewColumn*
}{col
}}
104 Add a
\helpref{wxDataViewColumn
}{wxdataviewcolumn
} to the control. Returns
105 {\it true
} on success.
107 Note that there is a number of short cut methods which implicitly create
108 a
\helpref{wxDataViewColumn
}{wxdataviewcolumn
} and a
109 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
} for it (see below).
111 \membersection{wxDataViewCtrl::AppendBitmapColumn
}\label{wxdataviewctrlappendbitmapcolumn
}
113 \func{wxDataViewColumn*
}{AppendBitmapColumn
}{\param{const wxString\&
}{label
},
\param{unsigned int
}{model
\_column},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT},
\param{int
}{width = -
1},
\param{wxAlignment
}{align = wxALIGN
\_CENTER},
\param{int
}{flags = wxDATAVIEW
\_COL\_RESIZABLE}}
115 \func{wxDataViewColumn*
}{AppendBitmapColumn
}{\param{const wxBitmap\&
}{label
},
\param{unsigned int
}{model
\_column},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT},
\param{int
}{width = -
1},
\param{wxAlignment
}{align = wxALIGN
\_CENTER},
\param{int
}{flags = wxDATAVIEW
\_COL\_RESIZABLE}}
117 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
118 created in the function or NULL on failure.
120 \membersection{wxDataViewCtrl::AppendDateColumn
}\label{wxdataviewctrlappenddatecolumn
}
122 \func{wxDataViewColumn*
}{AppendDateColumn
}{\param{const wxString\&
}{label
},
\param{unsigned int
}{model
\_column},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_ACTIVATABLE},
\param{int
}{width = -
1},
\param{wxAlignment
}{align = wxALIGN
\_CENTER},
\param{int
}{flags = wxDATAVIEW
\_COL\_RESIZABLE}}
124 \func{wxDataViewColumn*
}{AppendDateColumn
}{\param{const wxBitmap\&
}{label
},
\param{unsigned int
}{model
\_column},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_ACTIVATABLE},
\param{int
}{width = -
1},
\param{wxAlignment
}{align = wxALIGN
\_CENTER},
\param{int
}{flags = wxDATAVIEW
\_COL\_RESIZABLE}}
126 Appends a column for rendering a date. Returns the wxDataViewColumn
127 created in the function or NULL on failure.
129 \membersection{wxDataViewCtrl::AppendProgressColumn
}\label{wxdataviewctrlappendprogresscolumn
}
131 \func{wxDataViewColumn*
}{AppendProgressColumn
}{\param{const wxString\&
}{label
},
\param{unsigned int
}{model
\_column},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT},
\param{int
}{width =
80},
\param{wxAlignment
}{align = wxALIGN
\_CENTER},
\param{int
}{flags = wxDATAVIEW
\_COL\_RESIZABLE}}
133 \func{wxDataViewColumn*
}{AppendProgressColumn
}{\param{const wxBitmap\&
}{label
},
\param{unsigned int
}{model
\_column},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT},
\param{int
}{width =
80},
\param{wxAlignment
}{align = wxALIGN
\_CENTER},
\param{int
}{flags = wxDATAVIEW
\_COL\_RESIZABLE}}
135 Appends a column for rendering a progress indicator. Returns the wxDataViewColumn
136 created in the function or NULL on failure.
138 \membersection{wxDataViewCtrl::AppendIconTextColumn
}\label{wxdataviewctrlappendicontextcolumn
}
140 \func{wxDataViewColumn*
}{AppendIconTextColumn
}{\param{const wxString\&
}{label
},
\param{unsigned int
}{model
\_column},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT},
\param{int
}{width = -
1},
\param{wxAlignment
}{align = wxALIGN
\_LEFT},
\param{int
}{flags = wxDATAVIEW
\_COL\_RESIZABLE}}
142 \func{wxDataViewColumn*
}{AppendIconTextColumn
}{\param{const wxBitmap\&
}{label
},
\param{unsigned int
}{model
\_column},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT},
\param{int
}{width = -
1},
\param{wxAlignment
}{align = wxALIGN
\_LEFT},
\param{int
}{flags = wxDATAVIEW
\_COL\_RESIZABLE}}
144 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
145 created in the function or NULL on failure. This uses the
146 \helpref{wxDataViewIconTextRenderer
}{wxdataviewicontextrenderer
}.
148 \membersection{wxDataViewCtrl::AppendTextColumn
}\label{wxdataviewctrlappendtextcolumn
}
150 \func{wxDataViewColumn*
}{AppendTextColumn
}{\param{const wxString\&
}{label
},
\param{unsigned int
}{model
\_column},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT},
\param{int
}{width = -
1},
\param{wxAlignment
}{align = wxALIGN
\_LEFT},
\param{int
}{flags = wxDATAVIEW
\_COL\_RESIZABLE}}
152 \func{wxDataViewColumn*
}{AppendTextColumn
}{\param{const wxBitmap\&
}{label
},
\param{unsigned int
}{model
\_column},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT},
\param{int
}{width = -
1},
\param{wxAlignment
}{align = wxALIGN
\_LEFT},
\param{int
}{flags = wxDATAVIEW
\_COL\_RESIZABLE}}
154 Appends a column for rendering text. Returns the wxDataViewColumn
155 created in the function or NULL on failure.
157 \membersection{wxDataViewCtrl::AppendToggleColumn
}\label{wxdataviewctrlappendtogglecolumn
}
159 \func{wxDataViewColumn*
}{AppendToggleColumn
}{\param{const wxString\&
}{label
},
\param{unsigned int
}{model
\_column},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT},
\param{int
}{width =
30},
\param{wxAlignment
}{align = wxALIGN
\_CENTER},
\param{int
}{flags = wxDATAVIEW
\_COL\_RESIZABLE}}
161 \func{wxDataViewColumn*
}{AppendToggleColumn
}{\param{const wxBitmap\&
}{label
},
\param{unsigned int
}{model
\_column},
\param{wxDataViewCellMode
}{mode = wxDATAVIEW
\_CELL\_INERT},
\param{int
}{width =
30},
\param{wxAlignment
}{align = wxALIGN
\_CENTER},
\param{int
}{flags = wxDATAVIEW
\_COL\_RESIZABLE}}
163 Appends a column for rendering a toggle. Returns the wxDataViewColumn
164 created in the function or NULL on failure.
166 \membersection{wxDataViewCtrl::AssociateModel
}\label{wxdataviewctrlassociatemodel
}
168 \func{virtual bool
}{AssociateModel
}{\param{wxDataViewModel*
}{model
}}
170 Associates a
\helpref{wxDataViewModel
}{wxdataviewmodel
} with the
171 control. This increases the reference count of the model by
1.
173 \membersection{wxDataViewCtrl::Create
}\label{wxdataviewctrlcreate
}
175 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\param{const wxPoint\&
}{pos = wxDefaultPosition
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\param{long
}{style =
0},
\param{const wxValidator\&
}{validator = wxDefaultValidator
}}
177 Create the control. Useful for two step creation.
179 \membersection{wxDataViewCtrl::ClearColumns
}\label{wxdataviewctrlclearcolumns
}
181 \func{virtual bool
}{ClearColumns
}{\void}
185 \membersection{wxDataViewCtrl::ClearSelection
}\label{wxdataviewctrlclearselection
}
187 \func{void
}{ClearSelection
}{\void}
191 \membersection{wxDataViewCtrl::Collapse
}\label{wxdataviewctrlcollapse
}
193 \func{void
}{Collapse
}{\param{const wxDataViewItem \&
}{item
}}
197 \membersection{wxDataViewCtrl::DeleteColumn
}\label{wxdataviewctrldeletecolumn
}
199 \func{virtual bool
}{DeleteColumn
}{\param{const wxDataViewColumn*
}{column
}}
201 Deletes given column.
203 \membersection{wxDataViewCtrl::Expand
}\label{wxdataviewctrlexpand
}
205 \func{void
}{Expand
}{\param{const wxDataViewItem \&
}{item
}}
209 \membersection{wxDataViewCtrl::GetColumn
}\label{wxdataviewctrlgetcolumn
}
211 \constfunc{virtual wxDataViewColumn*
}{GetColumn
}{\param{unsigned int
}{pos
}}
213 Returns pointer to the column.
{\it pos
} refers to the
214 position in the control which may change after reordering
217 \membersection{wxDataViewCtrl::GetColumnCount
}\label{wxdataviewctrlgetcolumncount
}
219 \constfunc{virtual unsigned int
}{GetColumnCount
}{\void}
221 Returns the number of columns.
223 \membersection{wxDataViewCtrl::GetColumnPosition
}\label{wxdataviewctrlgetcolumnposition
}
225 \constfunc{virtual int
}{GetColumnPosition
}{\param{const wxDataViewColumn*
}{column
}}
227 Returns the position of the column or -
1 if not found in the control.
229 \membersection{wxDataViewCtrl::EnsureVisible
}\label{wxdataviewctrlensurevisible
}
231 \func{void
}{EnsureVisible
}{\param{const wxDataViewItem \&
}{item
},
\param{const wxDataViewColumn*
}{column = NULL
}}
233 Call this to ensure that the given item is visible.
235 \membersection{wxDataViewCtrl::GetExpanderColumn
}\label{wxdataviewctrlgetexpandercolumn
}
237 \constfunc{wxDataViewColumn *
}{GetExpanderColumn
}{\void}
239 Returns column containing the expanders.
241 \membersection{wxDataViewCtrl::GetIndent
}\label{wxdataviewctrlgetindent
}
243 \constfunc{int
}{GetIndent
}{\void}
247 \membersection{wxDataViewCtrl::GetItemRect
}\label{wxdataviewctrlgetitemrect
}
249 \constfunc{wxRect
}{GetItemRect
}{\param{const wxDataViewItem\&
}{item
},
\param{const wxDataViewColumn *
}{col = NULL
}}
253 \membersection{wxDataViewCtrl::GetModel
}\label{wxdataviewctrlgetmodel
}
255 \constfunc{virtual wxDataViewModel*
}{GetModel
}{\void}
257 Returns pointer to the data model associated with the
260 \membersection{wxDataViewCtrl::GetSelection
}\label{wxdataviewctrlgetselection
}
262 \constfunc{wxDataViewItem
}{GetSelection
}{\void}
264 Returns first selected item or an invalid item if none is selected.
266 \membersection{wxDataViewCtrl::GetSelections
}\label{wxdataviewctrlgetselections
}
268 \constfunc{int
}{GetSelections
}{\param{wxDataViewItemArray \&
}{sel
}}
270 Fills
{\it sel
} with currently selected items and returns
273 \membersection{wxDataViewCtrl::GetSortingColumn
}\label{wxdataviewctrlgetsortingcolumn
}
275 \constfunc{virtual wxDataViewColumn*
}{GetSortingColumn
}{\void}
277 Returns the wxDataViewColumn currently responsible for sorting
278 or NULL if none has been selected.
280 \membersection{wxDataViewCtrl::HitTest
}\label{wxdataviewctrlhittest
}
282 \constfunc{void
}{HitTest
}{\param{const wxPoint\&
}{point
},
\param{wxDataViewItem\&
}{item
},
\param{wxDataViewColumn *\&
}{col
}}
286 \membersection{wxDataViewCtrl::IsSelected
}\label{wxdataviewctrlisselected
}
288 \constfunc{bool
}{IsSelected
}{\param{const wxDataViewItem \&
}{item
}}
290 Return true if the item is selected.
292 \membersection{wxDataViewCtrl::Select
}\label{wxdataviewctrlselect
}
294 \func{void
}{Select
}{\param{const wxDataViewItem \&
}{item
}}
296 Select the given item.
298 \membersection{wxDataViewCtrl::SelectAll
}\label{wxdataviewctrlselectall
}
300 \func{void
}{SelectAll
}{\void}
304 \membersection{wxDataViewCtrl::SetExpanderColumn
}\label{wxdataviewctrlsetexpandercolumn
}
306 \func{void
}{SetExpanderColumn
}{\param{wxDataViewColumn *
}{col
}}
308 Set which column shall contain the tree-like expanders.
310 \membersection{wxDataViewCtrl::SetIndent
}\label{wxdataviewctrlsetindent
}
312 \func{void
}{SetIndent
}{\param{int
}{indent
}}
314 Sets the indendation.
316 \membersection{wxDataViewCtrl::SetSelections
}\label{wxdataviewctrlsetselections
}
318 \func{void
}{SetSelections
}{\param{const wxDataViewItemArray \&
}{sel
}}
320 Sets the selection to the array of wxDataViewItems.
322 \membersection{wxDataViewCtrl::Unselect
}\label{wxdataviewctrlunselect
}
324 \func{void
}{Unselect
}{\param{const wxDataViewItem \&
}{item
}}
326 Unselect the given item.
328 \membersection{wxDataViewCtrl::UnselectAll
}\label{wxdataviewctrlunselectall
}
330 \func{void
}{UnselectAll
}{\void}
332 Unselect all item. This method only has effect if multiple
333 selections are allowed.