Applied Motif patches from Ian Brown

[ 609894 ] motif staticbox improvement
[ 611042 ] fix for motif crash

Everything looks fine with Lesstif from Debian 3.0 (emulated
Motif version is 1.2).


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17321 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon
2002-09-21 16:20:49 +00:00
parent 93add80831
commit 64e8d107f0
4 changed files with 35 additions and 98 deletions

View File

@@ -55,20 +55,11 @@ public:
// Implementation // Implementation
virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeFont(bool keepOriginalSize = TRUE);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
WXWidget GetTopWidget() const { return m_formWidget; }
WXWidget GetLabelWidget() const { return m_labelWidget; }
protected: protected:
// Motif-specific // Motif-specific
WXWidget m_formWidget;
WXWidget m_labelWidget; WXWidget m_labelWidget;
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
private: private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@@ -383,6 +383,12 @@ wxFrame::~wxFrame()
m_frameStatusBar = NULL; m_frameStatusBar = NULL;
} }
if (m_frameToolBar)
{
delete m_frameToolBar;
m_frameToolBar = NULL;
}
DestroyChildren(); DestroyChildren();
if (m_workArea) if (m_workArea)
@@ -392,6 +398,11 @@ wxFrame::~wxFrame()
XtDestroyWidget ((Widget) m_workArea); XtDestroyWidget ((Widget) m_workArea);
} }
// We need to destroy the base class icons here before we stop
// the event loop. This is a hack until we have a real top level
// window (which would be responsible for killing the event loop).
m_icons.m_icons.Empty();
if (m_frameWidget) if (m_frameWidget)
{ {
wxDeleteWindowFromTable((Widget) m_frameWidget); wxDeleteWindowFromTable((Widget) m_frameWidget);

View File

@@ -48,7 +48,6 @@ END_EVENT_TABLE()
wxStaticBox::wxStaticBox() wxStaticBox::wxStaticBox()
{ {
m_formWidget = (WXWidget) 0;
m_labelWidget = (WXWidget) 0; m_labelWidget = (WXWidget) 0;
} }
@@ -59,8 +58,6 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
long style, long style,
const wxString& name) const wxString& name)
{ {
m_formWidget = (WXWidget) 0;
m_labelWidget = (WXWidget) 0;
m_backgroundColour = parent->GetBackgroundColour(); m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour(); m_foregroundColour = parent->GetForegroundColour();
m_font = parent->GetFont(); m_font = parent->GetFont();
@@ -76,59 +73,35 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
m_windowStyle = style; m_windowStyle = style;
bool hasLabel = (!label.IsNull() && !label.IsEmpty()) ;
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();
Widget formWidget = XtVaCreateManagedWidget ((char*) (const char*) name, m_mainWidget = XtVaCreateManagedWidget ("staticboxframe",
xmFormWidgetClass, parentWidget, xmFrameWidgetClass, parentWidget,
XmNmarginHeight, 0,
XmNmarginWidth, 0,
NULL);
if (hasLabel)
{
XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay(parentWidget));
wxString label1(wxStripMenuCodes(label));
XmString text = XmStringCreateSimple ((char*) (const char*) label1);
m_labelWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) label1,
xmLabelWidgetClass, formWidget,
XmNfontList, fontList,
XmNlabelString, text,
NULL);
XmStringFree (text);
}
Widget frameWidget = XtVaCreateManagedWidget ("frame",
xmFrameWidgetClass, formWidget,
XmNshadowType, XmSHADOW_IN, XmNshadowType, XmSHADOW_IN,
//XmNmarginHeight, 0, //XmNmarginHeight, 0,
//XmNmarginWidth, 0, //XmNmarginWidth, 0,
NULL); NULL);
bool hasLabel = (!label.IsNull() && !label.IsEmpty()) ;
if (hasLabel) if (hasLabel)
XtVaSetValues ((Widget) m_labelWidget, {
XmNtopAttachment, XmATTACH_FORM, XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay(parentWidget));
XmNleftAttachment, XmATTACH_FORM, wxString label1(wxStripMenuCodes(label));
XmNrightAttachment, XmATTACH_FORM, wxXmString text(label1);
XmNalignment, XmALIGNMENT_BEGINNING, m_labelWidget = (WXWidget) XtVaCreateManagedWidget (label1.c_str(),
xmLabelWidgetClass, (Widget)m_mainWidget,
XmNfontList, fontList,
XmNlabelString, text(),
#if (XmVersion > 1200)
XmNframeChildType, XmFRAME_TITLE_CHILD,
#else
XmNchildType, XmFRAME_TITLE_CHILD,
#endif
NULL); NULL);
}
XtVaSetValues (frameWidget,
XmNtopAttachment, hasLabel ? XmATTACH_WIDGET : XmATTACH_FORM,
XmNtopWidget, hasLabel ? (Widget) m_labelWidget : formWidget,
XmNbottomAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
m_mainWidget = (WXWidget) frameWidget;
m_formWidget = (WXWidget) formWidget;
SetCanAddEventHandler(TRUE); SetCanAddEventHandler(TRUE);
AttachWidget (parent, (WXWidget) frameWidget, (WXWidget) formWidget, pos.x, pos.y, size.x, size.y); AttachWidget (parent, m_mainWidget, NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour(); ChangeBackgroundColour();
return TRUE; return TRUE;
@@ -136,16 +109,11 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
wxStaticBox::~wxStaticBox() wxStaticBox::~wxStaticBox()
{ {
DetachWidget(m_formWidget);
DetachWidget(m_mainWidget); DetachWidget(m_mainWidget);
XtDestroyWidget((Widget) m_mainWidget); XtDestroyWidget((Widget) m_mainWidget);
if (m_labelWidget)
XtDestroyWidget((Widget) m_labelWidget);
XtDestroyWidget((Widget) m_formWidget);
m_mainWidget = (WXWidget) 0; m_mainWidget = (WXWidget) 0;
m_labelWidget = (WXWidget) 0; m_labelWidget = (WXWidget) 0;
m_formWidget = (WXWidget) 0;
} }
void wxStaticBox::SetLabel(const wxString& label) void wxStaticBox::SetLabel(const wxString& label)
@@ -157,12 +125,11 @@ void wxStaticBox::SetLabel(const wxString& label)
{ {
wxString label1(wxStripMenuCodes(label)); wxString label1(wxStripMenuCodes(label));
XmString text = XmStringCreateSimple ((char*) (const char*) label1); wxXmString text(label1);
XtVaSetValues ((Widget) m_labelWidget, XtVaSetValues ((Widget) m_labelWidget,
XmNlabelString, text, XmNlabelString, text(),
XmNlabelType, XmSTRING, XmNlabelType, XmSTRING,
NULL); NULL);
XmStringFree (text);
} }
} }
@@ -192,40 +159,9 @@ wxString wxStaticBox::GetLabel() const
} }
} }
void wxStaticBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
wxControl::DoSetSize (x, y, width, height, sizeFlags);
if (m_labelWidget)
{
Dimension xx, yy;
XtVaGetValues ((Widget) m_labelWidget, XmNwidth, &xx, XmNheight, &yy, NULL);
if (width > -1)
XtVaSetValues ((Widget) m_mainWidget, XmNwidth, width,
NULL);
if (height > -1)
XtVaSetValues ((Widget) m_mainWidget, XmNheight, height - yy,
NULL);
}
}
void wxStaticBox::ChangeFont(bool keepOriginalSize) void wxStaticBox::ChangeFont(bool keepOriginalSize)
{ {
wxWindow::ChangeFont(keepOriginalSize); wxWindow::ChangeFont(keepOriginalSize);
} }
void wxStaticBox::ChangeBackgroundColour()
{
wxWindow::ChangeBackgroundColour();
if (m_labelWidget)
DoChangeBackgroundColour(m_labelWidget, m_backgroundColour);
}
void wxStaticBox::ChangeForegroundColour()
{
wxWindow::ChangeForegroundColour();
if (m_labelWidget)
DoChangeForegroundColour(m_labelWidget, m_foregroundColour);
}

View File

@@ -164,9 +164,8 @@ wxToolBarTool::~wxToolBarTool()
{ {
if ( m_widget ) if ( m_widget )
XtDestroyWidget(m_widget); XtDestroyWidget(m_widget);
if ( m_pixmap ) // note: do not delete m_pixmap here because it will be deleted
XmDestroyPixmap(DefaultScreenOfDisplay((Display*)wxGetDisplay()), // by the base class when the bitmap is destroyed.
m_pixmap);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------