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