From d83d1269597d2b9af04d2383e9b821a28649819a Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Sat, 13 Feb 2021 13:09:18 +0100 Subject: [PATCH] Fix off-by-ones with bottom and right aligned positioning wxDC::DrawLabel() positions the text one to the left with wxALIGN_RIGHT alignment and one up with wxALIGN_BOTTOM alignment. The same occurs in wxControlRenderer::DrawBitmap() for bitmaps. Both off-by-ones exist since inception in respectively 4d3c4c2f94 and bc60c3d699. This fix vertically aligns wxALIGN_BOTTOM drawing of wxDC::DrawLabel() with themed text drawing through wxRendererXP::DrawItemText(). --- src/common/dcbase.cpp | 4 ++-- src/univ/ctrlrend.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index c669a028b9..fe93ee18bb 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -1196,7 +1196,7 @@ void wxDC::DrawLabel(const wxString& text, wxCoord x, y; if ( alignment & wxALIGN_RIGHT ) { - x = rect.GetRight() - width; + x = rect.GetRight() - width + 1; } else if ( alignment & wxALIGN_CENTRE_HORIZONTAL ) { @@ -1209,7 +1209,7 @@ void wxDC::DrawLabel(const wxString& text, if ( alignment & wxALIGN_BOTTOM ) { - y = rect.GetBottom() - height; + y = rect.GetBottom() - height + 1; } else if ( alignment & wxALIGN_CENTRE_VERTICAL ) { diff --git a/src/univ/ctrlrend.cpp b/src/univ/ctrlrend.cpp index 6039922384..70b27679fa 100644 --- a/src/univ/ctrlrend.cpp +++ b/src/univ/ctrlrend.cpp @@ -185,7 +185,7 @@ void wxControlRenderer::DrawBitmap(wxDC &dc, { if ( alignment & wxALIGN_RIGHT ) { - x = rect.GetRight() - width; + x = rect.GetRight() - width + 1; } else if ( alignment & wxALIGN_CENTRE ) { @@ -198,7 +198,7 @@ void wxControlRenderer::DrawBitmap(wxDC &dc, if ( alignment & wxALIGN_BOTTOM ) { - y = rect.GetBottom() - height; + y = rect.GetBottom() - height + 1; } else if ( alignment & wxALIGN_CENTRE_VERTICAL ) {