- tr = new wxDataViewTextRenderer( wxT("string"), wxDATAVIEW_CELL_EDITABLE );
- wxDataViewColumn *column1 = new wxDataViewColumn( wxT("artist"), tr, 1, 150, wxALIGN_LEFT,
- wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE );
- column1->SetMinWidth(150); // this column can't be resized to be smaller
- m_musicCtrl->AppendColumn( column1 );
-
- wxDataViewSpinRenderer *sr = new wxDataViewSpinRenderer( 0, 2010, wxDATAVIEW_CELL_EDITABLE, wxALIGN_RIGHT );
- wxDataViewColumn *column2 = new wxDataViewColumn( wxT("year"), sr, 2, 60, wxALIGN_LEFT,
- wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE );
- m_musicCtrl->AppendColumn( column2 );
-
- wxArrayString choices;
- choices.Add( "good" );
- choices.Add( "bad" );
- choices.Add( "lousy" );
- wxDataViewChoiceRenderer *c = new wxDataViewChoiceRenderer( choices, wxDATAVIEW_CELL_EDITABLE, wxALIGN_RIGHT );
- wxDataViewColumn *column3 = new wxDataViewColumn( wxT("rating"), c, 3, 100, wxALIGN_LEFT,
- wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE );
- m_musicCtrl->AppendColumn( column3 );
-
- m_musicCtrl->AppendProgressColumn( wxT("popularity"), 4, wxDATAVIEW_CELL_INERT, 80 );
-
- MyCustomRenderer *cr = new MyCustomRenderer( wxDATAVIEW_CELL_ACTIVATABLE, wxALIGN_RIGHT );
- wxDataViewColumn *column4 = new wxDataViewColumn( wxT("custom"), cr, 5, -1, wxALIGN_LEFT,
- wxDATAVIEW_COL_RESIZABLE );
- m_musicCtrl->AppendColumn( column4 );
-
- data_sizer->Add( m_musicCtrl, 3, wxGROW );
-
- // MyList
-
- m_listCtrl = new wxDataViewCtrl( panel, wxID_ANY, wxDefaultPosition,
- wxSize(400,200), wxDV_MULTIPLE | wxDV_ROW_LINES);
-
- m_list_model = new MyListModel;
- m_listCtrl->AssociateModel( m_list_model.get() );
-
-#if 1
- m_listCtrl->AppendTextColumn (wxT("editable string"), 0, wxDATAVIEW_CELL_EDITABLE, 120 );
- m_listCtrl->AppendIconTextColumn(wxIcon(small1_xpm), 1, wxDATAVIEW_CELL_INERT )->SetTitle( wxT("icon") );
-#else
- m_listCtrl->AppendTextColumn (wxT("editable string"), 0, wxDATAVIEW_CELL_EDITABLE );
- m_listCtrl->AppendIconTextColumn(wxT("icon"), 1, wxDATAVIEW_CELL_INERT );
-#endif
+void MyFrame::OnStyleChange( wxCommandEvent& WXUNUSED(event) )
+{
+ unsigned int nPanel = m_notebook->GetSelection();
+
+ // build the style
+ unsigned long style = 0;
+ /*if (GetMenuBar()->FindItem(ID_SINGLE)->IsChecked())
+ style |= wxDV_SINGLE;*/
+ if (GetMenuBar()->FindItem(ID_MULTIPLE)->IsChecked())
+ style |= wxDV_MULTIPLE;
+ if (GetMenuBar()->FindItem(ID_ROW_LINES)->IsChecked())
+ style |= wxDV_ROW_LINES;
+ if (GetMenuBar()->FindItem(ID_HORIZ_RULES)->IsChecked())
+ style |= wxDV_HORIZ_RULES;
+ if (GetMenuBar()->FindItem(ID_VERT_RULES)->IsChecked())
+ style |= wxDV_VERT_RULES;
+
+ wxSizer* sz = m_ctrl[nPanel]->GetContainingSizer();
+ wxASSERT(sz);
+
+ sz->Detach(m_ctrl[nPanel]);
+ wxDELETE(m_ctrl[nPanel]);
+ m_ctrl[nPanel] = NULL;
+
+ if (nPanel == 0)
+ m_music_model.reset(NULL);
+ else if (nPanel == 1)
+ m_list_model.reset(NULL);
+
+ // rebuild the DVC for the selected panel:
+ BuildDataViewCtrl((wxPanel*)m_notebook->GetPage(nPanel), nPanel, style);
+
+ sz->Prepend(m_ctrl[nPanel], 1, wxGROW|wxALL, 5);
+ sz->Layout();
+}
+
+void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) )
+{
+ Close(true);
+}