]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/private/markupparserattr.h
Fix wrong tab order in wxAuiNotebook after dragging.
[wxWidgets.git] / include / wx / private / markupparserattr.h
index 8f078efb7da25ae5e150fe461dd9e4c8f0246e1a..7a58acd46d48d9773e754f3d91a2f25590a691a1 100644 (file)
@@ -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<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;