X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/62381daaaf09071bdc408645ed46acd14ffb133a..072252d9aa2216f2b6e18ce92eaf60a7d7419bff:/src/richtext/richtextbuffer.cpp?ds=inline diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index e46b074005..ac9cb9522a 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -1176,7 +1176,8 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParag wxRichTextParagraph* firstPara = wxDynamicCast(firstParaNode->GetData(), wxRichTextParagraph); wxASSERT(firstPara != NULL); - para->SetAttributes(firstPara->GetAttributes()); + if (!(fragment.GetAttributes().GetFlags() & wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE)) + para->SetAttributes(firstPara->GetAttributes()); // Save empty paragraph attributes for appending later // These are character attributes deliberately set for a new paragraph. Without this, @@ -1253,7 +1254,9 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParag } } - if (finalPara && finalPara != para) + if ((fragment.GetAttributes().GetFlags() & wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE) && firstPara) + finalPara->SetAttributes(firstPara->GetAttributes()); + else if (finalPara && finalPara != para) finalPara->SetAttributes(originalAttr); return true; @@ -1455,6 +1458,7 @@ bool wxRichTextParagraphLayoutBox::DeleteRange(const wxRichTextRange& range) obj->DeleteRange(range); wxRichTextRange thisRange = obj->GetRange(); + wxTextAttrEx thisAttr = obj->GetAttributes(); // If the whole paragraph is within the range to delete, // delete the whole thing. @@ -1488,7 +1492,14 @@ bool wxRichTextParagraphLayoutBox::DeleteRange(const wxRichTextRange& range) wxTextAttrEx nextParaAttr; if (applyFinalParagraphStyle) - nextParaAttr = nextParagraph->GetAttributes(); + { + // Special case when deleting the end of a paragraph - use _this_ paragraph's style, + // not the next one. + if (range.GetStart() == range.GetEnd() && range.GetStart() == thisRange.GetEnd()) + nextParaAttr = thisAttr; + else + nextParaAttr = nextParagraph->GetAttributes(); + } if (firstPara && nextParagraph && firstPara != nextParagraph) { @@ -4333,7 +4344,7 @@ bool wxRichTextPlainText::Draw(wxDC& dc, const wxRichTextRange& range, const wxR // (c) Part selected, part not // Let's draw unselected chunk, selected chunk, then unselected chunk. - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); // 1. Initial unselected chunk, if any, up until start of selection. if (selectionRange.GetStart() > range.GetStart() && selectionRange.GetStart() <= range.GetEnd()) @@ -4450,7 +4461,7 @@ bool wxRichTextPlainText::DrawTabbedString(wxDC& dc, const wxTextAttr& attr, con wxCheckSetBrush(dc, wxBrush(highlightColour)); wxCheckSetPen(dc, wxPen(highlightColour)); dc.SetTextForeground(highlightTextColour); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); } else { @@ -4458,11 +4469,11 @@ bool wxRichTextPlainText::DrawTabbedString(wxDC& dc, const wxTextAttr& attr, con if (attr.HasFlag(wxTEXT_ATTR_BACKGROUND_COLOUR) && attr.GetBackgroundColour().IsOk()) { - dc.SetBackgroundMode(wxSOLID); + dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); dc.SetTextBackground(attr.GetBackgroundColour()); } else - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); } while (hasTabs) @@ -4934,17 +4945,19 @@ bool wxRichTextBuffer::InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int wxRichTextParagraph* para = GetParagraphAtPosition(pos, false); long pos1 = pos; + if (p) + newPara->SetAttributes(*p); + if (flags & wxRICHTEXT_INSERT_INTERACTIVE) { if (para && para->GetRange().GetEnd() == pos) pos1 ++; + if (newPara->GetAttributes().HasBulletNumber()) + newPara->GetAttributes().SetBulletNumber(newPara->GetAttributes().GetBulletNumber()+1); } action->SetPosition(pos); - if (p) - newPara->SetAttributes(*p); - // Use the default character style // Use the default character style if (!GetDefaultStyle().IsDefault() && newPara->GetChildren().GetFirst()) @@ -5088,22 +5101,18 @@ bool wxRichTextBuffer::DeleteRangeWithUndo(const wxRichTextRange& range, wxRichT // Copy the fragment that we'll need to restore in Undo CopyFragment(range, action->GetOldParagraphs()); - // Special case: if there is only one (non-partial) paragraph, - // we must save the *next* paragraph's style, because that - // is the style we must apply when inserting the content back - // when undoing the delete. (This is because we're merging the - // paragraph with the previous paragraph and throwing away - // the style, and we need to restore it.) - if (!action->GetOldParagraphs().GetPartialParagraph() && action->GetOldParagraphs().GetChildCount() == 1) + // See if we're deleting a paragraph marker, in which case we need to + // make a note not to copy the attributes from the 2nd paragraph to the 1st. + if (range.GetStart() == range.GetEnd()) { - wxRichTextParagraph* lastPara = GetParagraphAtPosition(range.GetStart()); - if (lastPara) + wxRichTextParagraph* para = GetParagraphAtPosition(range.GetStart()); + if (para && para->GetRange().GetEnd() == range.GetEnd()) { - wxRichTextParagraph* nextPara = GetParagraphAtPosition(range.GetEnd()+1); - if (nextPara) + wxRichTextParagraph* nextPara = GetParagraphAtPosition(range.GetStart()+1); + if (nextPara && nextPara != para) { - wxRichTextParagraph* para = (wxRichTextParagraph*) action->GetOldParagraphs().GetChild(0); - para->SetAttributes(nextPara->GetAttributes()); + action->GetOldParagraphs().GetChildren().GetFirst()->GetData()->SetAttributes(nextPara->GetAttributes()); + action->GetOldParagraphs().GetAttributes().SetFlags(action->GetOldParagraphs().GetAttributes().GetFlags() | wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE); } } } @@ -6010,7 +6019,7 @@ bool wxRichTextStdRenderer::DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& if (attr.GetTextColour().Ok()) dc.SetTextForeground(attr.GetTextColour()); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); int charHeight = dc.GetCharHeight(); wxCoord tw, th;