X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8e77fd8bca165aab9709649d79a7cbc6a172d4e1..dfb39a3727a85d0e075b10d9a9388be514d2f8e1:/src/richtext/richtextbuffer.cpp diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index b15c5c5f49..57c5b0c131 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -4,7 +4,6 @@ // Author: Julian Smart // Modified by: // Created: 2005-09-30 -// RCS-ID: $Id$ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -7447,7 +7446,10 @@ bool wxRichTextParagraphLayoutBox::InsertParagraphsWithUndo(wxRichTextBuffer* bu /// Submit command to insert the given text bool wxRichTextBuffer::InsertTextWithUndo(long pos, const wxString& text, wxRichTextCtrl* ctrl, int flags) { - return ctrl->GetFocusObject()->InsertTextWithUndo(this, pos, text, ctrl, flags); + if (ctrl) + return ctrl->GetFocusObject()->InsertTextWithUndo(this, pos, text, ctrl, flags); + else + return wxRichTextParagraphLayoutBox::InsertTextWithUndo(this, pos, text, ctrl, flags); } /// Submit command to insert the given text @@ -8317,6 +8319,7 @@ wxString wxRichTextBuffer::GetExtWildcard(bool combine, bool save, wxArrayInt* t return wildcard; } +#if wxUSE_FFILE && wxUSE_STREAMS /// Load a file bool wxRichTextBuffer::LoadFile(const wxString& filename, wxRichTextFileType type) { @@ -8345,7 +8348,9 @@ bool wxRichTextBuffer::SaveFile(const wxString& filename, wxRichTextFileType typ else return false; } +#endif // wxUSE_FFILE && wxUSE_STREAMS +#if wxUSE_STREAMS /// Load from a stream bool wxRichTextBuffer::LoadFile(wxInputStream& stream, wxRichTextFileType type) { @@ -8374,6 +8379,7 @@ bool wxRichTextBuffer::SaveFile(wxOutputStream& stream, wxRichTextFileType type) else return false; } +#endif // wxUSE_STREAMS /// Copy the range to the clipboard bool wxRichTextBuffer::CopyToClipboard(const wxRichTextRange& range) @@ -9337,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); @@ -9397,7 +9444,8 @@ void ExpandCellsWithRowspan(const wxRichTextTable* table, int paddingY, int& bot const int colCount = table->GetColumnCount(); wxArrayInt rowTops; rowTops.Add(0, rowCount+1); - for (int row = 0; row < rowCount; ++row) + int row; + for (row = 0; row < rowCount; ++row) { for (int column = 0; column < colCount; ++column) { @@ -9413,10 +9461,9 @@ void ExpandCellsWithRowspan(const wxRichTextTable* table, int paddingY, int& bot bool needsRelay = false; - int row, col; for (row = 0; row < rowCount-1; ++row) // -1 as the bottom row can't rowspan { - for (col = 0; col < colCount; ++col) + for (int col = 0; col < colCount; ++col) { wxRichTextCell* cell = table->GetCell(row, col); if (cell && cell->IsShown()) @@ -9473,7 +9520,7 @@ void ExpandCellsWithRowspan(const wxRichTextTable* table, int paddingY, int& bot // There were overflowing rowspanning cells, so layout yet again to make the increased row depths show for (row = 0; row < rowCount; ++row) { - for (col = 0; col < colCount; ++col) + for (int col = 0; col < colCount; ++col) { wxRichTextCell* cell = table->GetCell(row, col); if (cell && cell->IsShown()) @@ -9517,12 +9564,13 @@ bool wxRichTextTable::Layout(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextAttr attr(GetAttributes()); context.ApplyVirtualAttributes(attr, this); + bool tableHasPercentWidth = (attr.GetTextBoxAttr().GetWidth().GetUnits() == wxTEXT_ATTR_UNITS_PERCENTAGE); // If we have no fixed table size, and assuming we're not pushed for // space, then we don't have to try to stretch the table to fit the contents. - bool stretchToFitTableWidth = false; - + bool stretchToFitTableWidth = tableHasPercentWidth; + int tableWidth = rect.width; - if (attr.GetTextBoxAttr().GetWidth().IsValid()) + if (attr.GetTextBoxAttr().GetWidth().IsValid() && !tableHasPercentWidth) { tableWidth = converter.GetPixels(attr.GetTextBoxAttr().GetWidth());