]> git.saurik.com Git - wxWidgets.git/commitdiff
Michaels change to OnEraseBackground()
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 21 Feb 2000 14:31:55 +0000 (14:31 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 21 Feb 2000 14:31:55 +0000 (14:31 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6176 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/grid.cpp

index 9e0952c3b5b68c7613ef1cd53c9fc0617aa4f9a6..8e30520e945a69949ce8d9c4b2bf8d53ca501cdc 100644 (file)
@@ -1965,10 +1965,41 @@ void wxGridWindow::OnKeyDown( wxKeyEvent& event )
     if ( !m_owner->ProcessEvent( event ) ) event.Skip();
 }
 
-void wxGridWindow::OnEraseBackground(wxEraseEvent&)
-{ }
-
-
+// We are trapping erase background events to reduce flicker under MSW
+// and GTK but this can leave junk in the space beyond the last row and
+// col.  So here we paint these spaces if they are visible.
+//
+void wxGridWindow::OnEraseBackground(wxEraseEvent& event)
+{
+    int cw, ch;
+    GetClientSize( &cw, &ch );
+    
+    int right, bottom;
+    m_owner->CalcUnscrolledPosition( cw, ch, &right, &bottom );
+    
+    wxRect rightRect;
+    rightRect = m_owner->CellToRect( 0, m_owner->GetNumberCols()-1 );
+
+    wxRect bottomRect;
+    bottomRect = m_owner->CellToRect( m_owner->GetNumberRows()-1, 0 );
+    
+    if ( right > rightRect.GetRight()  ||  bottom > bottomRect.GetBottom() )
+    {
+        int left, top;
+        m_owner->CalcUnscrolledPosition( 0, 0, &left, &top );
+        
+        wxClientDC dc( this );
+        m_owner->PrepareDC( dc );
+        dc.SetBrush( wxBrush(m_owner->GetDefaultCellBackgroundColour(), wxSOLID) );
+        dc.SetPen( *wxTRANSPARENT_PEN );
+        
+        if ( right > rightRect.GetRight() )
+            dc.DrawRectangle( rightRect.GetRight()+1, top, right - rightRect.GetRight(), ch );
+            
+        if ( bottom > bottomRect.GetBottom() )
+            dc.DrawRectangle( left, bottomRect.GetBottom()+1, cw, bottom - bottomRect.GetBottom() );
+    }
+}
 
 
 //////////////////////////////////////////////////////////////////////