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