1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/statbox.cpp
3 // Purpose: wxStaticBox
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
14 #include "wx/statbox.h"
21 #pragma message disable nosimpint
26 #pragma message enable nosimpint
29 #include "wx/motif/private.h"
31 BEGIN_EVENT_TABLE(wxStaticBox
, wxControl
)
32 //EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 // helper class to reduce code duplication
45 wxXmSizeKeeper( Widget w
)
48 XtVaGetValues( m_widget
,
58 XtVaGetValues( m_widget
,
62 if( x
!= m_x
|| y
!= m_y
)
63 XtVaSetValues( m_widget
,
74 wxStaticBox::wxStaticBox()
76 m_labelWidget
= (WXWidget
) 0;
79 bool wxStaticBox::Create(wxWindow
*parent
, wxWindowID id
,
80 const wxString
& label
,
86 if( !CreateControl( parent
, id
, pos
, size
, style
,
87 wxDefaultValidator
, name
) )
89 m_labelWidget
= (WXWidget
) 0;
92 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
94 m_mainWidget
= XtVaCreateManagedWidget ("staticboxframe",
95 xmFrameWidgetClass
, parentWidget
,
96 // MBN: why override default?
97 // XmNshadowType, XmSHADOW_IN,
102 wxString
label1(GetLabelText(label
));
103 wxXmString
text(label1
);
104 Display
* dpy
= XtDisplay( parentWidget
);
106 m_labelWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticboxlabel",
107 xmLabelWidgetClass
, (Widget
)m_mainWidget
,
108 wxFont::GetFontTag(), m_font
.GetFontTypeC(dpy
),
109 XmNlabelString
, text(),
110 #if wxCHECK_MOTIF_VERSION( 2, 0 )
111 XmNframeChildType
, XmFRAME_TITLE_CHILD
,
113 XmNchildType
, XmFRAME_TITLE_CHILD
,
119 AttachWidget (parent
, m_mainWidget
, NULL
, pos
.x
, pos
.y
, size
.x
, size
.y
);
124 wxStaticBox::~wxStaticBox()
126 DetachWidget(m_mainWidget
);
127 XtDestroyWidget((Widget
) m_mainWidget
);
129 m_mainWidget
= (WXWidget
) 0;
130 m_labelWidget
= (WXWidget
) 0;
133 void wxStaticBox::SetLabel( const wxString
& label
)
135 wxXmSizeKeeper
sk( (Widget
)GetMainWidget() );
137 wxStaticBoxBase::SetLabel( label
);
142 void wxStaticBox::GetBordersForSizer(int *borderTop
, int *borderOther
) const
144 Dimension shadow
, border
;
146 XtVaGetValues( (Widget
) GetMainWidget(),
147 XmNshadowThickness
, &shadow
,
148 XmNborderWidth
, &border
,
151 *borderOther
= shadow
+ border
;
153 if( GetLabelWidget() )
155 XtWidgetGeometry preferred
;
156 XtQueryGeometry( (Widget
) GetLabelWidget(), NULL
, &preferred
);
158 *borderTop
= preferred
.height
;