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"
23 #pragma message disable nosimpint
28 #pragma message enable nosimpint
31 #include "wx/motif/private.h"
33 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
)
35 BEGIN_EVENT_TABLE(wxStaticBox
, wxControl
)
36 //EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
43 // helper class to reduce code duplication
49 wxXmSizeKeeper( Widget w
)
52 XtVaGetValues( m_widget
,
62 XtVaGetValues( m_widget
,
66 if( x
!= m_x
|| y
!= m_y
)
67 XtVaSetValues( m_widget
,
78 wxStaticBox::wxStaticBox()
80 m_labelWidget
= (WXWidget
) 0;
83 bool wxStaticBox::Create(wxWindow
*parent
, wxWindowID id
,
84 const wxString
& label
,
90 if( !CreateControl( parent
, id
, pos
, size
, style
,
91 wxDefaultValidator
, name
) )
94 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
96 m_mainWidget
= XtVaCreateManagedWidget ("staticboxframe",
97 xmFrameWidgetClass
, parentWidget
,
98 // MBN: why override default?
99 // XmNshadowType, XmSHADOW_IN,
104 wxString
label1(wxStripMenuCodes(label
));
105 wxXmString
text(label1
);
106 Display
* dpy
= XtDisplay( parentWidget
);
108 m_labelWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticboxlabel",
109 xmLabelWidgetClass
, (Widget
)m_mainWidget
,
110 wxFont::GetFontTag(), m_font
.GetFontTypeC(dpy
),
111 XmNlabelString
, text(),
112 #if wxCHECK_MOTIF_VERSION( 2, 0 )
113 XmNframeChildType
, XmFRAME_TITLE_CHILD
,
115 XmNchildType
, XmFRAME_TITLE_CHILD
,
120 AttachWidget (parent
, m_mainWidget
, NULL
, pos
.x
, pos
.y
, size
.x
, size
.y
);
121 ChangeBackgroundColour();
126 wxStaticBox::~wxStaticBox()
128 DetachWidget(m_mainWidget
);
129 XtDestroyWidget((Widget
) m_mainWidget
);
131 m_mainWidget
= (WXWidget
) 0;
132 m_labelWidget
= (WXWidget
) 0;
135 void wxStaticBox::SetLabel( const wxString
& label
)
137 wxXmSizeKeeper
sk( (Widget
)GetMainWidget() );
139 wxStaticBoxBase::SetLabel( label
);
144 void wxStaticBox::GetBordersForSizer(int *borderTop
, int *borderOther
) const
146 Dimension shadow
, border
;
148 XtVaGetValues( (Widget
) GetMainWidget(),
149 XmNshadowThickness
, &shadow
,
150 XmNborderWidth
, &border
,
153 *borderOther
= shadow
+ border
;
155 if( GetLabelWidget() )
157 XtWidgetGeometry preferred
;
158 XtQueryGeometry( (Widget
) GetLabelWidget(), NULL
, &preferred
);
160 *borderTop
= preferred
.height
;