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.
}
40 \twocolitem{\windowstyle{wxDV
\_ROW\_LINES}}{Use alternating colours for rows if supported by platform and theme.
}
41 \twocolitem{\windowstyle{wxDV
\_HORIZ\_RULES}}{Display fine rules between row if supported.
}
42 \twocolitem{\windowstyle{wxDV
\_VERT\_RULES}}{Display fine rules between columns is supported.
}
46 \wxheading{Event handling
}
48 To process input from a dataview control, use the following event handler
49 macros to direct input to member functions that take a
50 \helpref{wxDataViewEvent
}{wxdataviewevent
} argument.
53 \begin{twocollist
}\itemsep=
0pt
55 \twocolitem{{\bf EVT
\_DATAVIEW\_SELECTION\_CHANGED(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_SELECTION\_CHANGED event.
}
56 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_ACTIVATED(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_ACTIVATED event.
}
57 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_EDITING\_STARTED(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_EDITING\_STARTED event.
}
58 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_EDITING\_DONE(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_EDITING\_DONE event.
}
59 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_COLLAPSING(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_COLLAPSING event.
}
60 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_COLLAPSED(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_COLLAPSED event.
}
61 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_EXPANDING(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_EXPANDING event.
}
62 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_EXPANDED(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_EXPANDED event.
}
63 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_VALUE\_CHANGED(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_VALUE\_CHANGED event.
}
64 \twocolitem{{\bf EVT
\_DATAVIEW\_ITEM\_CONTEXT\_MENU(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_ITEM\_CONTEXT\_MENU event.
}
65 \twocolitem{{\bf EVT
\_DATAVIEW\_COLUMN\_HEADER\_CLICK(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_COLUMN\_HEADER\_CLICKED event.
}
66 \twocolitem{{\bf EVT
\_DATAVIEW\_COLUMN\_HEADER\_RIGHT\_CLICK(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_COLUMN\_HEADER\_RIGHT\_CLICKED event.
}
67 \twocolitem{{\bf EVT
\_DATAVIEW\_COLUMN\_HEADER\_SORTED(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_COLUMN\_HEADER\_SORTED event.
}
68 \twocolitem{{\bf EVT
\_DATAVIEW\_COLUMN\_REORDERED(id, func)
}}{Processes a wxEVT
\_COMMAND\_DATAVIEW\_COLUMN\_REORDERED event.
}
73 \wxheading{Derived from
}
75 \helpref{wxControl
}{wxcontrol
}\\
76 \helpref{wxWindow
}{wxwindow
}\\
77 \helpref{wxEvtHandler
}{wxevthandler
}\\
78 \helpref{wxObject
}{wxobject
}
80 \wxheading{Include files
}
86 \helpref{wxAdv
}{librarieslist
}
89 \latexignore{\rtfignore{\wxheading{Members
}}}
91 \membersection{wxDataViewCtrl::wxDataViewCtrl
}\label{wxdataviewctrlwxdataviewctrl
}
93 \func{}{wxDataViewCtrl
}{\void}
95 \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
}}
97 Constructor. Calls
\helpref{Create
}{wxdataviewctrlcreate
}.
99 \membersection{wxDataViewCtrl::
\destruct{wxDataViewCtrl
}}\label{wxdataviewctrldtor
}
101 \func{}{\destruct{wxDataViewCtrl
}}{\void}
105 \membersection{wxDataViewCtrl::AppendColumn
}\label{wxdataviewctrlappendcolumn
}
107 \func{virtual bool
}{AppendColumn
}{\param{wxDataViewColumn*
}{col
}}
109 Add a
\helpref{wxDataViewColumn
}{wxdataviewcolumn
} to the control. Returns
110 {\it true
} on success.
112 Note that there is a number of short cut methods which implicitly create
113 a
\helpref{wxDataViewColumn
}{wxdataviewcolumn
} and a
114 \helpref{wxDataViewRenderer
}{wxdataviewrenderer
} for it (see below).
116 \membersection{wxDataViewCtrl::AppendBitmapColumn
}\label{wxdataviewctrlappendbitmapcolumn
}
118 \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}}
120 \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}}
122 Appends a column for rendering a bitmap. Returns the wxDataViewColumn
123 created in the function or NULL on failure.
125 \membersection{wxDataViewCtrl::AppendDateColumn
}\label{wxdataviewctrlappenddatecolumn
}
127 \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}}
129 \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}}
131 Appends a column for rendering a date. Returns the wxDataViewColumn
132 created in the function or NULL on failure.
134 \membersection{wxDataViewCtrl::AppendProgressColumn
}\label{wxdataviewctrlappendprogresscolumn
}
136 \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}}
138 \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}}
140 Appends a column for rendering a progress indicator. Returns the wxDataViewColumn
141 created in the function or NULL on failure.
143 \membersection{wxDataViewCtrl::AppendIconTextColumn
}\label{wxdataviewctrlappendicontextcolumn
}
145 \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}}
147 \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}}
149 Appends a column for rendering text with an icon. Returns the wxDataViewColumn
150 created in the function or NULL on failure. This uses the
151 \helpref{wxDataViewIconTextRenderer
}{wxdataviewicontextrenderer
}.
153 \membersection{wxDataViewCtrl::AppendTextColumn
}\label{wxdataviewctrlappendtextcolumn
}
155 \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}}
157 \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}}
159 Appends a column for rendering text. Returns the wxDataViewColumn
160 created in the function or NULL on failure.
162 \membersection{wxDataViewCtrl::AppendToggleColumn
}\label{wxdataviewctrlappendtogglecolumn
}
164 \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}}
166 \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}}
168 Appends a column for rendering a toggle. Returns the wxDataViewColumn
169 created in the function or NULL on failure.
171 \membersection{wxDataViewCtrl::AssociateModel
}\label{wxdataviewctrlassociatemodel
}
173 \func{virtual bool
}{AssociateModel
}{\param{wxDataViewModel*
}{model
}}
175 Associates a
\helpref{wxDataViewModel
}{wxdataviewmodel
} with the
176 control. This increases the reference count of the model by
1.
178 \membersection{wxDataViewCtrl::Create
}\label{wxdataviewctrlcreate
}
180 \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
}}
182 Create the control. Useful for two step creation.
184 \membersection{wxDataViewCtrl::ClearColumns
}\label{wxdataviewctrlclearcolumns
}
186 \func{virtual bool
}{ClearColumns
}{\void}
190 \membersection{wxDataViewCtrl::ClearSelection
}\label{wxdataviewctrlclearselection
}
192 \func{void
}{ClearSelection
}{\void}
196 \membersection{wxDataViewCtrl::Collapse
}\label{wxdataviewctrlcollapse
}
198 \func{void
}{Collapse
}{\param{const wxDataViewItem \&
}{item
}}
202 \membersection{wxDataViewCtrl::DeleteColumn
}\label{wxdataviewctrldeletecolumn
}
204 \func{virtual bool
}{DeleteColumn
}{\param{const wxDataViewColumn*
}{column
}}
206 Deletes given column.
208 \membersection{wxDataViewCtrl::Expand
}\label{wxdataviewctrlexpand
}
210 \func{void
}{Expand
}{\param{const wxDataViewItem \&
}{item
}}
214 \membersection{wxDataViewCtrl::GetColumn
}\label{wxdataviewctrlgetcolumn
}
216 \constfunc{virtual wxDataViewColumn*
}{GetColumn
}{\param{unsigned int
}{pos
}}
218 Returns pointer to the column.
{\it pos
} refers to the
219 position in the control which may change after reordering
222 \membersection{wxDataViewCtrl::GetColumnCount
}\label{wxdataviewctrlgetcolumncount
}
224 \constfunc{virtual unsigned int
}{GetColumnCount
}{\void}
226 Returns the number of columns.
228 \membersection{wxDataViewCtrl::GetColumnPosition
}\label{wxdataviewctrlgetcolumnposition
}
230 \constfunc{virtual int
}{GetColumnPosition
}{\param{const wxDataViewColumn*
}{column
}}
232 Returns the position of the column or -
1 if not found in the control.
234 \membersection{wxDataViewCtrl::EnsureVisible
}\label{wxdataviewctrlensurevisible
}
236 \func{void
}{EnsureVisible
}{\param{const wxDataViewItem \&
}{item
},
\param{const wxDataViewColumn*
}{column = NULL
}}
238 Call this to ensure that the given item is visible.
240 \membersection{wxDataViewCtrl::GetExpanderColumn
}\label{wxdataviewctrlgetexpandercolumn
}
242 \constfunc{wxDataViewColumn *
}{GetExpanderColumn
}{\void}
244 Returns column containing the expanders.
246 \membersection{wxDataViewCtrl::GetIndent
}\label{wxdataviewctrlgetindent
}
248 \constfunc{int
}{GetIndent
}{\void}
252 \membersection{wxDataViewCtrl::GetItemRect
}\label{wxdataviewctrlgetitemrect
}
254 \constfunc{wxRect
}{GetItemRect
}{\param{const wxDataViewItem\&
}{item
},
\param{const wxDataViewColumn *
}{col = NULL
}}
258 \membersection{wxDataViewCtrl::GetModel
}\label{wxdataviewctrlgetmodel
}
260 \constfunc{virtual wxDataViewModel*
}{GetModel
}{\void}
262 Returns pointer to the data model associated with the
265 \membersection{wxDataViewCtrl::GetSelection
}\label{wxdataviewctrlgetselection
}
267 \constfunc{wxDataViewItem
}{GetSelection
}{\void}
269 Returns first selected item or an invalid item if none is selected.
271 \membersection{wxDataViewCtrl::GetSelections
}\label{wxdataviewctrlgetselections
}
273 \constfunc{int
}{GetSelections
}{\param{wxDataViewItemArray \&
}{sel
}}
275 Fills
{\it sel
} with currently selected items and returns
278 \membersection{wxDataViewCtrl::GetSortingColumn
}\label{wxdataviewctrlgetsortingcolumn
}
280 \constfunc{virtual wxDataViewColumn*
}{GetSortingColumn
}{\void}
282 Returns the wxDataViewColumn currently responsible for sorting
283 or NULL if none has been selected.
285 \membersection{wxDataViewCtrl::HitTest
}\label{wxdataviewctrlhittest
}
287 \constfunc{void
}{HitTest
}{\param{const wxPoint\&
}{point
},
\param{wxDataViewItem\&
}{item
},
\param{wxDataViewColumn *\&
}{col
}}
291 \membersection{wxDataViewCtrl::IsSelected
}\label{wxdataviewctrlisselected
}
293 \constfunc{bool
}{IsSelected
}{\param{const wxDataViewItem \&
}{item
}}
295 Return true if the item is selected.
297 \membersection{wxDataViewCtrl::Select
}\label{wxdataviewctrlselect
}
299 \func{void
}{Select
}{\param{const wxDataViewItem \&
}{item
}}
301 Select the given item.
303 \membersection{wxDataViewCtrl::SelectAll
}\label{wxdataviewctrlselectall
}
305 \func{void
}{SelectAll
}{\void}
309 \membersection{wxDataViewCtrl::SetExpanderColumn
}\label{wxdataviewctrlsetexpandercolumn
}
311 \func{void
}{SetExpanderColumn
}{\param{wxDataViewColumn *
}{col
}}
313 Set which column shall contain the tree-like expanders.
315 \membersection{wxDataViewCtrl::SetIndent
}\label{wxdataviewctrlsetindent
}
317 \func{void
}{SetIndent
}{\param{int
}{indent
}}
319 Sets the indendation.
321 \membersection{wxDataViewCtrl::SetSelections
}\label{wxdataviewctrlsetselections
}
323 \func{void
}{SetSelections
}{\param{const wxDataViewItemArray \&
}{sel
}}
325 Sets the selection to the array of wxDataViewItems.
327 \membersection{wxDataViewCtrl::Unselect
}\label{wxdataviewctrlunselect
}
329 \func{void
}{Unselect
}{\param{const wxDataViewItem \&
}{item
}}
331 Unselect the given item.
333 \membersection{wxDataViewCtrl::UnselectAll
}\label{wxdataviewctrlunselectall
}
335 \func{void
}{UnselectAll
}{\void}
337 Unselect all item. This method only has effect if multiple
338 selections are allowed.