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"
15 #include "wx/statbox.h"
22 #pragma message disable nosimpint
27 #pragma message enable nosimpint
30 #include "wx/motif/private.h"
32 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
)
34 BEGIN_EVENT_TABLE(wxStaticBox
, wxControl
)
35 //EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 // helper class to reduce code duplication
48 wxXmSizeKeeper( Widget w
)
51 XtVaGetValues( m_widget
,
61 XtVaGetValues( m_widget
,
65 if( x
!= m_x
|| y
!= m_y
)
66 XtVaSetValues( m_widget
,
77 wxStaticBox::wxStaticBox()
79 m_labelWidget
= (WXWidget
) 0;
82 bool wxStaticBox::Create(wxWindow
*parent
, wxWindowID id
,
83 const wxString
& label
,
89 if( !CreateControl( parent
, id
, pos
, size
, style
,
90 wxDefaultValidator
, name
) )
92 m_labelWidget
= (WXWidget
) 0;
95 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
97 m_mainWidget
= XtVaCreateManagedWidget ("staticboxframe",
98 xmFrameWidgetClass
, parentWidget
,
99 // MBN: why override default?
100 // XmNshadowType, XmSHADOW_IN,
105 wxString
label1(GetLabelText(label
));
106 wxXmString
text(label1
);
107 Display
* dpy
= XtDisplay( parentWidget
);
109 m_labelWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticboxlabel",
110 xmLabelWidgetClass
, (Widget
)m_mainWidget
,
111 wxFont::GetFontTag(), m_font
.GetFontTypeC(dpy
),
112 XmNlabelString
, text(),
113 #if wxCHECK_MOTIF_VERSION( 2, 0 )
114 XmNframeChildType
, XmFRAME_TITLE_CHILD
,
116 XmNchildType
, XmFRAME_TITLE_CHILD
,
122 AttachWidget (parent
, m_mainWidget
, NULL
, pos
.x
, pos
.y
, size
.x
, size
.y
);
127 wxStaticBox::~wxStaticBox()
129 DetachWidget(m_mainWidget
);
130 XtDestroyWidget((Widget
) m_mainWidget
);
132 m_mainWidget
= (WXWidget
) 0;
133 m_labelWidget
= (WXWidget
) 0;
136 void wxStaticBox::SetLabel( const wxString
& label
)
138 wxXmSizeKeeper
sk( (Widget
)GetMainWidget() );
140 wxStaticBoxBase::SetLabel( label
);
145 void wxStaticBox::GetBordersForSizer(int *borderTop
, int *borderOther
) const
147 Dimension shadow
, border
;
149 XtVaGetValues( (Widget
) GetMainWidget(),
150 XmNshadowThickness
, &shadow
,
151 XmNborderWidth
, &border
,
154 *borderOther
= shadow
+ border
;
156 if( GetLabelWidget() )
158 XtWidgetGeometry preferred
;
159 XtQueryGeometry( (Widget
) GetLabelWidget(), NULL
, &preferred
);
161 *borderTop
= preferred
.height
;