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