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
) )
96 m_labelWidget
= (WXWidget
) 0;
99 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
101 m_mainWidget
= XtVaCreateManagedWidget ("staticboxframe",
102 xmFrameWidgetClass
, parentWidget
,
103 // MBN: why override default?
104 // XmNshadowType, XmSHADOW_IN,
109 wxString
label1(GetLabelText(label
));
110 wxXmString
text(label1
);
111 Display
* dpy
= XtDisplay( parentWidget
);
113 m_labelWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticboxlabel",
114 xmLabelWidgetClass
, (Widget
)m_mainWidget
,
115 wxFont::GetFontTag(), m_font
.GetFontTypeC(dpy
),
116 XmNlabelString
, text(),
117 #if wxCHECK_MOTIF_VERSION( 2, 0 )
118 XmNframeChildType
, XmFRAME_TITLE_CHILD
,
120 XmNchildType
, XmFRAME_TITLE_CHILD
,
126 AttachWidget (parent
, m_mainWidget
, NULL
, pos
.x
, pos
.y
, size
.x
, size
.y
);
131 wxStaticBox::~wxStaticBox()
133 DetachWidget(m_mainWidget
);
134 XtDestroyWidget((Widget
) m_mainWidget
);
136 m_mainWidget
= (WXWidget
) 0;
137 m_labelWidget
= (WXWidget
) 0;
140 void wxStaticBox::SetLabel( const wxString
& label
)
142 wxXmSizeKeeper
sk( (Widget
)GetMainWidget() );
144 wxStaticBoxBase::SetLabel( label
);
149 void wxStaticBox::GetBordersForSizer(int *borderTop
, int *borderOther
) const
151 Dimension shadow
, border
;
153 XtVaGetValues( (Widget
) GetMainWidget(),
154 XmNshadowThickness
, &shadow
,
155 XmNborderWidth
, &border
,
158 *borderOther
= shadow
+ border
;
160 if( GetLabelWidget() )
162 XtWidgetGeometry preferred
;
163 XtQueryGeometry( (Widget
) GetLabelWidget(), NULL
, &preferred
);
165 *borderTop
= preferred
.height
;