From: Robert Roebling Date: Fri, 16 Jan 2009 15:44:12 +0000 (+0000) Subject: Document wxDataViewListCtrl, minor corrections X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/832df1710864e21007e9f1457b11b3d7d752c6bc Document wxDataViewListCtrl, minor corrections git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58141 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/dataview.h b/include/wx/dataview.h index 5437a4dc0c..c9b931d44c 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -1021,15 +1021,20 @@ public: { GetStore()->DeleteAllItems(); } void SetValue( const wxVariant &value, unsigned int row, unsigned int col ) - { GetStore()->SetValueByRow( value, row, col ); } + { GetStore()->SetValueByRow( value, row, col ); + GetStore()->RowValueChanged( row, col); } + void GetValue( wxVariant &value, unsigned int row, unsigned int col ) + { GetStore()->GetValueByRow( value, row, col ); } void SetTextValue( const wxString &value, unsigned int row, unsigned int col ) - { GetStore()->SetValueByRow( value, row, col ); } + { GetStore()->SetValueByRow( value, row, col ); + GetStore()->RowValueChanged( row, col); } wxString GetTextValue( unsigned int row, unsigned int col ) const { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetString(); } void SetToggleValue( bool value, unsigned int row, unsigned int col ) - { GetStore()->SetValueByRow( value, row, col ); } + { GetStore()->SetValueByRow( value, row, col ); + GetStore()->RowValueChanged( row, col); } bool GetToggleValue( unsigned int row, unsigned int col ) const { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetBool(); } diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index 9fd9063146..37b6f17c00 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -485,8 +485,12 @@ public: wxDataViewCtrl is a control to display data either in a tree like fashion or in a tabular form or both. + If you only need to display a simple tree structure with an API more like the older wxTreeCtrl class, then the specialized wxDataViewTreeCtrl can be used. + Likewise, if you only want to display simple table structure you can use + the specialized wxDataViewListCtrl class. Both wxDataViewTreeCtrl and + wxDataViewListCtrl can be used without defining your own wxDataViewModel. A wxDataViewItem is used to represent a (visible) item in the control. @@ -1477,6 +1481,170 @@ public: +/** + @class wxDataViewListCtrl + + This class is a wxDataViewCtrl which internally uses a wxDataViewListStore + and forwards most of its API to that class. + + The purpose of this class is to offer a simple way to display and + edit a small table of data without having to write your own wxDataViewModel. + + @library{wxadv} + @category{ctrl,dvc} +*/ + +class wxDataViewListCtrl: public wxDataViewCtrl +{ + /** + Default ctor. + */ + wxDataViewListCtrl(); + + /** + Constructor. Calls Create(). + */ + wxDataViewListCtrl( wxWindow *parent, wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, + const wxValidator& validator = wxDefaultValidator ); + + /** + Destructor. Deletes the image list if any. + */ + ~wxDataViewListCtrl(); + + /** + Creates the control and a wxDataViewListStore as its internal model. + */ + bool Create( wxWindow *parent, wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, + const wxValidator& validator = wxDefaultValidator ); + + //@{ + /** + Returns the store. + */ + wxDataViewListStore *GetStore(); + const wxDataViewListStore *GetStore() const; + //@} + + /** + Appends a column to the control and additonally appends a + column to the store with the type @a varianttype. + */ + void AppendCol( wxDataViewColumn *column, const wxString &varianttype ); + + /** + Prepends a column to the control and additonally prepends a + column to the store with the type @a varianttype. + */ + void PrependCol( wxDataViewColumn *column, const wxString &varianttype ); + + /** + Inserts a column to the control and additonally inserts a + column to the store with the type @a varianttype. + */ + void InsertCol( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype ); + + /** + Inserts a text column to the control and the store. + */ + wxDataViewColumn *AppendTextCol( const wxString &label, + wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, + int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); + + /** + Inserts a toggle column to the control and the store. + */ + wxDataViewColumn *AppendToggleCol( const wxString &label, + wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, + int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); + + /** + Inserts a progress column to the control and the store. + */ + wxDataViewColumn *AppendProgressCol( const wxString &label, + wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, + int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); + + /** + Inserts a icon and text column to the control and the store. + */ + wxDataViewColumn *AppendIconTextCol( const wxString &label, + wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, + int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE ); + + /** + Appends an item (=row) to the control and store. + */ + void AppendItem( const wxVector &values, wxClientData *data = NULL ); + + /** + Prepends an item (=row) to the control and store. + */ + void PrependItem( const wxVector &values, wxClientData *data = NULL ); + + /** + Inserts an item (=row) to the control and store. + */ + void InsertItem( unsigned int row, const wxVector &values, wxClientData *data = NULL ); + + /** + Delete the row at position @a row. + */ + void DeleteItem( unsigned row ); + + /** + Delete all items (= all rows). + */ + void DeleteAllItems(); + + /** + Sets the value in the store and update the control. + */ + void SetValue( const wxVariant &value, unsigned int row, unsigned int col ); + + /** + Returns the value from the store. + */ + void GetValue( wxVariant &value, unsigned int row, unsigned int col ); + + /** + Sets the value in the store and update the control. + + This method assumes that the a string is stored in respective + column. + */ + void SetTextValue( const wxString &value, unsigned int row, unsigned int col ); + + /** + Returns the value from the store. + + This method assumes that the a string is stored in respective + column. + */ + wxString GetTextValue( unsigned int row, unsigned int col ) const; + + /** + Sets the value in the store and update the control. + + This method assumes that the a boolean value is stored in + respective column. + */ + void SetToggleValue( bool value, unsigned int row, unsigned int col ); + + /** + Returns the value from the store. + + This method assumes that the a boolean value is stored in + respective column. + */ + bool GetToggleValue( unsigned int row, unsigned int col ) const; +}; + + /** @class wxDataViewTreeCtrl