]>
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_font
= 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_font
.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
,
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
);
130 DetachWidget(m_mainWidget
);
131 XtDestroyWidget((Widget
) m_mainWidget
);
133 XtDestroyWidget((Widget
) m_labelWidget
);
134 XtDestroyWidget((Widget
) m_formWidget
);
136 m_mainWidget
= (WXWidget
) 0;
137 m_labelWidget
= (WXWidget
) 0;
138 m_formWidget
= (WXWidget
) 0;
141 void wxStaticBox::SetLabel(const wxString
& label
)
148 wxString
label1(wxStripMenuCodes(label
));
150 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
151 XtVaSetValues ((Widget
) m_labelWidget
,
152 XmNlabelString
, text
,
153 XmNlabelType
, XmSTRING
,
159 wxString
wxStaticBox::GetLabel() const
162 return wxEmptyString
;
166 XtVaGetValues ((Widget
) m_labelWidget
,
167 XmNlabelString
, &text
,
171 return wxEmptyString
;
173 if (XmStringGetLtoR (text
, XmSTRING_DEFAULT_CHARSET
, &s
))
181 return wxEmptyString
;
185 void wxStaticBox::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
187 wxControl::DoSetSize (x
, y
, width
, height
, sizeFlags
);
192 XtVaGetValues ((Widget
) m_labelWidget
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
195 XtVaSetValues ((Widget
) m_mainWidget
, XmNwidth
, width
,
198 XtVaSetValues ((Widget
) m_mainWidget
, XmNheight
, height
- yy
,
203 void wxStaticBox::ChangeFont(bool keepOriginalSize
)
205 wxWindow::ChangeFont(keepOriginalSize
);
208 void wxStaticBox::ChangeBackgroundColour()
210 wxWindow::ChangeBackgroundColour();
212 DoChangeBackgroundColour(m_labelWidget
, m_backgroundColour
);
215 void wxStaticBox::ChangeForegroundColour()
217 wxWindow::ChangeForegroundColour();
219 DoChangeForegroundColour(m_labelWidget
, m_foregroundColour
);