]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextctrl.cpp
Add default constructor to wxGraphicsGradientStop.
[wxWidgets.git] / src / richtext / richtextctrl.cpp
index a9910f4210f9f32c9bf257874752f09e91aaa7d2..be2bc269ee5185a1612451b0463ad9835fea250b 100644 (file)
@@ -963,7 +963,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event)
                 }
             }
 
-            if (!processed)
+            if (!processed && newPos < (GetLastPosition()-1))
                 GetBuffer().DeleteRangeWithUndo(wxRichTextRange(newPos+1, newPos+1), this);
         }
 
@@ -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);
@@ -2805,7 +2812,8 @@ void wxRichTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
 
 void wxRichTextCtrl::OnSelectAll(wxCommandEvent& WXUNUSED(event))
 {
-    SelectAll();
+    if (GetLastPosition() > 0)
+        SelectAll();
 }
 
 void wxRichTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event)