]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextbuffer.cpp
Add default constructor to wxGraphicsGradientStop.
[wxWidgets.git] / src / richtext / richtextbuffer.cpp
index 4e00843d4bab8e7204866d6cc93042b36c8ff86a..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())
         {
             // 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))
             {
 
             if (!para->GetRange().IsOutside(range))
             {
@@ -2478,7 +2478,12 @@ bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange&
                 while (node2)
                 {
                     wxRichTextObject* child = node2->GetData();
                 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());
                     {
                         foundCount ++;
                         wxTextAttr textAttr = para->GetCombinedAttributes(child->GetAttributes());
@@ -2495,7 +2500,7 @@ bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange&
         node = node->GetNext();
     }
 
         node = node->GetNext();
     }
 
-    return foundCount == matchingCount;
+    return foundCount == matchingCount && foundCount != 0;
 }
 
 /// Test if this whole range has paragraph attributes of the specified kind. If any
 }
 
 /// Test if this whole range has paragraph attributes of the specified kind. If any
@@ -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())
         {
             // 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))
             {
 
             if (!para->GetRange().IsOutside(range))
             {
@@ -2533,7 +2538,7 @@ bool wxRichTextParagraphLayoutBox::HasParagraphAttributes(const wxRichTextRange&
 
         node = node->GetNext();
     }
 
         node = node->GetNext();
     }
-    return foundCount == matchingCount;
+    return foundCount == matchingCount && foundCount != 0;
 }
 
 void wxRichTextParagraphLayoutBox::Clear()
 }
 
 void wxRichTextParagraphLayoutBox::Clear()
@@ -3355,8 +3360,8 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
     wxPoint currentPosition(0, spaceBeforePara); // We will calculate lines relative to paragraph
     int lineHeight = 0;
     int maxWidth = 0;
     wxPoint currentPosition(0, spaceBeforePara); // We will calculate lines relative to paragraph
     int lineHeight = 0;
     int maxWidth = 0;
+    int maxAscent = 0;
     int maxDescent = 0;
     int maxDescent = 0;
-
     int lineCount = 0;
 
     wxRichTextObjectList::compatibility_iterator node;
     int lineCount = 0;
 
     wxRichTextObjectList::compatibility_iterator node;
@@ -3484,8 +3489,9 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
 #endif
 
             currentWidth = actualSize.x;
 #endif
 
             currentWidth = actualSize.x;
-            lineHeight = wxMax(lineHeight, actualSize.y);
             maxDescent = wxMax(childDescent, maxDescent);
             maxDescent = wxMax(childDescent, maxDescent);
+            maxAscent = wxMax(actualSize.y-childDescent, maxAscent);
+            lineHeight = maxDescent + maxAscent;
 
             // Add a new line
             wxRichTextLine* line = AllocateLine(lineCount);
 
             // Add a new line
             wxRichTextLine* line = AllocateLine(lineCount);
@@ -3501,6 +3507,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
             currentPosition.y += lineSpacing;
             currentWidth = 0;
             maxDescent = 0;
             currentPosition.y += lineSpacing;
             currentWidth = 0;
             maxDescent = 0;
+            maxAscent = 0;
             maxWidth = wxMax(maxWidth, currentWidth);
 
             lineCount ++;
             maxWidth = wxMax(maxWidth, currentWidth);
 
             lineCount ++;
@@ -3524,8 +3531,9 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
         {
             // We still fit, so don't add a line, and keep going
             currentWidth += childSize.x;
         {
             // We still fit, so don't add a line, and keep going
             currentWidth += childSize.x;
-            lineHeight = wxMax(lineHeight, childSize.y);
             maxDescent = wxMax(childDescent, maxDescent);
             maxDescent = wxMax(childDescent, maxDescent);
+            maxAscent = wxMax(childSize.y-childDescent, maxAscent);
+            lineHeight = maxDescent + maxAscent;
 
             maxWidth = wxMax(maxWidth, currentWidth);
             lastEndPos = child->GetRange().GetEnd();
 
             maxWidth = wxMax(maxWidth, currentWidth);
             lastEndPos = child->GetRange().GetEnd();
@@ -3641,17 +3649,13 @@ void wxRichTextParagraph::ApplyParagraphStyle(const wxTextAttr& attr, const wxRe
         if (attr.HasAlignment() && GetAttributes().GetAlignment() == wxTEXT_ALIGNMENT_CENTRE)
         {
             int rightIndent = ConvertTenthsMMToPixels(dc, attr.GetRightIndent());
         if (attr.HasAlignment() && GetAttributes().GetAlignment() == wxTEXT_ALIGNMENT_CENTRE)
         {
             int rightIndent = ConvertTenthsMMToPixels(dc, attr.GetRightIndent());
-            pos.x = (rect.GetWidth() - (pos.x - rect.x) - rightIndent - size.x)/2 + pos.x;
-            // Lines are relative to the paragraph position
-            pos.x -= GetPosition().x;
+            pos.x = (rect.GetWidth() - pos.x - rightIndent - size.x)/2 + pos.x;
             line->SetPosition(pos);
         }
         else if (attr.HasAlignment() && GetAttributes().GetAlignment() == wxTEXT_ALIGNMENT_RIGHT)
         {
             int rightIndent = ConvertTenthsMMToPixels(dc, attr.GetRightIndent());
             line->SetPosition(pos);
         }
         else if (attr.HasAlignment() && GetAttributes().GetAlignment() == wxTEXT_ALIGNMENT_RIGHT)
         {
             int rightIndent = ConvertTenthsMMToPixels(dc, attr.GetRightIndent());
-            pos.x = rect.x + rect.GetWidth() - size.x - rightIndent;
-            // Lines are relative to the paragraph position
-            pos.x -= GetPosition().x;
+            pos.x = rect.GetWidth() - size.x - rightIndent;
             line->SetPosition(pos);
         }
 
             line->SetPosition(pos);
         }
 
@@ -6960,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()))
                         {
                         // 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();
 
                             node2 = wxRichTextLineList::compatibility_iterator();
                             node = wxRichTextObjectList::compatibility_iterator();