X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6959763942eb0e852113945c54113f3521b9c26f..480f42ec8edda474543e24760c350cbecb21e0c4:/src/gtk/stattext.cpp?ds=sidebyside diff --git a/src/gtk/stattext.cpp b/src/gtk/stattext.cpp index 8d2c1e01b4..6fe31c64c6 100644 --- a/src/gtk/stattext.cpp +++ b/src/gtk/stattext.cpp @@ -72,15 +72,15 @@ bool wxStaticText::Create(wxWindow *parent, justify = GTK_JUSTIFY_RIGHT; else // wxALIGN_LEFT is 0 justify = GTK_JUSTIFY_LEFT; - + if (GetLayoutDirection() == wxLayout_RightToLeft) - { + { if (justify == GTK_JUSTIFY_RIGHT) justify = GTK_JUSTIFY_LEFT; if (justify == GTK_JUSTIFY_LEFT) justify = GTK_JUSTIFY_RIGHT; } - + gtk_label_set_justify(GTK_LABEL(m_widget), justify); // GTK_JUSTIFY_LEFT is 0, RIGHT 1 and CENTER 2 @@ -129,8 +129,34 @@ void wxStaticText::SetLabel( const wxString &label ) bool wxStaticText::SetFont( const wxFont &font ) { + const bool wasUnderlined = GetFont().GetUnderlined(); + bool ret = wxControl::SetFont(font); + if ( font.GetUnderlined() != wasUnderlined ) + { + // the underlines for mnemonics are incompatible with using attributes + // so turn them off when setting underlined font and restore them when + // unsetting it + gtk_label_set_use_underline(GTK_LABEL(m_widget), wasUnderlined); + + if ( wasUnderlined ) + { + // it's not underlined any more, remove the attributes we set + gtk_label_set_attributes(GTK_LABEL(m_widget), NULL); + } + else // the text is underlined now + { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE); + a->start_index = 0; + a->end_index = (guint)-1; + pango_attr_list_insert(attrs, a); + gtk_label_set_attributes(GTK_LABEL(m_widget), attrs); + pango_attr_list_unref(attrs); + } + } + // adjust the label size to the new label unless disabled if (!HasFlag(wxST_NO_AUTORESIZE)) {