if ( IsVisible( m_currentCellCoords, FALSE ) )
{
wxRect r;
- r = BlockToDeviceRect(m_currentCellCoords, coords);
+ r = BlockToDeviceRect(m_currentCellCoords, m_currentCellCoords);
if ( !m_gridLinesEnabled )
{
r.x--;
r.height++;
}
- wxGridCellCoordsArray cells = CalcCellsExposed( r );
+ wxGridCellCoordsArray cells = CalcCellsExposed( r );
// Otherwise refresh redraws the highlight!
m_currentCellCoords = coords;
updateTopLeft = wxGridCellCoords( topRow, leftCol );
updateBottomRight = wxGridCellCoords( bottomRow, rightCol );
- if ( m_selectingTopLeft != updateTopLeft ||
- m_selectingBottomRight != updateBottomRight )
+ // First the case that we selected a completely new area
+ if ( m_selectingTopLeft == wxGridNoCellCoords ||
+ m_selectingBottomRight == wxGridNoCellCoords )
+ {
+ wxRect rect;
+ rect = BlockToDeviceRect( wxGridCellCoords ( topRow, leftCol ),
+ wxGridCellCoords ( bottomRow, rightCol ) );
+ m_gridWin->Refresh( FALSE, &rect );
+ }
+ // Now handle changing an existing selection area.
+ else if ( m_selectingTopLeft != updateTopLeft ||
+ m_selectingBottomRight != updateBottomRight )
{
// Compute two optimal update rectangles:
// Either one rectangle is a real subset of the
if ( oldLeft < leftCol )
{
+ // Refresh the newly selected or deselected
+ // area to the left of the old or new selection.
need_refresh[0] = TRUE;
rect[0] = BlockToDeviceRect( wxGridCellCoords ( oldTop,
oldLeft ),
if ( oldTop < topRow )
{
+ // Refresh the newly selected or deselected
+ // area above the old or new selection.
need_refresh[1] = TRUE;
rect[1] = BlockToDeviceRect( wxGridCellCoords ( oldTop,
leftCol ),
if ( oldRight > rightCol )
{
+ // Refresh the newly selected or deselected
+ // area to the right of the old or new selection.
need_refresh[2] = TRUE;
rect[2] = BlockToDeviceRect( wxGridCellCoords ( oldTop,
rightCol + 1 ),
if ( oldBottom > bottomRow )
{
+ // Refresh the newly selected or deselected
+ // area below the old or new selection.
need_refresh[3] = TRUE;
rect[3] = BlockToDeviceRect( wxGridCellCoords ( bottomRow + 1,
leftCol ),
rightCol ) );
}
-
- // Change Selection
- m_selectingTopLeft = updateTopLeft;
- m_selectingBottomRight = updateBottomRight;
-
// various Refresh() calls
for (i = 0; i < 4; i++ )
if ( need_refresh[i] && rect[i] != wxGridNoCellRect )
m_gridWin->Refresh( FALSE, &(rect[i]) );
}
-
- // never generate an event as it will be generated from
- // wxGridSelection::SelectBlock!
- // (old comment from when this was the body of SelectBlock)
+ // Change Selection
+ m_selectingTopLeft = updateTopLeft;
+ m_selectingBottomRight = updateBottomRight;
}
//
if ( cell == cells[j] )
{
marked = TRUE;
- break;;
+ break;
}
}
if (!marked)
// wxNoCellCoords, as this will confuse memory management.
if ( row >= 0 )
{
- if ( !LookupAttr(row, col, &attr) )
- {
- attr = m_table ? m_table->GetAttr(row, col , wxGridCellAttr::Any)
- : (wxGridCellAttr *)NULL;
- CacheAttr(row, col, attr);
- }
+ if ( !LookupAttr(row, col, &attr) )
+ {
+ attr = m_table ? m_table->GetAttr(row, col , wxGridCellAttr::Any)
+ : (wxGridCellAttr *)NULL;
+ CacheAttr(row, col, attr);
+ }
}
if (attr)
{
int rightCol = bottomRight.GetCol();
int bottomRow = bottomRight.GetRow();
+ if (left > right)
+ {
+ i = left;
+ left = right;
+ right = i;
+ i = leftCol;
+ leftCol=rightCol;
+ rightCol = i;
+ }
+
+ if (top > bottom)
+ {
+ i = top;
+ top = bottom;
+ bottom = i;
+ i = topRow;
+ topRow = bottomRow;
+ bottomRow = i;
+ }
+
+
for ( j = topRow; j <= bottomRow; j++ )
{
for ( i = leftCol; i <= rightCol; i++ )
if (cellRect.y + cellRect.height > bottom)
bottom = cellRect.y + cellRect.height;
}
+ else i = rightCol; // jump over inner cells.
}
}