]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/stattext.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/stattext.cpp
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
21 #include "wx/stattext.h"
24 #pragma message disable nosimpint
28 #pragma message enable nosimpint
31 #include "wx/motif/private.h"
33 IMPLEMENT_DYNAMIC_CLASS(wxStaticText
, wxControl
)
35 bool wxStaticText::Create(wxWindow
*parent
, wxWindowID id
,
36 const wxString
& label
,
42 if( !CreateControl( parent
, id
, pos
, size
, style
,
43 wxDefaultValidator
, name
) )
45 m_labelWidget
= (WXWidget
) 0;
48 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
51 (Widget
) wxCreateBorderWidget( (WXWidget
)parentWidget
, style
);
54 XtVaCreateManagedWidget (wxConstCast(name
.mb_str(), char),
56 borderWidget
? borderWidget
: parentWidget
,
57 wxFont::GetFontTag(), m_font
.GetFontTypeC(XtDisplay(parentWidget
)),
58 XmNalignment
, ((style
& wxALIGN_RIGHT
) ? XmALIGNMENT_END
:
59 ((style
& wxALIGN_CENTRE
) ? XmALIGNMENT_CENTER
:
60 XmALIGNMENT_BEGINNING
)),
61 XmNrecomputeSize
, ((style
& wxST_NO_AUTORESIZE
) ? TRUE
: FALSE
),
64 m_mainWidget
= borderWidget
? borderWidget
: m_labelWidget
;
68 wxSize best
= GetBestSize();
69 if( size
.x
!= -1 ) best
.x
= size
.x
;
70 if( size
.y
!= -1 ) best
.y
= size
.y
;
73 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
,
74 pos
.x
, pos
.y
, best
.x
, best
.y
);
79 void wxStaticText::SetLabel(const wxString
& label
)
81 m_labelOrig
= label
; // save original label
83 // Motif does not support neither ellipsize nor markup in static text:
84 DoSetLabel(GetEllipsizedLabelWithoutMarkup());
87 // for wxST_ELLIPSIZE_* support:
89 wxString
wxStaticText::DoGetLabel() const
91 XmString label
= NULL
;
92 XtVaGetValues((Widget
)m_labelWidget
, XmNlabelString
, &label
, NULL
);
94 return wxXmStringToString(label
);
97 void wxStaticText::DoSetLabel(const wxString
& str
)
99 // build our own cleaned label
100 wxXmString
label_str(RemoveMnemonics(str
));
102 // This variable means we don't need so many casts later.
103 Widget widget
= (Widget
) m_labelWidget
;
105 XtVaSetValues(widget
,
106 XmNlabelString
, label_str(),
107 XmNlabelType
, XmSTRING
,
112 FIXME: UpdateLabel() should be called on size events to allow correct
113 dynamic ellipsizing of the label
116 wxSize
wxStaticText::DoGetBestSize() const
119 GetTextExtent(GetLabelText(), &w
, &h
, NULL
, NULL
, NULL
);
124 #endif // wxUSE_STATTEXT