]>
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
= (WXWidget
) frameWidget
;
118 m_formWidget
= (WXWidget
) formWidget
;
120 SetCanAddEventHandler(TRUE
);
121 AttachWidget (parent
, (WXWidget
) frameWidget
, (WXWidget
) formWidget
, pos
.x
, pos
.y
, size
.x
, size
.y
);
122 ChangeBackgroundColour();
127 wxStaticBox::~wxStaticBox()
129 DetachWidget(m_formWidget
);
132 void wxStaticBox::SetLabel(const wxString
& label
)
139 wxString
label1(wxStripMenuCodes(label
));
141 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
142 XtVaSetValues ((Widget
) m_labelWidget
,
143 XmNlabelString
, text
,
144 XmNlabelType
, XmSTRING
,
150 wxString
wxStaticBox::GetLabel() const
153 return wxEmptyString
;
157 XtVaGetValues ((Widget
) m_labelWidget
,
158 XmNlabelString
, &text
,
162 return wxEmptyString
;
164 if (XmStringGetLtoR (text
, XmSTRING_DEFAULT_CHARSET
, &s
))
172 return wxEmptyString
;
176 void wxStaticBox::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
178 wxControl::SetSize (x
, y
, width
, height
, sizeFlags
);
183 XtVaGetValues ((Widget
) m_labelWidget
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
186 XtVaSetValues ((Widget
) m_mainWidget
, XmNwidth
, width
,
189 XtVaSetValues ((Widget
) m_mainWidget
, XmNheight
, height
- yy
,
194 void wxStaticBox::ChangeFont(bool keepOriginalSize
)
196 wxWindow::ChangeFont(keepOriginalSize
);
199 void wxStaticBox::ChangeBackgroundColour()
201 wxWindow::ChangeBackgroundColour();
203 DoChangeBackgroundColour(m_labelWidget
, m_backgroundColour
);
206 void wxStaticBox::ChangeForegroundColour()
208 wxWindow::ChangeForegroundColour();
210 DoChangeForegroundColour(m_labelWidget
, m_foregroundColour
);