From fe5de1ea1041bc97e3e2735e6866ad3485eea78c Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Fri, 13 Sep 2002 13:17:12 +0000 Subject: [PATCH] Applied patch [ 608370 ] fix for static text sizing behaviour 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 | 1 + src/makeg95.env | 4 ++-- src/motif/stattext.cpp | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/include/wx/motif/stattext.h b/include/wx/motif/stattext.h index e64de49452..336ff7ae76 100644 --- a/include/wx/motif/stattext.h +++ b/include/wx/motif/stattext.h @@ -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 diff --git a/src/makeg95.env b/src/makeg95.env index 46c9254159..39f402da26 100644 --- a/src/makeg95.env +++ b/src/makeg95.env @@ -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 diff --git a/src/motif/stattext.cpp b/src/motif/stattext.cpp index 2b4166a75a..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, @@ -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); + } +} + -- 2.47.2