]>
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;
57 if (parent
) parent
->AddChild(this);
60 m_windowId
= (int)NewControlId();
64 m_windowStyle
= style
;
66 bool hasLabel
= (!label
.IsNull() && !label
.IsEmpty()) ;
68 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
70 Widget formWidget
= XtVaCreateManagedWidget ((char*) (const char*) name
,
71 xmFormWidgetClass
, parentWidget
,
79 wxString
label1(wxStripMenuCodes(label
));
80 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
81 m_labelWidget
= (WXWidget
) XtVaCreateManagedWidget ((char*) (const char*) label1
,
82 xmLabelWidgetClass
, formWidget
,
88 Widget frameWidget
= XtVaCreateManagedWidget ("frame",
89 xmFrameWidgetClass
, formWidget
,
90 XmNshadowType
, XmSHADOW_IN
,
91 // XmNmarginHeight, 0,
96 XtVaSetValues ((Widget
) m_labelWidget
,
97 XmNtopAttachment
, XmATTACH_FORM
,
98 XmNleftAttachment
, XmATTACH_FORM
,
99 XmNrightAttachment
, XmATTACH_FORM
,
100 XmNalignment
, XmALIGNMENT_BEGINNING
,
103 XtVaSetValues (frameWidget
,
104 XmNtopAttachment
, hasLabel
? XmATTACH_WIDGET
: XmATTACH_FORM
,
105 XmNtopWidget
, hasLabel
? (Widget
) m_labelWidget
: formWidget
,
106 XmNbottomAttachment
, XmATTACH_FORM
,
107 XmNleftAttachment
, XmATTACH_FORM
,
108 XmNrightAttachment
, XmATTACH_FORM
,
111 m_mainWidget
= (Widget
) formWidget
;
113 SetCanAddEventHandler(TRUE
);
114 AttachWidget (parent
, m_mainWidget
, (WXWidget
) frameWidget
, pos
.x
, pos
.y
, size
.x
, size
.y
);
115 ChangeColour(m_mainWidget
);
120 void wxStaticBox::SetLabel(const wxString
& label
)
127 wxString
label1(wxStripMenuCodes(label
));
129 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
130 XtVaSetValues ((Widget
) m_labelWidget
,
131 XmNlabelString
, text
,
132 XmNlabelType
, XmSTRING
,
138 wxString
wxStaticBox::GetLabel() const
141 return wxEmptyString
;
145 XtVaGetValues ((Widget
) m_labelWidget
,
146 XmNlabelString
, &text
,
150 return wxEmptyString
;
152 if (XmStringGetLtoR (text
, XmSTRING_DEFAULT_CHARSET
, &s
))
160 return wxEmptyString
;
164 void wxStaticBox::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
166 wxControl::SetSize (x
, y
, width
, height
, sizeFlags
);
171 XtVaGetValues ((Widget
) m_labelWidget
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
174 XtVaSetValues ((Widget
) m_mainWidget
, XmNwidth
, width
,
177 XtVaSetValues ((Widget
) m_mainWidget
, XmNheight
, height
- yy
,