]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/dataviewctrl.tex
Added Forty Thieves icon
[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.}
40\end{twocollist}
41
42
43\wxheading{Event handling}
44
45To process input from a dataview control, use the following event handler
46macros to direct input to member functions that take a
47\helpref{wxDataViewEvent}{wxdataviewevent} argument.
48
49\twocolwidtha{7cm}
50\begin{twocollist}\itemsep=0pt
51
d86c1870 52\twocolitem{{\bf EVT\_DATAVIEW\_SELECTION\_CHANGED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_SELECTION\_CHANGED event.}
1ab4aff2 53\twocolitem{{\bf EVT\_DATAVIEW\_ITEM\_ACTIVATED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_ITEM\_ACTIVATED event.}
e0000f94
RR
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.}
7f733b26 60\twocolitem{{\bf EVT\_DATAVIEW\_ITEM\_VALUE\_CHANGED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_ITEM\_VALUE\_CHANGED event.}
b6b9d556
RR
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.}
1ab4aff2 63\twocolitem{{\bf EVT\_DATAVIEW\_COLUMN\_HEADER\_SORTED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_COLUMN\_HEADER\_SORTED event.}
1821abd1
RR
64
65\end{twocollist}
b6b9d556
RR
66
67
68\wxheading{Derived from}
69
7376079d
VZ
70\helpref{wxControl}{wxcontrol}\\
71\helpref{wxWindow}{wxwindow}\\
72\helpref{wxEvtHandler}{wxevthandler}\\
73\helpref{wxObject}{wxobject}
b6b9d556
RR
74
75\wxheading{Include files}
76
77<wx/dataview.h>
78
a7af285d
VZ
79\wxheading{Library}
80
81\helpref{wxAdv}{librarieslist}
82
b6b9d556 83
809e21b5
FM
84\latexignore{\rtfignore{\wxheading{Members}}}
85
b6b9d556
RR
86\membersection{wxDataViewCtrl::wxDataViewCtrl}\label{wxdataviewctrlwxdataviewctrl}
87
88\func{}{wxDataViewCtrl}{\void}
89
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}}
91
92Constructor. Calls \helpref{Create}{wxdataviewctrlcreate}.
93
94\membersection{wxDataViewCtrl::\destruct{wxDataViewCtrl}}\label{wxdataviewctrldtor}
95
96\func{}{\destruct{wxDataViewCtrl}}{\void}
97
98Destructor.
99
100\membersection{wxDataViewCtrl::AppendColumn}\label{wxdataviewctrlappendcolumn}
101
102\func{virtual bool}{AppendColumn}{\param{wxDataViewColumn* }{col}}
103
c7074d44
RR
104Add a \helpref{wxDataViewColumn}{wxdataviewcolumn} to the control. Returns
105{\it true} on success.
106
107Note that there is a number of short cut methods which implicitly create
b6b9d556 108a \helpref{wxDataViewColumn}{wxdataviewcolumn} and a
314cd032 109\helpref{wxDataViewRenderer}{wxdataviewrenderer} for it (see below).
b6b9d556 110
b6b9d556
RR
111\membersection{wxDataViewCtrl::AppendBitmapColumn}\label{wxdataviewctrlappendbitmapcolumn}
112
e807896d 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}}
b6b9d556 114
e807896d 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}}
b6b9d556 116
c7074d44
RR
117Appends a column for rendering a bitmap. Returns the wxDataViewColumn
118created in the function or NULL on failure.
b6b9d556
RR
119
120\membersection{wxDataViewCtrl::AppendDateColumn}\label{wxdataviewctrlappenddatecolumn}
121
e807896d 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}}
b6b9d556 123
e807896d 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}}
b6b9d556 125
c7074d44
RR
126Appends a column for rendering a date. Returns the wxDataViewColumn
127created in the function or NULL on failure.
b6b9d556
RR
128
129\membersection{wxDataViewCtrl::AppendProgressColumn}\label{wxdataviewctrlappendprogresscolumn}
130
e807896d 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}}
b6b9d556 132
e807896d 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}}
b6b9d556 134
c7074d44
RR
135Appends a column for rendering a progress indicator. Returns the wxDataViewColumn
136created in the function or NULL on failure.
b6b9d556 137
b04fcede
RR
138\membersection{wxDataViewCtrl::AppendIconTextColumn}\label{wxdataviewctrlappendicontextcolumn}
139
e807896d 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}}
b04fcede 141
e807896d 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}}
b04fcede
RR
143
144Appends a column for rendering text with an icon. Returns the wxDataViewColumn
145created in the function or NULL on failure. This uses the
146\helpref{wxDataViewIconTextRenderer}{wxdataviewicontextrenderer}.
147
b6b9d556
RR
148\membersection{wxDataViewCtrl::AppendTextColumn}\label{wxdataviewctrlappendtextcolumn}
149
e807896d 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}}
b6b9d556 151
e807896d 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}}
b6b9d556 153
c7074d44
RR
154Appends a column for rendering text. Returns the wxDataViewColumn
155created in the function or NULL on failure.
b6b9d556
RR
156
157\membersection{wxDataViewCtrl::AppendToggleColumn}\label{wxdataviewctrlappendtogglecolumn}
158
e807896d 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}}
b6b9d556 160
e807896d 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}}
b6b9d556 162
c7074d44
RR
163Appends a column for rendering a toggle. Returns the wxDataViewColumn
164created in the function or NULL on failure.
b6b9d556
RR
165
166\membersection{wxDataViewCtrl::AssociateModel}\label{wxdataviewctrlassociatemodel}
167
1ab4aff2 168\func{virtual bool}{AssociateModel}{\param{wxDataViewModel* }{model}}
b6b9d556 169
1ab4aff2 170Associates a \helpref{wxDataViewModel}{wxdataviewmodel} with the
729a8b9b 171control. This increases the reference count of the model by 1.
b6b9d556
RR
172
173\membersection{wxDataViewCtrl::Create}\label{wxdataviewctrlcreate}
174
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}}
176
177Create the control. Useful for two step creation.
178
179\membersection{wxDataViewCtrl::ClearColumns}\label{wxdataviewctrlclearcolumns}
180
181\func{virtual bool}{ClearColumns}{\void}
182
183Removes all columns.
184
185\membersection{wxDataViewCtrl::ClearSelection}\label{wxdataviewctrlclearselection}
186
187\func{void}{ClearSelection}{\void}
188
189Unselects all rows.
190
e15c84ce
RR
191\membersection{wxDataViewCtrl::Collapse}\label{wxdataviewctrlcollapse}
192
193\func{void}{Collapse}{\param{const wxDataViewItem \& }{item}}
194
195Collapses the item.
196
b6b9d556
RR
197\membersection{wxDataViewCtrl::DeleteColumn}\label{wxdataviewctrldeletecolumn}
198
91a6c655 199\func{virtual bool}{DeleteColumn}{\param{const wxDataViewColumn* }{column}}
b6b9d556
RR
200
201Deletes given column.
202
e15c84ce
RR
203\membersection{wxDataViewCtrl::Expand}\label{wxdataviewctrlexpand}
204
205\func{void}{Expand}{\param{const wxDataViewItem \& }{item}}
206
207Expands the item.
208
b6b9d556
RR
209\membersection{wxDataViewCtrl::GetColumn}\label{wxdataviewctrlgetcolumn}
210
e0976f6d 211\constfunc{virtual wxDataViewColumn*}{GetColumn}{\param{unsigned int }{pos}}
b6b9d556 212
91a6c655
RR
213Returns pointer to the column. {\it pos} refers to the
214position in the control which may change after reordering
215columns by the user.
b6b9d556 216
a29d690d 217\membersection{wxDataViewCtrl::GetColumnCount}\label{wxdataviewctrlgetcolumncount}
b6b9d556 218
e0976f6d 219\constfunc{virtual unsigned int}{GetColumnCount}{\void}
b6b9d556
RR
220
221Returns the number of columns.
222
453091c2
RR
223\membersection{wxDataViewCtrl::GetColumnPosition}\label{wxdataviewctrlgetcolumnposition}
224
225\constfunc{virtual int}{GetColumnPosition}{\param{const wxDataViewColumn* }{column}}
226
227Returns the position of the column or -1 if not found in the control.
228
1ab4aff2
RR
229\membersection{wxDataViewCtrl::EnsureVisible}\label{wxdataviewctrlensurevisible}
230
daf5b37a 231\func{void}{EnsureVisible}{\param{const wxDataViewItem \& }{item}, \param{const wxDataViewColumn* }{column = NULL}}
1ab4aff2
RR
232
233Call this to ensure that the given item is visible.
234
235\membersection{wxDataViewCtrl::GetExpanderColumn}\label{wxdataviewctrlgetexpandercolumn}
236
1b27b2bd 237\constfunc{wxDataViewColumn *}{GetExpanderColumn}{\void}
1ab4aff2
RR
238
239Returns column containing the expanders.
240
241\membersection{wxDataViewCtrl::GetIndent}\label{wxdataviewctrlgetindent}
242
243\constfunc{int}{GetIndent}{\void}
244
245Returns indentation.
246
247\membersection{wxDataViewCtrl::GetItemRect}\label{wxdataviewctrlgetitemrect}
248
e0976f6d 249\constfunc{wxRect}{GetItemRect}{\param{const wxDataViewItem\& }{item}, \param{const wxDataViewColumn *}{col = NULL}}
1ab4aff2
RR
250
251Returns item rect.
252
453091c2
RR
253\membersection{wxDataViewCtrl::GetModel}\label{wxdataviewctrlgetmodel}
254
255\constfunc{virtual wxDataViewModel*}{GetModel}{\void}
256
257Returns pointer to the data model associated with the
258control (if any).
259
b6b9d556
RR
260\membersection{wxDataViewCtrl::GetSelection}\label{wxdataviewctrlgetselection}
261
e0976f6d 262\constfunc{wxDataViewItem}{GetSelection}{\void}
b6b9d556 263
1ab4aff2 264Returns first selected item or an invalid item if none is selected.
b6b9d556
RR
265
266\membersection{wxDataViewCtrl::GetSelections}\label{wxdataviewctrlgetselections}
267
1ab4aff2 268\constfunc{int}{GetSelections}{\param{wxDataViewItemArray \& }{sel}}
b6b9d556 269
1ab4aff2
RR
270Fills {\it sel} with currently selected items and returns
271their number.
272
21f47fb9
RR
273\membersection{wxDataViewCtrl::GetSortingColumn}\label{wxdataviewctrlgetsortingcolumn}
274
275\constfunc{virtual wxDataViewColumn*}{GetSortingColumn}{\void}
276
277Returns the wxDataViewColumn currently responsible for sorting
278or NULL if none has been selected.
279
1ab4aff2
RR
280\membersection{wxDataViewCtrl::HitTest}\label{wxdataviewctrlhittest}
281
513edac2 282\constfunc{void}{HitTest}{\param{const wxPoint\& }{point}, \param{wxDataViewItem\& }{item}, \param{wxDataViewColumn *\&}{col}}
1ab4aff2
RR
283
284Hittest.
b6b9d556
RR
285
286\membersection{wxDataViewCtrl::IsSelected}\label{wxdataviewctrlisselected}
287
1ab4aff2
RR
288\constfunc{bool}{IsSelected}{\param{const wxDataViewItem \& }{item}}
289
290Return true if the item is selected.
b6b9d556 291
1ab4aff2 292\membersection{wxDataViewCtrl::Select}\label{wxdataviewctrlselect}
b6b9d556 293
1ab4aff2 294\func{void}{Select}{\param{const wxDataViewItem \& }{item}}
b6b9d556 295
1ab4aff2 296Select the given item.
b6b9d556 297
1ab4aff2 298\membersection{wxDataViewCtrl::SelectAll}\label{wxdataviewctrlselectall}
b6b9d556 299
1ab4aff2 300\func{void}{SelectAll}{\void}
b6b9d556 301
1ab4aff2 302Select all items.
b6b9d556 303
1ab4aff2
RR
304\membersection{wxDataViewCtrl::SetExpanderColumn}\label{wxdataviewctrlsetexpandercolumn}
305
1b27b2bd 306\func{void}{SetExpanderColumn}{\param{wxDataViewColumn *}{col}}
1ab4aff2
RR
307
308Set which column shall contain the tree-like expanders.
309
310\membersection{wxDataViewCtrl::SetIndent}\label{wxdataviewctrlsetindent}
311
312\func{void}{SetIndent}{\param{int }{indent}}
313
314Sets the indendation.
b6b9d556
RR
315
316\membersection{wxDataViewCtrl::SetSelections}\label{wxdataviewctrlsetselections}
317
1ab4aff2 318\func{void}{SetSelections}{\param{const wxDataViewItemArray \& }{sel}}
b6b9d556 319
1ab4aff2 320Sets the selection to the array of wxDataViewItems.
b6b9d556
RR
321
322\membersection{wxDataViewCtrl::Unselect}\label{wxdataviewctrlunselect}
323
1ab4aff2
RR
324\func{void}{Unselect}{\param{const wxDataViewItem \& }{item}}
325
326Unselect the given item.
327
328\membersection{wxDataViewCtrl::UnselectAll}\label{wxdataviewctrlunselectall}
329
330\func{void}{UnselectAll}{\void}
b6b9d556 331
1ab4aff2
RR
332Unselect all item. This method only has effect if multiple
333selections are allowed.
b6b9d556 334