]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextbuffer.cpp
don't assume there's always an active wxEventLoop instance
[wxWidgets.git] / src / richtext / richtextbuffer.cpp
index 949d375ced59ed1b5c6b9465a1967bcd0d3bf96d..dc91157cc32f6d67fe0c60fa9182a9111b59b43b 100644 (file)
@@ -3017,6 +3017,16 @@ bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& range, const wxR
 
             wxTextAttrEx bulletAttr(GetCombinedAttributes());
 
+            // Combine with the font of the first piece of content, if one is specified
+            if (GetChildren().GetCount() > 0)
+            {
+                wxRichTextObject* firstObj = (wxRichTextObject*) GetChildren().GetFirst()->GetData();
+                if (firstObj->GetAttributes().HasFont())
+                {
+                    wxRichTextApplyStyle(bulletAttr, firstObj->GetAttributes());
+                }
+            }
+
             // Get line height from first line, if any
             wxRichTextLine* line = m_cachedLines.GetFirst() ? (wxRichTextLine* ) m_cachedLines.GetFirst()->GetData() : (wxRichTextLine*) NULL;
 
@@ -4730,7 +4740,8 @@ bool wxRichTextBuffer::InsertTextWithUndo(long pos, const wxString& text, wxRich
     wxTextAttrEx paraAttr;
     if (flags & wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE)
     {
-        paraAttr = GetStyleForNewParagraph(pos);
+        // Get appropriate paragraph style
+        paraAttr = GetStyleForNewParagraph(pos, false, false);
         if (!paraAttr.IsDefault())
             p = & paraAttr;
     }
@@ -4767,7 +4778,7 @@ bool wxRichTextBuffer::InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int
     wxTextAttrEx paraAttr;
     if (flags & wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE)
     {
-        paraAttr = GetStyleForNewParagraph(pos);
+        paraAttr = GetStyleForNewParagraph(pos, false, true /* look for next paragraph style */);
         if (!paraAttr.IsDefault())
             p = & paraAttr;
     }
@@ -4831,7 +4842,7 @@ bool wxRichTextBuffer::InsertImageWithUndo(long pos, const wxRichTextImageBlock&
 /// 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.
-wxRichTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPosition) const
+wxRichTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPosition, bool lookUpNewParaStyle) const
 {
     wxRichTextParagraph* para = GetParagraphAtPosition(pos, caretPosition);
     if (para)
@@ -4840,7 +4851,7 @@ wxRichTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPos
         bool foundAttributes = false;
         
         // Look for a matching paragraph style
-        if (!para->GetAttributes().GetParagraphStyleName().IsEmpty() && GetStyleSheet())
+        if (lookUpNewParaStyle && !para->GetAttributes().GetParagraphStyleName().IsEmpty() && GetStyleSheet())
         {
             wxRichTextParagraphStyleDefinition* paraDef = GetStyleSheet()->FindParagraphStyle(para->GetAttributes().GetParagraphStyleName());
             if (paraDef)
@@ -6041,7 +6052,7 @@ bool wxRichTextAction::Do()
             if (m_newParagraphs.GetPartialParagraph())
                 newCaretPosition --;
             else
-                if (m_newParagraphs.GetChildren().GetCount() > 0)
+                if (m_newParagraphs.GetChildren().GetCount() > 1)
                 {
                     wxRichTextObject* p = (wxRichTextObject*) m_newParagraphs.GetChildren().GetLast()->GetData();
                     if (p->GetRange().GetLength() == 1)