+ return ret;
+}
+
+
+
+// ----------------------------------------------------------------------------
+// wxStaticTextBase - generic implementation for wxST_ELLIPSIZE_* support
+// ----------------------------------------------------------------------------
+
+void wxStaticTextBase::UpdateLabel()
+{
+ if (!IsEllipsized())
+ return;
+
+ wxString newlabel = GetEllipsizedLabelWithoutMarkup();
+
+ // we need to touch the "real" label (i.e. the text set inside the control,
+ // using port-specific functions) instead of the string returned by GetLabel().
+ //
+ // In fact, we must be careful not to touch the original label passed to
+ // SetLabel() otherwise GetLabel() will behave in a strange way to the user
+ // (e.g. returning a "Ver...ing" instead of "Very long string") !
+ if (newlabel == DoGetLabel())
+ return;
+ DoSetLabel(newlabel);
+}
+
+wxString wxStaticTextBase::GetEllipsizedLabelWithoutMarkup() const
+{
+ // this function should be used only by ports which do not support
+ // ellipsis in static texts: we first remove markup (which cannot
+ // be handled safely by Ellipsize()) and then ellipsize the result.
+
+ wxString ret(m_labelOrig);
+
+ // the order of the following two blocks is important!
+
+ if (HasFlag(wxST_MARKUP))
+ ret = RemoveMarkup(ret);
+
+ if (IsEllipsized())
+ ret = Ellipsize(ret);
+
+ return ret;
+}
+
+wxString wxStaticTextBase::Ellipsize(const wxString& label) const
+{
+ wxSize sz(GetSize());
+ if (sz.GetWidth() < 2 || sz.GetHeight() < 2)
+ {
+ // the size of this window is not valid (yet)
+ return label;
+ }
+
+ wxClientDC dc(const_cast<wxStaticTextBase*>(this));
+ dc.SetFont(GetFont());
+
+ wxEllipsizeMode mode;
+ if (HasFlag(wxST_ELLIPSIZE_START)) mode = wxST_ELLIPSIZE_START;
+ else if (HasFlag(wxST_ELLIPSIZE_MIDDLE)) mode = wxST_ELLIPSIZE_MIDDLE;
+ else if (HasFlag(wxST_ELLIPSIZE_END)) mode = wxST_ELLIPSIZE_END;
+
+ return Ellipsize(label, dc, mode, sz.GetWidth());