Use symbolic constants for list model columns in dataview sample.
Using Col_EditableText, Col_IconText and Col_TextWithAttr instead of 0, 1 and 2 makes the sample code a bit easier to read. Also use switch on the column value instead of nested ifs everywhere to give compiler a chance to warn us if we forget to update some function when a new column is added. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62587 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -188,6 +188,14 @@ private:
|
||||
class MyListModel: public wxDataViewVirtualListModel
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
Col_EditableText,
|
||||
Col_IconText,
|
||||
Col_TextWithAttr,
|
||||
Col_Max
|
||||
};
|
||||
|
||||
MyListModel();
|
||||
|
||||
// helper methods to change the model
|
||||
@@ -202,12 +210,12 @@ public:
|
||||
|
||||
virtual unsigned int GetColumnCount() const
|
||||
{
|
||||
return 3;
|
||||
return Col_Max;
|
||||
}
|
||||
|
||||
virtual wxString GetColumnType( unsigned int col ) const
|
||||
{
|
||||
if (col == 1)
|
||||
if (col == Col_IconText)
|
||||
return wxT("wxDataViewIconText");
|
||||
|
||||
return wxT("string");
|
||||
|
Reference in New Issue
Block a user