Added wxDataViewListIndexModel::RowsDeleted() and various related corrections
[wxWidgets.git] / docs / latex / wx / dataviewctrl.tex
CommitLineData
b6b9d556
RR
1\section{\class{wxDataViewCtrl}}\label{wxdataviewctrl}
2
1ab4aff2 3wxDataViewCtrl is a control to display data either
6f0a23b8
RR
4in a tree like fashion or in a tabular form or both.
5If you only need to display a simple tree structure
6with an API more like the older wxTreeCtrl class,
7then the specialized \helpref{wxDataViewTreeCtrl}{wxdataviewtreectrl}
8can be used.
305c49a1 9
4f76c1a2
RR
10A \helpref{wxDataViewItem}{wxdataviewitem} is used
11to represent a (visible) item in the control.
12
305c49a1 13Unlike \helpref{wxListCtrl}{wxlistctrl} wxDataViewCtrl doesn't
1ab4aff2
RR
14get its data from the user through virtual functions or by
15setting it directly. Instead you need to write your own
16\helpref{wxDataViewModel}{wxdataviewmodel} and associate
b6b9d556
RR
17it with this control. Then you need to add a number of
18\helpref{wxDataViewColumn}{wxdataviewcolumn} to this control to
19define what each column shall display. Each wxDataViewColumn
20in turn owns 1 instance of a
21\helpref{wxDataViewRenderer}{wxdataviewrenderer} to render its
22cells. A number of standard renderers for rendering text, dates,
23images, toggle, a progress bar etc. are provided. Additionally,
24the user can write custom renderes deriving from
25\helpref{wxDataViewCustomRenderer}{wxdataviewcustomrenderer}
26for displaying anything.
27
28All data transfer from the control to the model and the user
29code is done through \helpref{wxVariant}{wxvariant} which can
30be extended to support more data formats as necessary.
31Accordingly, all type information uses the strings returned
32from \helpref{wxVariant::GetType}{wxvariantgettype}.
33
b6b9d556
RR
34\wxheading{Window styles}
35
36\twocolwidtha{5cm}
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.}
1a07a730
RR
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.}
b6b9d556
RR
43\end{twocollist}
44
45
46\wxheading{Event handling}
47
48To process input from a dataview control, use the following event handler
49macros to direct input to member functions that take a
50\helpref{wxDataViewEvent}{wxdataviewevent} argument.
51
52\twocolwidtha{7cm}
53\begin{twocollist}\itemsep=0pt
54
d86c1870 55\twocolitem{{\bf EVT\_DATAVIEW\_SELECTION\_CHANGED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_SELECTION\_CHANGED event.}
1ab4aff2 56\twocolitem{{\bf EVT\_DATAVIEW\_ITEM\_ACTIVATED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_ITEM\_ACTIVATED event.}
e0000f94
RR
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.}
7f733b26 63\twocolitem{{\bf EVT\_DATAVIEW\_ITEM\_VALUE\_CHANGED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_ITEM\_VALUE\_CHANGED event.}
6af3eec2 64\twocolitem{{\bf EVT\_DATAVIEW\_ITEM\_CONTEXT\_MENU(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_ITEM\_CONTEXT\_MENU event.}
b6b9d556
RR
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.}
1ab4aff2 67\twocolitem{{\bf EVT\_DATAVIEW\_COLUMN\_HEADER\_SORTED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_COLUMN\_HEADER\_SORTED event.}
1821abd1
RR
68
69\end{twocollist}
b6b9d556
RR
70
71
72\wxheading{Derived from}
73
7376079d
VZ
74\helpref{wxControl}{wxcontrol}\\
75\helpref{wxWindow}{wxwindow}\\
76\helpref{wxEvtHandler}{wxevthandler}\\
77\helpref{wxObject}{wxobject}
b6b9d556
RR
78
79\wxheading{Include files}
80
81<wx/dataview.h>
82
a7af285d
VZ
83\wxheading{Library}
84
85\helpref{wxAdv}{librarieslist}
86
b6b9d556 87
809e21b5
FM
88\latexignore{\rtfignore{\wxheading{Members}}}
89
b6b9d556
RR
90\membersection{wxDataViewCtrl::wxDataViewCtrl}\label{wxdataviewctrlwxdataviewctrl}
91
92\func{}{wxDataViewCtrl}{\void}
93
94\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}}
95
96Constructor. Calls \helpref{Create}{wxdataviewctrlcreate}.
97
98\membersection{wxDataViewCtrl::\destruct{wxDataViewCtrl}}\label{wxdataviewctrldtor}
99
100\func{}{\destruct{wxDataViewCtrl}}{\void}
101
102Destructor.
103
104\membersection{wxDataViewCtrl::AppendColumn}\label{wxdataviewctrlappendcolumn}
105
106\func{virtual bool}{AppendColumn}{\param{wxDataViewColumn* }{col}}
107
c7074d44
RR
108Add a \helpref{wxDataViewColumn}{wxdataviewcolumn} to the control. Returns
109{\it true} on success.
110
111Note that there is a number of short cut methods which implicitly create
b6b9d556 112a \helpref{wxDataViewColumn}{wxdataviewcolumn} and a
314cd032 113\helpref{wxDataViewRenderer}{wxdataviewrenderer} for it (see below).
b6b9d556 114
b6b9d556
RR
115\membersection{wxDataViewCtrl::AppendBitmapColumn}\label{wxdataviewctrlappendbitmapcolumn}
116
e807896d 117\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}}
b6b9d556 118
e807896d 119\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}}
b6b9d556 120
c7074d44
RR
121Appends a column for rendering a bitmap. Returns the wxDataViewColumn
122created in the function or NULL on failure.
b6b9d556
RR
123
124\membersection{wxDataViewCtrl::AppendDateColumn}\label{wxdataviewctrlappenddatecolumn}
125
e807896d 126\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}}
b6b9d556 127
e807896d 128\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}}
b6b9d556 129
c7074d44
RR
130Appends a column for rendering a date. Returns the wxDataViewColumn
131created in the function or NULL on failure.
b6b9d556
RR
132
133\membersection{wxDataViewCtrl::AppendProgressColumn}\label{wxdataviewctrlappendprogresscolumn}
134
e807896d 135\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}}
b6b9d556 136
e807896d 137\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}}
b6b9d556 138
c7074d44
RR
139Appends a column for rendering a progress indicator. Returns the wxDataViewColumn
140created in the function or NULL on failure.
b6b9d556 141
b04fcede
RR
142\membersection{wxDataViewCtrl::AppendIconTextColumn}\label{wxdataviewctrlappendicontextcolumn}
143
e807896d 144\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}}
b04fcede 145
e807896d 146\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}}
b04fcede
RR
147
148Appends a column for rendering text with an icon. Returns the wxDataViewColumn
149created in the function or NULL on failure. This uses the
150\helpref{wxDataViewIconTextRenderer}{wxdataviewicontextrenderer}.
151
b6b9d556
RR
152\membersection{wxDataViewCtrl::AppendTextColumn}\label{wxdataviewctrlappendtextcolumn}
153
e807896d 154\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}}
b6b9d556 155
e807896d 156\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}}
b6b9d556 157
c7074d44
RR
158Appends a column for rendering text. Returns the wxDataViewColumn
159created in the function or NULL on failure.
b6b9d556
RR
160
161\membersection{wxDataViewCtrl::AppendToggleColumn}\label{wxdataviewctrlappendtogglecolumn}
162
e807896d 163\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}}
b6b9d556 164
e807896d 165\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}}
b6b9d556 166
c7074d44
RR
167Appends a column for rendering a toggle. Returns the wxDataViewColumn
168created in the function or NULL on failure.
b6b9d556
RR
169
170\membersection{wxDataViewCtrl::AssociateModel}\label{wxdataviewctrlassociatemodel}
171
1ab4aff2 172\func{virtual bool}{AssociateModel}{\param{wxDataViewModel* }{model}}
b6b9d556 173
1ab4aff2 174Associates a \helpref{wxDataViewModel}{wxdataviewmodel} with the
729a8b9b 175control. This increases the reference count of the model by 1.
b6b9d556
RR
176
177\membersection{wxDataViewCtrl::Create}\label{wxdataviewctrlcreate}
178
179\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}}
180
181Create the control. Useful for two step creation.
182
183\membersection{wxDataViewCtrl::ClearColumns}\label{wxdataviewctrlclearcolumns}
184
185\func{virtual bool}{ClearColumns}{\void}
186
187Removes all columns.
188
189\membersection{wxDataViewCtrl::ClearSelection}\label{wxdataviewctrlclearselection}
190
191\func{void}{ClearSelection}{\void}
192
193Unselects all rows.
194
e15c84ce
RR
195\membersection{wxDataViewCtrl::Collapse}\label{wxdataviewctrlcollapse}
196
197\func{void}{Collapse}{\param{const wxDataViewItem \& }{item}}
198
199Collapses the item.
200
b6b9d556
RR
201\membersection{wxDataViewCtrl::DeleteColumn}\label{wxdataviewctrldeletecolumn}
202
91a6c655 203\func{virtual bool}{DeleteColumn}{\param{const wxDataViewColumn* }{column}}
b6b9d556
RR
204
205Deletes given column.
206
e15c84ce
RR
207\membersection{wxDataViewCtrl::Expand}\label{wxdataviewctrlexpand}
208
209\func{void}{Expand}{\param{const wxDataViewItem \& }{item}}
210
211Expands the item.
212
b6b9d556
RR
213\membersection{wxDataViewCtrl::GetColumn}\label{wxdataviewctrlgetcolumn}
214
e0976f6d 215\constfunc{virtual wxDataViewColumn*}{GetColumn}{\param{unsigned int }{pos}}
b6b9d556 216
91a6c655
RR
217Returns pointer to the column. {\it pos} refers to the
218position in the control which may change after reordering
219columns by the user.
b6b9d556 220
a29d690d 221\membersection{wxDataViewCtrl::GetColumnCount}\label{wxdataviewctrlgetcolumncount}
b6b9d556 222
e0976f6d 223\constfunc{virtual unsigned int}{GetColumnCount}{\void}
b6b9d556
RR
224
225Returns the number of columns.
226
453091c2
RR
227\membersection{wxDataViewCtrl::GetColumnPosition}\label{wxdataviewctrlgetcolumnposition}
228
229\constfunc{virtual int}{GetColumnPosition}{\param{const wxDataViewColumn* }{column}}
230
231Returns the position of the column or -1 if not found in the control.
232
1ab4aff2
RR
233\membersection{wxDataViewCtrl::EnsureVisible}\label{wxdataviewctrlensurevisible}
234
daf5b37a 235\func{void}{EnsureVisible}{\param{const wxDataViewItem \& }{item}, \param{const wxDataViewColumn* }{column = NULL}}
1ab4aff2
RR
236
237Call this to ensure that the given item is visible.
238
239\membersection{wxDataViewCtrl::GetExpanderColumn}\label{wxdataviewctrlgetexpandercolumn}
240
1b27b2bd 241\constfunc{wxDataViewColumn *}{GetExpanderColumn}{\void}
1ab4aff2
RR
242
243Returns column containing the expanders.
244
245\membersection{wxDataViewCtrl::GetIndent}\label{wxdataviewctrlgetindent}
246
247\constfunc{int}{GetIndent}{\void}
248
249Returns indentation.
250
251\membersection{wxDataViewCtrl::GetItemRect}\label{wxdataviewctrlgetitemrect}
252
e0976f6d 253\constfunc{wxRect}{GetItemRect}{\param{const wxDataViewItem\& }{item}, \param{const wxDataViewColumn *}{col = NULL}}
1ab4aff2
RR
254
255Returns item rect.
256
453091c2
RR
257\membersection{wxDataViewCtrl::GetModel}\label{wxdataviewctrlgetmodel}
258
259\constfunc{virtual wxDataViewModel*}{GetModel}{\void}
260
261Returns pointer to the data model associated with the
262control (if any).
263
b6b9d556
RR
264\membersection{wxDataViewCtrl::GetSelection}\label{wxdataviewctrlgetselection}
265
e0976f6d 266\constfunc{wxDataViewItem}{GetSelection}{\void}
b6b9d556 267
1ab4aff2 268Returns first selected item or an invalid item if none is selected.
b6b9d556
RR
269
270\membersection{wxDataViewCtrl::GetSelections}\label{wxdataviewctrlgetselections}
271
1ab4aff2 272\constfunc{int}{GetSelections}{\param{wxDataViewItemArray \& }{sel}}
b6b9d556 273
1ab4aff2
RR
274Fills {\it sel} with currently selected items and returns
275their number.
276
21f47fb9
RR
277\membersection{wxDataViewCtrl::GetSortingColumn}\label{wxdataviewctrlgetsortingcolumn}
278
279\constfunc{virtual wxDataViewColumn*}{GetSortingColumn}{\void}
280
281Returns the wxDataViewColumn currently responsible for sorting
282or NULL if none has been selected.
283
1ab4aff2
RR
284\membersection{wxDataViewCtrl::HitTest}\label{wxdataviewctrlhittest}
285
513edac2 286\constfunc{void}{HitTest}{\param{const wxPoint\& }{point}, \param{wxDataViewItem\& }{item}, \param{wxDataViewColumn *\&}{col}}
1ab4aff2
RR
287
288Hittest.
b6b9d556
RR
289
290\membersection{wxDataViewCtrl::IsSelected}\label{wxdataviewctrlisselected}
291
1ab4aff2
RR
292\constfunc{bool}{IsSelected}{\param{const wxDataViewItem \& }{item}}
293
294Return true if the item is selected.
b6b9d556 295
1ab4aff2 296\membersection{wxDataViewCtrl::Select}\label{wxdataviewctrlselect}
b6b9d556 297
1ab4aff2 298\func{void}{Select}{\param{const wxDataViewItem \& }{item}}
b6b9d556 299
1ab4aff2 300Select the given item.
b6b9d556 301
1ab4aff2 302\membersection{wxDataViewCtrl::SelectAll}\label{wxdataviewctrlselectall}
b6b9d556 303
1ab4aff2 304\func{void}{SelectAll}{\void}
b6b9d556 305
1ab4aff2 306Select all items.
b6b9d556 307
1ab4aff2
RR
308\membersection{wxDataViewCtrl::SetExpanderColumn}\label{wxdataviewctrlsetexpandercolumn}
309
1b27b2bd 310\func{void}{SetExpanderColumn}{\param{wxDataViewColumn *}{col}}
1ab4aff2
RR
311
312Set which column shall contain the tree-like expanders.
313
314\membersection{wxDataViewCtrl::SetIndent}\label{wxdataviewctrlsetindent}
315
316\func{void}{SetIndent}{\param{int }{indent}}
317
318Sets the indendation.
b6b9d556
RR
319
320\membersection{wxDataViewCtrl::SetSelections}\label{wxdataviewctrlsetselections}
321
1ab4aff2 322\func{void}{SetSelections}{\param{const wxDataViewItemArray \& }{sel}}
b6b9d556 323
1ab4aff2 324Sets the selection to the array of wxDataViewItems.
b6b9d556
RR
325
326\membersection{wxDataViewCtrl::Unselect}\label{wxdataviewctrlunselect}
327
1ab4aff2
RR
328\func{void}{Unselect}{\param{const wxDataViewItem \& }{item}}
329
330Unselect the given item.
331
332\membersection{wxDataViewCtrl::UnselectAll}\label{wxdataviewctrlunselectall}
333
334\func{void}{UnselectAll}{\void}
b6b9d556 335
1ab4aff2
RR
336Unselect all item. This method only has effect if multiple
337selections are allowed.
b6b9d556 338