Fix using wxDC::Blit() when using RTL layout under MSW

Work around what seems like a bug in StretchBlt() implementation by
applying an extra offset to it when using RTL layout and revert an
earlier attempt to fix this problem for wxMemoryDC used in wxNotebook
code from 6614aa496d (fix for tabs drawing in RTL (patch 1552881),
2006-10-21).

Closes #19190.
This commit is contained in:
Vadim Zeitlin
2021-08-20 22:06:41 +01:00
parent 6689feb648
commit 8ccfd32d04
2 changed files with 18 additions and 9 deletions

View File

@@ -2503,12 +2503,27 @@ bool wxMSWDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest,
{
StretchBltModeChanger stretchModeChanger(GetHdc());
/*
Workaround for #19190. See (reverted) 6614aa496d: "For some reason
in RTL mode, source offset has to be -1, otherwise the right
border (physical) remains unpainted." [note that the offset
actually is applied not only to the source but also dest]
Be conservative about using the offset and only do it for
currently currently known failing cases: when xdest and xsrc are
equal and only when not actually stretching.
*/
const wxCoord ofs = (GetLayoutDirection() == wxLayout_RightToLeft
&& xdest == xsrc
&& srcWidth == dstWidth
&& srcHeight == dstHeight) ? -1 : 0;
if ( !::StretchBlt
(
GetHdc(),
xdest, ydest, dstWidth, dstHeight,
xdest + ofs, ydest, dstWidth, dstHeight,
hdcSrc,
xsrc, ysrc, srcWidth, srcHeight,
xsrc + ofs, ysrc, srcWidth, srcHeight,
dwRop
) )
{

View File

@@ -795,9 +795,6 @@ void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event))
wxBitmap bmp(rc.right, rc.bottom);
wxMemoryDC memdc(bmp);
const wxLayoutDirection dir = dc.GetLayoutDirection();
memdc.SetLayoutDirection(dir);
const HDC hdc = GetHdcOf(memdc);
// The drawing logic of the native tab control is absolutely impenetrable
@@ -866,10 +863,7 @@ void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event))
::ExtFloodFill(hdc, x, y, ::GetSysColor(COLOR_BTNFACE), FLOODFILLSURFACE);
}
// For some reason in RTL mode, source offset has to be -1, otherwise the
// right border (physical) remains unpainted.
const wxCoord ofs = dir == wxLayout_RightToLeft ? -1 : 0;
dc.Blit(ofs, 0, rc.right, rc.bottom, &memdc, ofs, 0);
dc.Blit(0, 0, rc.right, rc.bottom, &memdc, 0, 0);
}
#endif // USE_NOTEBOOK_ANTIFLICKER