From 796df70a76bbf45168363a06e7a7e671d3ba7683 Mon Sep 17 00:00:00 2001 From: Stefan Neis Date: Sat, 5 Feb 2000 18:04:13 +0000 Subject: [PATCH] Added different strategy for updating grid lines. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5857 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/grid.h | 2 +- src/generic/grid.cpp | 38 ++++++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 10636a7778..e6aa4f7f7a 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -449,7 +449,7 @@ public: void DrawGridCellArea( wxDC& dc ); void DrawCellBorder( wxDC& dc, const wxGridCellCoords& ); - void DrawAllGridLines( wxDC& dc ); // TODO - delete this ? + void DrawAllGridLines( wxDC& dc, const wxRegion & reg = wxRegion() ); void DrawCell( wxDC& dc, const wxGridCellCoords& ); void DrawCellBackground( wxDC& dc, const wxGridCellCoords& ); void DrawCellValue( wxDC& dc, const wxGridCellCoords& ); diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index ed983aadc6..a5c4a06248 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -36,6 +36,10 @@ #include "wx/generic/grid.h" +#ifndef DRAW_LINES +#define DRAW_LINES 1 +#endif + ////////////////////////////////////////////////////////////////////// wxGridCellCoords wxGridNoCellCoords( -1, -1 ); @@ -869,9 +873,12 @@ void wxGridWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) { wxPaintDC dc( this ); m_owner->PrepareDC( dc ); - - m_owner->CalcCellsExposed( GetUpdateRegion() ); + wxRegion reg = GetUpdateRegion(); + m_owner->CalcCellsExposed( reg ); m_owner->DrawGridCellArea( dc ); +#if DRAW_LINES + m_owner->DrawAllGridLines( dc, reg ); +#endif } @@ -2602,8 +2609,10 @@ void wxGrid::DrawCell( wxDC& dc, const wxGridCellCoords& coords ) if ( m_colWidths[coords.GetCol()] <=0 || m_rowHeights[coords.GetRow()] <= 0 ) return; +#if !DRAW_LINES if ( m_gridLinesEnabled ) DrawCellBorder( dc, coords ); +#endif DrawCellBackground( dc, coords ); @@ -2707,20 +2716,29 @@ void wxGrid::DrawCellValue( wxDC& dc, const wxGridCellCoords& coords ) // This is used to redraw all grid lines e.g. when the grid line colour // has been changed // -void wxGrid::DrawAllGridLines( wxDC& dc ) +void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & reg ) { if ( !m_gridLinesEnabled || !m_numRows || !m_numCols ) return; - int cw, ch; - m_gridWin->GetClientSize(&cw, &ch); - - // virtual coords of visible area - // int top, bottom, left, right; - CalcUnscrolledPosition( 0, 0, &left, &top ); - CalcUnscrolledPosition( cw, ch, &right, &bottom ); + + if (reg.IsEmpty()){ + int cw, ch; + m_gridWin->GetClientSize(&cw, &ch); + + // virtual coords of visible area + // + CalcUnscrolledPosition( 0, 0, &left, &top ); + CalcUnscrolledPosition( cw, ch, &right, &bottom ); + } + else{ + wxCoord x, y, w, h; + reg.GetBox(x, y, w, h); + CalcUnscrolledPosition( x, y, &left, &top ); + CalcUnscrolledPosition( x + w, y + h, &right, &bottom ); + } dc.SetPen( wxPen(GetGridLineColour(), 1, wxSOLID) );