]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/textcmn.cpp
eliminate unused variable warning with wxUSE_LOG_DEBUG==0
[wxWidgets.git] / src / common / textcmn.cpp
index 76b0916d21200f1a0b2a56ba0fba8a9ffd928b8c..ed3e07f5053b9ef99633cbbf32c95956ebc4b5de 100644 (file)
@@ -164,6 +164,7 @@ void wxTextAttr::Init()
     m_fontStyle = wxFONTSTYLE_NORMAL;
     m_fontWeight = wxFONTWEIGHT_NORMAL;
     m_fontUnderlined = false;
+    m_fontStrikethrough = false;
     m_fontEncoding = wxFONTENCODING_DEFAULT;
     m_fontFamily = wxFONTFAMILY_DEFAULT;
 
@@ -193,6 +194,7 @@ void wxTextAttr::Copy(const wxTextAttr& attr)
     m_fontStyle = attr.m_fontStyle;
     m_fontWeight = attr.m_fontWeight;
     m_fontUnderlined = attr.m_fontUnderlined;
+    m_fontStrikethrough = attr.m_fontStrikethrough;
     m_fontFaceName = attr.m_fontFaceName;
     m_fontEncoding = attr.m_fontEncoding;
     m_fontFamily = attr.m_fontFamily;
@@ -403,6 +405,10 @@ wxFont wxTextAttr::GetFont() const
     if (HasFontUnderlined())
         underlined = GetFontUnderlined();
 
+    bool strikethrough = false;
+    if ( HasFontStrikethrough() )
+        strikethrough = GetFontStrikethrough();
+
     wxString fontFaceName;
     if (HasFontFaceName())
         fontFaceName = GetFontFaceName();
@@ -416,6 +422,8 @@ wxFont wxTextAttr::GetFont() const
         fontFamily = GetFontFamily();
 
     wxFont font(fontSize, fontFamily, fontStyle, fontWeight, underlined, fontFaceName, encoding);
+    if ( strikethrough )
+        font.SetStrikethrough( true );
     return font;
 }
 
@@ -437,6 +445,9 @@ bool wxTextAttr::GetFontAttributes(const wxFont& font, int flags)
     if (flags & wxTEXT_ATTR_FONT_UNDERLINE)
         m_fontUnderlined = font.GetUnderlined();
 
+    if (flags & wxTEXT_ATTR_FONT_STRIKETHROUGH)
+        m_fontStrikethrough = font.GetStrikethrough();
+
     if (flags & wxTEXT_ATTR_FONT_FACE)
         m_fontFaceName = font.GetFaceName();
 
@@ -500,6 +511,12 @@ bool wxTextAttr::Apply(const wxTextAttr& style, const wxTextAttr* compareWith)
             destStyle.SetFontUnderlined(style.GetFontUnderlined());
     }
 
+    if (style.HasFontStrikethrough())
+    {
+        if (!(compareWith && compareWith->HasFontStrikethrough() && compareWith->GetFontStrikethrough() == style.GetFontStrikethrough()))
+            destStyle.SetFontStrikethrough(style.GetFontStrikethrough());
+    }
+
     if (style.HasFontFaceName())
     {
         if (!(compareWith && compareWith->HasFontFaceName() && compareWith->GetFontFaceName() == style.GetFontFaceName()))
@@ -773,7 +790,7 @@ bool wxTextAttr::BitlistsEqPartial(int valueA, int valueB, int flags)
 {
     int relevantBitsA = valueA & flags;
     int relevantBitsB = valueB & flags;
-    return (relevantBitsA != relevantBitsB);
+    return relevantBitsA == relevantBitsB;
 }
 
 /// Split into paragraph and character styles
@@ -834,34 +851,36 @@ bool wxTextAreaBase::DoLoadFile(const wxString& filename, int WXUNUSED(fileType)
         {
             SetValue(text);
 
+            DiscardEdits();
+            m_filename = filename;
+
             return true;
         }
     }
 #endif // wxUSE_FFILE
 
+    wxLogError(_("File couldn't be loaded."));
+
     return false;
 }
 
-bool wxTextCtrlBase::DoLoadFile(const wxString& filename, int fileType)
+bool wxTextAreaBase::DoSaveFile(const wxString& filename, int WXUNUSED(fileType))
 {
-    if ( wxTextAreaBase::DoLoadFile(filename, fileType) )
+#if wxUSE_FFILE
+    wxFFile file(filename, wxT("w"));
+    if ( file.IsOpened() && file.Write(GetValue(), *wxConvCurrent) )
     {
-        DiscardEdits();
+        // if it worked, save for future calls
         m_filename = filename;
+
+        // it's not modified any longer
+        DiscardEdits();
+
         return true;
     }
-    wxLogError(_("File couldn't be loaded."));
-    return false;
-}
+#endif // wxUSE_FFILE
 
-bool wxTextAreaBase::DoSaveFile(const wxString& filename, int WXUNUSED(fileType))
-{
-#if wxUSE_FFILE
-    wxFFile file(filename, wxT("w"));
-    return file.IsOpened() && file.Write(GetValue(), *wxConvCurrent);
-#else
     return false;
-#endif // wxUSE_FFILE
 }
 
 bool wxTextAreaBase::SaveFile(const wxString& filename, int fileType)
@@ -878,21 +897,6 @@ bool wxTextAreaBase::SaveFile(const wxString& filename, int fileType)
     return DoSaveFile(filenameToUse, fileType);
 }
 
-bool wxTextCtrlBase::DoSaveFile(const wxString& filename, int fileType)
-{
-    if ( wxTextAreaBase::DoSaveFile(filename, fileType) )
-    {
-        // if it worked, save for future calls
-        m_filename = filename;
-
-        // it's not modified any longer
-        DiscardEdits();
-
-        return true;
-    }
-    return false;
-}
-
 // ----------------------------------------------------------------------------
 // stream-like insertion operator
 // ----------------------------------------------------------------------------