Fixed bug in wxGrid::DrawAllGridLines that was causing crashes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5880 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Michael Bedward
2000-02-07 03:36:01 +00:00
parent 69d16e3ef8
commit 9496deb586

View File

@@ -36,8 +36,8 @@
#include "wx/generic/grid.h" #include "wx/generic/grid.h"
#ifndef DRAW_LINES #ifndef WXGRID_DRAW_LINES
#define DRAW_LINES 1 #define WXGRID_DRAW_LINES 1
#endif #endif
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@@ -876,7 +876,7 @@ void wxGridWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
wxRegion reg = GetUpdateRegion(); wxRegion reg = GetUpdateRegion();
m_owner->CalcCellsExposed( reg ); m_owner->CalcCellsExposed( reg );
m_owner->DrawGridCellArea( dc ); m_owner->DrawGridCellArea( dc );
#if DRAW_LINES #if WXGRID_DRAW_LINES
m_owner->DrawAllGridLines( dc, reg ); m_owner->DrawAllGridLines( dc, reg );
#endif #endif
} }
@@ -2621,7 +2621,7 @@ void wxGrid::DrawCell( wxDC& dc, const wxGridCellCoords& coords )
if ( m_colWidths[coords.GetCol()] <=0 || if ( m_colWidths[coords.GetCol()] <=0 ||
m_rowHeights[coords.GetRow()] <= 0 ) return; m_rowHeights[coords.GetRow()] <= 0 ) return;
#if !DRAW_LINES #if !WXGRID_DRAW_LINES
if ( m_gridLinesEnabled ) if ( m_gridLinesEnabled )
DrawCellBorder( dc, coords ); DrawCellBorder( dc, coords );
#endif #endif
@@ -2752,12 +2752,17 @@ void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & reg )
CalcUnscrolledPosition( x + w, y + h, &right, &bottom ); CalcUnscrolledPosition( x + w, y + h, &right, &bottom );
} }
// avoid drawing grid lines past the last row and col
//
right = wxMin( right, m_colRights[m_numCols-1] );
bottom = wxMin( bottom, m_rowBottoms[m_numRows-1] );
dc.SetPen( wxPen(GetGridLineColour(), 1, wxSOLID) ); dc.SetPen( wxPen(GetGridLineColour(), 1, wxSOLID) );
// horizontal grid lines // horizontal grid lines
// //
int i; int i;
for ( i = 0; i <= m_numRows; i++ ) for ( i = 0; i < m_numRows; i++ )
{ {
if ( m_rowBottoms[i] > bottom ) if ( m_rowBottoms[i] > bottom )
{ {
@@ -2772,7 +2777,7 @@ void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & reg )
// vertical grid lines // vertical grid lines
// //
for ( i = 0; i <= m_numCols; i++ ) for ( i = 0; i < m_numCols; i++ )
{ {
if ( m_colRights[i] > right ) if ( m_colRights[i] > right )
{ {