]>
Commit | Line | Data |
---|---|---|
b6b9d556 RR |
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}. | |
1ab4aff2 RR |
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 | |
aa0576fe RR |
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 | ||
1ab4aff2 | 22 | wxDataViewModel (as indeed the entire wxDataViewCtrl |
b19add95 RR |
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 | ||
1ab4aff2 RR |
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 | ||
b6b9d556 | 43 | This class maintains a list of |
1ab4aff2 | 44 | \helpref{wxDataViewModelNotifier}{wxdataviewmodelnotifier} |
b6b9d556 | 45 | which link this class to the specific implementations on the |
b19add95 | 46 | supported platforms so that e.g. calling |
1ab4aff2 | 47 | \helpref{ValueChanged}{wxdataviewmodelvaluechanged} |
b6b9d556 | 48 | on this model will just call |
1ab4aff2 RR |
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. | |
b6b9d556 RR |
59 | |
60 | \wxheading{Derived from} | |
61 | ||
7376079d | 62 | \helpref{wxObjectRefData}{wxobjectrefdata} |
b6b9d556 RR |
63 | |
64 | \wxheading{Include files} | |
65 | ||
66 | <wx/dataview.h> | |
67 | ||
1ab4aff2 | 68 | \wxheading{Library} |
b6b9d556 | 69 | |
1ab4aff2 | 70 | \helpref{wxAdv}{librarieslist} |
1be9182d | 71 | |
809e21b5 FM |
72 | |
73 | ||
74 | \latexignore{\rtfignore{\wxheading{Members}}} | |
75 | ||
1ab4aff2 | 76 | \membersection{wxDataViewModel::wxDataViewModel}\label{wxdataviewmodelwxdataviewmodel} |
1be9182d | 77 | |
1ab4aff2 | 78 | \func{}{wxDataViewModel}{\void} |
b6b9d556 | 79 | |
1ab4aff2 | 80 | Constructor. |
b6b9d556 | 81 | |
1ab4aff2 | 82 | \membersection{wxDataViewModel::\destruct{wxDataViewModel}}\label{wxdataviewmodeldtor} |
b6b9d556 | 83 | |
1ab4aff2 | 84 | \func{}{\destruct{wxDataViewModel}}{\void} |
b6b9d556 | 85 | |
1ab4aff2 | 86 | Destructor. This should not be called directly. Use DecRef() instead. |
b6b9d556 | 87 | |
b6b9d556 | 88 | |
1ab4aff2 | 89 | \membersection{wxDataViewModel::AddNotifier}\label{wxdataviewmodeladdnotifier} |
b6b9d556 | 90 | |
1ab4aff2 | 91 | \func{void}{AddNotifier}{\param{wxDataViewModelNotifier* }{notifier}} |
b6b9d556 | 92 | |
1ab4aff2 RR |
93 | Adds a \helpref{wxDataViewModelNotifier}{wxdataviewlistmodelnotifier} |
94 | to the model. | |
b6b9d556 | 95 | |
1ab4aff2 | 96 | \membersection{wxDataViewModel::Cleared}\label{wxdataviewmodelcleared} |
b6b9d556 | 97 | |
1ab4aff2 | 98 | \func{bool}{Cleared}{\void} |
b6b9d556 | 99 | |
1ab4aff2 | 100 | Called to inform the model that all data has been deleted. |
b6b9d556 | 101 | |
1ab4aff2 | 102 | \membersection{wxDataViewModel::Compare}\label{wxdataviewmodelcompare} |
b6b9d556 | 103 | |
1ab4aff2 | 104 | \func{int}{Compare}{\param{const wxDataViewItem\& }{item1}, \param{const wxDataViewItem\& }{item2}, \param{unsigned int }{column}, \param{bool }{ascending}} |
b6b9d556 | 105 | |
1ab4aff2 RR |
106 | The compare function to be used by control. The default compare function |
107 | sorts by container and other items separately and in ascending order. | |
108 | Override this for a different sorting behaviour. | |
b6b9d556 | 109 | |
1ab4aff2 | 110 | \membersection{wxDataViewModel::GetColumnCount}\label{wxdataviewmodelgetcolumncount} |
b6b9d556 | 111 | |
1ab4aff2 | 112 | \constfunc{unsigned int}{GetColumnCount}{\void} |
b6b9d556 | 113 | |
1ab4aff2 | 114 | Override this to indicate the number of columns in the model. |
b6b9d556 | 115 | |
1ab4aff2 | 116 | \membersection{wxDataViewModel::GetColumnType}\label{wxdataviewmodelgetcolumntype} |
b6b9d556 | 117 | |
1ab4aff2 | 118 | \constfunc{wxString}{GetColumnType}{\param{unsigned int }{col}} |
b6b9d556 | 119 | |
1ab4aff2 RR |
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}. | |
b6b9d556 | 123 | |
1ab4aff2 | 124 | \membersection{wxDataViewModel::GetFirstChild}\label{wxdataviewmodelgetfirstchild} |
b6b9d556 | 125 | |
1ab4aff2 | 126 | \constfunc{wxDataViewItem}{GetFirstChild}{\param{const wxDataViewItem\& }{parent}} |
b6b9d556 | 127 | |
1ab4aff2 | 128 | To be removed. |
b6b9d556 | 129 | |
1ab4aff2 | 130 | \membersection{wxDataViewModel::GetNextSibling}\label{wxdataviewmodelgetnextsibling} |
b6b9d556 | 131 | |
1ab4aff2 | 132 | \constfunc{wxDataViewItem}{GetNextSibling}{\param{const wxDataViewItem\& }{item}} |
b6b9d556 | 133 | |
1ab4aff2 | 134 | To be removed. |
b6b9d556 | 135 | |
1ab4aff2 | 136 | \membersection{wxDataViewModel::GetParent}\label{wxdataviewmodelgetparent} |
b6b9d556 | 137 | |
1ab4aff2 | 138 | \constfunc{wxDataViewItem}{GetParent}{\param{const wxDataViewItem\& }{item}} |
b6b9d556 | 139 | |
1ab4aff2 RR |
140 | Override this to indicate which wxDataViewItem representing the parent |
141 | of {\it item} or an invalid wxDataViewItem if {\it item} is the root item. | |
b6b9d556 | 142 | |
1ab4aff2 | 143 | \membersection{wxDataViewModel::GetValue}\label{wxdataviewmodelgetvalue} |
b6b9d556 | 144 | |
1ab4aff2 | 145 | \constfunc{void}{GetValue}{\param{wxVariant\& }{variant}, \param{const wxDataViewItem\& }{item}, \param{unsigned int }{col}} |
b6b9d556 | 146 | |
1ab4aff2 RR |
147 | Override this to indicate the value of {\it item} |
148 | A \helpref{wxVariant}{wxvariant} is used to store the data. | |
b6b9d556 | 149 | |
1ab4aff2 | 150 | \membersection{wxDataViewModel::IsContainer}\label{wxdataviewmodeliscontainer} |
b6b9d556 | 151 | |
1ab4aff2 | 152 | \constfunc{bool}{IsContainer}{\param{const wxDataViewItem\& }{item}} |
b6b9d556 | 153 | |
1ab4aff2 RR |
154 | Override this to indicate of {\it item} is a container, i.e. if |
155 | it can have child items. | |
b6b9d556 | 156 | |
1ab4aff2 | 157 | \membersection{wxDataViewModel::ItemAdded}\label{wxdataviewmodelitemadded} |
b6b9d556 | 158 | |
1ab4aff2 | 159 | \func{bool}{ItemAdded}{\param{const wxDataViewItem\& }{parent}, \param{const wxDataViewItem\& }{item}} |
b6b9d556 | 160 | |
1ab4aff2 RR |
161 | Call this to inform the model that an item has been added |
162 | to the data. | |
b6b9d556 | 163 | |
1ab4aff2 | 164 | \membersection{wxDataViewModel::ItemChanged}\label{wxdataviewmodelitemchanged} |
b6b9d556 | 165 | |
1ab4aff2 | 166 | \func{bool}{ItemChanged}{\param{const wxDataViewItem\& }{item}} |
b6b9d556 | 167 | |
1ab4aff2 | 168 | Call this to inform the model that an item has changed. |
b6b9d556 | 169 | |
1ab4aff2 | 170 | \membersection{wxDataViewModel::ItemDeleted}\label{wxdataviewmodelitemdeleted} |
b6b9d556 | 171 | |
1ab4aff2 | 172 | \func{bool}{ItemDeleted}{\param{const wxDataViewItem\& }{parent}, \param{const wxDataViewItem\& }{item}} |
b6b9d556 | 173 | |
1ab4aff2 | 174 | Call this to inform the model that an item has been deleted. |
b6b9d556 | 175 | |
1ab4aff2 | 176 | \membersection{wxDataViewModel::RemoveNotifier}\label{wxdataviewmodelremovenotifier} |
b6b9d556 | 177 | |
1ab4aff2 | 178 | \func{void}{RemoveNotifier}{\param{wxDataViewModelNotifier* }{notifier}} |
b6b9d556 | 179 | |
1ab4aff2 | 180 | Remove the {\it notifier} from the list of notifiers. |
b6b9d556 | 181 | |
1ab4aff2 | 182 | \membersection{wxDataViewModel::Resort}\label{wxdataviewmodelresort} |
b6b9d556 | 183 | |
1ab4aff2 | 184 | \func{void}{Resort}{\void} |
b6b9d556 | 185 | |
1ab4aff2 RR |
186 | Call this to initiate a resort after the sort function has |
187 | been changed. | |
b6b9d556 | 188 | |
1ab4aff2 | 189 | \membersection{wxDataViewModel::SetValue}\label{wxdataviewmodelsetvalue} |
b6b9d556 | 190 | |
1ab4aff2 | 191 | \func{bool}{SetValue}{\param{const wxVariant\& }{variant}, \param{const wxDataViewItem\& }{item}, \param{unsigned int }{col}} |
b6b9d556 | 192 | |
1ab4aff2 RR |
193 | This gets called in order to set a value in the data model. |
194 | The most common scenario is that the wxDataViewCtrl calls | |
195 | this method after the user changed some data in the view. | |
196 | Afterwards \helpref{ValueChanged}{wxdataviewmodelvaluechanged} | |
197 | has to be called! | |
b6b9d556 | 198 | |
1ab4aff2 | 199 | \membersection{wxDataViewModel::ValueChanged}\label{wxdataviewmodelvaluechanged} |
b6b9d556 | 200 | |
1ab4aff2 | 201 | \func{bool}{ValueChanged}{\param{const wxDataViewItem\& }{item}, \param{unsigned int }{col}} |
b6b9d556 | 202 | |
1ab4aff2 RR |
203 | Call this to inform this model that a value in |
204 | the model has been changed. | |
b6b9d556 | 205 |