]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextctrl.cpp
Correct printf parameter mismatch in wxWndProc.
[wxWidgets.git] / src / richtext / richtextctrl.cpp
index 9c55ab02fbe022d08ccadf35834c1b7fd903b793..0b115f6b6b582cc7be0cc2c466323c973241eb41 100644 (file)
@@ -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