From: Julian Smart Date: Wed, 18 Sep 2013 08:18:32 +0000 (+0000) Subject: Ensure that the overall table border doesn't get overdrawn by cell borders with a... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e0effd7e3b8ad53abdcd008da75ba49a4af1ebf2?ds=sidebyside Ensure that the overall table border doesn't get overdrawn by cell borders with a different colour git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74830 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 230a8a4731..57c5b0c131 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -9343,7 +9343,48 @@ wxRichTextTable::wxRichTextTable(wxRichTextObject* parent): wxRichTextBox(parent // Draws the object. bool wxRichTextTable::Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style) { - return wxRichTextBox::Draw(dc, context, range, selection, rect, descent, style); + wxRichTextBox::Draw(dc, context, range, selection, rect, descent, style); + + // Now draw the table outline, if any, to ensure there are no breaks caused by + // different-coloured cell dividers overwriting the overall table border. + int colCount = GetColumnCount(); + int rowCount = GetRowCount(); + int col, row; + for (col = 0; col < colCount; col++) + { + for (row = 0; row < rowCount; row++) + { + if (row == 0 || row == (rowCount-1) || col == 0 || col == (colCount-1)) + { + wxRichTextCell* cell = GetCell(row, col); + if (cell && !cell->GetRange().IsOutside(range)) + { + wxRect childRect(cell->GetPosition(), cell->GetCachedSize()); + wxRichTextAttr attr(cell->GetAttributes()); + if (row != 0) + attr.GetTextBoxAttr().GetBorder().GetTop().Reset(); + if (row != (rowCount-1)) + attr.GetTextBoxAttr().GetBorder().GetBottom().Reset(); + if (col != 0) + attr.GetTextBoxAttr().GetBorder().GetLeft().Reset(); + if (col != (colCount-1)) + attr.GetTextBoxAttr().GetBorder().GetRight().Reset(); + + if (attr.GetTextBoxAttr().GetBorder().IsValid()) + { + wxRect boxRect(cell->GetPosition(), cell->GetCachedSize()); + wxRect marginRect = boxRect; + wxRect contentRect, borderRect, paddingRect, outlineRect; + + cell->GetBoxRects(dc, GetBuffer(), attr, marginRect, borderRect, contentRect, paddingRect, outlineRect); + cell->DrawBorder(dc, GetBuffer(), attr.GetTextBoxAttr().GetBorder(), borderRect); + } + } + } + } + } + + return true; } WX_DECLARE_OBJARRAY(wxRect, wxRichTextRectArray);