]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/statbox.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxStaticBox
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "statbox.h"
16 #include "wx/statbox.h"
22 #include <Xm/LabelG.h>
24 #include <wx/motif/private.h>
26 #if !USE_SHARED_LIBRARY
27 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
)
29 BEGIN_EVENT_TABLE(wxStaticBox
, wxControl
)
30 EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground
)
39 wxStaticBox::wxStaticBox()
41 m_formWidget
= (WXWidget
) 0;
42 m_labelWidget
= (WXWidget
) 0;
45 bool wxStaticBox::Create(wxWindow
*parent
, wxWindowID id
,
46 const wxString
& label
,
52 m_formWidget
= (WXWidget
) 0;
53 m_labelWidget
= (WXWidget
) 0;
54 m_backgroundColour
= parent
->GetBackgroundColour();
55 m_foregroundColour
= parent
->GetForegroundColour();
59 if (parent
) parent
->AddChild(this);
62 m_windowId
= (int)NewControlId();
66 m_windowStyle
= style
;
68 bool hasLabel
= (!label
.IsNull() && !label
.IsEmpty()) ;
70 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
72 Widget formWidget
= XtVaCreateManagedWidget ((char*) (const char*) name
,
73 xmFormWidgetClass
, parentWidget
,
81 wxString
label1(wxStripMenuCodes(label
));
82 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
83 m_labelWidget
= (WXWidget
) XtVaCreateManagedWidget ((char*) (const char*) label1
,
84 xmLabelWidgetClass
, formWidget
,
90 Widget frameWidget
= XtVaCreateManagedWidget ("frame",
91 xmFrameWidgetClass
, formWidget
,
92 XmNshadowType
, XmSHADOW_IN
,
93 // XmNmarginHeight, 0,
98 XtVaSetValues ((Widget
) m_labelWidget
,
99 XmNtopAttachment
, XmATTACH_FORM
,
100 XmNleftAttachment
, XmATTACH_FORM
,
101 XmNrightAttachment
, XmATTACH_FORM
,
102 XmNalignment
, XmALIGNMENT_BEGINNING
,
105 XtVaSetValues (frameWidget
,
106 XmNtopAttachment
, hasLabel
? XmATTACH_WIDGET
: XmATTACH_FORM
,
107 XmNtopWidget
, hasLabel
? (Widget
) m_labelWidget
: formWidget
,
108 XmNbottomAttachment
, XmATTACH_FORM
,
109 XmNleftAttachment
, XmATTACH_FORM
,
110 XmNrightAttachment
, XmATTACH_FORM
,
113 m_mainWidget
= (Widget
) formWidget
;
115 SetCanAddEventHandler(TRUE
);
116 AttachWidget (parent
, m_mainWidget
, (WXWidget
) frameWidget
, pos
.x
, pos
.y
, size
.x
, size
.y
);
117 ChangeBackgroundColour();
122 void wxStaticBox::SetLabel(const wxString
& label
)
129 wxString
label1(wxStripMenuCodes(label
));
131 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
132 XtVaSetValues ((Widget
) m_labelWidget
,
133 XmNlabelString
, text
,
134 XmNlabelType
, XmSTRING
,
140 wxString
wxStaticBox::GetLabel() const
143 return wxEmptyString
;
147 XtVaGetValues ((Widget
) m_labelWidget
,
148 XmNlabelString
, &text
,
152 return wxEmptyString
;
154 if (XmStringGetLtoR (text
, XmSTRING_DEFAULT_CHARSET
, &s
))
162 return wxEmptyString
;
166 void wxStaticBox::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
168 wxControl::SetSize (x
, y
, width
, height
, sizeFlags
);
173 XtVaGetValues ((Widget
) m_labelWidget
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
176 XtVaSetValues ((Widget
) m_mainWidget
, XmNwidth
, width
,
179 XtVaSetValues ((Widget
) m_mainWidget
, XmNheight
, height
- yy
,
184 void wxStaticBox::ChangeFont()
189 void wxStaticBox::ChangeBackgroundColour()
194 void wxStaticBox::ChangeForegroundColour()