X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7227cefd3b8a71e2d77e2c577ad05539585ba58b..1cff04deb5c17c95bef9c83e72645f105b90e750:/src/motif/stattext.cpp

diff --git a/src/motif/stattext.cpp b/src/motif/stattext.cpp
index 742fa52c76..722ea20e7b 100644
--- a/src/motif/stattext.cpp
+++ b/src/motif/stattext.cpp
@@ -33,6 +33,8 @@
 #pragma message enable nosimpint
 #endif
 
+#include "wx/motif/private.h"
+
 IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
 
 bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
@@ -106,7 +108,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
     
     XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay(parentWidget));
 
-    Widget labelWidget = XtVaCreateManagedWidget ((char*) (const char*) name,
+    m_labelWidget = XtVaCreateManagedWidget ((char*) (const char*) name,
                                          xmLabelWidgetClass,
                                          borderWidget ? borderWidget : parentWidget,
                                          XmNfontList, fontList,
@@ -119,7 +121,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
 
     XmStringFree (text);
 
-    m_mainWidget = borderWidget ? borderWidget : labelWidget;
+    m_mainWidget = borderWidget ? borderWidget : m_labelWidget;
 
     SetCanAddEventHandler(TRUE);
     AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
@@ -144,3 +146,36 @@ void wxStaticText::ChangeForegroundColour()
     wxWindow::ChangeForegroundColour();
 }
 
+void wxStaticText::SetLabel(const wxString& label)
+{
+    wxString buf(wxStripMenuCodes(label));
+    wxXmString label_str(buf);
+
+    // This variable means we don't need so many casts later.
+    Widget widget = (Widget) m_labelWidget;
+
+    if (GetWindowStyle() & wxST_NO_AUTORESIZE)
+    {
+        XtUnmanageChild(widget);
+        Dimension width, height;
+        XtVaGetValues(widget, XmNwidth, &width, XmNheight, &height, NULL);
+
+        XtVaSetValues(widget,
+            XmNlabelString, label_str(),
+            XmNlabelType, XmSTRING,
+            NULL);
+        XtVaSetValues(widget,
+            XmNwidth, width,
+            XmNheight, height,
+            NULL);        
+        XtManageChild(widget);
+    }
+    else
+    {
+        XtVaSetValues(widget,
+            XmNlabelString, label_str(),
+            XmNlabelType, XmSTRING,
+            NULL);
+    }
+}
+