]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dataview/dataview.cpp
build a 2.9.x windows setup file and chm and htb sets of docs
[wxWidgets.git] / samples / dataview / dataview.cpp
index e81528961dab14dfe360be5de7f4284987c5e386..cf7f30e41c6aaa503e3dc419902e48b06dd81e20 100644 (file)
@@ -98,6 +98,7 @@ public:     // event handlers
     void OnCollapsed( wxDataViewEvent &event );
     void OnSelectionChanged( wxDataViewEvent &event );
 
+    void OnStartEditing( wxDataViewEvent &event );
     void OnEditingStarted( wxDataViewEvent &event );
     void OnEditingDone( wxDataViewEvent &event );
 
@@ -287,6 +288,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_DATAVIEW_ITEM_COLLAPSED(ID_MUSIC_CTRL, MyFrame::OnCollapsed)
     EVT_DATAVIEW_SELECTION_CHANGED(ID_MUSIC_CTRL, MyFrame::OnSelectionChanged)
 
+    EVT_DATAVIEW_ITEM_START_EDITING(ID_MUSIC_CTRL, MyFrame::OnStartEditing)
     EVT_DATAVIEW_ITEM_EDITING_STARTED(ID_MUSIC_CTRL, MyFrame::OnEditingStarted)
     EVT_DATAVIEW_ITEM_EDITING_DONE(ID_MUSIC_CTRL, MyFrame::OnEditingDone)
 
@@ -433,7 +435,7 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
 
     mainSizer->Add( m_notebook, 1, wxGROW );
     mainSizer->Add( m_log, 0, wxGROW );
-
+    
     SetSizerAndFit(mainSizer);
 }
 
@@ -842,6 +844,20 @@ void MyFrame::OnExpanding( wxDataViewEvent &event )
 }
 
 
+void MyFrame::OnStartEditing( wxDataViewEvent &event )
+{
+    wxString artist = m_music_model->GetArtist( event.GetItem() );
+    if (artist == "Ludwig van Beethoven")
+    {
+        event.Veto();
+        
+        if (!m_log)
+           return;
+           
+        wxLogMessage( "wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING vetoed, Item: %s", artist );
+    }
+}
+
 void MyFrame::OnEditingStarted( wxDataViewEvent &event )
 {
     if (!m_log)
@@ -915,6 +931,7 @@ void MyFrame::OnHeaderClick( wxDataViewEvent &event )
     int pos = m_ctrl[0]->GetColumnPosition( event.GetDataViewColumn() );
 
     wxLogMessage( "wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, Column position: %d", pos );
+    wxLogMessage( "Column width: %d", event.GetDataViewColumn()->GetWidth() );
 }
 
 void MyFrame::OnHeaderRightClick( wxDataViewEvent &event )