1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/statbox.cpp
3 // Purpose: wxStaticBox
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
16 #define XtDisplay XTDISPLAY
19 #include "wx/statbox.h"
26 #pragma message disable nosimpint
31 #pragma message enable nosimpint
34 #include "wx/motif/private.h"
36 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
)
38 BEGIN_EVENT_TABLE(wxStaticBox
, wxControl
)
39 //EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
42 // ----------------------------------------------------------------------------
44 // ----------------------------------------------------------------------------
46 // helper class to reduce code duplication
52 wxXmSizeKeeper( Widget w
)
55 XtVaGetValues( m_widget
,
65 XtVaGetValues( m_widget
,
69 if( x
!= m_x
|| y
!= m_y
)
70 XtVaSetValues( m_widget
,
81 wxStaticBox::wxStaticBox()
83 m_labelWidget
= (WXWidget
) 0;
86 bool wxStaticBox::Create(wxWindow
*parent
, wxWindowID id
,
87 const wxString
& label
,
93 if( !CreateControl( parent
, id
, pos
, size
, style
,
94 wxDefaultValidator
, name
) )
97 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
99 m_mainWidget
= XtVaCreateManagedWidget ("staticboxframe",
100 xmFrameWidgetClass
, parentWidget
,
101 // MBN: why override default?
102 // XmNshadowType, XmSHADOW_IN,
107 wxString
label1(wxStripMenuCodes(label
));
108 wxXmString
text(label1
);
109 Display
* dpy
= XtDisplay( parentWidget
);
111 m_labelWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticboxlabel",
112 xmLabelWidgetClass
, (Widget
)m_mainWidget
,
113 wxFont::GetFontTag(), m_font
.GetFontTypeC(dpy
),
114 XmNlabelString
, text(),
115 #if wxCHECK_MOTIF_VERSION( 2, 0 )
116 XmNframeChildType
, XmFRAME_TITLE_CHILD
,
118 XmNchildType
, XmFRAME_TITLE_CHILD
,
123 AttachWidget (parent
, m_mainWidget
, NULL
, pos
.x
, pos
.y
, size
.x
, size
.y
);
124 ChangeBackgroundColour();
129 wxStaticBox::~wxStaticBox()
131 DetachWidget(m_mainWidget
);
132 XtDestroyWidget((Widget
) m_mainWidget
);
134 m_mainWidget
= (WXWidget
) 0;
135 m_labelWidget
= (WXWidget
) 0;
138 void wxStaticBox::SetLabel( const wxString
& label
)
140 wxXmSizeKeeper
sk( (Widget
)GetMainWidget() );
142 wxStaticBoxBase::SetLabel( label
);
147 void wxStaticBox::GetBordersForSizer(int *borderTop
, int *borderOther
) const
149 Dimension shadow
, border
;
151 XtVaGetValues( (Widget
) GetMainWidget(),
152 XmNshadowThickness
, &shadow
,
153 XmNborderWidth
, &border
,
156 *borderOther
= shadow
+ border
;
158 if( GetLabelWidget() )
160 XtWidgetGeometry preferred
;
161 XtQueryGeometry( (Widget
) GetLabelWidget(), NULL
, &preferred
);
163 *borderTop
= preferred
.height
;