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