Add wxGrid::DrawRangeGridLines().

This method draws only the grid lines for the cells in the specified range and
not for all of them.

It is not used yet but will be by the upcoming wxGrid::Render(), see #14294.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71576 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2012-05-27 13:00:13 +00:00
parent f31d3faf7a
commit b55d57aa24
2 changed files with 67 additions and 0 deletions

View File

@ -2133,6 +2133,12 @@ private:
// redraw the grid lines, should be called after changing their attributes
void RedrawGridLines();
// draw all grid lines in the given cell region (unlike the public
// DrawAllGridLines() which just draws all of them)
void DrawRangeGridLines(wxDC& dc, const wxRegion& reg,
const wxGridCellCoords& topLeft,
const wxGridCellCoords& bottomRight);
// draw all lines from top to bottom row and left to right column in the
// rectangle determined by (top, left)-(bottom, right) -- but notice that
// the caller must have set up the clipping correctly, this rectangle is

View File

@ -5346,6 +5346,67 @@ void wxGrid::DrawHighlight(wxDC& dc, const wxGridCellCoordsArray& cells)
}
}
// Used by wxGrid::Render() to draw the grid lines only for the cells in the
// specified range.
void
wxGrid::DrawRangeGridLines(wxDC& dc,
const wxRegion& reg,
const wxGridCellCoords& topLeft,
const wxGridCellCoords& bottomRight)
{
if ( !m_gridLinesEnabled )
return;
int top, left, width, height;
reg.GetBox( left, top, width, height );
// create a clipping region
wxRegion clippedcells( dc.LogicalToDeviceX( left ),
dc.LogicalToDeviceY( top ),
dc.LogicalToDeviceXRel( width ),
dc.LogicalToDeviceYRel( height ) );
// subtract multi cell span area from clipping region for lines
wxRect rect;
for ( int row = topLeft.GetRow(); row <= bottomRight.GetRow(); row++ )
{
for ( int col = topLeft.GetCol(); col <= bottomRight.GetCol(); col++ )
{
int cell_rows, cell_cols;
GetCellSize( row, col, &cell_rows, &cell_cols );
if ( cell_rows > 1 || cell_cols > 1 ) // multi cell
{
rect = CellToRect( row, col );
// cater for scaling
// device origin already set in ::Render() for x, y
rect.x = dc.LogicalToDeviceX( rect.x );
rect.y = dc.LogicalToDeviceY( rect.y );
rect.width = dc.LogicalToDeviceXRel( rect.width );
rect.height = dc.LogicalToDeviceYRel( rect.height ) - 1;
clippedcells.Subtract( rect );
}
else if ( cell_rows < 0 || cell_cols < 0 ) // part of multicell
{
rect = CellToRect( row + cell_rows, col + cell_cols );
rect.x = dc.LogicalToDeviceX( rect.x );
rect.y = dc.LogicalToDeviceY( rect.y );
rect.width = dc.LogicalToDeviceXRel( rect.width );
rect.height = dc.LogicalToDeviceYRel( rect.height ) - 1;
clippedcells.Subtract( rect );
}
}
}
dc.SetDeviceClippingRegion( clippedcells );
DoDrawGridLines(dc,
top, left, top + height, left + width,
topLeft.GetRow(), topLeft.GetCol(),
bottomRight.GetRow(), bottomRight.GetCol());
dc.DestroyClippingRegion();
}
// This is used to redraw all grid lines e.g. when the grid line colour
// has been changed
//