]>
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"
20 #pragma message disable nosimpint
25 #include <Xm/LabelG.h>
27 #pragma message enable nosimpint
30 #include "wx/motif/private.h"
32 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
)
34 BEGIN_EVENT_TABLE(wxStaticBox
, wxControl
)
35 //EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
43 wxStaticBox::wxStaticBox()
45 m_formWidget
= (WXWidget
) 0;
46 m_labelWidget
= (WXWidget
) 0;
49 bool wxStaticBox::Create(wxWindow
*parent
, wxWindowID id
,
50 const wxString
& label
,
56 m_formWidget
= (WXWidget
) 0;
57 m_labelWidget
= (WXWidget
) 0;
58 m_backgroundColour
= parent
->GetBackgroundColour();
59 m_foregroundColour
= parent
->GetForegroundColour();
60 m_font
= parent
->GetFont();
64 if (parent
) parent
->AddChild(this);
67 m_windowId
= (int)NewControlId();
71 m_windowStyle
= style
;
73 bool hasLabel
= (!label
.IsNull() && !label
.IsEmpty()) ;
75 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
77 Widget formWidget
= XtVaCreateManagedWidget ((char*) (const char*) name
,
78 xmFormWidgetClass
, parentWidget
,
86 XmFontList fontList
= (XmFontList
) m_font
.GetFontList(1.0, XtDisplay(parentWidget
));
88 wxString
label1(wxStripMenuCodes(label
));
89 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
90 m_labelWidget
= (WXWidget
) XtVaCreateManagedWidget ((char*) (const char*) label1
,
91 xmLabelWidgetClass
, formWidget
,
92 XmNfontList
, fontList
,
98 Widget frameWidget
= XtVaCreateManagedWidget ("frame",
99 xmFrameWidgetClass
, formWidget
,
100 XmNshadowType
, XmSHADOW_IN
,
101 //XmNmarginHeight, 0,
106 XtVaSetValues ((Widget
) m_labelWidget
,
107 XmNtopAttachment
, XmATTACH_FORM
,
108 XmNleftAttachment
, XmATTACH_FORM
,
109 XmNrightAttachment
, XmATTACH_FORM
,
110 XmNalignment
, XmALIGNMENT_BEGINNING
,
113 XtVaSetValues (frameWidget
,
114 XmNtopAttachment
, hasLabel
? XmATTACH_WIDGET
: XmATTACH_FORM
,
115 XmNtopWidget
, hasLabel
? (Widget
) m_labelWidget
: formWidget
,
116 XmNbottomAttachment
, XmATTACH_FORM
,
117 XmNleftAttachment
, XmATTACH_FORM
,
118 XmNrightAttachment
, XmATTACH_FORM
,
121 m_mainWidget
= (WXWidget
) frameWidget
;
122 m_formWidget
= (WXWidget
) formWidget
;
124 SetCanAddEventHandler(TRUE
);
125 AttachWidget (parent
, (WXWidget
) frameWidget
, (WXWidget
) formWidget
, pos
.x
, pos
.y
, size
.x
, size
.y
);
126 ChangeBackgroundColour();
131 wxStaticBox::~wxStaticBox()
133 DetachWidget(m_formWidget
);
134 DetachWidget(m_mainWidget
);
135 XtDestroyWidget((Widget
) m_mainWidget
);
137 XtDestroyWidget((Widget
) m_labelWidget
);
138 XtDestroyWidget((Widget
) m_formWidget
);
140 m_mainWidget
= (WXWidget
) 0;
141 m_labelWidget
= (WXWidget
) 0;
142 m_formWidget
= (WXWidget
) 0;
145 void wxStaticBox::SetLabel(const wxString
& label
)
152 wxString
label1(wxStripMenuCodes(label
));
154 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
155 XtVaSetValues ((Widget
) m_labelWidget
,
156 XmNlabelString
, text
,
157 XmNlabelType
, XmSTRING
,
163 wxString
wxStaticBox::GetLabel() const
166 return wxEmptyString
;
170 XtVaGetValues ((Widget
) m_labelWidget
,
171 XmNlabelString
, &text
,
175 return wxEmptyString
;
177 if (XmStringGetLtoR (text
, XmSTRING_DEFAULT_CHARSET
, &s
))
185 return wxEmptyString
;
189 void wxStaticBox::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
191 wxControl::DoSetSize (x
, y
, width
, height
, sizeFlags
);
196 XtVaGetValues ((Widget
) m_labelWidget
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
199 XtVaSetValues ((Widget
) m_mainWidget
, XmNwidth
, width
,
202 XtVaSetValues ((Widget
) m_mainWidget
, XmNheight
, height
- yy
,
207 void wxStaticBox::ChangeFont(bool keepOriginalSize
)
209 wxWindow::ChangeFont(keepOriginalSize
);
212 void wxStaticBox::ChangeBackgroundColour()
214 wxWindow::ChangeBackgroundColour();
216 DoChangeBackgroundColour(m_labelWidget
, m_backgroundColour
);
219 void wxStaticBox::ChangeForegroundColour()
221 wxWindow::ChangeForegroundColour();
223 DoChangeForegroundColour(m_labelWidget
, m_foregroundColour
);