]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/dataviewmodel.tex
Added const and virtual in various places
[wxWidgets.git] / docs / latex / wx / dataviewmodel.tex
CommitLineData
b6b9d556
RR
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}.
1ab4aff2
RR
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},
74fe973b 11\helpref{GetChildren}{wxdataviewmodelgetchildren},
1ab4aff2
RR
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
aa0576fe
RR
17usually also allow the wxDataViewCtrl to change your data
18through its graphical interface, you will also have to override
61cec318 19\helpref{SetValue}{wxdataviewmodelsetvalue} which the
aa0576fe
RR
20wxDataViewCtrl will call when a change to some data has been
21commited.
22
1ab4aff2 23wxDataViewModel (as indeed the entire wxDataViewCtrl
b19add95
RR
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
1ab4aff2
RR
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
0bd26819
RR
42which the wxDataViewCtrl may use to sort the data either
43in conjunction with a column header or without (see
44\helpref{HasDefaultCompare}{wxdataviewmodelhasdefaultcompare}.
1ab4aff2 45
b6b9d556 46This class maintains a list of
1ab4aff2 47\helpref{wxDataViewModelNotifier}{wxdataviewmodelnotifier}
b6b9d556 48which link this class to the specific implementations on the
b19add95 49supported platforms so that e.g. calling
1ab4aff2 50\helpref{ValueChanged}{wxdataviewmodelvaluechanged}
b6b9d556 51on this model will just call
1ab4aff2
RR
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.
b6b9d556
RR
62
63\wxheading{Derived from}
64
7376079d 65\helpref{wxObjectRefData}{wxobjectrefdata}
b6b9d556
RR
66
67\wxheading{Include files}
68
69<wx/dataview.h>
70
1ab4aff2 71\wxheading{Library}
b6b9d556 72
1ab4aff2 73\helpref{wxAdv}{librarieslist}
1be9182d 74
809e21b5
FM
75
76
77\latexignore{\rtfignore{\wxheading{Members}}}
78
1ab4aff2 79\membersection{wxDataViewModel::wxDataViewModel}\label{wxdataviewmodelwxdataviewmodel}
1be9182d 80
1ab4aff2 81\func{}{wxDataViewModel}{\void}
b6b9d556 82
1ab4aff2 83Constructor.
b6b9d556 84
1ab4aff2 85\membersection{wxDataViewModel::\destruct{wxDataViewModel}}\label{wxdataviewmodeldtor}
b6b9d556 86
1ab4aff2 87\func{}{\destruct{wxDataViewModel}}{\void}
b6b9d556 88
1ab4aff2 89Destructor. This should not be called directly. Use DecRef() instead.
b6b9d556 90
b6b9d556 91
1ab4aff2 92\membersection{wxDataViewModel::AddNotifier}\label{wxdataviewmodeladdnotifier}
b6b9d556 93
1ab4aff2 94\func{void}{AddNotifier}{\param{wxDataViewModelNotifier* }{notifier}}
b6b9d556 95
61cec318 96Adds a \helpref{wxDataViewModelNotifier}{wxdataviewmodelnotifier}
1ab4aff2 97to the model.
b6b9d556 98
1ab4aff2 99\membersection{wxDataViewModel::Cleared}\label{wxdataviewmodelcleared}
b6b9d556 100
09711964 101\func{virtual bool}{Cleared}{\void}
b6b9d556 102
1ab4aff2 103Called to inform the model that all data has been deleted.
b6b9d556 104
1ab4aff2 105\membersection{wxDataViewModel::Compare}\label{wxdataviewmodelcompare}
b6b9d556 106
09711964 107\func{virtual int}{Compare}{\param{const wxDataViewItem\& }{item1}, \param{const wxDataViewItem\& }{item2}, \param{unsigned int }{column}, \param{bool }{ascending}}
b6b9d556 108
1ab4aff2
RR
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.
b6b9d556 112
0bd26819
RR
113See also \helpref{HasDefaultCompare}{wxdataviewmodelhasdefaultcompare}.
114
1ab4aff2 115\membersection{wxDataViewModel::GetColumnCount}\label{wxdataviewmodelgetcolumncount}
b6b9d556 116
09711964 117\constfunc{virtual unsigned int}{GetColumnCount}{\void}
b6b9d556 118
1ab4aff2 119Override this to indicate the number of columns in the model.
b6b9d556 120
1ab4aff2 121\membersection{wxDataViewModel::GetColumnType}\label{wxdataviewmodelgetcolumntype}
b6b9d556 122
09711964 123\constfunc{virtual wxString}{GetColumnType}{\param{unsigned int }{col}}
b6b9d556 124
1ab4aff2
RR
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}.
b6b9d556 128
a9768412 129\membersection{wxDataViewModel::GetChildren}\label{wxdataviewmodelgetchildren}
b6b9d556 130
09711964 131\constfunc{virtual unsigned int}{GetChildren}{\param{const wxDataViewItem\& }{item}, \param{wxDataViewItemArray\& }{children} }
b6b9d556 132
74fe973b
RR
133Override this so the control can query the child items of
134an item. Returns the number of items.
b6b9d556 135
1ab4aff2 136\membersection{wxDataViewModel::GetParent}\label{wxdataviewmodelgetparent}
b6b9d556 137
09711964 138\constfunc{virtual wxDataViewItem}{GetParent}{\param{const wxDataViewItem\& }{item}}
b6b9d556 139
1ab4aff2
RR
140Override this to indicate which wxDataViewItem representing the parent
141of {\it item} or an invalid wxDataViewItem if {\it item} is the root item.
b6b9d556 142
1ab4aff2 143\membersection{wxDataViewModel::GetValue}\label{wxdataviewmodelgetvalue}
b6b9d556 144
09711964 145\constfunc{virtual void}{GetValue}{\param{wxVariant\& }{variant}, \param{const wxDataViewItem\& }{item}, \param{unsigned int }{col}}
b6b9d556 146
1ab4aff2
RR
147Override this to indicate the value of {\it item}
148A \helpref{wxVariant}{wxvariant} is used to store the data.
b6b9d556 149
0bd26819
RR
150\membersection{wxDataViewModel::HasDefaultCompare}\label{wxdataviewmodelhasdefaultcompare}
151
09711964 152\constfunc{virtual bool}{HasDefaultCompare}{\void}
0bd26819
RR
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
1ab4aff2 162\membersection{wxDataViewModel::IsContainer}\label{wxdataviewmodeliscontainer}
b6b9d556 163
09711964 164\constfunc{virtual bool}{IsContainer}{\param{const wxDataViewItem\& }{item}}
b6b9d556 165
1ab4aff2
RR
166Override this to indicate of {\it item} is a container, i.e. if
167it can have child items.
b6b9d556 168
1ab4aff2 169\membersection{wxDataViewModel::ItemAdded}\label{wxdataviewmodelitemadded}
b6b9d556 170
09711964 171\func{virtual bool}{ItemAdded}{\param{const wxDataViewItem\& }{parent}, \param{const wxDataViewItem\& }{item}}
b6b9d556 172
1ab4aff2
RR
173Call this to inform the model that an item has been added
174to the data.
b6b9d556 175
1ab4aff2 176\membersection{wxDataViewModel::ItemChanged}\label{wxdataviewmodelitemchanged}
b6b9d556 177
09711964 178\func{virtual bool}{ItemChanged}{\param{const wxDataViewItem\& }{item}}
b6b9d556 179
1ab4aff2 180Call this to inform the model that an item has changed.
b6b9d556 181
1ab4aff2 182\membersection{wxDataViewModel::ItemDeleted}\label{wxdataviewmodelitemdeleted}
b6b9d556 183
09711964 184\func{virtual bool}{ItemDeleted}{\param{const wxDataViewItem\& }{parent}, \param{const wxDataViewItem\& }{item}}
b6b9d556 185
1ab4aff2 186Call this to inform the model that an item has been deleted.
b6b9d556 187
1ab4aff2 188\membersection{wxDataViewModel::RemoveNotifier}\label{wxdataviewmodelremovenotifier}
b6b9d556 189
1ab4aff2 190\func{void}{RemoveNotifier}{\param{wxDataViewModelNotifier* }{notifier}}
b6b9d556 191
1ab4aff2 192Remove the {\it notifier} from the list of notifiers.
b6b9d556 193
1ab4aff2 194\membersection{wxDataViewModel::Resort}\label{wxdataviewmodelresort}
b6b9d556 195
09711964 196\func{virtual void}{Resort}{\void}
b6b9d556 197
1ab4aff2
RR
198Call this to initiate a resort after the sort function has
199been changed.
b6b9d556 200
1ab4aff2 201\membersection{wxDataViewModel::SetValue}\label{wxdataviewmodelsetvalue}
b6b9d556 202
09711964 203\func{virtual bool}{SetValue}{\param{const wxVariant\& }{variant}, \param{const wxDataViewItem\& }{item}, \param{unsigned int }{col}}
b6b9d556 204
1ab4aff2
RR
205This gets called in order to set a value in the data model.
206The most common scenario is that the wxDataViewCtrl calls
207this method after the user changed some data in the view.
208Afterwards \helpref{ValueChanged}{wxdataviewmodelvaluechanged}
209has to be called!
b6b9d556 210
1ab4aff2 211\membersection{wxDataViewModel::ValueChanged}\label{wxdataviewmodelvaluechanged}
b6b9d556 212
09711964 213\func{virtual bool}{ValueChanged}{\param{const wxDataViewItem\& }{item}, \param{unsigned int }{col}}
b6b9d556 214
1ab4aff2
RR
215Call this to inform this model that a value in
216the model has been changed.
b6b9d556 217