]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/dataviewctrl.tex
typo
[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.}
b6b9d556
RR
51\twocolitem{{\bf EVT\_DATAVIEW\_COLUMN\_HEADER\_CLICK(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_COLUMN\_HEADER\_CLICKED event.}
52\twocolitem{{\bf EVT\_DATAVIEW\_COLUMN\_HEADER\_RIGHT\_CLICK(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_COLUMN\_HEADER\_RIGHT\_CLICKED event.}
1ab4aff2 53\twocolitem{{\bf EVT\_DATAVIEW\_COLUMN\_HEADER\_SORTED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_COLUMN\_HEADER\_SORTED event.}
1821abd1
RR
54
55\end{twocollist}
b6b9d556
RR
56
57
58\wxheading{Derived from}
59
7376079d
VZ
60\helpref{wxControl}{wxcontrol}\\
61\helpref{wxWindow}{wxwindow}\\
62\helpref{wxEvtHandler}{wxevthandler}\\
63\helpref{wxObject}{wxobject}
b6b9d556
RR
64
65\wxheading{Include files}
66
67<wx/dataview.h>
68
a7af285d
VZ
69\wxheading{Library}
70
71\helpref{wxAdv}{librarieslist}
72
b6b9d556 73
809e21b5
FM
74\latexignore{\rtfignore{\wxheading{Members}}}
75
b6b9d556
RR
76\membersection{wxDataViewCtrl::wxDataViewCtrl}\label{wxdataviewctrlwxdataviewctrl}
77
78\func{}{wxDataViewCtrl}{\void}
79
80\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}}
81
82Constructor. Calls \helpref{Create}{wxdataviewctrlcreate}.
83
84\membersection{wxDataViewCtrl::\destruct{wxDataViewCtrl}}\label{wxdataviewctrldtor}
85
86\func{}{\destruct{wxDataViewCtrl}}{\void}
87
88Destructor.
89
90\membersection{wxDataViewCtrl::AppendColumn}\label{wxdataviewctrlappendcolumn}
91
92\func{virtual bool}{AppendColumn}{\param{wxDataViewColumn* }{col}}
93
c7074d44
RR
94Add a \helpref{wxDataViewColumn}{wxdataviewcolumn} to the control. Returns
95{\it true} on success.
96
97Note that there is a number of short cut methods which implicitly create
b6b9d556 98a \helpref{wxDataViewColumn}{wxdataviewcolumn} and a
314cd032 99\helpref{wxDataViewRenderer}{wxdataviewrenderer} for it (see below).
b6b9d556 100
b6b9d556
RR
101\membersection{wxDataViewCtrl::AppendBitmapColumn}\label{wxdataviewctrlappendbitmapcolumn}
102
c7074d44 103\func{wxDataViewColumn*}{AppendBitmapColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}}
b6b9d556 104
c7074d44 105\func{wxDataViewColumn*}{AppendBitmapColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}}
b6b9d556 106
c7074d44
RR
107Appends a column for rendering a bitmap. Returns the wxDataViewColumn
108created in the function or NULL on failure.
b6b9d556
RR
109
110\membersection{wxDataViewCtrl::AppendDateColumn}\label{wxdataviewctrlappenddatecolumn}
111
c7074d44 112\func{wxDataViewColumn*}{AppendDateColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_ACTIVATABLE}, \param{int }{width = -1}}
b6b9d556 113
c7074d44 114\func{wxDataViewColumn*}{AppendDateColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_ACTIVATABLE}, \param{int }{width = -1}}
b6b9d556 115
c7074d44
RR
116Appends a column for rendering a date. Returns the wxDataViewColumn
117created in the function or NULL on failure.
b6b9d556
RR
118
119\membersection{wxDataViewCtrl::AppendProgressColumn}\label{wxdataviewctrlappendprogresscolumn}
120
c7074d44 121\func{wxDataViewColumn*}{AppendProgressColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 80}}
b6b9d556 122
c7074d44 123\func{wxDataViewColumn*}{AppendProgressColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 80}}
b6b9d556 124
c7074d44
RR
125Appends a column for rendering a progress indicator. Returns the wxDataViewColumn
126created in the function or NULL on failure.
b6b9d556
RR
127
128\membersection{wxDataViewCtrl::AppendTextColumn}\label{wxdataviewctrlappendtextcolumn}
129
c7074d44 130\func{wxDataViewColumn*}{AppendTextColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}}
b6b9d556 131
c7074d44 132\func{wxDataViewColumn*}{AppendTextColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}}
b6b9d556 133
c7074d44
RR
134Appends a column for rendering text. Returns the wxDataViewColumn
135created in the function or NULL on failure.
b6b9d556
RR
136
137\membersection{wxDataViewCtrl::AppendToggleColumn}\label{wxdataviewctrlappendtogglecolumn}
138
c7074d44 139\func{wxDataViewColumn*}{AppendToggleColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 30}}
b6b9d556 140
c7074d44 141\func{wxDataViewColumn*}{AppendToggleColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 30}}
b6b9d556 142
c7074d44
RR
143Appends a column for rendering a toggle. Returns the wxDataViewColumn
144created in the function or NULL on failure.
b6b9d556
RR
145
146\membersection{wxDataViewCtrl::AssociateModel}\label{wxdataviewctrlassociatemodel}
147
1ab4aff2 148\func{virtual bool}{AssociateModel}{\param{wxDataViewModel* }{model}}
b6b9d556 149
1ab4aff2
RR
150Associates a \helpref{wxDataViewModel}{wxdataviewmodel} with the
151control.
b6b9d556
RR
152
153\membersection{wxDataViewCtrl::Create}\label{wxdataviewctrlcreate}
154
155\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}}
156
157Create the control. Useful for two step creation.
158
159\membersection{wxDataViewCtrl::ClearColumns}\label{wxdataviewctrlclearcolumns}
160
161\func{virtual bool}{ClearColumns}{\void}
162
163Removes all columns.
164
165\membersection{wxDataViewCtrl::ClearSelection}\label{wxdataviewctrlclearselection}
166
167\func{void}{ClearSelection}{\void}
168
169Unselects all rows.
170
171\membersection{wxDataViewCtrl::DeleteColumn}\label{wxdataviewctrldeletecolumn}
172
173\func{virtual bool}{DeleteColumn}{\param{unsigned int }{pos}}
174
175Deletes given column.
176
177\membersection{wxDataViewCtrl::GetColumn}\label{wxdataviewctrlgetcolumn}
178
179\func{virtual wxDataViewColumn*}{GetColumn}{\param{unsigned int }{pos}}
180
181Returns pointer to the column.
182
183\membersection{wxDataViewCtrl::GetModel}\label{wxdataviewctrlgetmodel}
184
1ab4aff2 185\func{virtual wxDataViewModel*}{GetModel}{\void}
b6b9d556
RR
186
187Returns pointer to the data model associated with the
188control (if any).
189
a29d690d 190\membersection{wxDataViewCtrl::GetColumnCount}\label{wxdataviewctrlgetcolumncount}
b6b9d556 191
a29d690d 192\func{virtual unsigned int}{GetColumnCount}{\void}
b6b9d556
RR
193
194Returns the number of columns.
195
1ab4aff2
RR
196\membersection{wxDataViewCtrl::EnsureVisible}\label{wxdataviewctrlensurevisible}
197
198\func{void}{EnsureVisible}{\param{const wxDataViewItem \& }{item}, \param{wxDataViewColumn* }{column = NULL}}
199
200Call this to ensure that the given item is visible.
201
202\membersection{wxDataViewCtrl::GetExpanderColumn}\label{wxdataviewctrlgetexpandercolumn}
203
204\constfunc{unsigned int}{GetExpanderColumn}{\void}
205
206Returns column containing the expanders.
207
208\membersection{wxDataViewCtrl::GetIndent}\label{wxdataviewctrlgetindent}
209
210\constfunc{int}{GetIndent}{\void}
211
212Returns indentation.
213
214\membersection{wxDataViewCtrl::GetItemRect}\label{wxdataviewctrlgetitemrect}
215
93fd94eb 216\constfunc{wxRect}{GetItemRect}{\param{const wxDataViewItem\& }{item}, \param{wxDataViewColumn *}{col}}
1ab4aff2
RR
217
218Returns item rect.
219
b6b9d556
RR
220\membersection{wxDataViewCtrl::GetSelection}\label{wxdataviewctrlgetselection}
221
1ab4aff2 222\func{wxDataViewItem}{GetSelection}{\void}
b6b9d556 223
1ab4aff2 224Returns first selected item or an invalid item if none is selected.
b6b9d556
RR
225
226\membersection{wxDataViewCtrl::GetSelections}\label{wxdataviewctrlgetselections}
227
1ab4aff2 228\constfunc{int}{GetSelections}{\param{wxDataViewItemArray \& }{sel}}
b6b9d556 229
1ab4aff2
RR
230Fills {\it sel} with currently selected items and returns
231their number.
232
233\membersection{wxDataViewCtrl::HitTest}\label{wxdataviewctrlhittest}
234
93fd94eb 235\constfunc{void}{HitTest}{\param{const wxPoint\& }{point}, \param{wxDataViewItem\& }{item}, \param{wxDataViewColumn *}{col}}
1ab4aff2
RR
236
237Hittest.
b6b9d556
RR
238
239\membersection{wxDataViewCtrl::IsSelected}\label{wxdataviewctrlisselected}
240
1ab4aff2
RR
241\constfunc{bool}{IsSelected}{\param{const wxDataViewItem \& }{item}}
242
243Return true if the item is selected.
b6b9d556 244
1ab4aff2 245\membersection{wxDataViewCtrl::Select}\label{wxdataviewctrlselect}
b6b9d556 246
1ab4aff2 247\func{void}{Select}{\param{const wxDataViewItem \& }{item}}
b6b9d556 248
1ab4aff2 249Select the given item.
b6b9d556 250
1ab4aff2 251\membersection{wxDataViewCtrl::SelectAll}\label{wxdataviewctrlselectall}
b6b9d556 252
1ab4aff2 253\func{void}{SelectAll}{\void}
b6b9d556 254
1ab4aff2 255Select all items.
b6b9d556 256
1ab4aff2
RR
257\membersection{wxDataViewCtrl::SetExpanderColumn}\label{wxdataviewctrlsetexpandercolumn}
258
259\func{void}{SetExpanderColumn}{\param{unsigned int }{col}}
260
261Set which column shall contain the tree-like expanders.
262
263\membersection{wxDataViewCtrl::SetIndent}\label{wxdataviewctrlsetindent}
264
265\func{void}{SetIndent}{\param{int }{indent}}
266
267Sets the indendation.
b6b9d556
RR
268
269\membersection{wxDataViewCtrl::SetSelections}\label{wxdataviewctrlsetselections}
270
1ab4aff2 271\func{void}{SetSelections}{\param{const wxDataViewItemArray \& }{sel}}
b6b9d556 272
1ab4aff2 273Sets the selection to the array of wxDataViewItems.
b6b9d556
RR
274
275\membersection{wxDataViewCtrl::Unselect}\label{wxdataviewctrlunselect}
276
1ab4aff2
RR
277\func{void}{Unselect}{\param{const wxDataViewItem \& }{item}}
278
279Unselect the given item.
280
281\membersection{wxDataViewCtrl::UnselectAll}\label{wxdataviewctrlunselectall}
282
283\func{void}{UnselectAll}{\void}
b6b9d556 284
1ab4aff2
RR
285Unselect all item. This method only has effect if multiple
286selections are allowed.
b6b9d556 287