diff --git a/samples/richtext/richtext.cpp b/samples/richtext/richtext.cpp index 2f0fb87c69..894045e0ae 100644 --- a/samples/richtext/richtext.cpp +++ b/samples/richtext/richtext.cpp @@ -754,9 +754,12 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos, r.WriteText(wxT("colour, like this red bit.")); r.EndTextColour(); - r.BeginTextColour(wxColour(0, 0, 255)); - r.WriteText(wxT(" And this blue bit.")); - r.EndTextColour(); + wxRichTextAttr backgroundColourAttr; + backgroundColourAttr.SetBackgroundColour(*wxGREEN); + backgroundColourAttr.SetTextColour(wxColour(0, 0, 255)); + r.BeginStyle(backgroundColourAttr); + r.WriteText(wxT(" And this blue on green bit.")); + r.EndStyle(); r.WriteText(wxT(" Naturally you can make things ")); r.BeginBold(); diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 4b412af4fa..ec6f0c6f47 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -4329,14 +4329,20 @@ bool wxRichTextPlainText::DrawTabbedString(wxDC& dc, const wxTextAttrEx& attr, c dc.SetBrush(*wxBLACK_BRUSH); dc.SetPen(*wxBLACK_PEN); dc.SetTextForeground(*wxWHITE); - dc.SetBackgroundMode(wxTRANSPARENT); } else { dc.SetTextForeground(attr.GetTextColour()); - dc.SetBackgroundMode(wxTRANSPARENT); } + if (attr.HasFlag(wxTEXT_ATTR_BACKGROUND_COLOUR) && attr.GetBackgroundColour().IsOk()) + { + dc.SetBackgroundMode(wxSOLID); + dc.SetTextBackground(attr.GetBackgroundColour()); + } + else + dc.SetBackgroundMode(wxTRANSPARENT); + while (hasTabs) { // the string has a tab