]>
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"
17 #include "wx/stattext.h"
20 #pragma message disable nosimpint
24 #pragma message enable nosimpint
27 #include "wx/motif/private.h"
29 bool wxStaticText::Create(wxWindow
*parent
, wxWindowID id
,
30 const wxString
& label
,
36 if( !CreateControl( parent
, id
, pos
, size
, style
,
37 wxDefaultValidator
, name
) )
39 m_labelWidget
= (WXWidget
) 0;
42 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
45 (Widget
) wxCreateBorderWidget( (WXWidget
)parentWidget
, style
);
48 XtVaCreateManagedWidget (name
.mb_str(),
50 borderWidget
? borderWidget
: parentWidget
,
51 wxFont::GetFontTag(), m_font
.GetFontTypeC(XtDisplay(parentWidget
)),
52 XmNalignment
, ((style
& wxALIGN_RIGHT
) ? XmALIGNMENT_END
:
53 ((style
& wxALIGN_CENTRE
) ? XmALIGNMENT_CENTER
:
54 XmALIGNMENT_BEGINNING
)),
55 XmNrecomputeSize
, ((style
& wxST_NO_AUTORESIZE
) ? TRUE
: FALSE
),
58 m_mainWidget
= borderWidget
? borderWidget
: m_labelWidget
;
62 wxSize best
= GetBestSize();
63 if( size
.x
!= -1 ) best
.x
= size
.x
;
64 if( size
.y
!= -1 ) best
.y
= size
.y
;
67 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
,
68 pos
.x
, pos
.y
, best
.x
, best
.y
);
73 void wxStaticText::SetLabel(const wxString
& label
)
75 m_labelOrig
= label
; // save original label
77 // Motif does not support neither ellipsize nor markup in static text:
78 DoSetLabel(GetEllipsizedLabelWithoutMarkup());
81 // for wxST_ELLIPSIZE_* support:
83 wxString
wxStaticText::DoGetLabel() const
85 XmString label
= NULL
;
86 XtVaGetValues((Widget
)m_labelWidget
, XmNlabelString
, &label
, NULL
);
88 return wxXmStringToString(label
);
91 void wxStaticText::DoSetLabel(const wxString
& str
)
93 // build our own cleaned label
94 wxXmString
label_str(RemoveMnemonics(str
));
96 // This variable means we don't need so many casts later.
97 Widget widget
= (Widget
) m_labelWidget
;
100 XmNlabelString
, label_str(),
101 XmNlabelType
, XmSTRING
,
106 FIXME: UpdateLabel() should be called on size events to allow correct
107 dynamic ellipsizing of the label
110 wxSize
wxStaticText::DoGetBestSize() const
113 GetTextExtent(GetLabelText(), &w
, &h
, NULL
, NULL
, NULL
);
118 #endif // wxUSE_STATTEXT