]>
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 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
16 #define XtDisplay XTDISPLAY
23 #include "wx/stattext.h"
26 #pragma message disable nosimpint
30 #pragma message enable nosimpint
33 #include "wx/motif/private.h"
35 IMPLEMENT_DYNAMIC_CLASS(wxStaticText
, wxControl
);
37 bool wxStaticText::Create(wxWindow
*parent
, wxWindowID id
,
38 const wxString
& label
,
44 if( !CreateControl( parent
, id
, pos
, size
, style
,
45 wxDefaultValidator
, name
) )
48 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
51 (Widget
) wxCreateBorderWidget( (WXWidget
)parentWidget
, style
);
52 wxXmString
text( wxStripMenuCodes( label
) );
55 XtVaCreateManagedWidget (wxConstCast(name
.c_str(), char),
57 borderWidget
? borderWidget
: parentWidget
,
58 wxFont::GetFontTag(), m_font
.GetFontTypeC(XtDisplay(parentWidget
)),
59 XmNlabelString
, text(),
60 XmNalignment
, ((style
& wxALIGN_RIGHT
) ? XmALIGNMENT_END
:
61 ((style
& wxALIGN_CENTRE
) ? XmALIGNMENT_CENTER
:
62 XmALIGNMENT_BEGINNING
)),
65 m_mainWidget
= borderWidget
? borderWidget
: m_labelWidget
;
67 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
,
68 pos
.x
, pos
.y
, size
.x
, size
.y
);
70 ChangeBackgroundColour ();
75 void wxStaticText::SetLabel(const wxString
& label
)
77 wxXmString
label_str(wxStripMenuCodes(label
));
79 // This variable means we don't need so many casts later.
80 Widget widget
= (Widget
) m_labelWidget
;
82 if (GetWindowStyle() & wxST_NO_AUTORESIZE
)
84 XtUnmanageChild(widget
);
85 Dimension width
, height
;
86 XtVaGetValues(widget
, XmNwidth
, &width
, XmNheight
, &height
, NULL
);
89 XmNlabelString
, label_str(),
90 XmNlabelType
, XmSTRING
,
96 XtManageChild(widget
);
100 XtVaSetValues(widget
,
101 XmNlabelString
, label_str(),
102 XmNlabelType
, XmSTRING
,
107 #endif // wxUSE_STATTEXT