Add wxGrid::RefreshBlock() helper

This simple function combines BlockToDeviceRect() and
wxWindow::Refresh() calls and allows to avoid the ugly casts in
wxGridSelection code as well as making the code slightly shorter and
more clear.

No real changes.
This commit is contained in:
lucian-rotariu
2019-07-11 01:13:54 +02:00
committed by Vadim Zeitlin
parent cf3709147a
commit 00224e3f30
3 changed files with 40 additions and 78 deletions

View File

@@ -259,9 +259,7 @@ void wxGridSelection::SelectRow(int row, const wxKeyboardState& kbd)
// Update View:
if ( !m_grid->GetBatchCount() )
{
wxRect r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, 0 ),
wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ) );
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
m_grid->RefreshBlock(row, 0, row, m_grid->GetNumberCols() - 1);
}
// Send Event
@@ -353,9 +351,7 @@ void wxGridSelection::SelectCol(int col, const wxKeyboardState& kbd)
// Update View:
if ( !m_grid->GetBatchCount() )
{
wxRect r = m_grid->BlockToDeviceRect( wxGridCellCoords( 0, col ),
wxGridCellCoords( m_grid->GetNumberRows() - 1, col ) );
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
m_grid->RefreshBlock(0, col, m_grid->GetNumberRows() - 1, col);
}
// Send Event
@@ -572,9 +568,7 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol,
// Update View:
if ( !m_grid->GetBatchCount() )
{
wxRect r = m_grid->BlockToDeviceRect( wxGridCellCoords( topRow, leftCol ),
wxGridCellCoords( bottomRow, rightCol ) );
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
m_grid->RefreshBlock(topRow, leftCol, bottomRow, rightCol);
}
// Send Event, if not disabled.
@@ -621,10 +615,7 @@ void wxGridSelection::SelectCell( int row, int col,
// Update View:
if ( !m_grid->GetBatchCount() )
{
wxRect r = m_grid->BlockToDeviceRect(
selectedTopLeft,
selectedBottomRight );
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
m_grid->RefreshBlock(selectedTopLeft, selectedBottomRight);
}
// Send event
@@ -674,8 +665,7 @@ wxGridSelection::ToggleCellSelection(int row, int col,
m_cellSelection.RemoveAt(n);
if ( !m_grid->GetBatchCount() )
{
wxRect r = m_grid->BlockToDeviceRect( coords, coords );
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
m_grid->RefreshBlock(coords, coords);
}
// Send event
@@ -810,10 +800,7 @@ wxGridSelection::ToggleCellSelection(int row, int col,
{
if ( !m_grid->GetBatchCount() )
{
r = m_grid->BlockToDeviceRect(
wxGridCellCoords( row, col ),
wxGridCellCoords( row, col ) );
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
m_grid->RefreshBlock(row, col, row, col);
}
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
@@ -839,10 +826,7 @@ wxGridSelection::ToggleCellSelection(int row, int col,
{
if ( !m_grid->GetBatchCount() )
{
r = m_grid->BlockToDeviceRect(
wxGridCellCoords( row, colFrom ),
wxGridCellCoords( row, colTo-1 ) );
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
m_grid->RefreshBlock(row, colFrom, row, colTo - 1);
}
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
@@ -872,10 +856,7 @@ wxGridSelection::ToggleCellSelection(int row, int col,
{
if ( !m_grid->GetBatchCount() )
{
r = m_grid->BlockToDeviceRect(
wxGridCellCoords( rowFrom, col ),
wxGridCellCoords( rowTo - 1, col ) );
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
m_grid->RefreshBlock(rowFrom, col, rowTo - 1, col);
}
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
@@ -911,8 +892,7 @@ void wxGridSelection::ClearSelection()
m_cellSelection.RemoveAt(n);
if ( !m_grid->GetBatchCount() )
{
r = m_grid->BlockToDeviceRect( coords1, coords1 );
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
m_grid->RefreshBlock(coords1, coords1);
#ifdef __WXMAC__
m_grid->UpdateGridWindows();
@@ -931,8 +911,7 @@ void wxGridSelection::ClearSelection()
m_blockSelectionBottomRight.RemoveAt(n);
if ( !m_grid->GetBatchCount() )
{
r = m_grid->BlockToDeviceRect( coords1, coords2 );
((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r );
m_grid->RefreshBlock(coords1, coords2);
#ifdef __WXMAC__
m_grid->UpdateGridWindows();
@@ -950,9 +929,7 @@ void wxGridSelection::ClearSelection()
m_rowSelection.RemoveAt(n);
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 );
m_grid->RefreshBlock(row, 0, row, m_grid->GetNumberCols() - 1);
#ifdef __WXMAC__
m_grid->UpdateGridWindows();
@@ -971,9 +948,7 @@ void wxGridSelection::ClearSelection()
m_colSelection.RemoveAt(n);
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 );
m_grid->RefreshBlock(0, col, m_grid->GetNumberRows() - 1, col);
#ifdef __WXMAC__
m_grid->UpdateGridWindows();