From 6223f67ccc8cb9784e6bf9351ae82e37c4ea04b8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 12 Nov 2019 23:18:35 +0100 Subject: [PATCH 1/2] Use client size when ellipsizing wxStaticText label The full size includes the borders and the return value of this function might not actually be fully visible if we use it, as it can fit into the full width but not the client width. And at least under MSW this resulted in the ellipsized label being wrapped, which was completely unexpected, especially if the second line of the control was not visible at all as it seemed that the last word simply disappeared. Closes #18573. --- src/common/stattextcmn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/stattextcmn.cpp b/src/common/stattextcmn.cpp index 553c607647..daf2488296 100644 --- a/src/common/stattextcmn.cpp +++ b/src/common/stattextcmn.cpp @@ -261,7 +261,7 @@ wxString wxStaticTextBase::GetEllipsizedLabel() const wxString wxStaticTextBase::Ellipsize(const wxString& label) const { - wxSize sz(GetSize()); + wxSize sz(GetClientSize()); if (sz.GetWidth() < 2 || sz.GetHeight() < 2) { // the size of this window is not valid (yet) From 73eabe2f12a30b7cc86006498c2ecf480b60c47a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 12 Nov 2019 23:21:51 +0100 Subject: [PATCH 2/2] Remove redundant wxClientDC::SetFont() call wxClientDC inherits the font used by the associated window anyhow, there is no need to set it explicitly. No real changes, just a micro optimization. --- src/common/stattextcmn.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common/stattextcmn.cpp b/src/common/stattextcmn.cpp index daf2488296..ac1c6c6cec 100644 --- a/src/common/stattextcmn.cpp +++ b/src/common/stattextcmn.cpp @@ -269,7 +269,6 @@ wxString wxStaticTextBase::Ellipsize(const wxString& label) const } wxClientDC dc(const_cast(this)); - dc.SetFont(GetFont()); wxEllipsizeMode mode; if ( HasFlag(wxST_ELLIPSIZE_START) )