X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c27126c7bca4ff702f6a185bb2cfba303ae20a62..6f41c10973643552837c6bd38b23779e65a2eaa3:/include/wx/private/markupparserattr.h?ds=inline diff --git a/include/wx/private/markupparserattr.h b/include/wx/private/markupparserattr.h index 8f078efb7d..7a58acd46d 100644 --- a/include/wx/private/markupparserattr.h +++ b/include/wx/private/markupparserattr.h @@ -78,8 +78,8 @@ public: virtual void OnUnderlinedStart() { DoChangeFont(&wxFont::Underlined); } virtual void OnUnderlinedEnd() { DoEndAttr(); } - virtual void OnStrikethroughStart() { } // TODO: No support in wxFont yet. - virtual void OnStrikethroughEnd() { } + virtual void OnStrikethroughStart() { DoChangeFont(&wxFont::Strikethrough); } + virtual void OnStrikethroughEnd() { DoEndAttr(); } virtual void OnBigStart() { DoChangeFont(&wxFont::Larger); } virtual void OnBigEnd() { DoEndAttr(); } @@ -101,14 +101,17 @@ public: if ( !spanAttr.m_fontFace.empty() ) font.SetFaceName(spanAttr.m_fontFace); - DoApplyToFont(spanAttr.m_isBold, font, &wxFont::SetWeight, - wxFONTWEIGHT_NORMAL, wxFONTWEIGHT_BOLD); + FontModifier()(spanAttr.m_isBold, + font, &wxFont::SetWeight, + wxFONTWEIGHT_NORMAL, wxFONTWEIGHT_BOLD); - DoApplyToFont(spanAttr.m_isItalic, font, &wxFont::SetStyle, - wxFONTSTYLE_NORMAL, wxFONTSTYLE_ITALIC); + FontModifier()(spanAttr.m_isItalic, + font, &wxFont::SetStyle, + wxFONTSTYLE_NORMAL, wxFONTSTYLE_ITALIC); - DoApplyToFont(spanAttr.m_isUnderlined, font, &wxFont::SetUnderlined, - false, true); + FontModifier()(spanAttr.m_isUnderlined, + font, &wxFont::SetUnderlined, + false, true); // TODO: No support for strike-through yet. @@ -191,28 +194,35 @@ private: OnAttrEnd(attr); } + // A helper class used to apply the given function to a wxFont object + // depending on the value of an OptionalBool. template - void - DoApplyToFont(wxMarkupSpanAttributes::OptionalBool isIt, - wxFont& font, - void (wxFont::*func)(T), - T noValue, - T yesValue) + struct FontModifier { - switch ( isIt ) - { - case wxMarkupSpanAttributes::Unspecified: - break; + FontModifier() { } - case wxMarkupSpanAttributes::No: - (font.*func)(noValue); - break; - - case wxMarkupSpanAttributes::Yes: - (font.*func)(yesValue); - break; + void operator()(wxMarkupSpanAttributes::OptionalBool isIt, + wxFont& font, + void (wxFont::*func)(T), + T noValue, + T yesValue) + { + switch ( isIt ) + { + case wxMarkupSpanAttributes::Unspecified: + break; + + case wxMarkupSpanAttributes::No: + (font.*func)(noValue); + break; + + case wxMarkupSpanAttributes::Yes: + (font.*func)(yesValue); + break; + } } - } + }; + wxStack m_attrs;