]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied patch [ 608370 ] fix for static text sizing behaviour
authorJulian Smart <julian@anthemion.co.uk>
Fri, 13 Sep 2002 13:17:12 +0000 (13:17 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 13 Sep 2002 13:17:12 +0000 (13:17 +0000)
wxStaticText is meant to resize when SetLabel is called
unless the flag wxST_NO_AUTORESIZE is used when
creating it. Motif currently ignores this flag and always
resizes the control.
The attached patch provides a wxStaticText specific
override of SetLabel() which honours the resize policy
requested via the wxST_NO_AUTORESIZE flag.

I have tested on AIX 4.3 which is Motif 2.1

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@17161 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/motif/stattext.h
src/makeg95.env
src/motif/stattext.cpp

index e64de49452fe6217960f5951d6f05a288be44d7f..336ff7ae76f7aa8da8de4d7c7bbd973965f62ec9 100644 (file)
@@ -56,6 +56,7 @@ public:
     virtual void ChangeFont(bool keepOriginalSize = TRUE);
     virtual void ChangeBackgroundColour();
     virtual void ChangeForegroundColour();
+    virtual void SetLabel(const wxString& label);
     
     // Get the widget that corresponds to the label (for font setting, label setting etc.)
     virtual WXWidget GetLabelWidget() const
index 46c9254159c4e74d00c4097fecb5412a9eb00c31..39f402da26cea12c8634ec620f64aa6971d06b1c 100644 (file)
@@ -15,8 +15,8 @@
 MINGW32=1
 
 # Set to the version you have
-MINGW32VERSION=2.95
-#MINGW32VERSION=3.0
+#MINGW32VERSION=2.95
+MINGW32VERSION=3.0
 
 # If building DLL, the version
 WXVERSION=233
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);
+    }
+}
+