]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/stattext.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxStaticText
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "stattext.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
20 #define XtDisplay XTDISPLAY
27 #include "wx/stattext.h"
30 #pragma message disable nosimpint
34 #pragma message enable nosimpint
37 #include "wx/motif/private.h"
39 IMPLEMENT_DYNAMIC_CLASS(wxStaticText
, wxControl
);
41 bool wxStaticText::Create(wxWindow
*parent
, wxWindowID id
,
42 const wxString
& label
,
48 if( !CreateControl( parent
, id
, pos
, size
, style
,
49 wxDefaultValidator
, name
) )
52 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
55 (Widget
) wxCreateBorderWidget( (WXWidget
)parentWidget
, style
);
56 wxXmString
text( wxStripMenuCodes( label
) );
59 XtVaCreateManagedWidget (wxConstCast(name
.c_str(), char),
61 borderWidget
? borderWidget
: parentWidget
,
62 wxFont::GetFontTag(), m_font
.GetFontTypeC(XtDisplay(parentWidget
)),
63 XmNlabelString
, text(),
64 XmNalignment
, ((style
& wxALIGN_RIGHT
) ? XmALIGNMENT_END
:
65 ((style
& wxALIGN_CENTRE
) ? XmALIGNMENT_CENTER
:
66 XmALIGNMENT_BEGINNING
)),
69 m_mainWidget
= borderWidget
? borderWidget
: m_labelWidget
;
71 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
,
72 pos
.x
, pos
.y
, size
.x
, size
.y
);
74 ChangeBackgroundColour ();
79 void wxStaticText::SetLabel(const wxString
& label
)
81 wxXmString
label_str(wxStripMenuCodes(label
));
83 // This variable means we don't need so many casts later.
84 Widget widget
= (Widget
) m_labelWidget
;
86 if (GetWindowStyle() & wxST_NO_AUTORESIZE
)
88 XtUnmanageChild(widget
);
89 Dimension width
, height
;
90 XtVaGetValues(widget
, XmNwidth
, &width
, XmNheight
, &height
, NULL
);
93 XmNlabelString
, label_str(),
94 XmNlabelType
, XmSTRING
,
100 XtManageChild(widget
);
104 XtVaSetValues(widget
,
105 XmNlabelString
, label_str(),
106 XmNlabelType
, XmSTRING
,
111 #endif // wxUSE_STATTEXT