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
This commit is contained in:
Julian Smart
2014-10-08 10:28:18 +00:00
parent 3ee48824fc
commit d0d4e49209
2 changed files with 16 additions and 4 deletions

View File

@@ -1416,6 +1416,9 @@ wxString wxRichTextCompositeObject::GetTextForRange(const wxRichTextRange& range
wxRichTextRange childRange = range;
if (!child->GetRange().IsOutside(range))
{
if (child->IsTopLevel())
childRange = child->GetOwnRange();
else
childRange.LimitTo(child->GetRange());
wxString childText = child->GetTextForRange(childRange);
@@ -3111,6 +3114,9 @@ wxString wxRichTextParagraphLayoutBox::GetTextForRange(const wxRichTextRange& ra
if (!child->GetRange().IsOutside(range))
{
wxRichTextRange childRange = range;
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 ++;

View File

@@ -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);
}
}