Some refresh optimizations.

Untabified.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@17038 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Neis
2002-09-07 12:28:03 +00:00
parent be604faa7b
commit 3ed884a0b8

View File

@@ -6073,7 +6073,7 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
if ( IsVisible( m_currentCellCoords, FALSE ) ) if ( IsVisible( m_currentCellCoords, FALSE ) )
{ {
wxRect r; wxRect r;
r = BlockToDeviceRect(m_currentCellCoords, coords); r = BlockToDeviceRect(m_currentCellCoords, m_currentCellCoords);
if ( !m_gridLinesEnabled ) if ( !m_gridLinesEnabled )
{ {
r.x--; r.x--;
@@ -6136,7 +6136,17 @@ void wxGrid::HighlightBlock( int topRow, int leftCol, int bottomRow, int rightCo
updateTopLeft = wxGridCellCoords( topRow, leftCol ); updateTopLeft = wxGridCellCoords( topRow, leftCol );
updateBottomRight = wxGridCellCoords( bottomRow, rightCol ); updateBottomRight = wxGridCellCoords( bottomRow, rightCol );
if ( m_selectingTopLeft != updateTopLeft || // 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 ) m_selectingBottomRight != updateBottomRight )
{ {
// Compute two optimal update rectangles: // Compute two optimal update rectangles:
@@ -6188,6 +6198,8 @@ void wxGrid::HighlightBlock( int topRow, int leftCol, int bottomRow, int rightCo
if ( oldLeft < leftCol ) if ( oldLeft < leftCol )
{ {
// Refresh the newly selected or deselected
// area to the left of the old or new selection.
need_refresh[0] = TRUE; need_refresh[0] = TRUE;
rect[0] = BlockToDeviceRect( wxGridCellCoords ( oldTop, rect[0] = BlockToDeviceRect( wxGridCellCoords ( oldTop,
oldLeft ), oldLeft ),
@@ -6197,6 +6209,8 @@ void wxGrid::HighlightBlock( int topRow, int leftCol, int bottomRow, int rightCo
if ( oldTop < topRow ) if ( oldTop < topRow )
{ {
// Refresh the newly selected or deselected
// area above the old or new selection.
need_refresh[1] = TRUE; need_refresh[1] = TRUE;
rect[1] = BlockToDeviceRect( wxGridCellCoords ( oldTop, rect[1] = BlockToDeviceRect( wxGridCellCoords ( oldTop,
leftCol ), leftCol ),
@@ -6206,6 +6220,8 @@ void wxGrid::HighlightBlock( int topRow, int leftCol, int bottomRow, int rightCo
if ( oldRight > rightCol ) if ( oldRight > rightCol )
{ {
// Refresh the newly selected or deselected
// area to the right of the old or new selection.
need_refresh[2] = TRUE; need_refresh[2] = TRUE;
rect[2] = BlockToDeviceRect( wxGridCellCoords ( oldTop, rect[2] = BlockToDeviceRect( wxGridCellCoords ( oldTop,
rightCol + 1 ), rightCol + 1 ),
@@ -6215,6 +6231,8 @@ void wxGrid::HighlightBlock( int topRow, int leftCol, int bottomRow, int rightCo
if ( oldBottom > bottomRow ) if ( oldBottom > bottomRow )
{ {
// Refresh the newly selected or deselected
// area below the old or new selection.
need_refresh[3] = TRUE; need_refresh[3] = TRUE;
rect[3] = BlockToDeviceRect( wxGridCellCoords ( bottomRow + 1, rect[3] = BlockToDeviceRect( wxGridCellCoords ( bottomRow + 1,
leftCol ), leftCol ),
@@ -6222,20 +6240,14 @@ void wxGrid::HighlightBlock( int topRow, int leftCol, int bottomRow, int rightCo
rightCol ) ); rightCol ) );
} }
// Change Selection
m_selectingTopLeft = updateTopLeft;
m_selectingBottomRight = updateBottomRight;
// various Refresh() calls // various Refresh() calls
for (i = 0; i < 4; i++ ) for (i = 0; i < 4; i++ )
if ( need_refresh[i] && rect[i] != wxGridNoCellRect ) if ( need_refresh[i] && rect[i] != wxGridNoCellRect )
m_gridWin->Refresh( FALSE, &(rect[i]) ); m_gridWin->Refresh( FALSE, &(rect[i]) );
} }
// Change Selection
// never generate an event as it will be generated from m_selectingTopLeft = updateTopLeft;
// wxGridSelection::SelectBlock! m_selectingBottomRight = updateBottomRight;
// (old comment from when this was the body of SelectBlock)
} }
// //
@@ -6306,7 +6318,7 @@ void wxGrid::DrawGridCellArea( wxDC& dc, const wxGridCellCoordsArray& cells )
if ( cell == cells[j] ) if ( cell == cells[j] )
{ {
marked = TRUE; marked = TRUE;
break;; break;
} }
} }
if (!marked) if (!marked)
@@ -9412,6 +9424,27 @@ wxRect wxGrid::BlockToDeviceRect( const wxGridCellCoords &topLeft,
int rightCol = bottomRight.GetCol(); int rightCol = bottomRight.GetCol();
int bottomRow = bottomRight.GetRow(); 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 ( j = topRow; j <= bottomRow; j++ )
{ {
for ( i = leftCol; i <= rightCol; i++ ) for ( i = leftCol; i <= rightCol; i++ )
@@ -9429,6 +9462,7 @@ wxRect wxGrid::BlockToDeviceRect( const wxGridCellCoords &topLeft,
if (cellRect.y + cellRect.height > bottom) if (cellRect.y + cellRect.height > bottom)
bottom = cellRect.y + cellRect.height; bottom = cellRect.y + cellRect.height;
} }
else i = rightCol; // jump over inner cells.
} }
} }