added support for ellipsization and markup in wxStaticText (modified patch 1629946)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45199 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-04-01 14:13:15 +00:00
parent 9d529fa05c
commit 39bc0347fd
35 changed files with 1387 additions and 280 deletions

View File

@@ -47,14 +47,12 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
Widget borderWidget =
(Widget) wxCreateBorderWidget( (WXWidget)parentWidget, style );
wxXmString text( GetLabelText( label ) );
m_labelWidget =
XtVaCreateManagedWidget (wxConstCast(name.mb_str(), char),
xmLabelWidgetClass,
borderWidget ? borderWidget : parentWidget,
wxFont::GetFontTag(), m_font.GetFontTypeC(XtDisplay(parentWidget)),
XmNlabelString, text(),
XmNalignment, ((style & wxALIGN_RIGHT) ? XmALIGNMENT_END :
((style & wxALIGN_CENTRE) ? XmALIGNMENT_CENTER :
XmALIGNMENT_BEGINNING)),
@@ -68,12 +66,33 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
ChangeBackgroundColour ();
SetLabel(label);
return true;
}
void wxStaticText::SetLabel(const wxString& label)
{
wxXmString label_str(GetLabelText(label));
m_labelOrig = label; // save original label
// Motif does not support neither ellipsize nor markup in static text:
DoSetLabel(GetEllipsizedLabelWithoutMarkup());
}
// for wxST_ELLIPSIZE_* support:
wxString wxStaticText::DoGetLabel() const
{
XmString label = NULL;
XtVaGetValues((Widget)m_labelWidget, XmNlabelString, &label, NULL);
return wxXmStringToString(label);
}
void wxStaticText::DoSetLabel(const wxString& str)
{
// build our own cleaned label
wxXmString label_str(RemoveMnemonics(str));
// This variable means we don't need so many casts later.
Widget widget = (Widget) m_labelWidget;
@@ -84,4 +103,9 @@ void wxStaticText::SetLabel(const wxString& label)
NULL);
}
/*
FIXME: UpdateLabel() should be called on size events to allow correct
dynamic ellipsizing of the label
*/
#endif // wxUSE_STATTEXT