]>
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
20 #include "wx/statbox.h"
24 #pragma message disable nosimpint
29 #include <Xm/LabelG.h>
31 #pragma message enable nosimpint
34 #include "wx/motif/private.h"
36 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox
, wxControl
)
38 BEGIN_EVENT_TABLE(wxStaticBox
, wxControl
)
39 //EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
47 wxStaticBox::wxStaticBox()
49 m_formWidget
= (WXWidget
) 0;
50 m_labelWidget
= (WXWidget
) 0;
53 bool wxStaticBox::Create(wxWindow
*parent
, wxWindowID id
,
54 const wxString
& label
,
60 m_formWidget
= (WXWidget
) 0;
61 m_labelWidget
= (WXWidget
) 0;
62 m_backgroundColour
= parent
->GetBackgroundColour();
63 m_foregroundColour
= parent
->GetForegroundColour();
64 m_font
= parent
->GetFont();
68 if (parent
) parent
->AddChild(this);
71 m_windowId
= (int)NewControlId();
75 m_windowStyle
= style
;
77 bool hasLabel
= (!label
.IsNull() && !label
.IsEmpty()) ;
79 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
81 Widget formWidget
= XtVaCreateManagedWidget ((char*) (const char*) name
,
82 xmFormWidgetClass
, parentWidget
,
90 XmFontList fontList
= (XmFontList
) m_font
.GetFontList(1.0, XtDisplay(parentWidget
));
92 wxString
label1(wxStripMenuCodes(label
));
93 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
94 m_labelWidget
= (WXWidget
) XtVaCreateManagedWidget ((char*) (const char*) label1
,
95 xmLabelWidgetClass
, formWidget
,
96 XmNfontList
, fontList
,
102 Widget frameWidget
= XtVaCreateManagedWidget ("frame",
103 xmFrameWidgetClass
, formWidget
,
104 XmNshadowType
, XmSHADOW_IN
,
105 //XmNmarginHeight, 0,
110 XtVaSetValues ((Widget
) m_labelWidget
,
111 XmNtopAttachment
, XmATTACH_FORM
,
112 XmNleftAttachment
, XmATTACH_FORM
,
113 XmNrightAttachment
, XmATTACH_FORM
,
114 XmNalignment
, XmALIGNMENT_BEGINNING
,
117 XtVaSetValues (frameWidget
,
118 XmNtopAttachment
, hasLabel
? XmATTACH_WIDGET
: XmATTACH_FORM
,
119 XmNtopWidget
, hasLabel
? (Widget
) m_labelWidget
: formWidget
,
120 XmNbottomAttachment
, XmATTACH_FORM
,
121 XmNleftAttachment
, XmATTACH_FORM
,
122 XmNrightAttachment
, XmATTACH_FORM
,
125 m_mainWidget
= (WXWidget
) frameWidget
;
126 m_formWidget
= (WXWidget
) formWidget
;
128 SetCanAddEventHandler(TRUE
);
129 AttachWidget (parent
, (WXWidget
) frameWidget
, (WXWidget
) formWidget
, pos
.x
, pos
.y
, size
.x
, size
.y
);
130 ChangeBackgroundColour();
135 wxStaticBox::~wxStaticBox()
137 DetachWidget(m_formWidget
);
138 DetachWidget(m_mainWidget
);
139 XtDestroyWidget((Widget
) m_mainWidget
);
141 XtDestroyWidget((Widget
) m_labelWidget
);
142 XtDestroyWidget((Widget
) m_formWidget
);
144 m_mainWidget
= (WXWidget
) 0;
145 m_labelWidget
= (WXWidget
) 0;
146 m_formWidget
= (WXWidget
) 0;
149 void wxStaticBox::SetLabel(const wxString
& label
)
156 wxString
label1(wxStripMenuCodes(label
));
158 XmString text
= XmStringCreateSimple ((char*) (const char*) label1
);
159 XtVaSetValues ((Widget
) m_labelWidget
,
160 XmNlabelString
, text
,
161 XmNlabelType
, XmSTRING
,
167 wxString
wxStaticBox::GetLabel() const
170 return wxEmptyString
;
174 XtVaGetValues ((Widget
) m_labelWidget
,
175 XmNlabelString
, &text
,
179 return wxEmptyString
;
181 if (XmStringGetLtoR (text
, XmSTRING_DEFAULT_CHARSET
, &s
))
189 return wxEmptyString
;
193 void wxStaticBox::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
195 wxControl::DoSetSize (x
, y
, width
, height
, sizeFlags
);
200 XtVaGetValues ((Widget
) m_labelWidget
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
203 XtVaSetValues ((Widget
) m_mainWidget
, XmNwidth
, width
,
206 XtVaSetValues ((Widget
) m_mainWidget
, XmNheight
, height
- yy
,
211 void wxStaticBox::ChangeFont(bool keepOriginalSize
)
213 wxWindow::ChangeFont(keepOriginalSize
);
216 void wxStaticBox::ChangeBackgroundColour()
218 wxWindow::ChangeBackgroundColour();
220 DoChangeBackgroundColour(m_labelWidget
, m_backgroundColour
);
223 void wxStaticBox::ChangeForegroundColour()
225 wxWindow::ChangeForegroundColour();
227 DoChangeForegroundColour(m_labelWidget
, m_foregroundColour
);