From acc57fccc7c4974d5cf9917c005656bc48247b9e Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 21 Aug 2016 21:22:05 +0200 Subject: [PATCH] Fix wxDC::Clear When complex transformation (including e.g. rotation) is applied to DC then coordinates of the clip box return by GetClipBox() API can be inaccurate due to the rounding errors. To compensate these errors we need to fill rectangle which is slightly larger then just retrieved clip box. Closes #17636. --- docs/changes.txt | 1 + src/msw/dc.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index d35373ea98..72059b89cd 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -122,6 +122,7 @@ wxMSW: - Revert to using equally-sized buttons in wxToolBar by default. - Restore dispatching wxThreadEvent while resizing the window broken in 3.1.0. - Fix wxGraphicsMatrix::TransformDistance for Direct2D renderer. +- Fix wxDC::Clear() for rotated DC. wxOSX: diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 186db72bb0..193067414c 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -722,6 +722,10 @@ void wxMSWDCImpl::Clear() HBRUSH brush = ::CreateSolidBrush(colour); RECT rect; ::GetClipBox(GetHdc(), &rect); + // Inflate the box by 1 unit in each direction + // to compensate rounding errors if DC is the subject + // of complex transformation (is e.g. rotated). + ::InflateRect(&rect, 1, 1); ::FillRect(GetHdc(), &rect, brush); ::DeleteObject(brush);