]>
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 #if !USE_SHARED_LIBRARY
33 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
)
35 BEGIN_EVENT_TABLE(wxStaticBox
, wxControl
)
36 //EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
45 wxStaticBox::wxStaticBox()
47 m_formWidget
= (WXWidget
) 0;
48 m_labelWidget
= (WXWidget
) 0;
51 bool wxStaticBox::Create(wxWindow
*parent
, wxWindowID id
,
52 const wxString
& label
,
58 m_formWidget
= (WXWidget
) 0;
59 m_labelWidget
= (WXWidget
) 0;
60 m_backgroundColour
= parent
->GetBackgroundColour();
61 m_foregroundColour
= parent
->GetForegroundColour();
62 m_font
= parent
->GetFont();
66 if (parent
) parent
->AddChild(this);
69 m_windowId
= (int)NewControlId();
73 m_windowStyle
= style
;
75 bool hasLabel
= (!label
.IsNull() && !label
.IsEmpty()) ;
77 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
79 Widget formWidget
= XtVaCreateManagedWidget ((char*) (const char*) name
,
80 xmFormWidgetClass
, parentWidget
,
88 XmFontList fontList
= (XmFontList
) m_font
.GetFontList(1.0, XtDisplay(parentWidget
));
90 wxString
label1(wxStripMenuCodes(label
));
91 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
92 m_labelWidget
= (WXWidget
) XtVaCreateManagedWidget ((char*) (const char*) label1
,
93 xmLabelWidgetClass
, formWidget
,
94 XmNfontList
, fontList
,
100 Widget frameWidget
= XtVaCreateManagedWidget ("frame",
101 xmFrameWidgetClass
, formWidget
,
102 XmNshadowType
, XmSHADOW_IN
,
103 //XmNmarginHeight, 0,
108 XtVaSetValues ((Widget
) m_labelWidget
,
109 XmNtopAttachment
, XmATTACH_FORM
,
110 XmNleftAttachment
, XmATTACH_FORM
,
111 XmNrightAttachment
, XmATTACH_FORM
,
112 XmNalignment
, XmALIGNMENT_BEGINNING
,
115 XtVaSetValues (frameWidget
,
116 XmNtopAttachment
, hasLabel
? XmATTACH_WIDGET
: XmATTACH_FORM
,
117 XmNtopWidget
, hasLabel
? (Widget
) m_labelWidget
: formWidget
,
118 XmNbottomAttachment
, XmATTACH_FORM
,
119 XmNleftAttachment
, XmATTACH_FORM
,
120 XmNrightAttachment
, XmATTACH_FORM
,
123 m_mainWidget
= (WXWidget
) frameWidget
;
124 m_formWidget
= (WXWidget
) formWidget
;
126 SetCanAddEventHandler(TRUE
);
127 AttachWidget (parent
, (WXWidget
) frameWidget
, (WXWidget
) formWidget
, pos
.x
, pos
.y
, size
.x
, size
.y
);
128 ChangeBackgroundColour();
133 wxStaticBox::~wxStaticBox()
135 DetachWidget(m_formWidget
);
136 DetachWidget(m_mainWidget
);
137 XtDestroyWidget((Widget
) m_mainWidget
);
139 XtDestroyWidget((Widget
) m_labelWidget
);
140 XtDestroyWidget((Widget
) m_formWidget
);
142 m_mainWidget
= (WXWidget
) 0;
143 m_labelWidget
= (WXWidget
) 0;
144 m_formWidget
= (WXWidget
) 0;
147 void wxStaticBox::SetLabel(const wxString
& label
)
154 wxString
label1(wxStripMenuCodes(label
));
156 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
157 XtVaSetValues ((Widget
) m_labelWidget
,
158 XmNlabelString
, text
,
159 XmNlabelType
, XmSTRING
,
165 wxString
wxStaticBox::GetLabel() const
168 return wxEmptyString
;
172 XtVaGetValues ((Widget
) m_labelWidget
,
173 XmNlabelString
, &text
,
177 return wxEmptyString
;
179 if (XmStringGetLtoR (text
, XmSTRING_DEFAULT_CHARSET
, &s
))
187 return wxEmptyString
;
191 void wxStaticBox::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
193 wxControl::DoSetSize (x
, y
, width
, height
, sizeFlags
);
198 XtVaGetValues ((Widget
) m_labelWidget
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
201 XtVaSetValues ((Widget
) m_mainWidget
, XmNwidth
, width
,
204 XtVaSetValues ((Widget
) m_mainWidget
, XmNheight
, height
- yy
,
209 void wxStaticBox::ChangeFont(bool keepOriginalSize
)
211 wxWindow::ChangeFont(keepOriginalSize
);
214 void wxStaticBox::ChangeBackgroundColour()
216 wxWindow::ChangeBackgroundColour();
218 DoChangeBackgroundColour(m_labelWidget
, m_backgroundColour
);
221 void wxStaticBox::ChangeForegroundColour()
223 wxWindow::ChangeForegroundColour();
225 DoChangeForegroundColour(m_labelWidget
, m_foregroundColour
);