X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8e43fc777628f4041451e2c17a9871541802978f..ef787038ecc3f071169e5400cf4202ad2a7d6e5c:/src/richtext/richtextctrl.cpp diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 9c55ab02fb..0b115f6b6b 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -409,6 +409,9 @@ void wxRichTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) dc.DestroyClippingRegion(); + // Other user defined painting after everything else (i.e. all text) is painted + PaintAboveContent(dc); + #if wxRICHTEXT_USE_OWN_CARET if (GetCaret()->IsVisible()) { @@ -963,7 +966,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) } } - if (!processed) + if (!processed && newPos < (GetLastPosition()-1)) GetBuffer().DeleteRangeWithUndo(wxRichTextRange(newPos+1, newPos+1), this); } @@ -1079,7 +1082,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 +2070,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 @@ -2174,8 +2185,7 @@ wxRichTextRange wxRichTextCtrl::AddImage(const wxImage& image) void wxRichTextCtrl::SelectAll() { - SetSelection(0, GetLastPosition()+1); - m_selectionAnchor = -1; + SetSelection(-1, -1); } /// Select none @@ -2590,10 +2600,10 @@ 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); - if (from > -2) - m_caretPosition = from-1; + + m_caretPosition = wxMax(-1, to-1); RefreshForSelectionChange(oldSelection, m_selectionRange); PositionCaret(); @@ -2805,7 +2815,8 @@ void wxRichTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event) void wxRichTextCtrl::OnSelectAll(wxCommandEvent& WXUNUSED(event)) { - SelectAll(); + if (GetLastPosition() > 0) + SelectAll(); } void wxRichTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event) @@ -3344,13 +3355,7 @@ wxRichTextRange wxRichTextCtrl::GetSelectionRange() const void wxRichTextCtrl::SetSelectionRange(const wxRichTextRange& range) { - wxRichTextRange range1(range); - if (range1 != wxRichTextRange(-2,-2) && range1 != wxRichTextRange(-1,-1) ) - range1.SetEnd(range1.GetEnd() - 1); - - wxASSERT( range1.GetStart() > range1.GetEnd() ); - - SetInternalSelectionRange(range1); + SetSelection(range.GetStart(), range.GetEnd()); } /// Set list style