Clear DC using white background by default in wxMSW
Since 848f5e78a6
the background wasn't
cleared at all if the background brush hadn't been explicitly set prior
to calling wxDC::Clear(). This was incompatible with the old behaviour
and even managed to break our own print preview code, so it clearly
wasn't a good idea to change Clear() like this.
Instead, continue to clear the DC using white background by default,
while still not doing anything if a transparent background brush had
been explicitly set.
This fixes print preview background under MSW.
See #10273, #18371.
This commit is contained in:
@@ -729,8 +729,23 @@ void wxMSWDCImpl::Clear()
|
||||
return;
|
||||
}
|
||||
|
||||
HBRUSH hbr;
|
||||
if ( !m_backgroundBrush.IsOk() )
|
||||
{
|
||||
// By default, use the stock white brush for compatibility with the
|
||||
// previous wx versions.
|
||||
hbr = WHITE_BRUSH;
|
||||
}
|
||||
else if ( !m_backgroundBrush.IsTransparent() )
|
||||
{
|
||||
hbr = GetHbrushOf(m_backgroundBrush);
|
||||
}
|
||||
else // Using transparent background brush.
|
||||
{
|
||||
// Clearing with transparent brush doesn't do anything, just as drawing
|
||||
// with transparent pen doesn't.
|
||||
return;
|
||||
}
|
||||
|
||||
RECT rect;
|
||||
::GetClipBox(GetHdc(), &rect);
|
||||
@@ -738,7 +753,7 @@ void wxMSWDCImpl::Clear()
|
||||
// to compensate rounding errors if DC is the subject
|
||||
// of complex transformation (is e.g. rotated).
|
||||
::InflateRect(&rect, 1, 1);
|
||||
::FillRect(GetHdc(), &rect, GetHbrushOf(m_backgroundBrush));
|
||||
::FillRect(GetHdc(), &rect, hbr);
|
||||
|
||||
RealizeScaleAndOrigin();
|
||||
}
|
||||
|
Reference in New Issue
Block a user