]> git.saurik.com Git - wxWidgets.git/commitdiff
Ensure that the overall table border doesn't get overdrawn by cell borders with a...
authorJulian Smart <julian@anthemion.co.uk>
Wed, 18 Sep 2013 08:18:32 +0000 (08:18 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Wed, 18 Sep 2013 08:18:32 +0000 (08:18 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74830 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/richtext/richtextbuffer.cpp

index 230a8a4731b8de220223312a1a8479e3af557121..57c5b0c13170fa1d76ca3205e8fcc7c26479800e 100644 (file)
@@ -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);