if ( event.Dragging() )
{
m_isDragging = TRUE;
-
if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
{
+ // Hide the edit control, so it
+ // won't interfer with drag-shrinking.
+ if ( IsCellEditControlEnabled() )
+ HideCellEditControl();
if ( coords != wxGridNoCellCoords )
{
if ( !IsSelection() )
}
else
{
- if ( !IsInSelection( coords ) )
- SelectBlock( m_currentCellCoords, coords );
+ SelectBlock( m_currentCellCoords, coords );
}
}
}
{
SendEvent( EVT_GRID_RANGE_SELECT, -1, -1, event );
}
+ // Show the edit control, if it has
+ // been hidden for drag-shrinking.
+ if ( IsCellEditControlEnabled() )
+ ShowCellEditControl();
}
m_dragLastPos = -1;
void wxGrid::SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol )
{
int temp;
+ bool changed = false;
+ wxGridCellCoords updateTopLeft, updateBottomRight;
if ( topRow > bottomRow )
{
leftCol = rightCol;
rightCol = temp;
}
-
- m_selectedTopLeft.Set( topRow, leftCol );
- m_selectedBottomRight.Set( bottomRow, rightCol );
-
- wxRect r;
- r = SelectionToDeviceRect();
- m_gridWin->Refresh( TRUE, &r );
+
+ updateTopLeft = m_selectedTopLeft;
+ if (m_selectedTopLeft != wxGridCellCoords( topRow, leftCol ) )
+ {
+ m_selectedTopLeft = wxGridCellCoords( topRow, leftCol );
+ if (updateTopLeft == wxGridNoCellCoords)
+ {
+ updateTopLeft = m_selectedTopLeft;
+ }
+ else
+ {
+ if(updateTopLeft.GetRow() > topRow)
+ updateTopLeft.SetRow(topRow);
+ if (updateTopLeft.GetCol() > leftCol)
+ updateTopLeft.SetCol(leftCol);
+ }
+ changed = true;
+ }
+
+ updateBottomRight = m_selectedBottomRight;
+ if (m_selectedBottomRight != wxGridCellCoords( bottomRow, rightCol ) )
+ {
+ m_selectedBottomRight = wxGridCellCoords( bottomRow, rightCol );
+ if (updateBottomRight == wxGridNoCellCoords)
+ {
+ updateBottomRight = m_selectedBottomRight;
+ }
+ else
+ {
+ if (updateBottomRight.GetRow() < bottomRow)
+ updateBottomRight.SetRow(bottomRow);
+ if (updateBottomRight.GetCol() < rightCol)
+ updateBottomRight.SetCol(rightCol);
+ }
+ changed = true;
+ }
+
+ if (changed)
+ {
+ wxRect r( BlockToDeviceRect( updateTopLeft, updateBottomRight ) );
+ m_gridWin->Refresh( TRUE, &r );
+ }
// only generate an event if the block is not being selected by
// dragging the mouse (in which case the event will be generated in
}
-// This function returns the rectangle that encloses the selected cells
+// This function returns the rectangle that encloses the given block
// in device coords clipped to the client size of the grid window.
//
-wxRect wxGrid::SelectionToDeviceRect()
+wxRect wxGrid::BlockToDeviceRect(const wxGridCellCoords & TopLeft,
+ const wxGridCellCoords & BottomRight)
{
wxRect rect;
wxRect cellRect;
if ( IsSelection() )
{
- cellRect = CellToRect( m_selectedTopLeft );
+ cellRect = CellToRect( TopLeft );
if ( cellRect != wxGridNoCellRect )
{
rect = cellRect;
rect = wxRect( 0, 0, 0, 0 );
}
- cellRect = CellToRect( m_selectedBottomRight );
+ cellRect = CellToRect( BottomRight );
if ( cellRect != wxGridNoCellRect )
{
rect += cellRect;