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:
@@ -101,14 +101,17 @@ public:
|
|||||||
if ( !spanAttr.m_fontFace.empty() )
|
if ( !spanAttr.m_fontFace.empty() )
|
||||||
font.SetFaceName(spanAttr.m_fontFace);
|
font.SetFaceName(spanAttr.m_fontFace);
|
||||||
|
|
||||||
DoApplyToFont<wxFontWeight>(spanAttr.m_isBold, font, &wxFont::SetWeight,
|
FontModifier<wxFontWeight>()(spanAttr.m_isBold,
|
||||||
wxFONTWEIGHT_NORMAL, wxFONTWEIGHT_BOLD);
|
font, &wxFont::SetWeight,
|
||||||
|
wxFONTWEIGHT_NORMAL, wxFONTWEIGHT_BOLD);
|
||||||
|
|
||||||
DoApplyToFont<wxFontStyle>(spanAttr.m_isItalic, font, &wxFont::SetStyle,
|
FontModifier<wxFontStyle>()(spanAttr.m_isItalic,
|
||||||
wxFONTSTYLE_NORMAL, wxFONTSTYLE_ITALIC);
|
font, &wxFont::SetStyle,
|
||||||
|
wxFONTSTYLE_NORMAL, wxFONTSTYLE_ITALIC);
|
||||||
|
|
||||||
DoApplyToFont(spanAttr.m_isUnderlined, font, &wxFont::SetUnderlined,
|
FontModifier<bool>()(spanAttr.m_isUnderlined,
|
||||||
false, true);
|
font, &wxFont::SetUnderlined,
|
||||||
|
false, true);
|
||||||
|
|
||||||
// TODO: No support for strike-through yet.
|
// TODO: No support for strike-through yet.
|
||||||
|
|
||||||
@@ -191,28 +194,35 @@ private:
|
|||||||
OnAttrEnd(attr);
|
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>
|
template <typename T>
|
||||||
void
|
struct FontModifier
|
||||||
DoApplyToFont(wxMarkupSpanAttributes::OptionalBool isIt,
|
|
||||||
wxFont& font,
|
|
||||||
void (wxFont::*func)(T),
|
|
||||||
T noValue,
|
|
||||||
T yesValue)
|
|
||||||
{
|
{
|
||||||
switch ( isIt )
|
FontModifier() { }
|
||||||
|
|
||||||
|
void operator()(wxMarkupSpanAttributes::OptionalBool isIt,
|
||||||
|
wxFont& font,
|
||||||
|
void (wxFont::*func)(T),
|
||||||
|
T noValue,
|
||||||
|
T yesValue)
|
||||||
{
|
{
|
||||||
case wxMarkupSpanAttributes::Unspecified:
|
switch ( isIt )
|
||||||
break;
|
{
|
||||||
|
case wxMarkupSpanAttributes::Unspecified:
|
||||||
|
break;
|
||||||
|
|
||||||
case wxMarkupSpanAttributes::No:
|
case wxMarkupSpanAttributes::No:
|
||||||
(font.*func)(noValue);
|
(font.*func)(noValue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxMarkupSpanAttributes::Yes:
|
case wxMarkupSpanAttributes::Yes:
|
||||||
(font.*func)(yesValue);
|
(font.*func)(yesValue);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
wxStack<Attr> m_attrs;
|
wxStack<Attr> m_attrs;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user