X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/456e28d28dcf6f379508e16ffef3aa85bf642c31..07aaf32633ecf18ec3edfbb41793a112914792d0:/src/generic/stattextg.cpp diff --git a/src/generic/stattextg.cpp b/src/generic/stattextg.cpp index 2047f27d0e..4d8d120b11 100644 --- a/src/generic/stattextg.cpp +++ b/src/generic/stattextg.cpp @@ -24,6 +24,9 @@ #include "wx/generic/stattextg.h" +#if wxUSE_MARKUP + #include "wx/generic/private/markuptext.h" +#endif // wxUSE_MARKUP IMPLEMENT_DYNAMIC_CLASS(wxGenericStaticText, wxStaticTextBase) @@ -46,12 +49,26 @@ bool wxGenericStaticText::Create(wxWindow *parent, return true; } +wxGenericStaticText::~wxGenericStaticText() +{ +#if wxUSE_MARKUP + delete m_markupText; +#endif // wxUSE_MARKUP +} + +void wxGenericStaticText::DoDrawLabel(wxDC& dc, const wxRect& rect) +{ +#if wxUSE_MARKUP + if ( m_markupText ) + m_markupText->Render(dc, rect, wxMarkupText::Render_ShowAccels); + else +#endif // wxUSE_MARKUP + dc.DrawLabel(m_label, rect, GetAlignment(), m_mnemonic); +} + void wxGenericStaticText::OnPaint(wxPaintEvent& WXUNUSED(event)) { - if ( m_label.empty() ) - return; wxPaintDC dc(this); - PrepareDC(dc); wxRect rect = GetClientRect(); if ( IsEnabled() ) @@ -66,36 +83,41 @@ void wxGenericStaticText::OnPaint(wxPaintEvent& WXUNUSED(event)) wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT)); wxRect rectShadow = rect; rectShadow.Offset(1, 1); - dc.DrawLabel(m_label, rectShadow, GetAlignment(), m_mnemonic); + DoDrawLabel(dc, rectShadow); dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)); } - dc.DrawLabel(m_label, wxNullBitmap, rect, GetAlignment(), m_mnemonic); + DoDrawLabel(dc, rect); } wxSize wxGenericStaticText::DoGetBestClientSize() const { wxClientDC dc(wxConstCast(this, wxGenericStaticText)); - wxCoord width, height; - dc.GetMultiLineTextExtent(GetLabel(), &width, &height); - return wxSize(width, height); -} -wxSize wxGenericStaticText::DoGetBestSize() const -{ - wxSize ret = DoGetBestClientSize(); - CacheBestSize(ret); - return ret; -} +#if wxUSE_MARKUP + if ( m_markupText ) + return m_markupText->Measure(dc); +#endif // wxUSE_MARKUP + return dc.GetMultiLineTextExtent(GetLabel()); +} void wxGenericStaticText::SetLabel(const wxString& label) { wxControl::SetLabel(label); - DoSetLabel(GetEllipsizedLabelWithoutMarkup()); + DoSetLabel(GetEllipsizedLabel()); if ( !HasFlag(wxST_NO_AUTORESIZE) && !IsEllipsized() ) InvalidateBestSize(); + +#if wxUSE_MARKUP + if ( m_markupText ) + { + delete m_markupText; + m_markupText = NULL; + } +#endif // wxUSE_MARKUP + Refresh(); } @@ -104,6 +126,28 @@ void wxGenericStaticText::DoSetLabel(const wxString& label) m_mnemonic = FindAccelIndex(label, &m_label); } +#if wxUSE_MARKUP + +bool wxGenericStaticText::DoSetLabelMarkup(const wxString& markup) +{ + if ( !wxStaticTextBase::DoSetLabelMarkup(markup) ) + return false; + + if ( !m_markupText ) + m_markupText = new wxMarkupText(markup); + else + m_markupText->SetMarkup(markup); + + if ( !HasFlag(wxST_NO_AUTORESIZE) ) + InvalidateBestSize(); + + Refresh(); + + return true; +} + +#endif // wxUSE_MARKUP + bool wxGenericStaticText::SetFont(const wxFont &font) { if ( !wxControl::SetFont(font) )