]>
Commit | Line | Data |
---|---|---|
b6b9d556 RR |
1 | |
2 | \section{\class{wxDataViewCtrl}}\label{wxdataviewctrl} | |
3 | ||
1ab4aff2 RR |
4 | wxDataViewCtrl is a control to display data either |
5 | in a tree like fashion or in a tabular form or both. | |
305c49a1 | 6 | |
4f76c1a2 RR |
7 | A \helpref{wxDataViewItem}{wxdataviewitem} is used |
8 | to represent a (visible) item in the control. | |
9 | ||
305c49a1 | 10 | Unlike \helpref{wxListCtrl}{wxlistctrl} wxDataViewCtrl doesn't |
1ab4aff2 RR |
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 | |
b6b9d556 RR |
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 | ||
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 | ||
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 | ||
d86c1870 | 49 | \twocolitem{{\bf EVT\_DATAVIEW\_SELECTION\_CHANGED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_SELECTION\_CHANGED event.} |
1ab4aff2 | 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 | ||
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 | ||
c7074d44 RR |
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 | |
b6b9d556 | 104 | a \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 |
113 | Appends a column for rendering a bitmap. Returns the wxDataViewColumn |
114 | created 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 |
122 | Appends a column for rendering a date. Returns the wxDataViewColumn |
123 | created 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 |
131 | Appends a column for rendering a progress indicator. Returns the wxDataViewColumn |
132 | created in the function or NULL on failure. | |
b6b9d556 | 133 | |
b04fcede RR |
134 | \membersection{wxDataViewCtrl::AppendIconTextColumn}\label{wxdataviewctrlappendicontextcolumn} |
135 | ||
136 | \func{wxDataViewColumn*}{AppendIconTextColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}} | |
137 | ||
138 | \func{wxDataViewColumn*}{AppendIconTextColumn}{\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 with an icon. Returns the wxDataViewColumn | |
141 | created in the function or NULL on failure. This uses the | |
142 | \helpref{wxDataViewIconTextRenderer}{wxdataviewicontextrenderer}. | |
143 | ||
b6b9d556 RR |
144 | \membersection{wxDataViewCtrl::AppendTextColumn}\label{wxdataviewctrlappendtextcolumn} |
145 | ||
c7074d44 | 146 | \func{wxDataViewColumn*}{AppendTextColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}} |
b6b9d556 | 147 | |
c7074d44 | 148 | \func{wxDataViewColumn*}{AppendTextColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}} |
b6b9d556 | 149 | |
c7074d44 RR |
150 | Appends a column for rendering text. Returns the wxDataViewColumn |
151 | created in the function or NULL on failure. | |
b6b9d556 RR |
152 | |
153 | \membersection{wxDataViewCtrl::AppendToggleColumn}\label{wxdataviewctrlappendtogglecolumn} | |
154 | ||
c7074d44 | 155 | \func{wxDataViewColumn*}{AppendToggleColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 30}} |
b6b9d556 | 156 | |
c7074d44 | 157 | \func{wxDataViewColumn*}{AppendToggleColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 30}} |
b6b9d556 | 158 | |
c7074d44 RR |
159 | Appends a column for rendering a toggle. Returns the wxDataViewColumn |
160 | created in the function or NULL on failure. | |
b6b9d556 RR |
161 | |
162 | \membersection{wxDataViewCtrl::AssociateModel}\label{wxdataviewctrlassociatemodel} | |
163 | ||
1ab4aff2 | 164 | \func{virtual bool}{AssociateModel}{\param{wxDataViewModel* }{model}} |
b6b9d556 | 165 | |
1ab4aff2 RR |
166 | Associates a \helpref{wxDataViewModel}{wxdataviewmodel} with the |
167 | control. | |
b6b9d556 RR |
168 | |
169 | \membersection{wxDataViewCtrl::Create}\label{wxdataviewctrlcreate} | |
170 | ||
171 | \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}} | |
172 | ||
173 | Create the control. Useful for two step creation. | |
174 | ||
175 | \membersection{wxDataViewCtrl::ClearColumns}\label{wxdataviewctrlclearcolumns} | |
176 | ||
177 | \func{virtual bool}{ClearColumns}{\void} | |
178 | ||
179 | Removes all columns. | |
180 | ||
181 | \membersection{wxDataViewCtrl::ClearSelection}\label{wxdataviewctrlclearselection} | |
182 | ||
183 | \func{void}{ClearSelection}{\void} | |
184 | ||
185 | Unselects all rows. | |
186 | ||
e15c84ce RR |
187 | \membersection{wxDataViewCtrl::Collapse}\label{wxdataviewctrlcollapse} |
188 | ||
189 | \func{void}{Collapse}{\param{const wxDataViewItem \& }{item}} | |
190 | ||
191 | Collapses the item. | |
192 | ||
b6b9d556 RR |
193 | \membersection{wxDataViewCtrl::DeleteColumn}\label{wxdataviewctrldeletecolumn} |
194 | ||
91a6c655 | 195 | \func{virtual bool}{DeleteColumn}{\param{const wxDataViewColumn* }{column}} |
b6b9d556 RR |
196 | |
197 | Deletes given column. | |
198 | ||
e15c84ce RR |
199 | \membersection{wxDataViewCtrl::Expand}\label{wxdataviewctrlexpand} |
200 | ||
201 | \func{void}{Expand}{\param{const wxDataViewItem \& }{item}} | |
202 | ||
203 | Expands the item. | |
204 | ||
b6b9d556 RR |
205 | \membersection{wxDataViewCtrl::GetColumn}\label{wxdataviewctrlgetcolumn} |
206 | ||
e0976f6d | 207 | \constfunc{virtual wxDataViewColumn*}{GetColumn}{\param{unsigned int }{pos}} |
b6b9d556 | 208 | |
91a6c655 RR |
209 | Returns pointer to the column. {\it pos} refers to the |
210 | position in the control which may change after reordering | |
211 | columns by the user. | |
b6b9d556 | 212 | |
a29d690d | 213 | \membersection{wxDataViewCtrl::GetColumnCount}\label{wxdataviewctrlgetcolumncount} |
b6b9d556 | 214 | |
e0976f6d | 215 | \constfunc{virtual unsigned int}{GetColumnCount}{\void} |
b6b9d556 RR |
216 | |
217 | Returns the number of columns. | |
218 | ||
453091c2 RR |
219 | \membersection{wxDataViewCtrl::GetColumnPosition}\label{wxdataviewctrlgetcolumnposition} |
220 | ||
221 | \constfunc{virtual int}{GetColumnPosition}{\param{const wxDataViewColumn* }{column}} | |
222 | ||
223 | Returns the position of the column or -1 if not found in the control. | |
224 | ||
1ab4aff2 RR |
225 | \membersection{wxDataViewCtrl::EnsureVisible}\label{wxdataviewctrlensurevisible} |
226 | ||
daf5b37a | 227 | \func{void}{EnsureVisible}{\param{const wxDataViewItem \& }{item}, \param{const wxDataViewColumn* }{column = NULL}} |
1ab4aff2 RR |
228 | |
229 | Call this to ensure that the given item is visible. | |
230 | ||
231 | \membersection{wxDataViewCtrl::GetExpanderColumn}\label{wxdataviewctrlgetexpandercolumn} | |
232 | ||
1b27b2bd | 233 | \constfunc{wxDataViewColumn *}{GetExpanderColumn}{\void} |
1ab4aff2 RR |
234 | |
235 | Returns column containing the expanders. | |
236 | ||
237 | \membersection{wxDataViewCtrl::GetIndent}\label{wxdataviewctrlgetindent} | |
238 | ||
239 | \constfunc{int}{GetIndent}{\void} | |
240 | ||
241 | Returns indentation. | |
242 | ||
243 | \membersection{wxDataViewCtrl::GetItemRect}\label{wxdataviewctrlgetitemrect} | |
244 | ||
e0976f6d | 245 | \constfunc{wxRect}{GetItemRect}{\param{const wxDataViewItem\& }{item}, \param{const wxDataViewColumn *}{col = NULL}} |
1ab4aff2 RR |
246 | |
247 | Returns item rect. | |
248 | ||
453091c2 RR |
249 | \membersection{wxDataViewCtrl::GetModel}\label{wxdataviewctrlgetmodel} |
250 | ||
251 | \constfunc{virtual wxDataViewModel*}{GetModel}{\void} | |
252 | ||
253 | Returns pointer to the data model associated with the | |
254 | control (if any). | |
255 | ||
b6b9d556 RR |
256 | \membersection{wxDataViewCtrl::GetSelection}\label{wxdataviewctrlgetselection} |
257 | ||
e0976f6d | 258 | \constfunc{wxDataViewItem}{GetSelection}{\void} |
b6b9d556 | 259 | |
1ab4aff2 | 260 | Returns first selected item or an invalid item if none is selected. |
b6b9d556 RR |
261 | |
262 | \membersection{wxDataViewCtrl::GetSelections}\label{wxdataviewctrlgetselections} | |
263 | ||
1ab4aff2 | 264 | \constfunc{int}{GetSelections}{\param{wxDataViewItemArray \& }{sel}} |
b6b9d556 | 265 | |
1ab4aff2 RR |
266 | Fills {\it sel} with currently selected items and returns |
267 | their number. | |
268 | ||
21f47fb9 RR |
269 | \membersection{wxDataViewCtrl::GetSortingColumn}\label{wxdataviewctrlgetsortingcolumn} |
270 | ||
271 | \constfunc{virtual wxDataViewColumn*}{GetSortingColumn}{\void} | |
272 | ||
273 | Returns the wxDataViewColumn currently responsible for sorting | |
274 | or NULL if none has been selected. | |
275 | ||
1ab4aff2 RR |
276 | \membersection{wxDataViewCtrl::HitTest}\label{wxdataviewctrlhittest} |
277 | ||
513edac2 | 278 | \constfunc{void}{HitTest}{\param{const wxPoint\& }{point}, \param{wxDataViewItem\& }{item}, \param{wxDataViewColumn *\&}{col}} |
1ab4aff2 RR |
279 | |
280 | Hittest. | |
b6b9d556 RR |
281 | |
282 | \membersection{wxDataViewCtrl::IsSelected}\label{wxdataviewctrlisselected} | |
283 | ||
1ab4aff2 RR |
284 | \constfunc{bool}{IsSelected}{\param{const wxDataViewItem \& }{item}} |
285 | ||
286 | Return true if the item is selected. | |
b6b9d556 | 287 | |
1ab4aff2 | 288 | \membersection{wxDataViewCtrl::Select}\label{wxdataviewctrlselect} |
b6b9d556 | 289 | |
1ab4aff2 | 290 | \func{void}{Select}{\param{const wxDataViewItem \& }{item}} |
b6b9d556 | 291 | |
1ab4aff2 | 292 | Select the given item. |
b6b9d556 | 293 | |
1ab4aff2 | 294 | \membersection{wxDataViewCtrl::SelectAll}\label{wxdataviewctrlselectall} |
b6b9d556 | 295 | |
1ab4aff2 | 296 | \func{void}{SelectAll}{\void} |
b6b9d556 | 297 | |
1ab4aff2 | 298 | Select all items. |
b6b9d556 | 299 | |
1ab4aff2 RR |
300 | \membersection{wxDataViewCtrl::SetExpanderColumn}\label{wxdataviewctrlsetexpandercolumn} |
301 | ||
1b27b2bd | 302 | \func{void}{SetExpanderColumn}{\param{wxDataViewColumn *}{col}} |
1ab4aff2 RR |
303 | |
304 | Set which column shall contain the tree-like expanders. | |
305 | ||
306 | \membersection{wxDataViewCtrl::SetIndent}\label{wxdataviewctrlsetindent} | |
307 | ||
308 | \func{void}{SetIndent}{\param{int }{indent}} | |
309 | ||
310 | Sets the indendation. | |
b6b9d556 RR |
311 | |
312 | \membersection{wxDataViewCtrl::SetSelections}\label{wxdataviewctrlsetselections} | |
313 | ||
1ab4aff2 | 314 | \func{void}{SetSelections}{\param{const wxDataViewItemArray \& }{sel}} |
b6b9d556 | 315 | |
1ab4aff2 | 316 | Sets the selection to the array of wxDataViewItems. |
b6b9d556 RR |
317 | |
318 | \membersection{wxDataViewCtrl::Unselect}\label{wxdataviewctrlunselect} | |
319 | ||
1ab4aff2 RR |
320 | \func{void}{Unselect}{\param{const wxDataViewItem \& }{item}} |
321 | ||
322 | Unselect the given item. | |
323 | ||
324 | \membersection{wxDataViewCtrl::UnselectAll}\label{wxdataviewctrlunselectall} | |
325 | ||
326 | \func{void}{UnselectAll}{\void} | |
b6b9d556 | 327 | |
1ab4aff2 RR |
328 | Unselect all item. This method only has effect if multiple |
329 | selections are allowed. | |
b6b9d556 | 330 |