Compute update rectangle only when needed [i.e. if (!m_grid->GetBatchCount())]

[Patch 882656]


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25367 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Neis
2004-01-25 14:26:06 +00:00
parent 59f098d159
commit 3665f7d07e

View File

@@ -259,10 +259,12 @@ void wxGridSelection::SelectRow( int row,
} }
// Update View: // Update View:
if ( !m_grid->GetBatchCount() )
{
wxRect r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, 0 ), wxRect r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, 0 ),
wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ) ); wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ) );
if ( !m_grid->GetBatchCount() )
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r ); ((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
}
// Send Event // Send Event
wxGridRangeSelectEvent gridEvt( m_grid->GetId(), wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
@@ -352,10 +354,12 @@ void wxGridSelection::SelectCol( int col,
} }
// Update View: // Update View:
if ( !m_grid->GetBatchCount() )
{
wxRect r = m_grid->BlockToDeviceRect( wxGridCellCoords( 0, col ), wxRect r = m_grid->BlockToDeviceRect( wxGridCellCoords( 0, col ),
wxGridCellCoords( m_grid->GetNumberRows() - 1, col ) ); wxGridCellCoords( m_grid->GetNumberRows() - 1, col ) );
if ( !m_grid->GetBatchCount() )
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r ); ((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
}
// Send Event // Send Event
wxGridRangeSelectEvent gridEvt( m_grid->GetId(), wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
@@ -494,10 +498,12 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol,
m_blockSelectionBottomRight.Add( wxGridCellCoords( bottomRow, rightCol ) ); m_blockSelectionBottomRight.Add( wxGridCellCoords( bottomRow, rightCol ) );
// Update View: // Update View:
if ( !m_grid->GetBatchCount() )
{
wxRect r = m_grid->BlockToDeviceRect( wxGridCellCoords( topRow, leftCol ), wxRect r = m_grid->BlockToDeviceRect( wxGridCellCoords( topRow, leftCol ),
wxGridCellCoords( bottomRow, rightCol ) ); wxGridCellCoords( bottomRow, rightCol ) );
if ( !m_grid->GetBatchCount() )
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r ); ((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
}
// Send Event, if not disabled. // Send Event, if not disabled.
if ( sendEvent ) if ( sendEvent )
@@ -536,10 +542,12 @@ void wxGridSelection::SelectCell( int row, int col,
m_cellSelection.Add( wxGridCellCoords( row, col ) ); m_cellSelection.Add( wxGridCellCoords( row, col ) );
// Update View: // Update View:
if ( !m_grid->GetBatchCount() )
{
wxRect r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, col ), wxRect r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, col ),
wxGridCellCoords( row, col ) ); wxGridCellCoords( row, col ) );
if ( !m_grid->GetBatchCount() )
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r ); ((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
}
// Send event // Send event
if (sendEvent) if (sendEvent)
@@ -585,12 +593,13 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
wxGridCellCoords& coords = m_cellSelection[n]; wxGridCellCoords& coords = m_cellSelection[n];
if ( row == coords.GetRow() && col == coords.GetCol() ) if ( row == coords.GetRow() && col == coords.GetCol() )
{ {
wxRect r; wxGridCellCoords coords = m_cellSelection[n];
r = m_grid->BlockToDeviceRect( m_cellSelection[n],
m_cellSelection[n] );
m_cellSelection.RemoveAt(n); m_cellSelection.RemoveAt(n);
if ( !m_grid->GetBatchCount() ) if ( !m_grid->GetBatchCount() )
{
wxRect r = m_grid->BlockToDeviceRect( coords, coords );
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r ); ((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
}
// Send event // Send event
wxGridRangeSelectEvent gridEvt( m_grid->GetId(), wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
@@ -718,11 +727,14 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
switch (m_selectionMode) switch (m_selectionMode)
{ {
case wxGrid::wxGridSelectCells: case wxGrid::wxGridSelectCells:
{
if ( !m_grid->GetBatchCount() )
{ {
r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, col ), r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, col ),
wxGridCellCoords( row, col ) ); wxGridCellCoords( row, col ) );
if ( !m_grid->GetBatchCount() )
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r ); ((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
}
wxGridRangeSelectEvent gridEvt( m_grid->GetId(), wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
wxEVT_GRID_RANGE_SELECT, wxEVT_GRID_RANGE_SELECT,
m_grid, m_grid,
@@ -735,11 +747,14 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
break; break;
} }
case wxGrid::wxGridSelectRows: case wxGrid::wxGridSelectRows:
{
if ( !m_grid->GetBatchCount() )
{ {
r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, 0 ), r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, 0 ),
wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ) ); wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ) );
if ( !m_grid->GetBatchCount() )
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r ); ((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
}
wxGridRangeSelectEvent gridEvt( m_grid->GetId(), wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
wxEVT_GRID_RANGE_SELECT, wxEVT_GRID_RANGE_SELECT,
m_grid, m_grid,
@@ -752,11 +767,14 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
break; break;
} }
case wxGrid::wxGridSelectColumns: case wxGrid::wxGridSelectColumns:
{
if ( !m_grid->GetBatchCount() )
{ {
r = m_grid->BlockToDeviceRect( wxGridCellCoords( 0, col ), r = m_grid->BlockToDeviceRect( wxGridCellCoords( 0, col ),
wxGridCellCoords( m_grid->GetNumberRows() - 1, col ) ); wxGridCellCoords( m_grid->GetNumberRows() - 1, col ) );
if ( !m_grid->GetBatchCount() )
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r ); ((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
}
wxGridRangeSelectEvent gridEvt( m_grid->GetId(), wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
wxEVT_GRID_RANGE_SELECT, wxEVT_GRID_RANGE_SELECT,
m_grid, m_grid,
@@ -774,35 +792,39 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
void wxGridSelection::ClearSelection() void wxGridSelection::ClearSelection()
{ {
size_t n; size_t n;
wxRect r;
wxGridCellCoords coords1, coords2;
// deselect all invidiual cells and update the screen // deselect all invidiual cells and update the screen
if ( m_selectionMode == wxGrid::wxGridSelectCells ) if ( m_selectionMode == wxGrid::wxGridSelectCells )
{ {
while( ( n = m_cellSelection.GetCount() ) > 0) while( ( n = m_cellSelection.GetCount() ) > 0)
{ {
wxRect r;
n--; n--;
r = m_grid->BlockToDeviceRect( m_cellSelection[n], coords1 = m_cellSelection[n];
m_cellSelection[n] );
m_cellSelection.RemoveAt(n); m_cellSelection.RemoveAt(n);
if ( !m_grid->GetBatchCount() ) if ( !m_grid->GetBatchCount() )
{
r = m_grid->BlockToDeviceRect( coords1, coords1 );
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r ); ((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
} }
} }
}
// deselect all blocks and update the screen // deselect all blocks and update the screen
while( ( n = m_blockSelectionTopLeft.GetCount() ) > 0) while( ( n = m_blockSelectionTopLeft.GetCount() ) > 0)
{ {
wxRect r;
n--; n--;
r = m_grid->BlockToDeviceRect( m_blockSelectionTopLeft[n], coords1 = m_blockSelectionTopLeft[n];
m_blockSelectionBottomRight[n] ); coords2 = m_blockSelectionBottomRight[n];
m_blockSelectionTopLeft.RemoveAt(n); m_blockSelectionTopLeft.RemoveAt(n);
m_blockSelectionBottomRight.RemoveAt(n); m_blockSelectionBottomRight.RemoveAt(n);
if ( !m_grid->GetBatchCount() ) if ( !m_grid->GetBatchCount() )
{
r = m_grid->BlockToDeviceRect( coords1, coords2 );
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r ); ((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
} }
}
// deselect all rows and update the screen // deselect all rows and update the screen
if ( m_selectionMode != wxGrid::wxGridSelectColumns ) if ( m_selectionMode != wxGrid::wxGridSelectColumns )
@@ -810,15 +832,16 @@ void wxGridSelection::ClearSelection()
while( ( n = m_rowSelection.GetCount() ) > 0) while( ( n = m_rowSelection.GetCount() ) > 0)
{ {
n--; n--;
int & row = m_rowSelection[n]; int row = m_rowSelection[n];
wxRect r;
r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, 0 ),
wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ) );
m_rowSelection.RemoveAt(n); m_rowSelection.RemoveAt(n);
if ( !m_grid->GetBatchCount() ) if ( !m_grid->GetBatchCount() )
{
r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, 0 ),
wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ) );
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r ); ((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
} }
} }
}
// deselect all columns and update the screen // deselect all columns and update the screen
if ( m_selectionMode != wxGrid::wxGridSelectRows ) if ( m_selectionMode != wxGrid::wxGridSelectRows )
@@ -826,15 +849,16 @@ void wxGridSelection::ClearSelection()
while( ( n = m_colSelection.GetCount() ) > 0) while( ( n = m_colSelection.GetCount() ) > 0)
{ {
n--; n--;
int & col = m_colSelection[n]; int col = m_colSelection[n];
wxRect r;
r = m_grid->BlockToDeviceRect( wxGridCellCoords( 0, col ),
wxGridCellCoords( m_grid->GetNumberRows() - 1, col ) );
m_colSelection.RemoveAt(n); m_colSelection.RemoveAt(n);
if ( !m_grid->GetBatchCount() ) if ( !m_grid->GetBatchCount() )
{
r = m_grid->BlockToDeviceRect( wxGridCellCoords( 0, col ),
wxGridCellCoords( m_grid->GetNumberRows() - 1, col ) );
((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r ); ((wxWindow *)m_grid->m_gridWin)->Refresh( FALSE, &r );
} }
} }
}
// One deselection event, indicating deselection of _all_ cells. // One deselection event, indicating deselection of _all_ cells.
// (No finer grained events for each of the smaller regions // (No finer grained events for each of the smaller regions