]>
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"
17 #define XtDisplay XTDISPLAY
22 #include "wx/statbox.h"
26 #pragma message disable nosimpint
31 #include <Xm/LabelG.h>
33 #pragma message enable nosimpint
36 #include "wx/motif/private.h"
38 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
)
40 BEGIN_EVENT_TABLE(wxStaticBox
, wxControl
)
41 //EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
49 wxStaticBox::wxStaticBox()
51 m_formWidget
= (WXWidget
) 0;
52 m_labelWidget
= (WXWidget
) 0;
55 bool wxStaticBox::Create(wxWindow
*parent
, wxWindowID id
,
56 const wxString
& label
,
62 m_formWidget
= (WXWidget
) 0;
63 m_labelWidget
= (WXWidget
) 0;
64 m_backgroundColour
= parent
->GetBackgroundColour();
65 m_foregroundColour
= parent
->GetForegroundColour();
66 m_font
= parent
->GetFont();
70 if (parent
) parent
->AddChild(this);
73 m_windowId
= (int)NewControlId();
77 m_windowStyle
= style
;
79 bool hasLabel
= (!label
.IsNull() && !label
.IsEmpty()) ;
81 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
83 Widget formWidget
= XtVaCreateManagedWidget ((char*) (const char*) name
,
84 xmFormWidgetClass
, parentWidget
,
92 XmFontList fontList
= (XmFontList
) m_font
.GetFontList(1.0, XtDisplay(parentWidget
));
94 wxString
label1(wxStripMenuCodes(label
));
95 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
96 m_labelWidget
= (WXWidget
) XtVaCreateManagedWidget ((char*) (const char*) label1
,
97 xmLabelWidgetClass
, formWidget
,
98 XmNfontList
, fontList
,
104 Widget frameWidget
= XtVaCreateManagedWidget ("frame",
105 xmFrameWidgetClass
, formWidget
,
106 XmNshadowType
, XmSHADOW_IN
,
107 //XmNmarginHeight, 0,
112 XtVaSetValues ((Widget
) m_labelWidget
,
113 XmNtopAttachment
, XmATTACH_FORM
,
114 XmNleftAttachment
, XmATTACH_FORM
,
115 XmNrightAttachment
, XmATTACH_FORM
,
116 XmNalignment
, XmALIGNMENT_BEGINNING
,
119 XtVaSetValues (frameWidget
,
120 XmNtopAttachment
, hasLabel
? XmATTACH_WIDGET
: XmATTACH_FORM
,
121 XmNtopWidget
, hasLabel
? (Widget
) m_labelWidget
: formWidget
,
122 XmNbottomAttachment
, XmATTACH_FORM
,
123 XmNleftAttachment
, XmATTACH_FORM
,
124 XmNrightAttachment
, XmATTACH_FORM
,
127 m_mainWidget
= (WXWidget
) frameWidget
;
128 m_formWidget
= (WXWidget
) formWidget
;
130 SetCanAddEventHandler(TRUE
);
131 AttachWidget (parent
, (WXWidget
) frameWidget
, (WXWidget
) formWidget
, pos
.x
, pos
.y
, size
.x
, size
.y
);
132 ChangeBackgroundColour();
137 wxStaticBox::~wxStaticBox()
139 DetachWidget(m_formWidget
);
140 DetachWidget(m_mainWidget
);
141 XtDestroyWidget((Widget
) m_mainWidget
);
143 XtDestroyWidget((Widget
) m_labelWidget
);
144 XtDestroyWidget((Widget
) m_formWidget
);
146 m_mainWidget
= (WXWidget
) 0;
147 m_labelWidget
= (WXWidget
) 0;
148 m_formWidget
= (WXWidget
) 0;
151 void wxStaticBox::SetLabel(const wxString
& label
)
158 wxString
label1(wxStripMenuCodes(label
));
160 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
161 XtVaSetValues ((Widget
) m_labelWidget
,
162 XmNlabelString
, text
,
163 XmNlabelType
, XmSTRING
,
169 wxString
wxStaticBox::GetLabel() const
172 return wxEmptyString
;
176 XtVaGetValues ((Widget
) m_labelWidget
,
177 XmNlabelString
, &text
,
181 return wxEmptyString
;
183 if (XmStringGetLtoR (text
, XmSTRING_DEFAULT_CHARSET
, &s
))
191 return wxEmptyString
;
195 void wxStaticBox::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
197 wxControl::DoSetSize (x
, y
, width
, height
, sizeFlags
);
202 XtVaGetValues ((Widget
) m_labelWidget
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
205 XtVaSetValues ((Widget
) m_mainWidget
, XmNwidth
, width
,
208 XtVaSetValues ((Widget
) m_mainWidget
, XmNheight
, height
- yy
,
213 void wxStaticBox::ChangeFont(bool keepOriginalSize
)
215 wxWindow::ChangeFont(keepOriginalSize
);
218 void wxStaticBox::ChangeBackgroundColour()
220 wxWindow::ChangeBackgroundColour();
222 DoChangeBackgroundColour(m_labelWidget
, m_backgroundColour
);
225 void wxStaticBox::ChangeForegroundColour()
227 wxWindow::ChangeForegroundColour();
229 DoChangeForegroundColour(m_labelWidget
, m_foregroundColour
);