From f7f8a13c0466725ffffc0cbe9f10da729c3423dd Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Fri, 27 Sep 2013 13:36:46 +0000 Subject: [PATCH] wxRTC: fixed guidelines overwriting adjacent cell borders; corrected capitalisation in command labels; now sends text update event when an object is changed. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74866 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/richtext/richtextbuffer.h | 2 +- interface/wx/richtext/richtextbuffer.h | 2 +- src/richtext/richtextbuffer.cpp | 24 ++++++++++++++++++------ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/include/wx/richtext/richtextbuffer.h b/include/wx/richtext/richtextbuffer.h index 604229a8c4..6cec5eca81 100644 --- a/include/wx/richtext/richtextbuffer.h +++ b/include/wx/richtext/richtextbuffer.h @@ -2708,7 +2708,7 @@ public: Draws the borders and background for the given rectangle and attributes. @a boxRect is taken to be the outer margin box, not the box around the content. */ - static bool DrawBoxAttributes(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& attr, const wxRect& boxRect, int flags = 0); + static bool DrawBoxAttributes(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& attr, const wxRect& boxRect, int flags = 0, wxRichTextObject* obj = NULL); /** Draws a border. diff --git a/interface/wx/richtext/richtextbuffer.h b/interface/wx/richtext/richtextbuffer.h index 2636f83fc5..03a8338abf 100644 --- a/interface/wx/richtext/richtextbuffer.h +++ b/interface/wx/richtext/richtextbuffer.h @@ -2581,7 +2581,7 @@ public: Draws the borders and background for the given rectangle and attributes. @a boxRect is taken to be the outer margin box, not the box around the content. */ - static bool DrawBoxAttributes(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& attr, const wxRect& boxRect, int flags = 0); + static bool DrawBoxAttributes(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& attr, const wxRect& boxRect, int flags = 0, wxRichTextObject* obj = NULL); /** Draws a border. diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 2eb12f119a..f8c4020eab 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -662,7 +662,7 @@ int wxRichTextObject::ConvertPixelsToTenthsMM(int ppi, int pixels, double scale) // Draw the borders and background for the given rectangle and attributes. // Width and height are taken to be the outer margin size, not the content. -bool wxRichTextObject::DrawBoxAttributes(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& attr, const wxRect& boxRect, int flags) +bool wxRichTextObject::DrawBoxAttributes(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& attr, const wxRect& boxRect, int flags, wxRichTextObject* obj) { // Assume boxRect is the area around the content wxRect marginRect = boxRect; @@ -692,12 +692,24 @@ bool wxRichTextObject::DrawBoxAttributes(wxDC& dc, wxRichTextBuffer* buffer, con if (flags & wxRICHTEXT_DRAW_GUIDELINES) { - wxRichTextAttr editBorderAttr = attr; + wxRichTextAttr editBorderAttr; // TODO: make guideline colour configurable editBorderAttr.GetTextBoxAttr().GetBorder().SetColour(*wxLIGHT_GREY); editBorderAttr.GetTextBoxAttr().GetBorder().SetWidth(1, wxTEXT_ATTR_UNITS_PIXELS); editBorderAttr.GetTextBoxAttr().GetBorder().SetStyle(wxTEXT_BOX_ATTR_BORDER_SOLID); + if (obj) + { + wxRichTextCell* cell = wxDynamicCast(obj, wxRichTextCell); + if (cell) + { + // This ensures that thin lines drawn by adjacent cells (left and above) + // don't get overwritten by the guidelines. + editBorderAttr.GetTextBoxAttr().GetBorder().GetLeft().Reset(); + editBorderAttr.GetTextBoxAttr().GetBorder().GetTop().Reset(); + } + } + DrawBorder(dc, buffer, editBorderAttr.GetTextBoxAttr().GetBorder(), borderRect, flags); } @@ -1847,7 +1859,7 @@ bool wxRichTextParagraphLayoutBox::Draw(wxDC& dc, wxRichTextDrawingContext& cont int theseFlags = flags; if (!GetParent()) theseFlags &= ~wxRICHTEXT_DRAW_GUIDELINES; - DrawBoxAttributes(dc, GetBuffer(), attr, thisRect, theseFlags); + DrawBoxAttributes(dc, GetBuffer(), attr, thisRect, theseFlags, this); if (wxRichTextBuffer::GetFloatingLayoutMode()) DrawFloats(dc, context, range, selection, rect, descent, style); @@ -10549,7 +10561,7 @@ bool wxRichTextTable::DeleteRows(int startRow, int noRows) // Create a clone containing the current state of the table. It will be used to Undo the action clone = wxStaticCast(this->Clone(), wxRichTextTable); clone->SetParent(GetParent()); - action = new wxRichTextAction(NULL, _("Delete row"), wxRICHTEXT_CHANGE_OBJECT, buffer, this, rtc); + action = new wxRichTextAction(NULL, _("Delete Row"), wxRICHTEXT_CHANGE_OBJECT, buffer, this, rtc); action->SetObject(this); action->SetPosition(GetRange().GetStart()); } @@ -10617,7 +10629,7 @@ bool wxRichTextTable::DeleteColumns(int startCol, int noCols) // Create a clone containing the current state of the table. It will be used to Undo the action clone = wxStaticCast(this->Clone(), wxRichTextTable); clone->SetParent(GetParent()); - action = new wxRichTextAction(NULL, _("Delete column"), wxRICHTEXT_CHANGE_OBJECT, buffer, this, rtc); + action = new wxRichTextAction(NULL, _("Delete Column"), wxRICHTEXT_CHANGE_OBJECT, buffer, this, rtc); action->SetObject(this); action->SetPosition(GetRange().GetStart()); } @@ -11174,7 +11186,7 @@ bool wxRichTextAction::Do() else container->InvalidateHierarchy(GetRange()); - UpdateAppearance(GetPosition()); + UpdateAppearance(GetPosition(), true); // TODO: send new kind of modification event -- 2.45.2