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