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