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
This commit is contained in:
Julian Smart
2002-09-13 13:17:12 +00:00
parent 8b5be08a09
commit fe5de1ea10
3 changed files with 38 additions and 2 deletions

View 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

View 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

View 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);
}
}