]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextbuffer.cpp
support for toggle bitmap button
[wxWidgets.git] / src / richtext / richtextbuffer.cpp
index bf1efe3ca3ba09712883bf39edf1c300c7e171eb..eccbc7dfb008026da4907d4278235bbee037102d 100644 (file)
@@ -2469,7 +2469,7 @@ bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange&
         {
             // Stop searching if we're beyond the range of interest
             if (para->GetRange().GetStart() > range.GetEnd())
-                return foundCount == matchingCount;
+                return foundCount == matchingCount && foundCount != 0;
 
             if (!para->GetRange().IsOutside(range))
             {
@@ -2478,7 +2478,12 @@ bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange&
                 while (node2)
                 {
                     wxRichTextObject* child = node2->GetData();
-                    if (!child->GetRange().IsOutside(range) && child->IsKindOf(CLASSINFO(wxRichTextPlainText)))
+                    // Allow for empty string if no buffer
+                    wxRichTextRange childRange = child->GetRange();
+                    if (childRange.GetLength() == 0 && GetRange().GetLength() == 1)
+                        childRange.SetEnd(childRange.GetEnd()+1);
+
+                    if (!childRange.IsOutside(range) && child->IsKindOf(CLASSINFO(wxRichTextPlainText)))
                     {
                         foundCount ++;
                         wxTextAttr textAttr = para->GetCombinedAttributes(child->GetAttributes());
@@ -2517,7 +2522,7 @@ bool wxRichTextParagraphLayoutBox::HasParagraphAttributes(const wxRichTextRange&
         {
             // Stop searching if we're beyond the range of interest
             if (para->GetRange().GetStart() > range.GetEnd())
-                return foundCount == matchingCount;
+                return foundCount == matchingCount && foundCount != 0;
 
             if (!para->GetRange().IsOutside(range))
             {
@@ -6959,8 +6964,12 @@ void wxRichTextAction::UpdateAppearance(long caretPosition, bool sendUpdateEvent
                         // Detect last line in the buffer
                         else if (!node2->GetNext() && para->GetRange().Contains(m_buffer->GetRange().GetEnd()))
                         {
-                            foundEnd = true;
-                            lastY = pt.y + line->GetSize().y;
+                            // If deleting text, make sure we refresh below as well as above
+                            if (positionOffset >= 0)
+                            {
+                                foundEnd = true;
+                                lastY = pt.y + line->GetSize().y;
+                            }
 
                             node2 = wxRichTextLineList::compatibility_iterator();
                             node = wxRichTextObjectList::compatibility_iterator();