Also rename wxGridSelection::ExtendOrCreateCurrentBlock()

This function finally doesn't ever create a new block, except for the
trivial case when there is no current block, so rename it to a simpler
and more clear name.

No real changes.
This commit is contained in:
Vadim Zeitlin
2020-04-12 02:42:37 +02:00
parent 30eaa28de5
commit b98f439686
3 changed files with 23 additions and 24 deletions

View File

@@ -67,9 +67,10 @@ public:
void UpdateRows( size_t pos, int numRows );
void UpdateCols( size_t pos, int numCols );
// Extend (or shrink) the current selection block to the one specified by
// the start and end coordinates of its opposite corners (which don't have
// to be in top/bottom left/right order).
// Extend (or shrink) the current selection block (creating it if
// necessary, i.e. if there is no selection at all currently) to the one
// specified by the start and end coordinates of its opposite corners
// (which don't have to be in top/bottom left/right order).
//
// Note that blockStart is equal to wxGrid::m_currentCellCoords almost
// always, but not always (the exception is when we scrolled out from
@@ -80,9 +81,9 @@ public:
// Both components of both blockStart and blockEnd must be valid.
//
// Return true if the current block was actually changed.
bool ExtendOrCreateCurrentBlock(const wxGridCellCoords& blockStart,
const wxGridCellCoords& blockEnd,
const wxKeyboardState& kbd);
bool ExtendCurrentBlock(const wxGridCellCoords& blockStart,
const wxGridCellCoords& blockEnd,
const wxKeyboardState& kbd);
// Return the row of the current selection block if it exists and we can

View File

@@ -3675,7 +3675,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event, wxGridRowLabelWindo
if ( (row = YToRow( pos.y )) >= 0 )
{
m_selection->ExtendOrCreateCurrentBlock(
m_selection->ExtendCurrentBlock(
wxGridCellCoords(m_currentCellCoords.GetRow(), 0),
wxGridCellCoords(row, GetNumberCols() - 1),
event);
@@ -3728,7 +3728,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event, wxGridRowLabelWindo
{
// Continue editing the current selection and don't
// move the grid cursor.
m_selection->ExtendOrCreateCurrentBlock
m_selection->ExtendCurrentBlock
(
wxGridCellCoords(m_currentCellCoords.GetRow(), 0),
wxGridCellCoords(row, GetNumberCols() - 1),
@@ -4006,7 +4006,7 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event, wxGridColLabelWindo
if ( !m_selection || m_numRows == 0 || m_numCols == 0 )
break;
m_selection->ExtendOrCreateCurrentBlock(
m_selection->ExtendCurrentBlock(
wxGridCellCoords(0, m_currentCellCoords.GetCol()),
wxGridCellCoords(GetNumberRows() - 1, col),
event);
@@ -4126,7 +4126,7 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event, wxGridColLabelWindo
{
// Continue editing the current selection and don't
// move the grid cursor.
m_selection->ExtendOrCreateCurrentBlock
m_selection->ExtendCurrentBlock
(
wxGridCellCoords(0, m_currentCellCoords.GetCol()),
wxGridCellCoords(GetNumberRows() - 1, col),
@@ -4490,7 +4490,7 @@ wxGrid::DoGridCellDrag(wxMouseEvent& event,
// Edit the current selection block independently of the modifiers state.
if ( m_selection )
m_selection->ExtendOrCreateCurrentBlock(m_currentCellCoords, coords, event);
m_selection->ExtendCurrentBlock(m_currentCellCoords, coords, event);
return performDefault;
}
@@ -4535,9 +4535,7 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
{
if ( m_selection )
{
m_selection->ExtendOrCreateCurrentBlock(m_currentCellCoords,
coords,
event);
m_selection->ExtendCurrentBlock(m_currentCellCoords, coords, event);
MakeCellVisible(coords);
}
}
@@ -5789,7 +5787,7 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
if ( event.ShiftDown() )
{
if ( m_selection )
m_selection->ExtendOrCreateCurrentBlock(
m_selection->ExtendCurrentBlock(
m_currentCellCoords,
wxGridCellCoords(row, col),
event);
@@ -7978,9 +7976,9 @@ wxGrid::DoMoveCursor(const wxKeyboardState& kbdState,
diroper.Advance(coords);
if ( m_selection->ExtendOrCreateCurrentBlock(m_currentCellCoords,
coords,
kbdState) )
if ( m_selection->ExtendCurrentBlock(m_currentCellCoords,
coords,
kbdState) )
{
// We want to show a line (a row or a column), not the end of
// the selection block. And do it only if the selection block
@@ -8129,9 +8127,9 @@ wxGrid::DoMoveCursorByBlock(const wxKeyboardState& kbdState,
{
if ( m_selection )
{
if ( m_selection->ExtendOrCreateCurrentBlock(m_currentCellCoords,
coords,
kbdState) )
if ( m_selection->ExtendCurrentBlock(m_currentCellCoords,
coords,
kbdState) )
{
// We want to show a line (a row or a column), not the end of
// the selection block. And do it only if the selection block

View File

@@ -482,9 +482,9 @@ void wxGridSelection::UpdateCols( size_t pos, int numCols )
}
}
bool wxGridSelection::ExtendOrCreateCurrentBlock(const wxGridCellCoords& blockStart,
const wxGridCellCoords& blockEnd,
const wxKeyboardState& kbd)
bool wxGridSelection::ExtendCurrentBlock(const wxGridCellCoords& blockStart,
const wxGridCellCoords& blockEnd,
const wxKeyboardState& kbd)
{
wxASSERT( blockStart.GetRow() != -1 && blockStart.GetCol() != -1 &&
blockEnd.GetRow() != -1 && blockEnd.GetCol() != -1 );