From 682cb8355cc898278adb25ed41b107602e8eb429 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 21 Aug 2020 02:15:57 +0200 Subject: [PATCH] Replace "sendEvent" parameter in wxGridSelection with "eventType" Instead of just passing a boolean flag indicating whether wxEVT_GRID_RANGE_SELECTED should be sent, pass wxEventType to send, with wxEVT_NULL being interpreted as "don't send anything". No real changes yet, but this will allow using the existing functions to send wxEVT_GRID_RANGE_SELECTING and not only SELECTED in the upcoming commits. --- include/wx/generic/gridsel.h | 13 ++++++++----- src/generic/gridsel.cpp | 17 +++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/wx/generic/gridsel.h b/include/wx/generic/gridsel.h index 04399e4cd4..a39a42e128 100644 --- a/include/wx/generic/gridsel.h +++ b/include/wx/generic/gridsel.h @@ -21,6 +21,8 @@ typedef wxVector wxVectorGridBlockCoords; +// Note: for all eventType arguments of the methods of this class wxEVT_NULL +// may be passed to forbid events generation completely. class WXDLLIMPEXP_CORE wxGridSelection { public: @@ -41,15 +43,15 @@ public: void SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol, const wxKeyboardState& kbd = wxKeyboardState(), - bool sendEvent = true ); + wxEventType eventType = wxEVT_GRID_RANGE_SELECTED); void SelectBlock(const wxGridCellCoords& topLeft, const wxGridCellCoords& bottomRight, const wxKeyboardState& kbd = wxKeyboardState(), - bool sendEvent = true ) + wxEventType eventType = wxEVT_GRID_RANGE_SELECTED) { SelectBlock(topLeft.GetRow(), topLeft.GetCol(), bottomRight.GetRow(), bottomRight.GetCol(), - kbd, sendEvent); + kbd, eventType); } // This function replaces all the existing selected blocks (which become @@ -58,7 +60,7 @@ public: void DeselectBlock(const wxGridBlockCoords& block, const wxKeyboardState& kbd = wxKeyboardState(), - bool sendEvent = true ); + wxEventType eventType = wxEVT_GRID_RANGE_SELECTED); // Note that this method refreshes the previously selected blocks and sends // an event about the selection change. @@ -121,7 +123,8 @@ private: // Really select the block and don't check for the current selection mode. void Select(const wxGridBlockCoords& block, - const wxKeyboardState& kbd, bool sendEvent); + const wxKeyboardState& kbd, + wxEventType eventType); // Ensure that the new "block" becomes part of "blocks", adding it to them // if necessary and, if we do it, also removing any existing elements of diff --git a/src/generic/gridsel.cpp b/src/generic/gridsel.cpp index 39323a5ea8..4ab51f784d 100644 --- a/src/generic/gridsel.cpp +++ b/src/generic/gridsel.cpp @@ -182,7 +182,7 @@ void wxGridSelection::SelectCol(int col, const wxKeyboardState& kbd) void wxGridSelection::SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol, const wxKeyboardState& kbd, - bool sendEvent ) + wxEventType eventType ) { // Fix the coordinates of the block if needed. int allowed = -1; @@ -224,7 +224,7 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol, return; Select(wxGridBlockCoords(topRow, leftCol, bottomRow, rightCol).Canonicalize(), - kbd, sendEvent); + kbd, eventType); } void @@ -247,7 +247,7 @@ wxGridSelection::SelectAll() void wxGridSelection::DeselectBlock(const wxGridBlockCoords& block, const wxKeyboardState& kbd, - bool sendEvent) + wxEventType eventType) { const wxGridBlockCoords canonicalizedBlock = block.Canonicalize(); @@ -361,10 +361,10 @@ wxGridSelection::DeselectBlock(const wxGridBlockCoords& block, refBlock.GetBottomRow(), refBlock.GetRightCol()); } - if ( sendEvent ) + if ( eventType != wxEVT_NULL ) { wxGridRangeSelectEvent gridEvt(m_grid->GetId(), - wxEVT_GRID_RANGE_SELECTED, + eventType, m_grid, refBlock.GetTopLeft(), refBlock.GetBottomRight(), @@ -818,7 +818,8 @@ wxArrayInt wxGridSelection::GetColSelection() const void wxGridSelection::Select(const wxGridBlockCoords& block, - const wxKeyboardState& kbd, bool sendEvent) + const wxKeyboardState& kbd, + wxEventType eventType) { if (m_grid->GetNumberRows() == 0 || m_grid->GetNumberCols() == 0) return; @@ -832,10 +833,10 @@ wxGridSelection::Select(const wxGridBlockCoords& block, } // Send Event, if not disabled. - if ( sendEvent ) + if ( eventType != wxEVT_NULL ) { wxGridRangeSelectEvent gridEvt( m_grid->GetId(), - wxEVT_GRID_RANGE_SELECTED, + eventType, m_grid, block.GetTopLeft(), block.GetBottomRight(),