From d0d4e4920966e461de3c2f28ecf312ded0125e4a Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 8 Oct 2014 10:28:18 +0000 Subject: [PATCH] Page up/down behaviour now takes into account margins and scale GetTextForRange takes composites into account properly HasCharacterAttributes correction git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@77980 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/richtext/richtextbuffer.cpp | 11 +++++++++-- src/richtext/richtextctrl.cpp | 9 +++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index eab5652e05..8cf3e4ee21 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -1416,7 +1416,10 @@ wxString wxRichTextCompositeObject::GetTextForRange(const wxRichTextRange& range wxRichTextRange childRange = range; if (!child->GetRange().IsOutside(range)) { - childRange.LimitTo(child->GetRange()); + if (child->IsTopLevel()) + childRange = child->GetOwnRange(); + else + childRange.LimitTo(child->GetRange()); wxString childText = child->GetTextForRange(childRange); @@ -3111,7 +3114,10 @@ wxString wxRichTextParagraphLayoutBox::GetTextForRange(const wxRichTextRange& ra if (!child->GetRange().IsOutside(range)) { wxRichTextRange childRange = range; - childRange.LimitTo(child->GetRange()); + if (child->IsTopLevel()) + childRange = child->GetOwnRange(); + else + childRange.LimitTo(child->GetRange()); wxString childText = child->GetTextForRange(childRange); @@ -3641,6 +3647,7 @@ bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange& { foundCount ++; wxRichTextAttr textAttr = para->GetCombinedAttributes(child->GetAttributes()); + textAttr.SetFlags(textAttr.GetFlags() & ~wxTEXT_ATTR_PARAGRAPH); if (textAttr.EqPartial(style, false /* strong test - attributes must be valid in both objects */)) matchingCount ++; diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 8d3a420fdf..4a98bb7356 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -2416,7 +2416,10 @@ bool wxRichTextCtrl::PageDown(int noPages, int flags) if (line) { wxSize clientSize = GetClientSize(); - int newY = line->GetAbsolutePosition().y + noPages*clientSize.y; + int topMargin = GetBuffer().GetTopMargin(); + int bottomMargin = GetBuffer().GetBottomMargin(); + int height = int( 0.5 + ((clientSize.y - topMargin - bottomMargin) / GetScale())); + int newY = line->GetAbsolutePosition().y + noPages*height; wxRichTextLine* newLine = GetFocusObject()->GetLineAtYPosition(newY); if (newLine) @@ -3951,7 +3954,9 @@ wxRichTextLine* wxRichTextCtrl::GetVisibleLineForCaretPosition(long caretPositio if (caretPosition == lineRange.GetStart()-1 && (para->GetRange().GetStart() != lineRange.GetStart())) { - if (!m_caretAtLineStart) + // Only test for caret start/end position if we're looking at the current caret position, + // otherwise m_caretAtLineStart is meaningless + if (!m_caretAtLineStart && (caretPosition == m_caretPosition)) line = GetFocusObject()->GetLineAtPosition(caretPosition-1, true); } }