X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7f85af8223ebd7ef47b441237b22588916d4eb96..4776c0b783a9776f94b049aecdc253d379686b6b:/src/gtk/stattext.cpp?ds=sidebyside diff --git a/src/gtk/stattext.cpp b/src/gtk/stattext.cpp index 5e9bac45b2..b3f96071ae 100644 --- a/src/gtk/stattext.cpp +++ b/src/gtk/stattext.cpp @@ -52,9 +52,10 @@ bool wxStaticText::Create(wxWindow *parent, } m_widget = gtk_label_new(NULL); + g_object_ref(m_widget); GtkJustification justify; - if ( style & wxALIGN_CENTER ) + if ( style & wxALIGN_CENTER_HORIZONTAL ) justify = GTK_JUSTIFY_CENTER; else if ( style & wxALIGN_RIGHT ) justify = GTK_JUSTIFY_RIGHT; @@ -71,12 +72,6 @@ bool wxStaticText::Create(wxWindow *parent, gtk_label_set_justify(GTK_LABEL(m_widget), justify); - // GTK_JUSTIFY_LEFT is 0, RIGHT 1 and CENTER 2 - static const float labelAlignments[] = { 0.0, 1.0, 0.5 }; - gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0); - - gtk_label_set_line_wrap( GTK_LABEL(m_widget), TRUE ); - #ifdef __WXGTK26__ if (!gtk_check_version(2,6,0)) { @@ -93,6 +88,12 @@ bool wxStaticText::Create(wxWindow *parent, } #endif // __WXGTK26__ + // GTK_JUSTIFY_LEFT is 0, RIGHT 1 and CENTER 2 + static const float labelAlignments[] = { 0.0, 1.0, 0.5 }; + gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0); + + gtk_label_set_line_wrap( GTK_LABEL(m_widget), TRUE ); + SetLabel(label); m_parent->DoAddChild( this ); @@ -130,8 +131,8 @@ void wxStaticText::SetLabel( const wxString& str ) GTKSetLabelForLabel(GTK_LABEL(m_widget), label); // adjust the label size to the new label unless disabled - if ( !HasFlag(wxST_NO_AUTORESIZE) && - !IsEllipsized() ) // if ellipsize is ON, then we don't want to get resized! + if ( !HasFlag(wxST_NO_AUTORESIZE) && + !IsEllipsized() ) // if ellipsization is ON, then we don't want to get resized! SetSize( GetBestSize() ); } @@ -174,8 +175,8 @@ bool wxStaticText::SetFont( const wxFont &font ) } void wxStaticText::DoSetSize(int x, int y, - int width, int height, - int sizeFlags ) + int width, int height, + int sizeFlags ) { wxStaticTextBase::DoSetSize(x, y, width, height, sizeFlags); @@ -229,7 +230,11 @@ wxString wxStaticText::DoGetLabel() const void wxStaticText::DoSetLabel(const wxString& str) { - GTKSetLabelForLabel(GTK_LABEL(m_widget), str); + // this function looks like GTKSetLabelForLabel() but here we just want to modify + // the GTK control without altering any internal wxStaticText variable + + const wxString labelGTK = GTKConvertMnemonics(str); + gtk_label_set_text_with_mnemonic(GTK_LABEL(m_widget), wxGTK_CONV(labelGTK)); } // static