]>
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 void wxStaticBox::SetLabel(const wxString
& label
)
134 wxString
label1(wxStripMenuCodes(label
));
136 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
137 XtVaSetValues ((Widget
) m_labelWidget
,
138 XmNlabelString
, text
,
139 XmNlabelType
, XmSTRING
,
145 wxString
wxStaticBox::GetLabel() const
148 return wxEmptyString
;
152 XtVaGetValues ((Widget
) m_labelWidget
,
153 XmNlabelString
, &text
,
157 return wxEmptyString
;
159 if (XmStringGetLtoR (text
, XmSTRING_DEFAULT_CHARSET
, &s
))
167 return wxEmptyString
;
171 void wxStaticBox::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
173 wxControl::SetSize (x
, y
, width
, height
, sizeFlags
);
178 XtVaGetValues ((Widget
) m_labelWidget
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
181 XtVaSetValues ((Widget
) m_mainWidget
, XmNwidth
, width
,
184 XtVaSetValues ((Widget
) m_mainWidget
, XmNheight
, height
- yy
,
189 void wxStaticBox::ChangeFont(bool keepOriginalSize
)
191 wxWindow::ChangeFont(keepOriginalSize
);
194 void wxStaticBox::ChangeBackgroundColour()
196 wxWindow::ChangeBackgroundColour();
199 void wxStaticBox::ChangeForegroundColour()
201 wxWindow::ChangeForegroundColour();