+void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
+{
+ wxAboutDialogInfo info;
+ info.SetName(_("DataView sample"));
+ info.SetDescription(_("This sample demonstrates wxDataViewCtrl"));
+ info.SetCopyright(_T("(C) 2007-2009 Robert Roebling"));
+ info.AddDeveloper("Robert Roebling");
+ info.AddDeveloper("Francesco Montorsi");
+
+ wxAboutBox(info);
+}
+
+
+// ----------------------------------------------------------------------------
+// MyFrame - event handlers for the first page
+// ----------------------------------------------------------------------------
+
+void MyFrame::OnBeginDrag( wxDataViewEvent &event )
+{
+ wxDataViewItem item( event.GetItem() );
+
+ // only allow drags for item, not containers
+ if (m_music_model->IsContainer( item ) )
+ {
+ event.Veto();
+ return;
+ }
+
+ MyMusicTreeModelNode *node = (MyMusicTreeModelNode*) item.GetID();
+ wxTextDataObject *obj = new wxTextDataObject;
+ obj->SetText( node->m_title );
+ event.SetDataObject( obj );
+}
+
+void MyFrame::OnDropPossible( wxDataViewEvent &event )
+{
+ wxDataViewItem item( event.GetItem() );
+
+ // only allow drags for item, not containers
+ if (m_music_model->IsContainer( item ) )
+ event.Veto();
+
+ if (event.GetDataFormat() != wxDF_UNICODETEXT)
+ event.Veto();
+}
+
+void MyFrame::OnDrop( wxDataViewEvent &event )
+{
+ wxDataViewItem item( event.GetItem() );
+
+ // only allow drops for item, not containers
+ if (m_music_model->IsContainer( item ) )
+ {
+ event.Veto();
+ return;
+ }
+
+ if (event.GetDataFormat() != wxDF_UNICODETEXT)
+ {
+ event.Veto();
+ return;
+ }
+
+ wxTextDataObject obj;
+ obj.SetData( wxDF_UNICODETEXT, event.GetDataSize(), event.GetDataBuffer() );
+
+ wxLogMessage( "Text dropped: %s", obj.GetText() );
+}
+
+void MyFrame::OnAddMozart( wxCommandEvent& WXUNUSED(event) )
+{
+ m_music_model->AddToClassical( "Kleine Nachtmusik", "Wolfgang Mozart", 1787 );
+}
+
+void MyFrame::OnDeleteMusic( wxCommandEvent& WXUNUSED(event) )
+{
+ wxDataViewItemArray items;
+ int len = m_ctrl[0]->GetSelections( items );
+ for( int i = 0; i < len; i ++ )
+ if (items[i].IsOk())
+ m_music_model->Delete( items[i] );
+}
+
+void MyFrame::OnDeleteYear( wxCommandEvent& WXUNUSED(event) )
+{
+ m_ctrl[0]->DeleteColumn( m_ctrl[0]->GetColumn( 2 ) );
+ FindWindow( ID_DELETE_YEAR )->Disable();
+}
+
+void MyFrame::OnSelectNinth( wxCommandEvent& WXUNUSED(event) )
+{
+ if (!m_music_model->GetNinthItem().IsOk())
+ {
+ wxLogError( "Cannot select the ninth symphony: it was removed!" );
+ return;
+ }
+
+ m_ctrl[0]->Select( m_music_model->GetNinthItem() );
+}
+
+void MyFrame::OnCollapse( wxCommandEvent& WXUNUSED(event) )
+{
+ wxDataViewItem item = m_ctrl[0]->GetSelection();
+ if (item.IsOk())
+ m_ctrl[0]->Collapse( item );
+}
+
+void MyFrame::OnExpand( wxCommandEvent& WXUNUSED(event) )
+{
+ wxDataViewItem item = m_ctrl[0]->GetSelection();
+ if (item.IsOk())
+ m_ctrl[0]->Expand( item );
+}
+
+void MyFrame::OnValueChanged( wxDataViewEvent &event )
+{
+ if (!m_log)
+ return;
+
+ wxLogMessage( "wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, Item Id: %d; Column: %d",
+ event.GetItem().GetID(), event.GetColumn() );
+}
+
+void MyFrame::OnActivated( wxDataViewEvent &event )
+{
+ if(!m_log)
+ return;
+
+ wxString title = m_music_model->GetTitle( event.GetItem() );
+ wxLogMessage( "wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, Item: %s", title );
+
+ if (m_ctrl[0]->IsExpanded( event.GetItem() ))
+ wxLogMessage( "Item: %s is expanded", title );
+}
+
+void MyFrame::OnSelectionChanged( wxDataViewEvent &event )
+{
+ if(!m_log)
+ return;
+
+ wxString title = m_music_model->GetTitle( event.GetItem() );
+ if (title.empty())
+ title = "None";
+
+ wxLogMessage( "wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, First selected Item: %s", title );
+}
+
+void MyFrame::OnExpanding( wxDataViewEvent &event )