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")
|
wxDEPRECATED_MSG("Pass the argument to the ctor instead")
|
||||||
void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
|
void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
|
||||||
wxDEPRECATED_MSG("Pass the argument to the ctor instead")
|
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; }
|
void SetItem( const wxDataViewItem &item ) { m_item = item; }
|
||||||
#endif // WXWIN_COMPATIBILITY_3_0
|
#endif // WXWIN_COMPATIBILITY_3_0
|
||||||
|
|
||||||
|
void SetColumn( int col ) { m_col = col; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxDataViewItem m_item;
|
wxDataViewItem m_item;
|
||||||
int m_col;
|
int m_col;
|
||||||
|
@@ -3648,8 +3648,8 @@ public:
|
|||||||
Process a @c wxEVT_DATAVIEW_COLUMN_SORTED event.
|
Process a @c wxEVT_DATAVIEW_COLUMN_SORTED event.
|
||||||
@event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
|
@event{EVT_DATAVIEW_COLUMN_REORDERED(id, func)}
|
||||||
Process a @c wxEVT_DATAVIEW_COLUMN_REORDERED event.
|
Process a @c wxEVT_DATAVIEW_COLUMN_REORDERED event.
|
||||||
Currently this event is only generated when using the native OS X
|
Currently this event is not generated when using the native GTK+
|
||||||
version.
|
version of the control.
|
||||||
@event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
|
@event{EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, func)}
|
||||||
Process a @c wxEVT_DATAVIEW_ITEM_BEGIN_DRAG event.
|
Process a @c wxEVT_DATAVIEW_ITEM_BEGIN_DRAG event.
|
||||||
@event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
|
@event{EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, func)}
|
||||||
@@ -3675,6 +3675,9 @@ public:
|
|||||||
/**
|
/**
|
||||||
Returns the position of the column in the control or -1
|
Returns the position of the column in the control or -1
|
||||||
if no column field was set by the event emitter.
|
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;
|
int GetColumn() const;
|
||||||
|
|
||||||
|
@@ -133,6 +133,7 @@ private:
|
|||||||
void OnHeaderClickList( wxDataViewEvent &event );
|
void OnHeaderClickList( wxDataViewEvent &event );
|
||||||
void OnSorted( wxDataViewEvent &event );
|
void OnSorted( wxDataViewEvent &event );
|
||||||
void OnSortedList( wxDataViewEvent &event );
|
void OnSortedList( wxDataViewEvent &event );
|
||||||
|
void OnColumnReordered( wxDataViewEvent &event);
|
||||||
|
|
||||||
void OnContextMenu( 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_HEADER_RIGHT_CLICK(ID_MUSIC_CTRL, MyFrame::OnHeaderRightClick)
|
||||||
EVT_DATAVIEW_COLUMN_SORTED(ID_MUSIC_CTRL, MyFrame::OnSorted)
|
EVT_DATAVIEW_COLUMN_SORTED(ID_MUSIC_CTRL, MyFrame::OnSorted)
|
||||||
EVT_DATAVIEW_COLUMN_SORTED(ID_ATTR_CTRL, MyFrame::OnSortedList)
|
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_COLUMN_HEADER_CLICK(ID_ATTR_CTRL, MyFrame::OnHeaderClickList)
|
||||||
|
|
||||||
EVT_DATAVIEW_ITEM_CONTEXT_MENU(ID_MUSIC_CTRL, MyFrame::OnContextMenu)
|
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 );
|
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*/)
|
void MyFrame::OnSortedList( wxDataViewEvent &/*event*/)
|
||||||
{
|
{
|
||||||
wxVector<wxDataViewColumn *> const columns = m_ctrl[1]->GetSortingColumns();
|
wxVector<wxDataViewColumn *> const columns = m_ctrl[1]->GetSortingColumns();
|
||||||
|
@@ -5512,13 +5512,16 @@ unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const
|
|||||||
return max_width;
|
return max_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataViewCtrl::ColumnMoved(wxDataViewColumn * WXUNUSED(col),
|
void wxDataViewCtrl::ColumnMoved(wxDataViewColumn *col, unsigned int new_pos)
|
||||||
unsigned int WXUNUSED(new_pos))
|
|
||||||
{
|
{
|
||||||
// do _not_ reorder m_cols elements here, they should always be in the
|
// 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
|
// order in which columns were added, we only display the columns in
|
||||||
// different order
|
// different order
|
||||||
m_clientArea->UpdateDisplay();
|
m_clientArea->UpdateDisplay();
|
||||||
|
|
||||||
|
wxDataViewEvent event(wxEVT_DATAVIEW_COLUMN_REORDERED, this, col);
|
||||||
|
event.SetColumn(new_pos);
|
||||||
|
ProcessWindowEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
|
bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
|
||||||
|
@@ -1881,6 +1881,7 @@ outlineView:(NSOutlineView*)outlineView
|
|||||||
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
|
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
|
||||||
|
|
||||||
wxDataViewEvent event(wxEVT_DATAVIEW_COLUMN_REORDERED, dvc, col);
|
wxDataViewEvent event(wxEVT_DATAVIEW_COLUMN_REORDERED, dvc, col);
|
||||||
|
event.SetColumn(newColumnPosition);
|
||||||
dvc->GetEventHandler()->ProcessEvent(event);
|
dvc->GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user