]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextbuffer.cpp
Avoid using wxHtmlTag::HasParam() unnecessarily.
[wxWidgets.git] / src / richtext / richtextbuffer.cpp
index 7ffc2cc3b4eccacaa53be5de8610a5a21bd28e72..e00ff83983f07b9a80e7f4a47162a0ef77adb86c 100644 (file)
@@ -7723,6 +7723,53 @@ wxRichTextField* wxRichTextParagraphLayoutBox::InsertFieldWithUndo(wxRichTextBuf
     return obj;
 }
 
+bool wxRichTextParagraphLayoutBox::SetObjectPropertiesWithUndo(wxRichTextObject& obj, const wxRichTextProperties& properties)
+{
+    wxRichTextBuffer* buffer = GetBuffer();
+    wxCHECK_MSG(buffer, false, wxT("Invalid buffer"));
+    wxRichTextCtrl* rtc = buffer->GetRichTextCtrl();
+    wxCHECK_MSG(rtc, false, wxT("Invalid rtc"));
+
+    wxRichTextAction* action = NULL;
+    wxRichTextObject* clone = NULL;
+
+#if 1
+    if (rtc->SuppressingUndo())
+        obj.SetProperties(properties);
+    else
+    {
+        clone = obj.Clone();
+        clone->SetProperties(obj.GetProperties());
+        action = new wxRichTextAction(NULL, _("Change Properties"), wxRICHTEXT_CHANGE_OBJECT, buffer, obj.GetParentContainer(), rtc);
+        action->SetOldAndNewObjects(& obj, clone);
+        action->SetPosition(obj.GetRange().GetStart());
+        action->SetRange(obj.GetRange());
+        buffer->SubmitAction(action);
+    }
+#else
+    if (!rtc->SuppressingUndo())
+    {
+        // Create a clone containing the current state of the object. It will be used to Undo the action
+        clone = obj.Clone();
+        clone->SetParent(obj.GetParent());
+        action = new wxRichTextAction(NULL, _("Change Properties"), wxRICHTEXT_CHANGE_OBJECT, buffer, rtc->GetFocusObject(), rtc);
+        action->SetObject(&obj);
+        action->SetPosition(GetRange().GetStart());
+    }
+
+    obj.SetProperties(properties);
+
+    if (!rtc->SuppressingUndo())
+    {
+        buffer->SubmitAction(action);
+        // Finally store the original-state clone; doing so earlier would cause various failures
+        action->StoreObject(clone);
+    }
+#endif
+
+    return true;
+}
+
 /// Get the style that is appropriate for a new paragraph at this position.
 /// If the previous paragraph has a paragraph style name, look up the next-paragraph
 /// style.
@@ -9375,8 +9422,6 @@ bool wxRichTextTable::Draw(wxDC& dc, wxRichTextDrawingContext& context, const wx
 {
     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;
@@ -9387,7 +9432,7 @@ bool wxRichTextTable::Draw(wxDC& dc, wxRichTextDrawingContext& context, const wx
             if (row == 0 || row == (rowCount-1) || col == 0 || col == (colCount-1))
             {
                 wxRichTextCell* cell = GetCell(row, col);
-                if (cell && !cell->GetRange().IsOutside(range))
+                if (cell && cell->IsShown() && !cell->GetRange().IsOutside(range))
                 {
                     wxRect childRect(cell->GetPosition(), cell->GetCachedSize());
                     wxRichTextAttr attr(cell->GetAttributes());