Send wxEVT_DATAVIEW_COLUMN_REORDERED in generic wxDataViewCtrl
Simply translate wxEVT_HEADER_END_REORDER into this event, which was previously only sent by the macOS version. GtkTreeView doesn't seem to support column drag-and-drop at all, so this event is still never generated by wxGTK. Closes #14297.
This commit is contained in:
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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<wxDataViewColumn *> const columns = m_ctrl[1]->GetSortingColumns();
|
||||
|
@@ -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 )
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user