]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/dataviewmodel.tex
d5ea8cdd6344dcbefa71b7786b112d1fd92aeae0
[wxWidgets.git] / docs / latex / wx / dataviewmodel.tex
1
2 \section{\class{wxDataViewModel}}\label{wxdataviewmodel}
3
4 wxDataViewModel is the base class for all data model to be
5 displayed by a \helpref{wxDataViewCtrl}{wxdataviewctrl}.
6 Currently, this class has no functionality at all and the
7 only existing implementation of it is the
8 \helpref{wxDataViewListModel}{wxdataviewlistmodel}. The
9 plan is to move all functionality of wxDataViewListModel
10 and a to-be-written wxDataViewTreeModel into wxDataViewModel
11 and make wxDataViewListModel and wxDataViewTreeModel subsets
12 of the abstract wxDataViewModel.
13
14 \wxheading{Derived from}
15
16 \helpref{wxObject}{wxobject}
17
18 \wxheading{Include files}
19
20 <wx/dataview.h>
21
22 \membersection{wxDataViewModel::wxDataViewModel}\label{wxdataviewmodelwxdataviewmodel}
23
24 \func{}{wxDataViewModel}{\void}
25
26 Constructor.
27
28 \membersection{wxDataViewModel::\destruct{wxDataViewModel}}\label{wxdataviewmodeldtor}
29
30 \func{}{\destruct{wxDataViewModel}}{\void}
31
32 Destructor.
33
34 \section{\class{wxDataViewListModel}}\label{wxdataviewlistmodel}
35
36 wxDataViewListModel is currently the only existing variant
37 of a \helpref{wxDataViewModel}{wxdataviewmodel}. It allows
38 to define a table like data model to be displayed by a
39 \helpref{wxDataViewCtrl}{wxdataviewctrl}. You need to derive
40 from this class to define your own data model.
41
42 You need to override \helpref{GetNumberOfRows}{wxdataviewlistmodelgetnumberofrows},
43 \helpref{GetNumberOfCols}{wxdataviewlistmodelgetnumberofcols},
44 \helpref{GetColType}{wxdataviewlistmodelgetcoltype} and
45 \helpref{GetValue}{wxdataviewlistmodelgetvalue} in order to
46 define the data model (which acts as an interface between
47 your actual data and the wxDataViewCtrl).
48
49 wxDataViewModel and this class (as indeed the entire wxDataViewCtrl
50 code) is using \helpref{wxVariant}{wxvariant} to store data and
51 its type in a generic way. wxVariant can be extended to contain
52 almost any data without changes to the original class.
53
54 This class maintains a list of
55 \helpref{wxDataListViewListModelNotifier}{wxdataviewlistmodelnotifier}
56 which link this class to the specific implementations on the
57 supported platforms so that e.g. calling
58 \helpref{ValueChanged}{wxdataviewlistmodelvaluechanged}
59 on this model will just call
60 \helpref{wxDataListViewListModelNotifier::ValueChanged}{wxdataviewlistmodelnotifiervaluechanged}
61 for each notifier that has been added. This is used both for
62 informing the native controls to redraw themselves and for informing
63 e.g. the \helpref{wxDataViewSortedListModel}{wxdataviewsortedlistmodel}
64 to resort itself. You can also add your own notifier in order
65 to get informed about any changes to the data in the list model.
66
67 Additionally, this class maintains a list of all
68 \helpref{wxDataViewColumns}{wxdataviewcolumn} which
69 display a certain column of this list model. This is
70 mostly used internally.
71
72 \wxheading{Derived from}
73
74 \helpref{wxDataViewModel}{wxdataviewmodel}\\
75 \helpref{wxObject}{wxobject}
76
77 \wxheading{Include files}
78
79 <wx/dataview.h>
80
81
82 \membersection{wxDataViewListModel::wxDataViewListModel}\label{wxdataviewlistmodelwxdataviewlistmodel}
83
84 \func{}{wxDataViewListModel}{\void}
85
86 Constructor.
87
88 \membersection{wxDataViewListModel::\destruct{wxDataViewListModel}}\label{wxdataviewlistmodeldtor}
89
90 \func{}{\destruct{wxDataViewListModel}}{\void}
91
92 Destructor.
93
94 \membersection{wxDataViewListModel::AddNotifier}\label{wxdataviewlistmodeladdnotifier}
95
96 \func{void}{AddNotifier}{\param{wxDataViewListModelNotifier* }{notifier}}
97
98 Adds {\it notifier} to the internal list of notifers.
99
100 See also \helpref{RemoveNotifier}{wxdataviewlistmodelremovenotifier}.
101
102 \membersection{wxDataViewListModel::AddViewingColumn}\label{wxdataviewlistmodeladdviewingcolumn}
103
104 \func{void}{AddViewingColumn}{\param{wxDataViewColumn* }{view\_column}, \param{unsigned int }{model\_column}}
105
106 Used internally. Used for maintaining a list of
107 \helpref{wxDataViewColumn}{wxdataviewcolumn} that
108 display a certain column of this model.
109
110 \membersection{wxDataViewListModel::Cleared}\label{wxdataviewlistmodelcleared}
111
112 \func{bool}{virtual Cleared}{\void}
113
114 Call this if all data in your model has been cleared.
115
116 \membersection{wxDataViewListModel::GetColType}\label{wxdataviewlistmodelgetcoltype}
117
118 \func{virtual wxString}{GetColType}{\param{unsigned int }{col}}
119
120 Override this to indicate what type of data is stored in the
121 column specified by {\it col}. This should return a string
122 indicating the type of data as reported by \helpref{wxVariant}{wxvariant}.
123
124 \membersection{wxDataViewListModel::GetNumberOfCols}\label{wxdataviewlistmodelgetnumberofcols}
125
126 \func{virtual unsigned int}{GetNumberOfCols}{\void}
127
128 Override this to indicate, how many columns the list
129 model has.
130
131 \membersection{wxDataViewListModel::GetNumberOfRows}\label{wxdataviewlistmodelgetnumberofrows}
132
133 \func{virtual unsigned int}{GetNumberOfRows}{\void}
134
135 Override this to indicate, how many rows the list
136 model has.
137
138 \membersection{wxDataViewListModel::GetValue}\label{wxdataviewlistmodelgetvalue}
139
140 \func{virtual void}{GetValue}{\param{wxVariant\& }{variant}, \param{unsigned int }{col}, \param{unsigned int }{row}}
141
142 Override this to indicate the value of a given value
143 in the list model. A \helpref{wxVariant}{wxvariant}
144 is used to store the data.
145
146 \membersection{wxDataViewListModel::RemoveNotifier}\label{wxdataviewlistmodelremovenotifier}
147
148 \func{void}{RemoveNotifier}{\param{wxDataViewListModelNotifier* }{notifier}}
149
150 Removes the notifier from the list of notifiers.
151
152 See also \helpref{AddNotifier}{wxdataviewlistmodeladdnotifier}.
153
154 \membersection{wxDataViewListModel::RemoveViewingColumn}\label{wxdataviewlistmodelremoveviewingcolumn}
155
156 \func{void}{RemoveViewingColumn}{\param{wxDataViewColumn* }{column}}
157
158 Used internally. Used for maintaining a list of
159 \helpref{wxDataViewColumn}{wxdataviewcolumn} that
160 display a certain column of this model.
161
162 \membersection{wxDataViewListModel::RowAppended}\label{wxdataviewlistmodelrowappended}
163
164 \func{virtual bool}{RowAppended}{\void}
165
166 Call this if a row has been appended to the list model.
167
168 \membersection{wxDataViewListModel::RowChanged}\label{wxdataviewlistmodelrowchanged}
169
170 \func{virtual bool}{RowChanged}{\param{unsigned int }{row}}
171
172 Call this if the values of this row have been changed.
173
174 \membersection{wxDataViewListModel::RowDeleted}\label{wxdataviewlistmodelrowdeleted}
175
176 \func{virtual bool}{RowDeleted}{\param{unsigned int }{row}}
177
178 Call this if this row has been deleted.
179
180 \membersection{wxDataViewListModel::RowInserted}\label{wxdataviewlistmodelrowinserted}
181
182 \func{virtual bool}{RowInserted}{\param{unsigned int }{before}}
183
184 Call this if a row has been inserted.
185
186 \membersection{wxDataViewListModel::RowPrepended}\label{wxdataviewlistmodelrowprepended}
187
188 \func{virtual bool}{RowPrepended}{\void}
189
190 Call this if a row has been prepended.
191
192 \membersection{wxDataViewListModel::RowsReordered}\label{wxdataviewlistmodelrowsreordered}
193
194 \func{virtual bool}{RowsReordered}{\param{unsigned int* }{new\_order}}
195
196 Call this if the rows have been reorderd.
197
198 \membersection{wxDataViewListModel::SetValue}\label{wxdataviewlistmodelsetvalue}
199
200 \func{virtual bool}{SetValue}{\param{wxVariant\& }{variant}, \param{unsigned int }{col}, \param{unsigned int }{row}}
201
202 This method gets called by e.g. the wxDataViewCtrl class if a
203 value has been changed through its graphical interface. You
204 need to override this method in order to update the data in
205 the underlying data structur. Afterwards,
206 \helpref{ValueChanged}{wxdataviewlistmodelvaluechanged} is called.
207
208
209 \membersection{wxDataViewListModel::ValueChanged}\label{wxdataviewlistmodelvaluechanged}
210
211 \func{virtual bool}{ValueChanged}{\param{unsigned int }{col}, \param{unsigned int }{row}}
212
213 Call this if a value in the model has been changed.
214
215
216 \section{\class{wxDataViewSortedListModel}}\label{wxdataviewsortedlistmodel}
217
218 This class is used for sorting data. It does not contain any
219 data itself. Rather, it provides a sorted interface for
220 another list model.
221
222 Currently, the sorting algorithm isn't thread safe. This needs
223 to be fixed.
224
225 \wxheading{Derived from}
226
227 \helpref{wxDataViewListModel}{wxdataviewlistmodel}\\
228 \helpref{wxDataViewModel}{wxdataviewmodel}\\
229 \helpref{wxObject}{wxobject}
230
231 \wxheading{Include files}
232
233 <wx/dataview.h>
234
235 \membersection{wxDataViewSortedListModel::wxDataViewSortedListModel}\label{wxdataviewsortedlistmodelwxdataviewsortedlistmodel}
236
237 \func{}{wxDataViewSortedListModel}{\param{wxDataViewListModel* }{child}}
238
239 Constructor. {\it child} is the child data model the data of
240 which this model is supposed to present in a sorted way.
241
242 \membersection{wxDataViewSortedListModel::\destruct{wxDataViewSortedListModel}}\label{wxdataviewsortedlistmodeldtor}
243
244 \func{}{\destruct{wxDataViewSortedListModel}}{\void}
245
246 Destructor.
247
248 \membersection{wxDataViewSortedListModel::GetAscending}\label{wxdataviewsortedlistmodelgetascending}
249
250 \func{bool}{GetAscending}{\void}
251
252 Returns true if the data is sorted in ascending order.
253
254 \membersection{wxDataViewSortedListModel::Resort}\label{wxdataviewsortedlistmodelresort}
255
256 \func{void}{Resort}{\void}
257
258 Tell the model to resort its data.
259
260 \membersection{wxDataViewSortedListModel::SetAscending}\label{wxdataviewsortedlistmodelsetascending}
261
262 \func{void}{SetAscending}{\param{bool }{ascending}}
263
264 Set the sort order of the data.
265