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())
{
}
}
- if (!processed)
+ if (!processed && newPos < (GetLastPosition()-1))
GetBuffer().DeleteRangeWithUndo(wxRichTextRange(newPos+1, newPos+1), this);
}
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)
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
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);
+ m_caretPosition = wxMax(-1, to-1);
RefreshForSelectionChange(oldSelection, m_selectionRange);
PositionCaret();
void wxRichTextCtrl::OnSelectAll(wxCommandEvent& WXUNUSED(event))
{
- SelectAll();
+ if (GetLastPosition() > 0)
+ SelectAll();
}
void wxRichTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event)
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
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;
}
}