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
This commit is contained in:
Vadim Zeitlin 2011-02-27 14:01:36 +00:00
parent 1a6e6d5475
commit c21a9bda7a

View File

@ -101,14 +101,17 @@ public:
if ( !spanAttr.m_fontFace.empty() )
font.SetFaceName(spanAttr.m_fontFace);
DoApplyToFont<wxFontWeight>(spanAttr.m_isBold, font, &wxFont::SetWeight,
wxFONTWEIGHT_NORMAL, wxFONTWEIGHT_BOLD);
FontModifier<wxFontWeight>()(spanAttr.m_isBold,
font, &wxFont::SetWeight,
wxFONTWEIGHT_NORMAL, wxFONTWEIGHT_BOLD);
DoApplyToFont<wxFontStyle>(spanAttr.m_isItalic, font, &wxFont::SetStyle,
wxFONTSTYLE_NORMAL, wxFONTSTYLE_ITALIC);
FontModifier<wxFontStyle>()(spanAttr.m_isItalic,
font, &wxFont::SetStyle,
wxFONTSTYLE_NORMAL, wxFONTSTYLE_ITALIC);
DoApplyToFont(spanAttr.m_isUnderlined, font, &wxFont::SetUnderlined,
false, true);
FontModifier<bool>()(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 <typename T>
void
DoApplyToFont(wxMarkupSpanAttributes::OptionalBool isIt,
wxFont& font,
void (wxFont::*func)(T),
T noValue,
T yesValue)
struct FontModifier
{
switch ( isIt )
FontModifier() { }
void operator()(wxMarkupSpanAttributes::OptionalBool isIt,
wxFont& font,
void (wxFont::*func)(T),
T noValue,
T yesValue)
{
case wxMarkupSpanAttributes::Unspecified:
break;
switch ( isIt )
{
case wxMarkupSpanAttributes::Unspecified:
break;
case wxMarkupSpanAttributes::No:
(font.*func)(noValue);
break;
case wxMarkupSpanAttributes::No:
(font.*func)(noValue);
break;
case wxMarkupSpanAttributes::Yes:
(font.*func)(yesValue);
break;
case wxMarkupSpanAttributes::Yes:
(font.*func)(yesValue);
break;
}
}
}
};
wxStack<Attr> m_attrs;