Merge branch 'grid-clip'

See https://github.com/wxWidgets/wxWidgets/pull/648
This commit is contained in:
Vadim Zeitlin
2018-01-10 17:19:03 +01:00
4 changed files with 27 additions and 13 deletions

View File

@@ -1436,16 +1436,30 @@ class WXDLLIMPEXP_CORE wxDCClipper
{
public:
wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc)
{ dc.SetClippingRegion(r.GetBox()); }
{
dc.GetClippingBox(m_oldClipRect);
dc.SetClippingRegion(r.GetBox());
}
wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
{ dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
{
dc.GetClippingBox(m_oldClipRect);
dc.SetClippingRegion(r.x, r.y, r.width, r.height);
}
wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)
{ dc.SetClippingRegion(x, y, w, h); }
{
dc.GetClippingBox(m_oldClipRect);
dc.SetClippingRegion(x, y, w, h);
}
~wxDCClipper() { m_dc.DestroyClippingRegion(); }
~wxDCClipper()
{
m_dc.DestroyClippingRegion();
m_dc.SetClippingRegion(m_oldClipRect);
}
private:
wxDC& m_dc;
wxRect m_oldClipRect;
wxDECLARE_NO_COPY_CLASS(wxDCClipper);
};

View File

@@ -1669,11 +1669,10 @@ public:
}
@endcode
@note Unlike other similar classes such as wxDCFontChanger, wxDCClipper
currently doesn't restore the previously active clipping region when it
is destroyed but simply resets clipping on the associated wxDC. This
may be changed in the future wxWidgets versions but has to be taken
into account explicitly in the current one.
@note Since 3.1.1 wxDCClipper restores the previously active clipping
region when it is destroyed. Previously it reset clipping on the
associated wxDC and this has to be taken into account explicitly in
previous wxWidgets versions.
@library{wxcore}
@category{gdi}

View File

@@ -1871,7 +1871,10 @@ void wxGrid::Render( wxDC& dc,
dc.DrawRectangle( pointOffSet, sizeCells );
// draw cells
DrawGridCellArea( dc, renderCells );
{
wxDCClipper clipper( dc, wxRect(pointOffSet, sizeCells) );
DrawGridCellArea( dc, renderCells );
}
// draw grid lines
if ( style & wxGRID_DRAW_CELL_LINES )

View File

@@ -630,8 +630,7 @@ void wxGridCellStringRenderer::Draw(wxGrid& grid,
for (int i = col + cell_cols; i <= col_end; i++)
{
clip.width = grid.GetColSize(i) - 1;
dc.DestroyClippingRegion();
dc.SetClippingRegion(clip);
wxDCClipper clipper(dc, clip);
SetTextColoursAndFont(grid, attr, dc,
grid.IsInSelection(row,i));
@@ -644,7 +643,6 @@ void wxGridCellStringRenderer::Draw(wxGrid& grid,
rect = rectCell;
rect.Inflate(-1);
rect.width++;
dc.DestroyClippingRegion();
}
}