]>
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
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
16 #include "wx/stattext.h"
19 #pragma message disable nosimpint
23 #pragma message enable nosimpint
26 #include "wx/motif/private.h"
28 bool wxStaticText::Create(wxWindow
*parent
, wxWindowID id
,
29 const wxString
& label
,
35 if( !CreateControl( parent
, id
, pos
, size
, style
,
36 wxDefaultValidator
, name
) )
38 m_labelWidget
= (WXWidget
) 0;
41 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
44 (Widget
) wxCreateBorderWidget( (WXWidget
)parentWidget
, style
);
47 XtVaCreateManagedWidget (name
.mb_str(),
49 borderWidget
? borderWidget
: parentWidget
,
50 wxFont::GetFontTag(), m_font
.GetFontTypeC(XtDisplay(parentWidget
)),
51 XmNalignment
, ((style
& wxALIGN_RIGHT
) ? XmALIGNMENT_END
:
52 ((style
& wxALIGN_CENTRE
) ? XmALIGNMENT_CENTER
:
53 XmALIGNMENT_BEGINNING
)),
54 XmNrecomputeSize
, ((style
& wxST_NO_AUTORESIZE
) ? TRUE
: FALSE
),
57 m_mainWidget
= borderWidget
? borderWidget
: m_labelWidget
;
61 wxSize best
= GetBestSize();
62 if( size
.x
!= -1 ) best
.x
= size
.x
;
63 if( size
.y
!= -1 ) best
.y
= size
.y
;
66 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
,
67 pos
.x
, pos
.y
, best
.x
, best
.y
);
72 void wxStaticText::SetLabel(const wxString
& label
)
74 m_labelOrig
= label
; // save original label
76 // Motif does not support ellipsized labels natively
77 DoSetLabel(GetEllipsizedLabel());
80 // for wxST_ELLIPSIZE_* support:
82 wxString
wxStaticText::DoGetLabel() const
84 XmString label
= NULL
;
85 XtVaGetValues((Widget
)m_labelWidget
, XmNlabelString
, &label
, NULL
);
87 return wxXmStringToString(label
);
90 void wxStaticText::DoSetLabel(const wxString
& str
)
92 // build our own cleaned label
93 wxXmString
label_str(RemoveMnemonics(str
));
95 // This variable means we don't need so many casts later.
96 Widget widget
= (Widget
) m_labelWidget
;
99 XmNlabelString
, label_str(),
100 XmNlabelType
, XmSTRING
,
105 FIXME: UpdateLabel() should be called on size events to allow correct
106 dynamic ellipsizing of the label
109 wxSize
wxStaticText::DoGetBestSize() const
112 GetTextExtent(GetLabelText(), &w
, &h
, NULL
, NULL
, NULL
);
117 #endif // wxUSE_STATTEXT