]>
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
24 #include "wx/stattext.h"
27 #pragma message disable nosimpint
31 #pragma message enable nosimpint
34 #include "wx/motif/private.h"
36 IMPLEMENT_DYNAMIC_CLASS(wxStaticText
, wxControl
);
38 bool wxStaticText::Create(wxWindow
*parent
, wxWindowID id
,
39 const wxString
& label
,
45 if( !CreateControl( parent
, id
, pos
, size
, style
,
46 wxDefaultValidator
, name
) )
49 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
52 (Widget
) wxCreateBorderWidget( (WXWidget
)parentWidget
, style
);
53 wxXmString
text( wxStripMenuCodes( label
) );
54 WXFontType fontType
= m_font
.GetFontType(XtDisplay(parentWidget
));
56 m_labelWidget
= XtVaCreateManagedWidget (wxConstCast(name
.c_str(), char),
58 borderWidget
? borderWidget
: parentWidget
,
59 wxFont::GetFontTag(), fontType
,
60 XmNlabelString
, text(),
62 ((style
& wxALIGN_RIGHT
) ? XmALIGNMENT_END
:
63 ((style
& wxALIGN_CENTRE
) ? XmALIGNMENT_CENTER
:
64 XmALIGNMENT_BEGINNING
)),
67 m_mainWidget
= borderWidget
? borderWidget
: m_labelWidget
;
69 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
,
70 pos
.x
, pos
.y
, size
.x
, size
.y
);
72 ChangeBackgroundColour ();
77 void wxStaticText::SetLabel(const wxString
& label
)
79 wxXmString
label_str(wxStripMenuCodes(label
));
81 // This variable means we don't need so many casts later.
82 Widget widget
= (Widget
) m_labelWidget
;
84 if (GetWindowStyle() & wxST_NO_AUTORESIZE
)
86 XtUnmanageChild(widget
);
87 Dimension width
, height
;
88 XtVaGetValues(widget
, XmNwidth
, &width
, XmNheight
, &height
, NULL
);
91 XmNlabelString
, label_str(),
92 XmNlabelType
, XmSTRING
,
98 XtManageChild(widget
);
102 XtVaSetValues(widget
,
103 XmNlabelString
, label_str(),
104 XmNlabelType
, XmSTRING
,