diff --git a/include/wx/dataview.h b/include/wx/dataview.h index c94c8fe3c1..79b200cc09 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -903,11 +903,11 @@ public: wxDEPRECATED_MSG("Pass the argument to the ctor instead") void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; } wxDEPRECATED_MSG("Pass the argument to the ctor instead") - void SetColumn( int col ) { m_col = col; } - wxDEPRECATED_MSG("Pass the argument to the ctor instead") void SetItem( const wxDataViewItem &item ) { m_item = item; } #endif // WXWIN_COMPATIBILITY_3_0 + void SetColumn( int col ) { m_col = col; } + protected: wxDataViewItem m_item; int m_col; diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index 8e3312c126..cbb5ba2566 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -3648,8 +3648,8 @@ public: Process a @c wxEVT_DATAVIEW_COLUMN_SORTED event. @event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)} Process a @c wxEVT_DATAVIEW_COLUMN_REORDERED event. - Currently this event is only generated when using the native OS X - version. + Currently this event is not generated when using the native GTK+ + version of the control. @event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)} Process a @c wxEVT_DATAVIEW_ITEM_BEGIN_DRAG event. @event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)} @@ -3675,6 +3675,9 @@ public: /** Returns the position of the column in the control or -1 if no column field was set by the event emitter. + + For wxEVT_DATAVIEW_COLUMN_REORDERED, this is the new position of the + column. */ int GetColumn() const; diff --git a/samples/dataview/dataview.cpp b/samples/dataview/dataview.cpp index 26773c624d..64e89e7b71 100644 --- a/samples/dataview/dataview.cpp +++ b/samples/dataview/dataview.cpp @@ -133,6 +133,7 @@ private: void OnHeaderClickList( wxDataViewEvent &event ); void OnSorted( wxDataViewEvent &event ); void OnSortedList( wxDataViewEvent &event ); + void OnColumnReordered( wxDataViewEvent &event); void OnContextMenu( wxDataViewEvent &event ); @@ -423,6 +424,7 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK(ID_MUSIC_CTRL, MyFrame::OnHeaderRightClick) EVT_DATAVIEW_COLUMN_SORTED(ID_MUSIC_CTRL, MyFrame::OnSorted) EVT_DATAVIEW_COLUMN_SORTED(ID_ATTR_CTRL, MyFrame::OnSortedList) + EVT_DATAVIEW_COLUMN_REORDERED(wxID_ANY, MyFrame::OnColumnReordered) EVT_DATAVIEW_COLUMN_HEADER_CLICK(ID_ATTR_CTRL, MyFrame::OnHeaderClickList) EVT_DATAVIEW_ITEM_CONTEXT_MENU(ID_MUSIC_CTRL, MyFrame::OnContextMenu) @@ -1290,6 +1292,19 @@ void MyFrame::OnHeaderRightClick( wxDataViewEvent &event ) wxLogMessage( "wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, Column position: %d", pos ); } +void MyFrame::OnColumnReordered(wxDataViewEvent& event) +{ + wxDataViewColumn* const col = event.GetDataViewColumn(); + if ( !col ) + { + wxLogError("Unknown column reordered?"); + return; + } + + wxLogMessage("wxEVT_DATAVIEW_COLUMN_REORDERED: \"%s\" is now at position %d", + col->GetTitle(), event.GetColumn()); +} + void MyFrame::OnSortedList( wxDataViewEvent &/*event*/) { wxVector const columns = m_ctrl[1]->GetSortingColumns(); diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 298ff6bcb8..54d745f6cf 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -5512,13 +5512,16 @@ unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const return max_width; } -void wxDataViewCtrl::ColumnMoved(wxDataViewColumn * WXUNUSED(col), - unsigned int WXUNUSED(new_pos)) +void wxDataViewCtrl::ColumnMoved(wxDataViewColumn *col, unsigned int new_pos) { // do _not_ reorder m_cols elements here, they should always be in the // order in which columns were added, we only display the columns in // different order m_clientArea->UpdateDisplay(); + + wxDataViewEvent event(wxEVT_DATAVIEW_COLUMN_REORDERED, this, col); + event.SetColumn(new_pos); + ProcessWindowEvent(event); } bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column ) diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index 0b1ee6b419..abaf02276d 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -1881,6 +1881,7 @@ outlineView:(NSOutlineView*)outlineView wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl(); wxDataViewEvent event(wxEVT_DATAVIEW_COLUMN_REORDERED, dvc, col); + event.SetColumn(newColumnPosition); dvc->GetEventHandler()->ProcessEvent(event); }