]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/dataviewmodel.tex
added wxBase64Decode() overload taking wxString, otherwise it's inconvenient to use...
[wxWidgets.git] / docs / latex / wx / dataviewmodel.tex
... / ...
CommitLineData
1
2\section{\class{wxDataViewModel}}\label{wxdataviewmodel}
3
4wxDataViewModel is the base class for all data model to be
5displayed by a \helpref{wxDataViewCtrl}{wxdataviewctrl}.
6All other models derive from it and must implement its
7pure virtual functions in order to define a complete
8data model. In detail, you need to override
9\helpref{IsContainer}{wxdataviewmodeliscontainer},
10\helpref{GetParent}{wxdataviewmodelgetparent},
11\helpref{GetChildren}{wxdataviewmodelgetchildren},
12\helpref{GetColumnCount}{wxdataviewmodelgetcolumncount},
13\helpref{GetColumnType}{wxdataviewmodelgetcolumntype} and
14\helpref{GetValue}{wxdataviewmodelgetvalue} in order to
15define the data model which acts as an interface between
16your actual data and the wxDataViewCtrl. Since you will
17usually also allow the wxDataViewCtrl to change your data
18through its graphical interface, you will also have to override
19\helpref{SetValue}{wxdataviewmodelsetvalue} which the
20wxDataViewCtrl will call when a change to some data has been
21commited.
22
23wxDataViewModel (as indeed the entire wxDataViewCtrl
24code) is using \helpref{wxVariant}{wxvariant} to store data and
25its type in a generic way. wxVariant can be extended to contain
26almost any data without changes to the original class.
27
28The data that is presented through this data model is expected
29to change at run-time. You need to inform the data model when
30a change happened. Depending on what happened you need to call
31one of the following methods:
32\helpref{ValueChanged}{wxdataviewmodelvaluechanged},
33\helpref{ItemAdded}{wxdataviewmodelitemadded},
34\helpref{ItemDeleted}{wxdataviewmodelitemdeleted},
35\helpref{ItemChanged}{wxdataviewmodelitemchanged},
36\helpref{Cleared}{wxdataviewmodelcleared}.
37
38Note that wxDataViewModel does not define the position or
39index of any item in the control since several control might
40display the data differently, but wxDataViewModel does
41provide a \helpref{Compare}{wxdataviewmodelcompare} method
42which the wxDataViewCtrl may use to sort the data either
43in conjunction with a column header or without (see
44\helpref{HasDefaultCompare}{wxdataviewmodelhasdefaultcompare}.
45
46This class maintains a list of
47\helpref{wxDataViewModelNotifier}{wxdataviewmodelnotifier}
48which link this class to the specific implementations on the
49supported platforms so that e.g. calling
50\helpref{ValueChanged}{wxdataviewmodelvaluechanged}
51on this model will just call
52\helpref{wxDataViewModelNotifier::ValueChanged}{wxdataviewmodelnotifiervaluechanged}
53for each notifier that has been added. You can also add
54your own notifier in order to get informed about any changes
55to the data in the list model.
56
57Currently wxWidgets provides the following models apart
58from the base model:
59\helpref{wxDataViewIndexListModel}{wxdataviewindexlistmodel}.
60It is planned to add helper classes for simple tree
61and list stores in the future.
62
63\wxheading{Derived from}
64
65\helpref{wxObjectRefData}{wxobjectrefdata}
66
67\wxheading{Include files}
68
69<wx/dataview.h>
70
71\wxheading{Library}
72
73\helpref{wxAdv}{librarieslist}
74
75
76
77\latexignore{\rtfignore{\wxheading{Members}}}
78
79\membersection{wxDataViewModel::wxDataViewModel}\label{wxdataviewmodelwxdataviewmodel}
80
81\func{}{wxDataViewModel}{\void}
82
83Constructor.
84
85\membersection{wxDataViewModel::\destruct{wxDataViewModel}}\label{wxdataviewmodeldtor}
86
87\func{}{\destruct{wxDataViewModel}}{\void}
88
89Destructor. This should not be called directly. Use DecRef() instead.
90
91
92\membersection{wxDataViewModel::AddNotifier}\label{wxdataviewmodeladdnotifier}
93
94\func{void}{AddNotifier}{\param{wxDataViewModelNotifier* }{notifier}}
95
96Adds a \helpref{wxDataViewModelNotifier}{wxdataviewmodelnotifier}
97to the model.
98
99\membersection{wxDataViewModel::Cleared}\label{wxdataviewmodelcleared}
100
101\func{virtual bool}{Cleared}{\void}
102
103Called to inform the model that all data has been deleted.
104
105\membersection{wxDataViewModel::Compare}\label{wxdataviewmodelcompare}
106
107\func{virtual int}{Compare}{\param{const wxDataViewItem\& }{item1}, \param{const wxDataViewItem\& }{item2}, \param{unsigned int }{column}, \param{bool }{ascending}}
108
109The compare function to be used by control. The default compare function
110sorts by container and other items separately and in ascending order.
111Override this for a different sorting behaviour.
112
113See also \helpref{HasDefaultCompare}{wxdataviewmodelhasdefaultcompare}.
114
115\membersection{wxDataViewModel::GetColumnCount}\label{wxdataviewmodelgetcolumncount}
116
117\constfunc{virtual unsigned int}{GetColumnCount}{\void}
118
119Override this to indicate the number of columns in the model.
120
121\membersection{wxDataViewModel::GetColumnType}\label{wxdataviewmodelgetcolumntype}
122
123\constfunc{virtual wxString}{GetColumnType}{\param{unsigned int }{col}}
124
125Override this to indicate what type of data is stored in the
126column specified by {\it col}. This should return a string
127indicating the type of data as reported by \helpref{wxVariant}{wxvariant}.
128
129\membersection{wxDataViewModel::GetChildren}\label{wxdataviewmodelgetchildren}
130
131\constfunc{virtual unsigned int}{GetChildren}{\param{const wxDataViewItem\& }{item}, \param{wxDataViewItemArray\& }{children} }
132
133Override this so the control can query the child items of
134an item. Returns the number of items.
135
136\membersection{wxDataViewModel::GetParent}\label{wxdataviewmodelgetparent}
137
138\constfunc{virtual wxDataViewItem}{GetParent}{\param{const wxDataViewItem\& }{item}}
139
140Override this to indicate which wxDataViewItem representing the parent
141of {\it item} or an invalid wxDataViewItem if {\it item} is the root item.
142
143\membersection{wxDataViewModel::GetValue}\label{wxdataviewmodelgetvalue}
144
145\constfunc{virtual void}{GetValue}{\param{wxVariant\& }{variant}, \param{const wxDataViewItem\& }{item}, \param{unsigned int }{col}}
146
147Override this to indicate the value of {\it item}
148A \helpref{wxVariant}{wxvariant} is used to store the data.
149
150\membersection{wxDataViewModel::HasDefaultCompare}\label{wxdataviewmodelhasdefaultcompare}
151
152\constfunc{virtual bool}{HasDefaultCompare}{\void}
153
154Override this to indicate that the model provides a default compare
155function that the control should use if no wxDataViewColumn has been
156chosen for sorting. Usually, the user clicks on a column header for
157sorting, the data will be sorted alphanumerically. If any other
158order (e.g. by index or order of appearance) is required, then this
159should be used. See also \helpref{wxDataViewIndexListModel}{wxdataviewindexlistmodel}
160for a model which makes use of this.
161
162\membersection{wxDataViewModel::IsContainer}\label{wxdataviewmodeliscontainer}
163
164\constfunc{virtual bool}{IsContainer}{\param{const wxDataViewItem\& }{item}}
165
166Override this to indicate of {\it item} is a container, i.e. if
167it can have child items.
168
169\membersection{wxDataViewModel::ItemAdded}\label{wxdataviewmodelitemadded}
170
171\func{virtual bool}{ItemAdded}{\param{const wxDataViewItem\& }{parent}, \param{const wxDataViewItem\& }{item}}
172
173Call this to inform the model that an item has been added
174to the data.
175
176\membersection{wxDataViewModel::ItemChanged}\label{wxdataviewmodelitemchanged}
177
178\func{virtual bool}{ItemChanged}{\param{const wxDataViewItem\& }{item}}
179
180Call this to inform the model that an item has changed.
181
182This will eventually emit a wxEVT\_DATAVIEW\_ITEM\_VALUE\_CHANGED
183event (in which the column fields will not be set) to the user.
184
185\membersection{wxDataViewModel::ItemsAdded}\label{wxdataviewmodelitemsadded}
186
187\func{virtual bool}{ItemsAdded}{\param{const wxDataViewItem\& }{parent}, \param{const wxDataViewItemArray\& }{items}}
188
189Call this to inform the model that several items have been added
190to the data.
191
192\membersection{wxDataViewModel::ItemsChanged}\label{wxdataviewmodelitemschanged}
193
194\func{virtual bool}{ItemsChanged}{\param{const wxDataViewItemArray\& }{items}}
195
196Call this to inform the model that several items have changed.
197
198This will eventually emit wxEVT\_DATAVIEW\_ITEM\_VALUE\_CHANGED
199events (in which the column fields will not be set) to the user.
200
201\membersection{wxDataViewModel::ItemsDeleted}\label{wxdataviewmodelitemsdeleted}
202
203\func{virtual bool}{ItemsDeleted}{\param{const wxDataViewItem\& }{parent}, \param{const wxDataViewItemArray\& }{items}}
204
205Call this to inform the model that several items have been deleted.
206
207\membersection{wxDataViewModel::RemoveNotifier}\label{wxdataviewmodelremovenotifier}
208
209\func{void}{RemoveNotifier}{\param{wxDataViewModelNotifier* }{notifier}}
210
211Remove the {\it notifier} from the list of notifiers.
212
213\membersection{wxDataViewModel::Resort}\label{wxdataviewmodelresort}
214
215\func{virtual void}{Resort}{\void}
216
217Call this to initiate a resort after the sort function has
218been changed.
219
220\membersection{wxDataViewModel::SetValue}\label{wxdataviewmodelsetvalue}
221
222\func{virtual bool}{SetValue}{\param{const wxVariant\& }{variant}, \param{const wxDataViewItem\& }{item}, \param{unsigned int }{col}}
223
224This gets called in order to set a value in the data model.
225The most common scenario is that the wxDataViewCtrl calls
226this method after the user changed some data in the view.
227Afterwards \helpref{ValueChanged}{wxdataviewmodelvaluechanged}
228has to be called!
229
230\membersection{wxDataViewModel::ValueChanged}\label{wxdataviewmodelvaluechanged}
231
232\func{virtual bool}{ValueChanged}{\param{const wxDataViewItem\& }{item}, \param{unsigned int }{col}}
233
234Call this to inform this model that a value in the model has
235been changed. This is also called from wxDataViewCtrl's
236internal editing code, e.g. when editing a text field
237in the control.
238
239This will eventually emit a wxEVT\_DATAVIEW\_ITEM\_VALUE\_CHANGED
240event to the user.
241