Simplify SetSelectionRange and make consistent with SetSelection.
Fix a bug that returns true for character and paragraph style tests if no characters or paragraphs were found. Fix SetSelection to position caret at end. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63344 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2495,7 +2495,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
|
||||||
@@ -2533,7 +2533,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()
|
||||||
|
@@ -2174,8 +2174,7 @@ wxRichTextRange wxRichTextCtrl::AddImage(const wxImage& image)
|
|||||||
|
|
||||||
void wxRichTextCtrl::SelectAll()
|
void wxRichTextCtrl::SelectAll()
|
||||||
{
|
{
|
||||||
SetSelection(0, GetLastPosition()+1);
|
SetSelection(-1, -1);
|
||||||
m_selectionAnchor = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Select none
|
/// Select none
|
||||||
@@ -2592,8 +2591,9 @@ void wxRichTextCtrl::SetSelection(long from, long to)
|
|||||||
wxRichTextRange oldSelection = m_selectionRange;
|
wxRichTextRange oldSelection = m_selectionRange;
|
||||||
m_selectionAnchor = from;
|
m_selectionAnchor = from;
|
||||||
m_selectionRange.SetRange(from, to-1);
|
m_selectionRange.SetRange(from, to-1);
|
||||||
if (from > -2)
|
|
||||||
m_caretPosition = from-1;
|
// Have to subtract 2, one because of endPos+1 rule (SetSelection docs) and another to turn into caret position.
|
||||||
|
m_caretPosition = wxMax(-1, to-2);
|
||||||
|
|
||||||
RefreshForSelectionChange(oldSelection, m_selectionRange);
|
RefreshForSelectionChange(oldSelection, m_selectionRange);
|
||||||
PositionCaret();
|
PositionCaret();
|
||||||
@@ -3344,13 +3344,7 @@ wxRichTextRange wxRichTextCtrl::GetSelectionRange() const
|
|||||||
|
|
||||||
void wxRichTextCtrl::SetSelectionRange(const wxRichTextRange& range)
|
void wxRichTextCtrl::SetSelectionRange(const wxRichTextRange& range)
|
||||||
{
|
{
|
||||||
wxRichTextRange range1(range);
|
SetSelection(range.GetStart(), range.GetEnd());
|
||||||
if (range1 != wxRichTextRange(-2,-2) && range1 != wxRichTextRange(-1,-1) )
|
|
||||||
range1.SetEnd(range1.GetEnd() - 1);
|
|
||||||
|
|
||||||
wxASSERT( range1.GetStart() > range1.GetEnd() );
|
|
||||||
|
|
||||||
SetInternalSelectionRange(range1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set list style
|
/// Set list style
|
||||||
|
Reference in New Issue
Block a user