Remove the selecting mode flag from wxGridSelection

Remove m_isSelecting and StartSelecting() from wxGridSelection to avoid
inconsistency of wxGridSelection selecting mode state with wxGrid state,
as wxGrid already has m_isDragging field which tells it if the selection
state is final or not.

Instead, just allow wxGrid to specify the event to send from
ExtendCurrentBlock().

We still need a separate EndSelecting() for sending the final
wxEVT_GRID_RANGE_SELECTED event, but send it only for the last selection
block, and not all the selected blocks, as this makes more sense (there
should be one SELECTED event for each block and it was already sent for
the other blocks before) and is consistent with the events generated
when performing the same actions from keyboard.
This commit is contained in:
Ilya Sinitsyn
2020-08-18 00:30:00 +07:00
committed by Vadim Zeitlin
parent decc255846
commit 0a2c62fc5c
3 changed files with 34 additions and 52 deletions

View File

@@ -82,10 +82,16 @@ public:
//
// Both components of both blockStart and blockEnd must be valid.
//
// This function sends an event notifying about the selection change using
// the provided event type, which is wxEVT_GRID_RANGE_SELECTED by default,
// but may also be wxEVT_GRID_RANGE_SELECTING, when the selection is not
// final yet.
//
// Return true if the current block was actually changed.
bool ExtendCurrentBlock(const wxGridCellCoords& blockStart,
const wxGridCellCoords& blockEnd,
const wxKeyboardState& kbd);
const wxKeyboardState& kbd,
wxEventType eventType = wxEVT_GRID_RANGE_SELECTED);
// Return the coordinates of the cell from which the selection should
@@ -103,9 +109,8 @@ public:
wxVectorGridBlockCoords& GetBlocks() { return m_selection; }
void StartSelecting();
void EndSelecting();
private:
void SelectBlockNoEvent(const wxGridBlockCoords& block)
{
@@ -141,7 +146,6 @@ private:
wxGrid *m_grid;
wxGrid::wxGridSelectionModes m_selectionMode;
bool m_isSelecting;
wxDECLARE_NO_COPY_CLASS(wxGridSelection);
};