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.
This commit is contained in:
Vadim Zeitlin
2020-08-21 02:15:57 +02:00
parent 767f19cf25
commit 682cb8355c
2 changed files with 17 additions and 13 deletions

View File

@@ -21,6 +21,8 @@
typedef wxVector<wxGridBlockCoords> 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

View File

@@ -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(),