Edit the current wxGrid selection block

Really edit the current selection block instead of storing the temporary
information about the current selection and applying it on releasing Shift
key or LKM.
This commit is contained in:
Ilya Sinitsyn
2020-03-04 20:12:09 +07:00
committed by Vadim Zeitlin
parent 72e7bde306
commit e1b9ece9a4
5 changed files with 227 additions and 222 deletions

View File

@@ -2508,16 +2508,6 @@ protected:
{ return SetCurrentCell( wxGridCellCoords(row, col) ); }
// this function is called to extend the block being currently selected
// from mouse and keyboard event handlers
void UpdateBlockBeingSelected(int blockStartRow, int blockStartCol,
int blockEndRow, int blockEndCol);
void UpdateBlockBeingSelected(const wxGridCellCoords& blockStart,
const wxGridCellCoords& blockEnd)
{ UpdateBlockBeingSelected(blockStart.GetRow(), blockStart.GetCol(),
blockEnd.GetRow(), blockEnd.GetCol()); }
virtual bool ShouldScrollToChildOnFocus(wxWindow* WXUNUSED(win)) wxOVERRIDE
{ return false; }

View File

@@ -61,6 +61,28 @@ public:
void UpdateRows( size_t pos, int numRows );
void UpdateCols( size_t pos, int numCols );
// Extend (or shrink) the current selection block or select a new one.
// blockStart and blockEnd specifies the opposite corners of the currently
// edited selection block. In almost all cases blockStart equals to
// wxGrid::m_currentCellCoords (the exception is when we scrolled out from
// the top of the grid and select a column or scrolled right and select
// a row: in this case the lowest visible row/column will be set as
// current, not the first one). If the row or the column component of
// blockEnd parametr has value of -1, it means that the corresponding
// component of the current block should not be changed.
// Return true if the current block was actually changed or created.
bool ExtendOrCreateCurrentBlock(const wxGridCellCoords& blockStart,
const wxGridCellCoords& blockEnd,
const wxKeyboardState& kbd);
// Return the row of the current selection block if it exists and we can
// edit the block vertically. Otherwise return -1.
int GetCurrentBlockCornerRow() const;
// Return the column of the current selection block if it exists and we can
// edit the block horizontally. Otherwise return -1.
int GetCurrentBlockCornerCol() const;
wxGridCellCoordsArray GetCellSelection() const;
wxGridCellCoordsArray GetBlockSelectionTopLeft() const;
wxGridCellCoordsArray GetBlockSelectionBottomRight() const;

View File

@@ -793,6 +793,19 @@ public:
// boundary, i.e. is the first/last row/column
virtual bool IsAtBoundary(const wxGridCellCoords& coords) const = 0;
// Check if the component of this point in our direction is
// valid, i.e. not -1
bool IsValid(const wxGridCellCoords& coords) const
{
return m_oper.Select(coords) != -1;
}
// Make the coordinates with the other component value of -1.
wxGridCellCoords MakeWholeLineCoords(const wxGridCellCoords& coords) const
{
return m_oper.MakeCoords(m_oper.Select(coords), -1);
}
// Increment the component of this point in our direction
virtual void Advance(wxGridCellCoords& coords) const = 0;