]>
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();
56 m_windowFont
= parent
->GetFont();
60 if (parent
) parent
->AddChild(this);
63 m_windowId
= (int)NewControlId();
67 m_windowStyle
= style
;
69 bool hasLabel
= (!label
.IsNull() && !label
.IsEmpty()) ;
71 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
73 Widget formWidget
= XtVaCreateManagedWidget ((char*) (const char*) name
,
74 xmFormWidgetClass
, parentWidget
,
82 XmFontList fontList
= (XmFontList
) m_windowFont
.GetFontList(1.0, XtDisplay(parentWidget
));
84 wxString
label1(wxStripMenuCodes(label
));
85 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
86 m_labelWidget
= (WXWidget
) XtVaCreateManagedWidget ((char*) (const char*) label1
,
87 xmLabelWidgetClass
, formWidget
,
88 XmNfontList
, fontList
,
94 Widget frameWidget
= XtVaCreateManagedWidget ("frame",
95 xmFrameWidgetClass
, formWidget
,
96 XmNshadowType
, XmSHADOW_IN
,
97 // XmNmarginHeight, 0,
102 XtVaSetValues ((Widget
) m_labelWidget
,
103 XmNtopAttachment
, XmATTACH_FORM
,
104 XmNleftAttachment
, XmATTACH_FORM
,
105 XmNrightAttachment
, XmATTACH_FORM
,
106 XmNalignment
, XmALIGNMENT_BEGINNING
,
109 XtVaSetValues (frameWidget
,
110 XmNtopAttachment
, hasLabel
? XmATTACH_WIDGET
: XmATTACH_FORM
,
111 XmNtopWidget
, hasLabel
? (Widget
) m_labelWidget
: formWidget
,
112 XmNbottomAttachment
, XmATTACH_FORM
,
113 XmNleftAttachment
, XmATTACH_FORM
,
114 XmNrightAttachment
, XmATTACH_FORM
,
117 m_mainWidget
= (Widget
) formWidget
;
119 SetCanAddEventHandler(TRUE
);
120 AttachWidget (parent
, m_mainWidget
, (WXWidget
) frameWidget
, pos
.x
, pos
.y
, size
.x
, size
.y
);
121 ChangeBackgroundColour();
126 void wxStaticBox::SetLabel(const wxString
& label
)
133 wxString
label1(wxStripMenuCodes(label
));
135 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
136 XtVaSetValues ((Widget
) m_labelWidget
,
137 XmNlabelString
, text
,
138 XmNlabelType
, XmSTRING
,
144 wxString
wxStaticBox::GetLabel() const
147 return wxEmptyString
;
151 XtVaGetValues ((Widget
) m_labelWidget
,
152 XmNlabelString
, &text
,
156 return wxEmptyString
;
158 if (XmStringGetLtoR (text
, XmSTRING_DEFAULT_CHARSET
, &s
))
166 return wxEmptyString
;
170 void wxStaticBox::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
172 wxControl::SetSize (x
, y
, width
, height
, sizeFlags
);
177 XtVaGetValues ((Widget
) m_labelWidget
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
180 XtVaSetValues ((Widget
) m_mainWidget
, XmNwidth
, width
,
183 XtVaSetValues ((Widget
) m_mainWidget
, XmNheight
, height
- yy
,
188 void wxStaticBox::ChangeFont(bool keepOriginalSize
)
190 wxWindow::ChangeFont(keepOriginalSize
);
193 void wxStaticBox::ChangeBackgroundColour()
195 wxWindow::ChangeBackgroundColour();
198 void wxStaticBox::ChangeForegroundColour()
200 wxWindow::ChangeForegroundColour();