wxGridCellCoordsArray dirtyCells = m_owner->CalcCellsExposed( reg );
m_owner->DrawGridCellArea( dc, dirtyCells );
+ m_owner->DrawGridSpace( dc );
+
m_owner->DrawAllGridLines( dc, reg );
- m_owner->DrawGridSpace( dc );
m_owner->DrawHighlight( dc, dirtyCells );
}
m_gridLineColour = wxColour( 192,192,192 );
m_gridLinesEnabled = true;
+ m_gridLinesClipHorz =
+ m_gridLinesClipVert = true;
m_cellHighlightColour = *wxBLACK;
m_cellHighlightPenWidth = 2;
m_cellHighlightROPenWidth = 1;
//
void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & WXUNUSED(reg) )
{
- if ( !m_gridLinesEnabled || !m_numRows || !m_numCols )
+ if ( !m_gridLinesEnabled )
return;
int top, bottom, left, right;
CalcUnscrolledPosition( cw, ch, &right, &bottom );
// avoid drawing grid lines past the last row and col
- //
- right = wxMin( right, GetColRight(GetColAt( m_numCols - 1 )) );
- bottom = wxMin( bottom, GetRowBottom(m_numRows - 1) );
+ if ( m_gridLinesClipHorz )
+ {
+ if ( !m_numCols )
+ return;
+
+ const int lastColRight = GetColRight(GetColAt(m_numCols - 1));
+ if ( right > lastColRight )
+ right = lastColRight;
+ }
+
+ if ( m_gridLinesClipVert )
+ {
+ if ( !m_numRows )
+ return;
+
+ const int lastRowBottom = GetRowBottom(m_numRows - 1);
+ if ( bottom > lastRowBottom )
+ bottom = lastRowBottom;
+ }
// no gridlines inside multicells, clip them out
int leftCol = GetColPos( internalXToCol(left) );
{
m_gridLineColour = colour;
- wxClientDC dc( m_gridWin );
- PrepareDC( dc );
- DrawAllGridLines( dc, wxRegion() );
+ if ( GridLinesEnabled() )
+ RedrawGridLines();
}
}
}
}
+void wxGrid::RedrawGridLines()
+{
+ // the lines will be redrawn when the window is thawn
+ if ( GetBatchCount() )
+ return;
+
+ if ( GridLinesEnabled() )
+ {
+ wxClientDC dc( m_gridWin );
+ PrepareDC( dc );
+ DrawAllGridLines( dc, wxRegion() );
+ }
+ else // remove the grid lines
+ {
+ m_gridWin->Refresh();
+ }
+}
+
void wxGrid::EnableGridLines( bool enable )
{
if ( enable != m_gridLinesEnabled )
{
m_gridLinesEnabled = enable;
- if ( !GetBatchCount() )
- {
- if ( enable )
- {
- wxClientDC dc( m_gridWin );
- PrepareDC( dc );
- DrawAllGridLines( dc, wxRegion() );
- }
- else
- {
- m_gridWin->Refresh();
- }
- }
+ RedrawGridLines();
+ }
+}
+
+void wxGrid::DoClipGridLines(bool& var, bool clip)
+{
+ if ( clip != var )
+ {
+ var = clip;
+
+ if ( GridLinesEnabled() )
+ RedrawGridLines();
}
}