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