Unify wxGrid code for processing row and column mouse events

Reuse the same code for handling mouse events for both rows and columns
instead of duplicating almost (but not quite) the same code for both of
them.

As part of resolving the inconsistencies between the two versions, add
wxEVT_GRID_ROW_AUTO_SIZE corresponding to the existing event with the
same name for the columns.

Closes #22380.
This commit is contained in:
DietmarSchwertberger
2022-04-30 21:59:36 +02:00
committed by Vadim Zeitlin
parent 1660584a45
commit ec737396d8
5 changed files with 389 additions and 593 deletions

View File

@@ -2802,8 +2802,7 @@ protected:
// Index of the row or column being drag-moved or -1 if there is no move
// operation in progress.
int m_dragMoveRow;
int m_dragMoveCol;
int m_dragMoveRowOrCol;
// Last horizontal mouse position while drag-moving a column.
int m_dragLastPos;
@@ -2885,10 +2884,10 @@ protected:
EventResult SendEvent(wxEventType evtType, const wxString& s = wxString())
{ return SendEvent(evtType, m_currentCellCoords, s); }
// send wxEVT_GRID_{ROW,COL}_SIZE or wxEVT_GRID_COL_AUTO_SIZE, return true
// send wxEVT_GRID_{ROW,COL}_SIZE or wxEVT_GRID_{ROW,COL}_AUTO_SIZE, return true
// if the event was processed, false otherwise
bool SendGridSizeEvent(wxEventType type,
int row, int col,
int rowOrCol,
const wxMouseEvent& mouseEv);
void OnSize( wxSizeEvent& );
@@ -2906,6 +2905,7 @@ protected:
{ return false; }
friend class WXDLLIMPEXP_FWD_CORE wxGridSelection;
friend class wxGridOperations;
friend class wxGridRowOperations;
friend class wxGridColumnOperations;
@@ -3047,19 +3047,18 @@ private:
void ProcessGridCellMouseEvent(wxMouseEvent& event, wxGridWindow* gridWindow);
// process mouse events in the row/column labels/corner windows
void ProcessRowLabelMouseEvent(wxMouseEvent& event,
wxGridRowLabelWindow* rowLabelWin);
void ProcessColLabelMouseEvent(wxMouseEvent& event,
wxGridColLabelWindow* colLabelWin);
void ProcessRowColLabelMouseEvent(const wxGridOperations &oper,
wxMouseEvent& event,
wxGridSubwindow* rowLabelWin);
void ProcessCornerLabelMouseEvent(wxMouseEvent& event);
void HandleRowAutosize(int col, const wxMouseEvent& event);
void HandleColumnAutosize(int col, const wxMouseEvent& event);
void DoColHeaderClick(int col);
void DoStartResizeRowOrCol(int col, int size);
void DoStartMoveRow(int col);
void DoStartMoveCol(int col);
void DoStartMoveRowOrCol(int col);
// These functions should only be called when actually resizing/moving,
// i.e. m_dragRowOrCol and m_dragMoveCol, respectively, are valid.
@@ -3486,6 +3485,7 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_LABEL_RIGHT_CLICK, wxGrid
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_LABEL_LEFT_DCLICK, wxGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_LABEL_RIGHT_DCLICK, wxGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_ROW_SIZE, wxGridSizeEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_ROW_AUTO_SIZE, wxGridSizeEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_COL_SIZE, wxGridSizeEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_COL_AUTO_SIZE, wxGridSizeEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_RANGE_SELECTING, wxGridRangeSelectEvent );