From c598f225189ff925264117e4f8d6c70f699b72ab Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Sun, 2 Dec 2001 13:29:21 +0000
Subject: [PATCH] SetDefaultStyle(wxTextAttr()) now resets the default style
 instead of not changing it at all

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12817 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/text.tex | 4 ++++
 src/common/textcmn.cpp | 9 +++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/docs/latex/wx/text.tex b/docs/latex/wx/text.tex
index 92cde1a233..af0fd12556 100644
--- a/docs/latex/wx/text.tex
+++ b/docs/latex/wx/text.tex
@@ -681,6 +681,10 @@ If either of the font, foreground, or background colour is not set in\rtfsp
 the previous default style didn't set them neither, the global font or colours
 of the text control itself are used as fall back.
 
+However if the {\it style} parameter is the default wxTextAttr, then the
+default style is just reset (instead of being combined with the new style which
+wouldn't change it at all).
+
 \wxheading{Parameters}
 
 \docparam{style}{The style for the new text.}
diff --git a/src/common/textcmn.cpp b/src/common/textcmn.cpp
index 7e081b9037..6a494d434c 100644
--- a/src/common/textcmn.cpp
+++ b/src/common/textcmn.cpp
@@ -115,8 +115,13 @@ bool wxTextCtrlBase::SetStyle(long WXUNUSED(start), long WXUNUSED(end),
 // change default text attributes
 bool wxTextCtrlBase::SetDefaultStyle(const wxTextAttr& style)
 {
-    // keep the old attributes if the new style doesn't specify them
-    m_defaultStyle = wxTextAttr::Combine(style, m_defaultStyle, this);
+    // keep the old attributes if the new style doesn't specify them unless the
+    // new style is empty - then reset m_defaultStyle (as there is no other way
+    // to do it)
+    if ( style.IsDefault() )
+        m_defaultStyle = style;
+    else
+        m_defaultStyle = wxTextAttr::Combine(style, m_defaultStyle, this);
 
     return TRUE;
 }
-- 
2.50.0

