]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/stattext.cpp
If -1 is used for width/height, use best size.
[wxWidgets.git] / src / motif / stattext.cpp
index 2b4166a75a4e7144498377a7b65f50faeae4f9bf..722ea20e7bc37c84a80c049d281920fe3a50747d 100644 (file)
@@ -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,
@@ -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);
+    }
+}
+