From a2b915af0fafd7a52758dcef6f45647953ff3bd5 Mon Sep 17 00:00:00 2001 From: YuSanka <yusanka@gmail.com> Date: Wed, 11 Nov 2020 12:04:15 +0100 Subject: [PATCH] Fixed of #5081 Width of sub-label is calculated by using of GetTextExtent() instead of PaintDC->GetMultiLineTextExtent, because of PaintDC is not OK sometimes. For example on GTK3 PaintDC->IsOk() only, when it's using in a native paint event see https://github.com/wxWidgets/wxWidgets/blob/master/src/gtk/dc.cpp, line 346 --- src/slic3r/GUI/OG_CustomCtrl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/OG_CustomCtrl.cpp b/src/slic3r/GUI/OG_CustomCtrl.cpp index 2a235f600..af9aeb42e 100644 --- a/src/slic3r/GUI/OG_CustomCtrl.cpp +++ b/src/slic3r/GUI/OG_CustomCtrl.cpp @@ -173,9 +173,9 @@ wxPoint OG_CustomCtrl::get_pos(const Line& line, Field* field_in/* = nullptr*/) _CTX(option.label, "Layers") : _(option.label); label += ":"; - wxPaintDC dc(this); - dc.SetFont(m_font); - h_pos += dc.GetMultiLineTextExtent(label).x + m_h_gap; + wxCoord label_w, label_h; + GetTextExtent(label, &label_w, &label_h, 0, 0, &m_font); + h_pos += label_w + 1 + m_h_gap; } h_pos += 3 * blinking_button_width;