Fix best size for non-left aligned wxStaticText in wxGTK2
Since the hack for making the alignment work with GTK+ 2 done in
4ae21c7f1a
, the best size was not computed
correctly for the right aligned or centered labels and the minimum possible
size was returned instead.
Fix this by temporarily disabling ellipsization during the best size
computation to ensure that the same best size is computed for left and right
aligned labels.
See #12539.
This commit is contained in:
parent
5683904c2a
commit
0724bc9a5a
@ -236,11 +236,20 @@ wxSize wxStaticText::DoGetBestSize() const
|
||||
gtk_label_set_line_wrap(GTK_LABEL(m_widget), false);
|
||||
#else
|
||||
GTK_LABEL(m_widget)->wrap = FALSE;
|
||||
|
||||
// Reset the ellipsize mode while computing the best size, otherwise it's
|
||||
// going to be too small as the control knows that it can be shrunk to the
|
||||
// bare minimum and just hide most of the text replacing it with ellipsis.
|
||||
// This is especially important because we can enable ellipsization
|
||||
// implicitly for GTK+ 2, see the code dealing with alignment in the ctor.
|
||||
const PangoEllipsizeMode ellipsizeMode = gtk_label_get_ellipsize(GTK_LABEL(m_widget));
|
||||
gtk_label_set_ellipsize(GTK_LABEL(m_widget), PANGO_ELLIPSIZE_NONE);
|
||||
#endif
|
||||
wxSize size = wxStaticTextBase::DoGetBestSize();
|
||||
#ifdef __WXGTK3__
|
||||
gtk_label_set_line_wrap(GTK_LABEL(m_widget), true);
|
||||
#else
|
||||
gtk_label_set_ellipsize(GTK_LABEL(m_widget), ellipsizeMode);
|
||||
GTK_LABEL(m_widget)->wrap = TRUE; // restore old value
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user