From c21a9bda7aa6b18c0729076ce2910e05dab4b6b7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 27 Feb 2011 14:01:36 +0000 Subject: [PATCH] Replace template function with template class to placate VC6. VC6 has very poor support for template functions and in particular doesn't understand explicitly choosing the type of the function to call so replace template DoApplyToFont() function with FontModifier template class in wxMarkupParserAttrOutput implementation. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67073 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/private/markupparserattr.h | 58 ++++++++++++++++----------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/include/wx/private/markupparserattr.h b/include/wx/private/markupparserattr.h index 8f078efb7d..f122d371ff 100644 --- a/include/wx/private/markupparserattr.h +++ b/include/wx/private/markupparserattr.h @@ -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; -- 2.47.2