]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextctrl.cpp
Update the text hint display correctly when ChangeValue() is called.
[wxWidgets.git] / src / richtext / richtextctrl.cpp
index 300a87d678d356863e61ead075e533a57ba094c3..d46d6c31dd5ffadea2e9c67d270796f09276a871 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())
         {
@@ -2600,7 +2603,7 @@ void wxRichTextCtrl::SetSelection(long from, long to)
         m_selectionAnchor = from-1;
         m_selectionRange.SetRange(from, to-1);
 
-        m_caretPosition = wxMax(-1, to-2);
+        m_caretPosition = wxMax(-1, to-1);
 
         RefreshForSelectionChange(oldSelection, m_selectionRange);
         PositionCaret();
@@ -2812,12 +2815,13 @@ void wxRichTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
 
 void wxRichTextCtrl::OnSelectAll(wxCommandEvent& WXUNUSED(event))
 {
-    SelectAll();
+    if (GetLastPosition() > 0)
+        SelectAll();
 }
 
 void wxRichTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event)
 {
-    event.Enable(GetLastPosition() >= 0);
+    event.Enable(GetLastPosition() > 0);
 }
 
 void wxRichTextCtrl::OnContextMenu(wxContextMenuEvent& event)
@@ -3244,9 +3248,12 @@ bool wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def)
         return SetListStyle(range, (wxRichTextListStyleDefinition*) def, flags);
     }
 
+    bool isPara = false;
+
     // Make sure the attr has the style name
     if (def->IsKindOf(CLASSINFO(wxRichTextParagraphStyleDefinition)))
     {
+        isPara = true;
         attr.SetParagraphStyleName(def->GetName());
 
         // If applying a paragraph style, we only want the paragraph nodes to adopt these
@@ -3261,9 +3268,28 @@ bool wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def)
         return SetStyleEx(GetSelectionRange(), attr, flags);
     else
     {
-        wxRichTextAttr current = GetDefaultStyleEx();
-        current.Apply(attr);
+        wxTextAttr current = GetDefaultStyleEx();
+        wxTextAttr defaultStyle(attr);
+        if (isPara)
+        {
+            // Don't apply extra character styles since they are already implied
+            // in the paragraph style
+            defaultStyle.SetFlags(defaultStyle.GetFlags() & ~wxTEXT_ATTR_CHARACTER);
+        }
+        current.Apply(defaultStyle);
         SetAndShowDefaultStyle(current);
+
+        // If it's a paragraph style, we want to apply the style to the
+        // current paragraph even if we didn't select any text.
+        if (isPara)
+        {
+            long pos = GetAdjustedCaretPosition(GetCaretPosition());
+            wxRichTextParagraph* para = GetBuffer().GetParagraphAtPosition(pos);
+            if (para)
+            {
+                return SetStyleEx(para->GetRange().FromInternal(), attr, flags);
+            }
+        }
         return true;
     }
 }