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 BEGIN_EVENT_TABLE(wxStaticBox
, wxControl
)
33 //EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 // helper class to reduce code duplication
46 wxXmSizeKeeper( Widget w
)
49 XtVaGetValues( m_widget
,
59 XtVaGetValues( m_widget
,
63 if( x
!= m_x
|| y
!= m_y
)
64 XtVaSetValues( m_widget
,
75 wxStaticBox::wxStaticBox()
77 m_labelWidget
= (WXWidget
) 0;
80 bool wxStaticBox::Create(wxWindow
*parent
, wxWindowID id
,
81 const wxString
& label
,
87 if( !CreateControl( parent
, id
, pos
, size
, style
,
88 wxDefaultValidator
, name
) )
90 m_labelWidget
= (WXWidget
) 0;
93 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
95 m_mainWidget
= XtVaCreateManagedWidget ("staticboxframe",
96 xmFrameWidgetClass
, parentWidget
,
97 // MBN: why override default?
98 // XmNshadowType, XmSHADOW_IN,
103 wxString
label1(GetLabelText(label
));
104 wxXmString
text(label1
);
105 Display
* dpy
= XtDisplay( parentWidget
);
107 m_labelWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticboxlabel",
108 xmLabelWidgetClass
, (Widget
)m_mainWidget
,
109 wxFont::GetFontTag(), m_font
.GetFontTypeC(dpy
),
110 XmNlabelString
, text(),
111 #if wxCHECK_MOTIF_VERSION( 2, 0 )
112 XmNframeChildType
, XmFRAME_TITLE_CHILD
,
114 XmNchildType
, XmFRAME_TITLE_CHILD
,
120 AttachWidget (parent
, m_mainWidget
, NULL
, pos
.x
, pos
.y
, size
.x
, size
.y
);
125 wxStaticBox::~wxStaticBox()
127 DetachWidget(m_mainWidget
);
128 XtDestroyWidget((Widget
) m_mainWidget
);
130 m_mainWidget
= (WXWidget
) 0;
131 m_labelWidget
= (WXWidget
) 0;
134 void wxStaticBox::SetLabel( const wxString
& label
)
136 wxXmSizeKeeper
sk( (Widget
)GetMainWidget() );
138 wxStaticBoxBase::SetLabel( label
);
143 void wxStaticBox::GetBordersForSizer(int *borderTop
, int *borderOther
) const
145 Dimension shadow
, border
;
147 XtVaGetValues( (Widget
) GetMainWidget(),
148 XmNshadowThickness
, &shadow
,
149 XmNborderWidth
, &border
,
152 *borderOther
= shadow
+ border
;
154 if( GetLabelWidget() )
156 XtWidgetGeometry preferred
;
157 XtQueryGeometry( (Widget
) GetLabelWidget(), NULL
, &preferred
);
159 *borderTop
= preferred
.height
;