Fixes for incorrect selection, extra newline insertion when undoing deletion of selection,

incorrect SetScrollbar optimization, insufficient refresh for operations on last line,
HasCharacter/ParagraphAttributes bug.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63357 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2010-02-02 22:19:33 +00:00
parent 7261371b17
commit 205a1ad98f
2 changed files with 26 additions and 10 deletions

View File

@@ -1079,7 +1079,15 @@ bool wxRichTextCtrl::DeleteSelectedContent(long* newPos)
if (HasSelection())
{
long pos = m_selectionRange.GetStart();
GetBuffer().DeleteRangeWithUndo(m_selectionRange, this);
wxRichTextRange range = m_selectionRange;
// SelectAll causes more to be selected than doing it interactively,
// and causes a new paragraph to be inserted. So for multiline buffers,
// don't delete the final position.
if (range.GetEnd() == GetLastPosition() && GetNumberOfLines() > 0)
range.SetEnd(range.GetEnd()-1);
GetBuffer().DeleteRangeWithUndo(range, this);
m_selectionRange.SetRange(-2, -2);
if (newPos)
@@ -2059,7 +2067,7 @@ void wxRichTextCtrl::SetupScrollbars(bool atTop)
return;
// Don't set scrollbars if there were none before, and there will be none now.
if (oldPPUY != 0 && (oldVirtualSizeY < clientSize.y) && (unitsY*pixelsPerUnit < clientSize.y))
if (oldPPUY != 0 && (oldVirtualSizeY*oldPPUY < clientSize.y) && (unitsY*pixelsPerUnit < clientSize.y))
return;
// Move to previous scroll position if
@@ -2589,10 +2597,9 @@ void wxRichTextCtrl::SetSelection(long from, long to)
else
{
wxRichTextRange oldSelection = m_selectionRange;
m_selectionAnchor = from;
m_selectionAnchor = from-1;
m_selectionRange.SetRange(from, to-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);
@@ -2810,7 +2817,7 @@ void wxRichTextCtrl::OnSelectAll(wxCommandEvent& WXUNUSED(event))
void wxRichTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event)
{
event.Enable(GetLastPosition() > 0);
event.Enable(GetLastPosition() >= 0);
}
void wxRichTextCtrl::OnContextMenu(wxContextMenuEvent& event)