From a7b9dc121bf39942da8253fdf1d0054b39a670dd Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Wed, 18 Aug 2021 21:56:24 +0200 Subject: [PATCH] Fix recent regression with drawing themed multi-line text Remove conditions from MSW themed text drawing that prevent multi-lines from being rendered properly and instead always use DT_TOP alignment for multi-lines. This fixes a regression occurring since 90ba137f20 (Work around text extent differences resulting in clipped text, 2021-07-26) with themed Vista+ : Non-top aligned multi-line text gets rendered as a single line because of DT_SINGLELINE being used if the height of the drawing rect and multi-line text happen to be equal. This occurs on the "Variable line height" page of the dataview sample, which calculates its cell height by multiplying the text extent by the number of lines in the text (a requirement with wxMSW, not wxGTK). Removing the conditions also exposes top aligned multi-line themed text to drawing beyond the drawing rect, which actually makes it behave more like wxGTK and wxOSX as well as wxMSW non-themed drawing as they try to render text fully without regard for the bounds of the drawing rect. Closes https://github.com/wxWidgets/wxWidgets/pull/2470 --- src/msw/renderer.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/msw/renderer.cpp b/src/msw/renderer.cpp index b85629e31f..260a8cfd81 100644 --- a/src/msw/renderer.cpp +++ b/src/msw/renderer.cpp @@ -1184,18 +1184,15 @@ void wxRendererXP::DrawItemText(wxWindow* win, consequences for particularly multi-line text: it will now always try to fit vertically while a rect received from wxDVC may have its extent based on calculations for a single line - only and therefore couldn't show more than one line. - As a result of the expanded height clipping may be needed - which at least already happens with wxDVC which (out of - necessity) confines rendering to a cell's bounds. + only and therefore couldn't show more than one line. This is + consistent with other major platforms where no clipping to + the rect takes places either, including non-themed MSW. */ - const int heightDiff = rect.GetHeight() - rcExtent.bottom; - if ( heightDiff - && (align & (wxALIGN_BOTTOM | wxALIGN_CENTRE_VERTICAL)) - && text.Contains(wxS('\n')) ) + if ( text.Contains(wxS('\n')) ) { useTopDrawing = true; + const int heightDiff = rect.GetHeight() - rcExtent.bottom; if ( align & wxALIGN_CENTRE_VERTICAL ) { const int heightOffset = heightDiff / 2;