+ wxLogMessage( "This is the log window" );
+
+ mainSizer->Add( m_notebook, 1, wxGROW );
+ mainSizer->Add( m_log, 0, wxGROW );
+
+ SetSizerAndFit(mainSizer);
+}
+
+MyFrame::~MyFrame()
+{
+ delete wxLog::SetActiveTarget(m_logOld);
+}
+
+void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned long style)
+{
+ switch (nPanel)
+ {
+ case 0:
+ {
+ wxASSERT(!m_ctrl[0] && !m_music_model);
+ m_ctrl[0] =
+ new wxDataViewCtrl( parent, ID_MUSIC_CTRL, wxDefaultPosition,
+ wxDefaultSize, style );
+
+ m_music_model = new MyMusicTreeModel;
+ m_ctrl[0]->AssociateModel( m_music_model.get() );
+
+ m_ctrl[0]->EnableDragSource( wxDF_UNICODETEXT );
+ m_ctrl[0]->EnableDropTarget( wxDF_UNICODETEXT );
+
+ // column 0 of the view control:
+
+ wxDataViewTextRenderer *tr =
+ new wxDataViewTextRenderer( "string", wxDATAVIEW_CELL_INERT );
+ wxDataViewColumn *column0 =
+ new wxDataViewColumn( "title", tr, 0, 200, wxALIGN_LEFT,
+ wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE );
+ m_ctrl[0]->AppendColumn( column0 );
+#if 0
+ // Call this and sorting is enabled
+ // immediatly upon start up.
+ column0->SetAsSortKey();
+#endif
+
+ // column 1 of the view control:
+
+ tr = new wxDataViewTextRenderer( "string", wxDATAVIEW_CELL_EDITABLE );
+ wxDataViewColumn *column1 =
+ new wxDataViewColumn( "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_ctrl[0]->AppendColumn( column1 );
+
+ // column 2 of the view control:
+
+ wxDataViewSpinRenderer *sr =
+ new wxDataViewSpinRenderer( 0, 2010, wxDATAVIEW_CELL_EDITABLE, wxALIGN_RIGHT );
+ wxDataViewColumn *column2 =
+ new wxDataViewColumn( "year", sr, 2, 60, wxALIGN_LEFT,
+ wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE );
+ m_ctrl[0]->AppendColumn( column2 );
+
+ // column 3 of the view control:
+
+ 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( "rating", c, 3, 100, wxALIGN_LEFT,
+ wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE );
+ m_ctrl[0]->AppendColumn( column3 );
+
+ // column 4 of the view control:
+
+ m_ctrl[0]->AppendProgressColumn( "popularity", 4, wxDATAVIEW_CELL_INERT, 80 );
+
+ // column 5 of the view control:
+
+ MyCustomRenderer *cr = new MyCustomRenderer( wxDATAVIEW_CELL_ACTIVATABLE, wxALIGN_RIGHT );
+ wxDataViewColumn *column5 =
+ new wxDataViewColumn( "custom", cr, 5, -1, wxALIGN_LEFT,
+ wxDATAVIEW_COL_RESIZABLE );
+ m_ctrl[0]->AppendColumn( column5 );
+
+
+ // select initially the ninth symphony:
+ m_ctrl[0]->Select(m_music_model->GetNinthItem());
+ }
+ break;
+
+ case 1:
+ {
+ wxASSERT(!m_ctrl[1] && !m_list_model);
+ m_ctrl[1] = new wxDataViewCtrl( parent, wxID_ANY, wxDefaultPosition,
+ wxDefaultSize, style );
+
+ m_list_model = new MyListModel;
+ m_ctrl[1]->AssociateModel( m_list_model.get() );
+
+ // the various columns
+#if 1
+ m_ctrl[1]->AppendTextColumn("editable string", 0, wxDATAVIEW_CELL_EDITABLE, 120);
+ m_ctrl[1]->AppendIconTextColumn(wxIcon(wx_small_xpm), 1, wxDATAVIEW_CELL_INERT )->SetTitle( "icon");
+#else
+ m_ctrl[1]->AppendTextColumn("editable string", 0, wxDATAVIEW_CELL_EDITABLE);
+ m_ctrl[1]->AppendIconTextColumn("icon", 1, wxDATAVIEW_CELL_INERT);
+#endif
+ m_ctrl[1]->AppendColumn(
+ new wxDataViewColumn("attributes", new wxDataViewTextRendererAttr, 2 ));
+ }
+ break;
+
+ case 2:
+ {
+ wxASSERT(!m_ctrl[2]);
+ wxDataViewListCtrl* lc =
+ new wxDataViewListCtrl( parent, wxID_ANY, wxDefaultPosition,
+ wxDefaultSize, style );
+ m_ctrl[2] = lc;
+
+ lc->AppendToggleColumn( "Toggle" );
+ lc->AppendTextColumn( "Text" );
+ lc->AppendProgressColumn( "Progress" );
+
+ wxVector<wxVariant> data;
+ for (unsigned int i=0; i<10; i++)
+ {
+ data.clear();
+ data.push_back( (i%3) == 0 );
+ data.push_back( wxString::Format("row %d", i) );
+ data.push_back( long(5*i) );
+
+ lc->AppendItem( data );
+ }
+ }
+ break;
+
+ case 3:
+ {
+ wxASSERT(!m_ctrl[3]);
+ wxDataViewTreeCtrl* tc =
+ new wxDataViewTreeCtrl( parent, wxID_ANY, wxDefaultPosition,
+ wxDefaultSize, style );
+ m_ctrl[3] = tc;
+
+ wxImageList *ilist = new wxImageList( 16, 16 );
+ ilist->Add( wxIcon(wx_small_xpm) );
+ tc->SetImageList( ilist );
+
+ wxDataViewItem parent =
+ tc->AppendContainer( wxDataViewItem(0), "The Root", 0 );
+ tc->AppendItem( parent, "Child 1", 0 );
+ tc->AppendItem( parent, "Child 2", 0 );
+ tc->AppendItem( parent, "Child 3, very long, long, long, long", 0 );
+
+ wxDataViewItem cont =
+ tc->AppendContainer( parent, "Container child", 0 );
+ tc->AppendItem( cont, "Child 4", 0 );
+ tc->AppendItem( cont, "Child 5", 0 );
+
+ tc->Expand(cont);
+ }
+ break;
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// MyFrame - generic event handlers
+// ----------------------------------------------------------------------------
+
+void MyFrame::OnClearLog( wxCommandEvent& WXUNUSED(event) )
+{
+ m_log->Clear();
+}
+
+void MyFrame::OnPageChanged( wxBookCtrlEvent& WXUNUSED(event) )
+{
+ unsigned int nPanel = m_notebook->GetSelection();
+
+ GetMenuBar()->FindItem(ID_STYLE_MENU)->SetItemLabel(
+ wxString::Format("Style of panel #%d", nPanel+1));
+
+ for (unsigned int id = ID_MULTIPLE; id <= ID_VERT_RULES; id++)
+ {
+ unsigned long style = 0;
+ switch (id)
+ {
+ /*case ID_SINGLE:
+ style = wxDV_SINGLE;
+ break;*/
+ case ID_MULTIPLE:
+ style = wxDV_MULTIPLE;
+ break;
+ case ID_ROW_LINES:
+ style = wxDV_ROW_LINES;
+ break;
+ case ID_HORIZ_RULES:
+ style = wxDV_HORIZ_RULES;
+ break;
+ case ID_VERT_RULES:
+ style = wxDV_VERT_RULES;
+ break;
+ default:
+ wxFAIL;
+ }