📄 dataviewmodel.tex
字号:
\section{\class{wxDataViewModel}}\label{wxdataviewmodel}wxDataViewModel is the base class for all data model to bedisplayed by a \helpref{wxDataViewCtrl}{wxdataviewctrl}. Currently, this class has no functionality at all and theonly existing implementation of it is the \helpref{wxDataViewListModel}{wxdataviewlistmodel}. Theplan is to move all functionality of wxDataViewListModeland a to-be-written wxDataViewTreeModel into wxDataViewModeland make wxDataViewListModel and wxDataViewTreeModel subsetsof the abstract wxDataViewModel.\wxheading{Derived from}\helpref{wxObject}{wxobject}\wxheading{Include files}<wx/dataview.h>\membersection{wxDataViewModel::wxDataViewModel}\label{wxdataviewmodelwxdataviewmodel}\func{}{wxDataViewModel}{\void}Constructor.\membersection{wxDataViewModel::\destruct{wxDataViewModel}}\label{wxdataviewmodeldtor}\func{}{\destruct{wxDataViewModel}}{\void}Destructor.\section{\class{wxDataViewListModel}}\label{wxdataviewlistmodel}wxDataViewListModel is currently the only existing variantof a \helpref{wxDataViewModel}{wxdataviewmodel}. It allowsto define a table like data model to be displayed by a\helpref{wxDataViewCtrl}{wxdataviewctrl}. You need to derivefrom this class to define your own data model.You need to override \helpref{GetNumberOfRows}{wxdataviewlistmodelgetnumberofrows},\helpref{GetNumberOfCols}{wxdataviewlistmodelgetnumberofcols},\helpref{GetColType}{wxdataviewlistmodelgetcoltype} and\helpref{GetValue}{wxdataviewlistmodelgetvalue} in order todefine the data model (which acts as an interface between your actual data and the wxDataViewCtrl). Since you willusually also allow the wxDataViewCtrl to change your datathrough its graphical interface, you will also have to override\helpref{SetValue}{wxdataviewlistmodelsetvalue} which thewxDataViewCtrl will call when a change to some data has beencommited.The data that is presented through this data model is expectedto change at run-time. You need to inform the data model thata change happens. Depending on what happened you need to callone of the following methods: \helpref{ValueChanged}{wxdataviewlistmodelvaluechanged},\helpref{RowChanged}{wxdataviewlistmodelrowchanged},\helpref{RowAppended}{wxdataviewlistmodelrowappended},\helpref{RowPrepended}{wxdataviewlistmodelrowprepended},\helpref{RowInserted}{wxdataviewlistmodelrowinserted},\helpref{RowDeleted}{wxdataviewlistmodelrowdeleted},\helpref{RowsReordered}{wxdataviewlistmodelrowsreordered} or\helpref{RowsCleared}{wxdataviewlistmodelcleared}.wxDataViewModel and this class (as indeed the entire wxDataViewCtrlcode) is using \helpref{wxVariant}{wxvariant} to store data andits type in a generic way. wxVariant can be extended to containalmost any data without changes to the original class.This class maintains a list of \helpref{wxDataListViewListModelNotifier}{wxdataviewlistmodelnotifier}which link this class to the specific implementations on thesupported platforms so that e.g. calling \helpref{ValueChanged}{wxdataviewlistmodelvaluechanged}on this model will just call \helpref{wxDataListViewListModelNotifier::ValueChanged}{wxdataviewlistmodelnotifiervaluechanged}for each notifier that has been added. This is used both forinforming the native controls to redraw themselves and for informinge.g. the \helpref{wxDataViewSortedListModel}{wxdataviewsortedlistmodel}to resort itself. You can also add your own notifier in orderto get informed about any changes to the data in the list model.Additionally, this class maintains a list of all \helpref{wxDataViewColumns}{wxdataviewcolumn} whichdisplay a certain column of this list model. This ismostly used internally.\wxheading{Derived from}\helpref{wxDataViewModel}{wxdataviewmodel}\\\helpref{wxObject}{wxobject}\wxheading{Include files}<wx/dataview.h>\membersection{wxDataViewListModel::wxDataViewListModel}\label{wxdataviewlistmodelwxdataviewlistmodel}\func{}{wxDataViewListModel}{\void}Constructor.\membersection{wxDataViewListModel::\destruct{wxDataViewListModel}}\label{wxdataviewlistmodeldtor}\func{}{\destruct{wxDataViewListModel}}{\void}Destructor.\membersection{wxDataViewListModel::AddNotifier}\label{wxdataviewlistmodeladdnotifier}\func{void}{AddNotifier}{\param{wxDataViewListModelNotifier* }{notifier}}Adds {\it notifier} to the internal list of notifers.See also \helpref{RemoveNotifier}{wxdataviewlistmodelremovenotifier}.\membersection{wxDataViewListModel::AddViewingColumn}\label{wxdataviewlistmodeladdviewingcolumn}\func{void}{AddViewingColumn}{\param{wxDataViewColumn* }{view\_column}, \param{unsigned int }{model\_column}}Used internally. Used for maintaining a list of\helpref{wxDataViewColumn}{wxdataviewcolumn} thatdisplay a certain column of this model.\membersection{wxDataViewListModel::Cleared}\label{wxdataviewlistmodelcleared}\func{bool}{virtual Cleared}{\void}Call this if all data in your model has been cleared.\membersection{wxDataViewListModel::GetColType}\label{wxdataviewlistmodelgetcoltype}\func{virtual wxString}{GetColType}{\param{unsigned int }{col}}Override this to indicate what type of data is stored in thecolumn specified by {\it col}. This should return a stringindicating the type of data as reported by \helpref{wxVariant}{wxvariant}.\membersection{wxDataViewListModel::GetNumberOfCols}\label{wxdataviewlistmodelgetnumberofcols}\func{virtual unsigned int}{GetNumberOfCols}{\void}Override this to indicate, how many columns the listmodel has.\membersection{wxDataViewListModel::GetNumberOfRows}\label{wxdataviewlistmodelgetnumberofrows}\func{virtual unsigned int}{GetNumberOfRows}{\void}Override this to indicate, how many rows the listmodel has.\membersection{wxDataViewListModel::GetValue}\label{wxdataviewlistmodelgetvalue}\func{virtual void}{GetValue}{\param{wxVariant\& }{variant}, \param{unsigned int }{col}, \param{unsigned int }{row}}Override this to indicate the value of a given valuein the list model. A \helpref{wxVariant}{wxvariant}is used to store the data.\membersection{wxDataViewListModel::RemoveNotifier}\label{wxdataviewlistmodelremovenotifier}\func{void}{RemoveNotifier}{\param{wxDataViewListModelNotifier* }{notifier}}Removes the notifier from the list of notifiers.See also \helpref{AddNotifier}{wxdataviewlistmodeladdnotifier}.\membersection{wxDataViewListModel::RemoveViewingColumn}\label{wxdataviewlistmodelremoveviewingcolumn}\func{void}{RemoveViewingColumn}{\param{wxDataViewColumn* }{column}}Used internally. Used for maintaining a list of\helpref{wxDataViewColumn}{wxdataviewcolumn} thatdisplay a certain column of this model.\membersection{wxDataViewListModel::RowAppended}\label{wxdataviewlistmodelrowappended}\func{virtual bool}{RowAppended}{\void}Call this if a row has been appended to the list model.\membersection{wxDataViewListModel::RowChanged}\label{wxdataviewlistmodelrowchanged}\func{virtual bool}{RowChanged}{\param{unsigned int }{row}}Call this if the values of this row have been changed.\membersection{wxDataViewListModel::RowDeleted}\label{wxdataviewlistmodelrowdeleted}\func{virtual bool}{RowDeleted}{\param{unsigned int }{row}}Call this if this row has been deleted.\membersection{wxDataViewListModel::RowInserted}\label{wxdataviewlistmodelrowinserted}\func{virtual bool}{RowInserted}{\param{unsigned int }{before}}Call this if a row has been inserted.\membersection{wxDataViewListModel::RowPrepended}\label{wxdataviewlistmodelrowprepended}\func{virtual bool}{RowPrepended}{\void}Call this if a row has been prepended.\membersection{wxDataViewListModel::RowsReordered}\label{wxdataviewlistmodelrowsreordered}\func{virtual bool}{RowsReordered}{\param{unsigned int* }{new\_order}}Call this if the rows have been reorderd.\membersection{wxDataViewListModel::SetValue}\label{wxdataviewlistmodelsetvalue}\func{virtual bool}{SetValue}{\param{wxVariant\& }{variant}, \param{unsigned int }{col}, \param{unsigned int }{row}}This method gets called by e.g. the wxDataViewCtrl class if a value has been changed through its graphical interface. Youneed to override this method in order to update the data inthe underlying data structur. Afterwards, \helpref{ValueChanged}{wxdataviewlistmodelvaluechanged} is called.\membersection{wxDataViewListModel::ValueChanged}\label{wxdataviewlistmodelvaluechanged}\func{virtual bool}{ValueChanged}{\param{unsigned int }{col}, \param{unsigned int }{row}}Call this if a value in the model has been changed.\section{\class{wxDataViewSortedListModel}}\label{wxdataviewsortedlistmodel}This class is used for sorting data. It does not contain anydata itself. Rather, it provides a sorted interface for another list model.Currently, the sorting algorithm isn't thread safe. This needsto be fixed.\wxheading{Derived from}\helpref{wxDataViewListModel}{wxdataviewlistmodel}\\\helpref{wxDataViewModel}{wxdataviewmodel}\\\helpref{wxObject}{wxobject}\wxheading{Include files}<wx/dataview.h>\membersection{wxDataViewSortedListModel::wxDataViewSortedListModel}\label{wxdataviewsortedlistmodelwxdataviewsortedlistmodel}\func{}{wxDataViewSortedListModel}{\param{wxDataViewListModel* }{child}}Constructor. {\it child} is the child data model the data ofwhich this model is supposed to present in a sorted way.\membersection{wxDataViewSortedListModel::\destruct{wxDataViewSortedListModel}}\label{wxdataviewsortedlistmodeldtor}\func{}{\destruct{wxDataViewSortedListModel}}{\void}Destructor.\membersection{wxDataViewSortedListModel::GetAscending}\label{wxdataviewsortedlistmodelgetascending}\func{bool}{GetAscending}{\void}Returns true if the data is sorted in ascending order.\membersection{wxDataViewSortedListModel::Resort}\label{wxdataviewsortedlistmodelresort}\func{void}{Resort}{\void}Tell the model to resort its data.\membersection{wxDataViewSortedListModel::SetAscending}\label{wxdataviewsortedlistmodelsetascending}\func{void}{SetAscending}{\param{bool }{ascending}}Set the sort order of the data.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -