]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextbuffer.cpp
Simplified event based Drag API for wxDataViewCtrl
[wxWidgets.git] / src / richtext / richtextbuffer.cpp
index f443e7647a18af7bed751a3fc33288c48b4625f6..5fa710cdadc6ca834bb35fe94efd4afffda83884 100644 (file)
@@ -66,6 +66,7 @@ inline void wxCheckSetFont(wxDC& dc, const wxFont& font)
             font1.GetStyle() == font.GetStyle() &&
             font1.GetWeight() == font.GetWeight() &&
             font1.GetUnderlined() == font.GetUnderlined() &&
+            font1.GetFamily() == font.GetFamily() &&
             font1.GetFaceName() == font.GetFaceName())
             return;
     }
@@ -1988,6 +1989,23 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
             }
         }
 
+        if (style.HasFontFamily() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_FAMILY))
+        {
+            if (currentStyle.HasFontFamily())
+            {
+                if (currentStyle.GetFontFamily() != style.GetFontFamily())
+                {
+                    // Clash of style - mark as such
+                    multipleStyleAttributes |= wxTEXT_ATTR_FONT_FAMILY;
+                    currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_FONT_FAMILY);
+                }
+            }
+            else
+            {
+                currentStyle.SetFontFamily(style.GetFontFamily());
+            }
+        }
+
         if (style.HasFontWeight() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_WEIGHT))
         {
             if (currentStyle.HasFontWeight())
@@ -3155,7 +3173,7 @@ bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& range, const wxR
             }
 
             // Get line height from first line, if any
-            wxRichTextLine* line = m_cachedLines.GetFirst() ? (wxRichTextLine* ) m_cachedLines.GetFirst()->GetData() : (wxRichTextLine*) NULL;
+            wxRichTextLine* line = m_cachedLines.GetFirst() ? (wxRichTextLine* ) m_cachedLines.GetFirst()->GetData() : NULL;
 
             wxPoint linePos;
             int lineHeight wxDUMMY_INITIALIZE(0);
@@ -3453,6 +3471,10 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
             wxSize actualSize;
             wxRichTextRange actualRange(lastCompletedEndPos+1, wrapPosition);
 
+            /// Use previous descent, not the wrapping descent we just found, since this may be too big
+            /// for the fragment we're about to add.
+            childDescent = maxDescent;
+
 #if wxRICHTEXT_USE_PARTIAL_TEXT_EXTENTS
             // Get height only, then the width using the partial extents
             GetRangeSize(actualRange, actualSize, childDescent, dc, wxRICHTEXT_UNFORMATTED|wxRICHTEXT_HEIGHT_ONLY);
@@ -3620,12 +3642,16 @@ void wxRichTextParagraph::ApplyParagraphStyle(const wxTextAttr& attr, const wxRe
         {
             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;
             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;
             line->SetPosition(pos);
         }
 
@@ -5660,7 +5686,7 @@ void wxRichTextBuffer::ClearStyleStack()
 bool wxRichTextBuffer::BeginBold()
 {
     wxTextAttr attr;
-    attr.SetFontWeight(wxBOLD);
+    attr.SetFontWeight(wxFONTWEIGHT_BOLD);
 
     return BeginStyle(attr);
 }
@@ -5669,7 +5695,7 @@ bool wxRichTextBuffer::BeginBold()
 bool wxRichTextBuffer::BeginItalic()
 {
     wxTextAttr attr;
-    attr.SetFontStyle(wxITALIC);
+    attr.SetFontStyle(wxFONTSTYLE_ITALIC);
 
     return BeginStyle(attr);
 }