X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ecad59d882da1482097248047152ea5dc0ec3763..5078fef715268169f8e1ab0c58dd983acb8767e3:/samples/dataview/dataview.cpp diff --git a/samples/dataview/dataview.cpp b/samples/dataview/dataview.cpp index e81528961d..cf7f30e41c 100644 --- a/samples/dataview/dataview.cpp +++ b/samples/dataview/dataview.cpp @@ -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 )