return obj;
}
+bool wxRichTextParagraphLayoutBox::SetObjectPropertiesWithUndo(wxRichTextObject& obj, const wxRichTextProperties& properties, wxRichTextObject* objToSet)
+{
+ 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;
+
+ // The object on which to set properties will usually be 'obj', but use objToSet if it's valid.
+ // This is necessary e.g. on setting a wxRichTextCell's properties, when obj will be the parent table
+ if (objToSet == NULL)
+ objToSet = &obj;
+
+ if (rtc->SuppressingUndo())
+ objToSet->SetProperties(properties);
+ else
+ {
+ clone = obj.Clone();
+ objToSet->SetProperties(properties);
+
+ // The 'true' parameter in the next line says "Ignore first time"; otherwise the objects are prematurely switched
+ action = new wxRichTextAction(NULL, _("Change Properties"), wxRICHTEXT_CHANGE_OBJECT, buffer, obj.GetParentContainer(), rtc, true);
+ action->SetOldAndNewObjects(& obj, clone);
+ action->SetPosition(obj.GetRange().GetStart());
+ action->SetRange(obj.GetRange());
+ buffer->SubmitAction(action);
+ }
+
+ 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.
if (BatchingUndo() && m_batchedCommand && !SuppressingUndo())
{
- wxRichTextCommand* cmd = new wxRichTextCommand(action->GetName());
- cmd->AddAction(action);
- cmd->Do();
- cmd->GetActions().Clear();
- delete cmd;
+ if (!action->GetIgnoreFirstTime())
+ {
+ wxRichTextCommand* cmd = new wxRichTextCommand(action->GetName());
+ cmd->AddAction(action);
+ cmd->Do();
+ cmd->GetActions().Clear();
+ delete cmd;
+ }
m_batchedCommand->AddAction(action);
}
cmd->AddAction(action);
// Only store it if we're not suppressing undo.
- return GetCommandProcessor()->Submit(cmd, !SuppressingUndo());
+ if (!action->GetIgnoreFirstTime())
+ {
+ return GetCommandProcessor()->Submit(cmd, !SuppressingUndo());
+ }
+ else if (!SuppressingUndo())
+ {
+ GetCommandProcessor()->Store(cmd); // Just store it, without Do()ing anything
+ }
}
return true;
{
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;
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());