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:
Vadim Zeitlin
2009-11-10 17:40:25 +00:00
parent f0368d28bf
commit 2746bccf23
3 changed files with 68 additions and 38 deletions

View File

@@ -545,10 +545,17 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
m_ctrl[1]->AssociateModel( m_list_model.get() );
// the various columns
m_ctrl[1]->AppendTextColumn("editable string", 0, wxDATAVIEW_CELL_EDITABLE);
m_ctrl[1]->AppendIconTextColumn("icon", 1, wxDATAVIEW_CELL_EDITABLE);
m_ctrl[1]->AppendTextColumn("editable string",
MyListModel::Col_EditableText,
wxDATAVIEW_CELL_EDITABLE);
m_ctrl[1]->AppendIconTextColumn("icon",
MyListModel::Col_IconText,
wxDATAVIEW_CELL_EDITABLE);
m_ctrl[1]->AppendColumn(
new wxDataViewColumn("attributes", new wxDataViewTextRenderer, 2 ));
new wxDataViewColumn("attributes",
new wxDataViewTextRenderer,
MyListModel::Col_TextWithAttr)
);
}
break;