]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied #12601: Background color when saving wxRichText to HTML file
authorJulian Smart <julian@anthemion.co.uk>
Fri, 25 Feb 2011 12:21:56 +0000 (12:21 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 25 Feb 2011 12:21:56 +0000 (12:21 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67021 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/richtext/richtexthtml.cpp

index e720fb449637807a62fbcd0cf65d91b6c814df09..7576075bc884577c27db9f51edc3109faf680726 100644 (file)
@@ -196,10 +196,27 @@ void wxRichTextHTMLHandler::BeginCharacterFormatting(const wxRichTextAttr& curre
     }
     if (thisStyle.GetFontSize() != currentStyle.GetFontSize())
         style += wxString::Format(wxT(" size=\"%ld\""), PtToSize(thisStyle.GetFontSize()));
-    if (thisStyle.GetTextColour() != currentStyle.GetTextColour() )
+
+    bool bTextColourChanged = (thisStyle.GetTextColour() != currentStyle.GetTextColour());
+    bool bBackgroundColourChanged = (thisStyle.GetBackgroundColour() != currentStyle.GetBackgroundColour());
+    if (bTextColourChanged || bBackgroundColourChanged)
     {
-        wxString color(thisStyle.GetTextColour().GetAsString(wxC2S_HTML_SYNTAX));
-        style += wxString::Format(wxT(" color=\"%s\""), color.c_str());
+        style += wxT(" style=\"");
+
+        if (bTextColourChanged)
+        {
+            wxString color(thisStyle.GetTextColour().GetAsString(wxC2S_HTML_SYNTAX));
+            style += wxString::Format(wxT("color: %s"), color.c_str());
+        }
+        if (bTextColourChanged && bBackgroundColourChanged)
+            style += wxT(";");
+        if (bBackgroundColourChanged)
+        {
+            wxString color(thisStyle.GetBackgroundColour().GetAsString(wxC2S_HTML_SYNTAX));
+            style += wxString::Format(wxT("background-color: %s"), color.c_str());
+        }
+
+        style += wxT("\"");
     }
 
     if (style.size())