]> git.saurik.com Git - wxWidgets.git/commitdiff
Replace template function with template class to placate VC6.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 27 Feb 2011 14:01:36 +0000 (14:01 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 27 Feb 2011 14:01:36 +0000 (14:01 +0000)
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

index 8f078efb7da25ae5e150fe461dd9e4c8f0246e1a..f122d371ffde642fa225739da2291d0aeb06fd38 100644 (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 )
-        {
-            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<Attr> m_attrs;