]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/stattext.cpp
multilib mode
[wxWidgets.git] / src / gtk / stattext.cpp
index 6afa92e419906f44f5a69e3509f0eea3fcda6fe9..53fe9f98e51c13b3dc644c3e178e07e108e92f2c 100644 (file)
 #include "gdk/gdk.h"
 #include "gtk/gtk.h"
 
+extern "C"
+void wxgtk_window_size_request_callback(GtkWidget *widget,
+                                        GtkRequisition *requisition,
+                                        wxWindow *win);
+
 //-----------------------------------------------------------------------------
 // wxStaticText
 //-----------------------------------------------------------------------------
@@ -87,6 +92,23 @@ bool wxStaticText::Create(wxWindow *parent,
 
     PostCreation();
     
+    // the bug below only happens with GTK 2
+#ifdef __WXGTK20__
+    if ( justify != GTK_JUSTIFY_LEFT )
+    {
+        // if we let GTK call wxgtk_window_size_request_callback the label
+        // always shrinks to its minimal size for some reason and so no
+        // alignment except the default left doesn't work (in fact it does,
+        // but you don't see it)
+        gtk_signal_disconnect_by_func
+        (
+            GTK_OBJECT(m_widget),
+            GTK_SIGNAL_FUNC(wxgtk_window_size_request_callback),
+            (gpointer) this
+        );
+    }
+#endif // __WXGTK20__
+
     ApplyWidgetStyle();
 
     wxControl::SetFont( parent->GetFont() );
@@ -109,8 +131,13 @@ bool wxStaticText::Create(wxWindow *parent,
 
 wxString wxStaticText::GetLabel() const
 {
-    char *str = (char *) NULL;
-    gtk_label_get( GTK_LABEL(m_widget), &str );
+    GtkLabel *label = GTK_LABEL(m_widget);
+
+#ifdef __WXGTK20__
+    wxString str = wxGTK_CONV_BACK( gtk_label_get_text( label ) );
+#else
+    wxString str = wxString( label->label );
+#endif
 
     return wxString(str);
 }