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