Use symbolic page numbers in the dataview sample
Make the code a bit more readable. No real changes.
This commit is contained in:
@@ -164,8 +164,17 @@ private:
|
||||
wxNotebook* m_notebook;
|
||||
|
||||
// the controls stored in the various tabs of the main notebook:
|
||||
enum Page
|
||||
{
|
||||
Page_Music,
|
||||
Page_List,
|
||||
Page_ListStore,
|
||||
Page_TreeStore,
|
||||
Page_VarHeight,
|
||||
Page_Max
|
||||
};
|
||||
|
||||
wxDataViewCtrl* m_ctrl[5];
|
||||
wxDataViewCtrl* m_ctrl[Page_Max];
|
||||
|
||||
// the models associated with the first two DVC:
|
||||
|
||||
@@ -503,11 +512,8 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
||||
m_log = NULL;
|
||||
m_col = NULL;
|
||||
|
||||
m_ctrl[0] = NULL;
|
||||
m_ctrl[1] = NULL;
|
||||
m_ctrl[2] = NULL;
|
||||
m_ctrl[3] = NULL;
|
||||
m_ctrl[4] = NULL;
|
||||
for ( int page = 0; page < Page_Max; ++page )
|
||||
m_ctrl[page] = NULL;
|
||||
|
||||
m_eventFromProgram = false;
|
||||
|
||||
@@ -566,7 +572,7 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
||||
|
||||
wxPanel *firstPanel = new wxPanel( m_notebook, wxID_ANY );
|
||||
|
||||
BuildDataViewCtrl(firstPanel, 0); // sets m_ctrl[0]
|
||||
BuildDataViewCtrl(firstPanel, Page_Music);
|
||||
|
||||
const wxSizerFlags border = wxSizerFlags().DoubleBorder();
|
||||
|
||||
@@ -587,8 +593,8 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
||||
"Change ninth &title"), border);
|
||||
|
||||
wxSizer *firstPanelSz = new wxBoxSizer( wxVERTICAL );
|
||||
m_ctrl[0]->SetMinSize(wxSize(-1, 200));
|
||||
firstPanelSz->Add(m_ctrl[0], 1, wxGROW|wxALL, 5);
|
||||
m_ctrl[Page_Music]->SetMinSize(wxSize(-1, 200));
|
||||
firstPanelSz->Add(m_ctrl[Page_Music], 1, wxGROW|wxALL, 5);
|
||||
firstPanelSz->Add(
|
||||
new wxStaticText(firstPanel, wxID_ANY, "Most of the cells above are editable!"),
|
||||
0, wxGROW|wxALL, 5);
|
||||
@@ -602,7 +608,7 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
||||
|
||||
wxPanel *secondPanel = new wxPanel( m_notebook, wxID_ANY );
|
||||
|
||||
BuildDataViewCtrl(secondPanel, 1); // sets m_ctrl[1]
|
||||
BuildDataViewCtrl(secondPanel, Page_List);
|
||||
|
||||
wxBoxSizer *button_sizer2 = new wxBoxSizer( wxHORIZONTAL );
|
||||
button_sizer2->Add( new wxButton( secondPanel, ID_PREPEND_LIST,"Prepend"), 0, wxALL, 10 );
|
||||
@@ -619,7 +625,7 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
||||
wxSizerFlags().Centre().DoubleBorder());
|
||||
|
||||
wxSizer *secondPanelSz = new wxBoxSizer( wxVERTICAL );
|
||||
secondPanelSz->Add(m_ctrl[1], 1, wxGROW|wxALL, 5);
|
||||
secondPanelSz->Add(m_ctrl[Page_List], 1, wxGROW|wxALL, 5);
|
||||
secondPanelSz->Add(button_sizer2);
|
||||
secondPanelSz->Add(sortSizer);
|
||||
secondPanel->SetSizerAndFit(secondPanelSz);
|
||||
@@ -630,10 +636,10 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
||||
|
||||
wxPanel *thirdPanel = new wxPanel( m_notebook, wxID_ANY );
|
||||
|
||||
BuildDataViewCtrl(thirdPanel, 2); // sets m_ctrl[2]
|
||||
BuildDataViewCtrl(thirdPanel, Page_ListStore);
|
||||
|
||||
wxSizer *thirdPanelSz = new wxBoxSizer( wxVERTICAL );
|
||||
thirdPanelSz->Add(m_ctrl[2], 1, wxGROW|wxALL, 5);
|
||||
thirdPanelSz->Add(m_ctrl[Page_ListStore], 1, wxGROW|wxALL, 5);
|
||||
thirdPanel->SetSizerAndFit(thirdPanelSz);
|
||||
|
||||
|
||||
@@ -642,7 +648,7 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
||||
|
||||
wxPanel *fourthPanel = new wxPanel( m_notebook, wxID_ANY );
|
||||
|
||||
BuildDataViewCtrl(fourthPanel, 3); // sets m_ctrl[3]
|
||||
BuildDataViewCtrl(fourthPanel, Page_TreeStore);
|
||||
// Buttons
|
||||
wxBoxSizer *button_sizer4 = new wxBoxSizer( wxHORIZONTAL );
|
||||
button_sizer4->Add( new wxButton( fourthPanel, ID_DELETE_TREE_ITEM, "Delete Selected"), 0, wxALL, 10 );
|
||||
@@ -651,7 +657,7 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
||||
button_sizer4->Add( new wxButton( fourthPanel, ID_ADD_TREE_CONTAINER_ITEM, "Add Container"), 0, wxALL, 10 );
|
||||
|
||||
wxSizer *fourthPanelSz = new wxBoxSizer( wxVERTICAL );
|
||||
fourthPanelSz->Add(m_ctrl[3], 1, wxGROW|wxALL, 5);
|
||||
fourthPanelSz->Add(m_ctrl[Page_TreeStore], 1, wxGROW|wxALL, 5);
|
||||
fourthPanelSz->Add(button_sizer4);
|
||||
fourthPanel->SetSizerAndFit(fourthPanelSz);
|
||||
|
||||
@@ -660,10 +666,10 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
||||
|
||||
wxPanel *fifthPanel = new wxPanel(m_notebook, wxID_ANY);
|
||||
|
||||
BuildDataViewCtrl(fifthPanel, 4); // sets m_ctrl[4]
|
||||
BuildDataViewCtrl(fifthPanel, Page_VarHeight);
|
||||
|
||||
wxSizer *fifthPanelSz = new wxBoxSizer(wxVERTICAL);
|
||||
fifthPanelSz->Add(m_ctrl[4], 1, wxGROW | wxALL, 5);
|
||||
fifthPanelSz->Add(m_ctrl[Page_VarHeight], 1, wxGROW | wxALL, 5);
|
||||
fifthPanel->SetSizerAndFit(fifthPanelSz);
|
||||
|
||||
|
||||
@@ -691,22 +697,23 @@ MyFrame::~MyFrame()
|
||||
|
||||
void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned long style)
|
||||
{
|
||||
wxASSERT(!m_ctrl[nPanel]); // should only be initialized once
|
||||
|
||||
switch (nPanel)
|
||||
{
|
||||
case 0:
|
||||
case Page_Music:
|
||||
{
|
||||
wxASSERT(!m_ctrl[0] && !m_music_model);
|
||||
m_ctrl[0] =
|
||||
m_ctrl[Page_Music] =
|
||||
new wxDataViewCtrl( parent, ID_MUSIC_CTRL, wxDefaultPosition,
|
||||
wxDefaultSize, style );
|
||||
m_ctrl[0]->Bind(wxEVT_CHAR, &MyFrame::OnDataViewChar, this);
|
||||
m_ctrl[Page_Music]->Bind(wxEVT_CHAR, &MyFrame::OnDataViewChar, this);
|
||||
|
||||
m_music_model = new MyMusicTreeModel;
|
||||
m_ctrl[0]->AssociateModel( m_music_model.get() );
|
||||
m_ctrl[Page_Music]->AssociateModel( m_music_model.get() );
|
||||
|
||||
#if wxUSE_DRAG_AND_DROP && wxUSE_UNICODE
|
||||
m_ctrl[0]->EnableDragSource( wxDF_UNICODETEXT );
|
||||
m_ctrl[0]->EnableDropTarget( wxDF_UNICODETEXT );
|
||||
m_ctrl[Page_Music]->EnableDragSource( wxDF_UNICODETEXT );
|
||||
m_ctrl[Page_Music]->EnableDropTarget( wxDF_UNICODETEXT );
|
||||
#endif // wxUSE_DRAG_AND_DROP && wxUSE_UNICODE
|
||||
|
||||
// column 0 of the view control:
|
||||
@@ -716,7 +723,7 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
|
||||
wxDataViewColumn *column0 =
|
||||
new wxDataViewColumn( "title", tr, 0, 200, wxALIGN_LEFT,
|
||||
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE );
|
||||
m_ctrl[0]->AppendColumn( column0 );
|
||||
m_ctrl[Page_Music]->AppendColumn( column0 );
|
||||
#if 0
|
||||
// Call this and sorting is enabled
|
||||
// immediately upon start up.
|
||||
@@ -731,7 +738,7 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
|
||||
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE |
|
||||
wxDATAVIEW_COL_RESIZABLE );
|
||||
column1->SetMinWidth(150); // this column can't be resized to be smaller
|
||||
m_ctrl[0]->AppendColumn( column1 );
|
||||
m_ctrl[Page_Music]->AppendColumn( column1 );
|
||||
|
||||
// column 2 of the view control:
|
||||
|
||||
@@ -741,7 +748,7 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
|
||||
wxDataViewColumn *column2 =
|
||||
new wxDataViewColumn( "year", sr, 2, 60, wxALIGN_LEFT,
|
||||
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE );
|
||||
m_ctrl[0]->AppendColumn( column2 );
|
||||
m_ctrl[Page_Music]->AppendColumn( column2 );
|
||||
|
||||
// column 3 of the view control:
|
||||
|
||||
@@ -755,11 +762,11 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
|
||||
wxDataViewColumn *column3 =
|
||||
new wxDataViewColumn( "rating", c, 3, 100, wxALIGN_LEFT,
|
||||
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE );
|
||||
m_ctrl[0]->AppendColumn( column3 );
|
||||
m_ctrl[Page_Music]->AppendColumn( column3 );
|
||||
|
||||
// column 4 of the view control:
|
||||
|
||||
m_ctrl[0]->AppendProgressColumn( "popularity", 4, wxDATAVIEW_CELL_INERT, 80 );
|
||||
m_ctrl[Page_Music]->AppendProgressColumn( "popularity", 4, wxDATAVIEW_CELL_INERT, 80 );
|
||||
|
||||
// column 5 of the view control:
|
||||
|
||||
@@ -768,43 +775,42 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
|
||||
new wxDataViewColumn( "custom", cr, 5, -1, wxALIGN_LEFT,
|
||||
wxDATAVIEW_COL_RESIZABLE );
|
||||
column5->SetBitmap(wxArtProvider::GetBitmap(wxART_INFORMATION, wxART_MENU));
|
||||
m_ctrl[0]->AppendColumn( column5 );
|
||||
m_ctrl[Page_Music]->AppendColumn( column5 );
|
||||
|
||||
|
||||
// select initially the ninth symphony:
|
||||
m_ctrl[0]->Select(m_music_model->GetNinthItem());
|
||||
m_ctrl[Page_Music]->Select(m_music_model->GetNinthItem());
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case Page_List:
|
||||
{
|
||||
wxASSERT(!m_ctrl[1] && !m_list_model);
|
||||
m_ctrl[1] = new wxDataViewCtrl( parent, ID_ATTR_CTRL, wxDefaultPosition,
|
||||
m_ctrl[Page_List] = new wxDataViewCtrl( parent, ID_ATTR_CTRL, wxDefaultPosition,
|
||||
wxDefaultSize, style );
|
||||
|
||||
m_list_model = new MyListModel;
|
||||
m_ctrl[1]->AssociateModel( m_list_model.get() );
|
||||
m_ctrl[Page_List]->AssociateModel( m_list_model.get() );
|
||||
|
||||
m_ctrl[1]->AppendToggleColumn(L"\u2714",
|
||||
m_ctrl[Page_List]->AppendToggleColumn(L"\u2714",
|
||||
MyListModel::Col_Toggle,
|
||||
wxDATAVIEW_CELL_ACTIVATABLE,
|
||||
wxCOL_WIDTH_AUTOSIZE);
|
||||
|
||||
// the various columns
|
||||
m_ctrl[1]->AppendTextColumn("editable string",
|
||||
m_ctrl[Page_List]->AppendTextColumn("editable string",
|
||||
MyListModel::Col_EditableText,
|
||||
wxDATAVIEW_CELL_EDITABLE,
|
||||
wxCOL_WIDTH_AUTOSIZE,
|
||||
wxALIGN_NOT,
|
||||
wxDATAVIEW_COL_SORTABLE);
|
||||
m_ctrl[1]->AppendIconTextColumn("icon",
|
||||
m_ctrl[Page_List]->AppendIconTextColumn("icon",
|
||||
MyListModel::Col_IconText,
|
||||
wxDATAVIEW_CELL_EDITABLE,
|
||||
wxCOL_WIDTH_AUTOSIZE,
|
||||
wxALIGN_NOT,
|
||||
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_SORTABLE);
|
||||
|
||||
m_ctrl[1]->AppendDateColumn("date",
|
||||
m_ctrl[Page_List]->AppendDateColumn("date",
|
||||
MyListModel::Col_Date);
|
||||
|
||||
wxDataViewTextRenderer* const markupRenderer = new wxDataViewTextRenderer();
|
||||
@@ -818,9 +824,9 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
|
||||
wxCOL_WIDTH_AUTOSIZE,
|
||||
wxALIGN_RIGHT,
|
||||
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
|
||||
m_ctrl[1]->AppendColumn( m_attributes );
|
||||
m_ctrl[Page_List]->AppendColumn( m_attributes );
|
||||
|
||||
m_ctrl[1]->AppendColumn(
|
||||
m_ctrl[Page_List]->AppendColumn(
|
||||
new wxDataViewColumn("custom renderer",
|
||||
new MyCustomRenderer(wxDATAVIEW_CELL_EDITABLE),
|
||||
MyListModel::Col_Custom)
|
||||
@@ -828,13 +834,12 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case Page_ListStore:
|
||||
{
|
||||
wxASSERT(!m_ctrl[2]);
|
||||
wxDataViewListCtrl* lc =
|
||||
new wxDataViewListCtrl( parent, wxID_ANY, wxDefaultPosition,
|
||||
wxDefaultSize, style );
|
||||
m_ctrl[2] = lc;
|
||||
m_ctrl[Page_ListStore] = lc;
|
||||
|
||||
MyListStoreDerivedModel* page2_model = new MyListStoreDerivedModel();
|
||||
lc->AssociateModel(page2_model);
|
||||
@@ -871,13 +876,12 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case Page_TreeStore:
|
||||
{
|
||||
wxASSERT(!m_ctrl[3]);
|
||||
wxDataViewTreeCtrl* tc =
|
||||
new wxDataViewTreeCtrl( parent, wxID_ANY, wxDefaultPosition,
|
||||
wxDefaultSize, style | wxDV_NO_HEADER );
|
||||
m_ctrl[3] = tc;
|
||||
m_ctrl[Page_TreeStore] = tc;
|
||||
|
||||
wxImageList *ilist = new wxImageList( 16, 16 );
|
||||
ilist->Add( wxIcon(wx_small_xpm) );
|
||||
@@ -898,15 +902,14 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
case Page_VarHeight:
|
||||
{
|
||||
wxASSERT(!m_ctrl[4] && !m_long_music_model);
|
||||
m_ctrl[4] =
|
||||
m_ctrl[Page_VarHeight] =
|
||||
new wxDataViewCtrl( parent, wxID_ANY, wxDefaultPosition,
|
||||
wxDefaultSize, style | wxDV_VARIABLE_LINE_HEIGHT );
|
||||
|
||||
m_long_music_model = new MyLongMusicTreeModel;
|
||||
m_ctrl[4]->AssociateModel(m_long_music_model.get());
|
||||
m_ctrl[Page_VarHeight]->AssociateModel(m_long_music_model.get());
|
||||
|
||||
// column 0 of the view control:
|
||||
MultiLineCustomRenderer *tr =
|
||||
@@ -914,7 +917,7 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
|
||||
wxDataViewColumn *column0 =
|
||||
new wxDataViewColumn("title", tr, 0, 200, wxALIGN_LEFT,
|
||||
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE);
|
||||
m_ctrl[4]->AppendColumn(column0);
|
||||
m_ctrl[Page_VarHeight]->AppendColumn(column0);
|
||||
|
||||
// column 1 of the view control:
|
||||
tr = new MultiLineCustomRenderer();
|
||||
@@ -923,7 +926,7 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
|
||||
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE |
|
||||
wxDATAVIEW_COL_RESIZABLE);
|
||||
column1->SetMinWidth(150); // this column can't be resized to be smaller
|
||||
m_ctrl[4]->AppendColumn(column1);
|
||||
m_ctrl[Page_VarHeight]->AppendColumn(column1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1202,7 +1205,7 @@ void MyFrame::OnAddMozart( wxCommandEvent& WXUNUSED(event) )
|
||||
void MyFrame::DeleteSelectedItems()
|
||||
{
|
||||
wxDataViewItemArray items;
|
||||
int len = m_ctrl[0]->GetSelections( items );
|
||||
int len = m_ctrl[Page_Music]->GetSelections( items );
|
||||
for( int i = 0; i < len; i ++ )
|
||||
if (items[i].IsOk())
|
||||
m_music_model->Delete( items[i] );
|
||||
@@ -1215,7 +1218,7 @@ void MyFrame::OnDeleteSelected( wxCommandEvent& WXUNUSED(event) )
|
||||
|
||||
void MyFrame::OnDeleteYear( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
m_ctrl[0]->DeleteColumn( m_ctrl[0]->GetColumn( 2 ) );
|
||||
m_ctrl[Page_Music]->DeleteColumn( m_ctrl[Page_Music]->GetColumn( 2 ) );
|
||||
FindWindow( ID_DELETE_YEAR )->Disable();
|
||||
}
|
||||
|
||||
@@ -1227,26 +1230,26 @@ void MyFrame::OnSelectNinth( wxCommandEvent& WXUNUSED(event) )
|
||||
return;
|
||||
}
|
||||
|
||||
m_ctrl[0]->Select( m_music_model->GetNinthItem() );
|
||||
m_ctrl[Page_Music]->Select( m_music_model->GetNinthItem() );
|
||||
}
|
||||
|
||||
void MyFrame::OnCollapse( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
wxDataViewItem item = m_ctrl[0]->GetSelection();
|
||||
wxDataViewItem item = m_ctrl[Page_Music]->GetSelection();
|
||||
if (item.IsOk())
|
||||
m_ctrl[0]->Collapse( item );
|
||||
m_ctrl[Page_Music]->Collapse( item );
|
||||
}
|
||||
|
||||
void MyFrame::OnExpand( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
wxDataViewItem item = m_ctrl[0]->GetSelection();
|
||||
wxDataViewItem item = m_ctrl[Page_Music]->GetSelection();
|
||||
if (item.IsOk())
|
||||
m_ctrl[0]->Expand( item );
|
||||
m_ctrl[Page_Music]->Expand( item );
|
||||
}
|
||||
|
||||
void MyFrame::OnShowCurrent(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxDataViewItem item = m_ctrl[0]->GetCurrentItem();
|
||||
wxDataViewItem item = m_ctrl[Page_Music]->GetCurrentItem();
|
||||
if ( item.IsOk() )
|
||||
{
|
||||
wxLogMessage("Current item: \"%s\" by %s",
|
||||
@@ -1258,11 +1261,11 @@ void MyFrame::OnShowCurrent(wxCommandEvent& WXUNUSED(event))
|
||||
wxLogMessage("There is no current item.");
|
||||
}
|
||||
|
||||
wxDataViewColumn *col = m_ctrl[0]->GetCurrentColumn();
|
||||
wxDataViewColumn *col = m_ctrl[Page_Music]->GetCurrentColumn();
|
||||
if ( col )
|
||||
{
|
||||
wxLogMessage("Current column: %d",
|
||||
m_ctrl[0]->GetColumnPosition(col));
|
||||
m_ctrl[Page_Music]->GetColumnPosition(col));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1279,7 +1282,7 @@ void MyFrame::OnSetNinthCurrent(wxCommandEvent& WXUNUSED(event))
|
||||
return;
|
||||
}
|
||||
|
||||
m_ctrl[0]->SetCurrentItem(item);
|
||||
m_ctrl[Page_Music]->SetCurrentItem(item);
|
||||
}
|
||||
|
||||
void MyFrame::OnChangeNinthTitle(wxCommandEvent& WXUNUSED(event))
|
||||
@@ -1308,7 +1311,7 @@ void MyFrame::OnActivated( wxDataViewEvent &event )
|
||||
wxLogMessage( "wxEVT_DATAVIEW_ITEM_ACTIVATED, Item: %s; Column: %d",
|
||||
title, event.GetColumn() );
|
||||
|
||||
if (m_ctrl[0]->IsExpanded( event.GetItem() ))
|
||||
if (m_ctrl[Page_Music]->IsExpanded( event.GetItem() ))
|
||||
{
|
||||
wxLogMessage( "Item: %s is expanded", title );
|
||||
}
|
||||
@@ -1390,7 +1393,7 @@ void MyFrame::OnContextMenu( wxDataViewEvent &event )
|
||||
menu.Append( 2, "menuitem 2" );
|
||||
menu.Append( 3, "menuitem 3" );
|
||||
|
||||
m_ctrl[0]->PopupMenu(&menu);
|
||||
m_ctrl[Page_Music]->PopupMenu(&menu);
|
||||
}
|
||||
|
||||
void MyFrame::OnAttrHeaderClick( wxDataViewEvent &event )
|
||||
@@ -1399,7 +1402,7 @@ void MyFrame::OnAttrHeaderClick( wxDataViewEvent &event )
|
||||
// this column when it is clicked to take place
|
||||
event.Skip();
|
||||
|
||||
int pos = m_ctrl[1]->GetColumnPosition( event.GetDataViewColumn() );
|
||||
int pos = m_ctrl[Page_List]->GetColumnPosition( event.GetDataViewColumn() );
|
||||
|
||||
wxLogMessage( "wxEVT_DATAVIEW_COLUMN_HEADER_CLICK, Column position: %d", pos );
|
||||
wxLogMessage( "Column title: %s Column width: %d", event.GetDataViewColumn()->GetTitle(), event.GetDataViewColumn()->GetWidth() );
|
||||
@@ -1411,7 +1414,7 @@ void MyFrame::OnHeaderClick( wxDataViewEvent &event )
|
||||
// this column when it is clicked to take place
|
||||
event.Skip();
|
||||
|
||||
int pos = m_ctrl[0]->GetColumnPosition( event.GetDataViewColumn() );
|
||||
int pos = m_ctrl[Page_Music]->GetColumnPosition( event.GetDataViewColumn() );
|
||||
|
||||
wxLogMessage( "wxEVT_DATAVIEW_COLUMN_HEADER_CLICK, Column position: %d", pos );
|
||||
wxLogMessage( "Column width: %d", event.GetDataViewColumn()->GetWidth() );
|
||||
@@ -1419,7 +1422,7 @@ void MyFrame::OnHeaderClick( wxDataViewEvent &event )
|
||||
|
||||
void MyFrame::OnHeaderRightClick( wxDataViewEvent &event )
|
||||
{
|
||||
int pos = m_ctrl[0]->GetColumnPosition( event.GetDataViewColumn() );
|
||||
int pos = m_ctrl[Page_Music]->GetColumnPosition( event.GetDataViewColumn() );
|
||||
|
||||
wxLogMessage( "wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, Column position: %d", pos );
|
||||
}
|
||||
@@ -1439,7 +1442,7 @@ void MyFrame::OnColumnReordered(wxDataViewEvent& event)
|
||||
|
||||
void MyFrame::OnSortedList( wxDataViewEvent &/*event*/)
|
||||
{
|
||||
wxVector<wxDataViewColumn *> const columns = m_ctrl[1]->GetSortingColumns();
|
||||
wxVector<wxDataViewColumn *> const columns = m_ctrl[Page_List]->GetSortingColumns();
|
||||
wxLogMessage( "wxEVT_DATAVIEW_COLUMN_SORTED using the following columns");
|
||||
|
||||
for ( wxVector<wxDataViewColumn *>::const_iterator it = columns.begin(),
|
||||
@@ -1460,14 +1463,14 @@ void MyFrame::OnHeaderClickList( wxDataViewEvent &event )
|
||||
{
|
||||
// Use control+click to toggle sorting by this column.
|
||||
if ( wxGetKeyState(WXK_CONTROL) )
|
||||
m_ctrl[1]->ToggleSortByColumn(event.GetColumn());
|
||||
m_ctrl[Page_List]->ToggleSortByColumn(event.GetColumn());
|
||||
else
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void MyFrame::OnSorted( wxDataViewEvent &event )
|
||||
{
|
||||
int pos = m_ctrl[0]->GetColumnPosition( event.GetDataViewColumn() );
|
||||
int pos = m_ctrl[Page_Music]->GetColumnPosition( event.GetDataViewColumn() );
|
||||
|
||||
wxLogMessage( "wxEVT_DATAVIEW_COLUMN_SORTED, Column position: %d", pos );
|
||||
}
|
||||
@@ -1492,7 +1495,7 @@ void MyFrame::OnPrependList( wxCommandEvent& WXUNUSED(event) )
|
||||
void MyFrame::OnDeleteList( wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
wxDataViewItemArray items;
|
||||
int len = m_ctrl[1]->GetSelections( items );
|
||||
int len = m_ctrl[Page_List]->GetSelections( items );
|
||||
if (len > 0)
|
||||
m_list_model->DeleteItems( items );
|
||||
}
|
||||
@@ -1500,7 +1503,7 @@ void MyFrame::OnDeleteList( wxCommandEvent& WXUNUSED(event) )
|
||||
void MyFrame::OnGoto(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxDataViewItem item = m_list_model->GetItem( 50 );
|
||||
m_ctrl[1]->EnsureVisible(item,m_col);
|
||||
m_ctrl[Page_List]->EnsureVisible(item,m_col);
|
||||
}
|
||||
|
||||
void MyFrame::OnAddMany(wxCommandEvent& WXUNUSED(event))
|
||||
@@ -1531,7 +1534,7 @@ void MyFrame::OnListValueChanged(wxDataViewEvent& event)
|
||||
return;
|
||||
}
|
||||
|
||||
wxDataViewListCtrl* const lc = static_cast<wxDataViewListCtrl*>(m_ctrl[2]);
|
||||
wxDataViewListCtrl* const lc = static_cast<wxDataViewListCtrl*>(m_ctrl[Page_ListStore]);
|
||||
|
||||
const int columnToggle = 1;
|
||||
|
||||
@@ -1566,7 +1569,7 @@ void MyFrame::OnListValueChanged(wxDataViewEvent& event)
|
||||
|
||||
void MyFrame::OnDeleteTreeItem(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxDataViewTreeCtrl* ctrl = (wxDataViewTreeCtrl*) m_ctrl[3];
|
||||
wxDataViewTreeCtrl* ctrl = (wxDataViewTreeCtrl*) m_ctrl[Page_TreeStore];
|
||||
wxDataViewItem selected = ctrl->GetSelection();
|
||||
if (!selected.IsOk())
|
||||
return;
|
||||
@@ -1576,13 +1579,13 @@ void MyFrame::OnDeleteTreeItem(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
void MyFrame::OnDeleteAllTreeItems(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxDataViewTreeCtrl* ctrl = (wxDataViewTreeCtrl*) m_ctrl[3];
|
||||
wxDataViewTreeCtrl* ctrl = (wxDataViewTreeCtrl*) m_ctrl[Page_TreeStore];
|
||||
ctrl->DeleteAllItems();
|
||||
}
|
||||
|
||||
void MyFrame::OnAddTreeItem(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxDataViewTreeCtrl* ctrl = (wxDataViewTreeCtrl*) m_ctrl[3];
|
||||
wxDataViewTreeCtrl* ctrl = (wxDataViewTreeCtrl*) m_ctrl[Page_TreeStore];
|
||||
wxDataViewItem selected = ctrl->GetSelection();
|
||||
if (ctrl->IsContainer(selected)) {
|
||||
wxDataViewItem newitem = ctrl->AppendItem( selected, "Item", 0 );
|
||||
@@ -1593,7 +1596,7 @@ void MyFrame::OnAddTreeItem(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
void MyFrame::OnAddTreeContainerItem(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxDataViewTreeCtrl* ctrl = (wxDataViewTreeCtrl*) m_ctrl[3];
|
||||
wxDataViewTreeCtrl* ctrl = (wxDataViewTreeCtrl*) m_ctrl[Page_TreeStore];
|
||||
wxDataViewItem selected = ctrl->GetSelection();
|
||||
if (ctrl->IsContainer(selected))
|
||||
ctrl->AppendContainer(selected, "Container", 0 );
|
||||
@@ -1601,13 +1604,13 @@ void MyFrame::OnAddTreeContainerItem(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
void MyFrame::OnMultipleSort( wxCommandEvent &event )
|
||||
{
|
||||
if ( !m_ctrl[1]->AllowMultiColumnSort(event.IsChecked()) )
|
||||
if ( !m_ctrl[Page_List]->AllowMultiColumnSort(event.IsChecked()) )
|
||||
wxLogMessage("Sorting by multiple columns not supported");
|
||||
}
|
||||
|
||||
void MyFrame::OnSortByFirstColumn(wxCommandEvent& event)
|
||||
{
|
||||
wxDataViewColumn* const col = m_ctrl[1]->GetColumn(0);
|
||||
wxDataViewColumn* const col = m_ctrl[Page_List]->GetColumn(0);
|
||||
if ( event.IsChecked() )
|
||||
col->SetSortOrder(true /* ascending */);
|
||||
else
|
||||
|
Reference in New Issue
Block a user