X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/343ae70d4cdc278596ab85a86fc67c5b58b2693c..fc2d42090058bb7ebb9545b857a9a435ecbdd876:/src/richtext/richtextctrl.cpp diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 33b82d92f5..4c3664423b 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -242,8 +242,6 @@ void wxRichTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) // Paint the background PaintBackground(dc); - wxRegion dirtyRegion = GetUpdateRegion(); - wxRect drawingArea(GetLogicalPoint(wxPoint(0, 0)), GetClientSize()); wxRect availableSpace(GetClientSize()); if (GetBuffer().GetDirty()) @@ -632,7 +630,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) event.Skip(); return; } - + default: { if (event.CmdDown() || event.AltDown()) @@ -1723,14 +1721,14 @@ bool wxRichTextCtrl::SelectWord(long position) { if (position < 0 || position > GetBuffer().GetRange().GetEnd()) return false; - + wxRichTextParagraph* para = GetBuffer().GetParagraphAtPosition(position); if (!para) return false; long positionStart = position; long positionEnd = position; - + for (positionStart = position; positionStart >= para->GetRange().GetStart(); positionStart --) { wxString text = GetBuffer().GetTextForRange(wxRichTextRange(positionStart, positionStart)); @@ -1742,7 +1740,7 @@ bool wxRichTextCtrl::SelectWord(long position) } if (positionStart < para->GetRange().GetStart()) positionStart = para->GetRange().GetStart(); - + for (positionEnd = position; positionEnd < para->GetRange().GetEnd(); positionEnd ++) { wxString text = GetBuffer().GetTextForRange(wxRichTextRange(positionEnd, positionEnd)); @@ -1754,13 +1752,13 @@ bool wxRichTextCtrl::SelectWord(long position) } if (positionEnd >= para->GetRange().GetEnd()) positionEnd = para->GetRange().GetEnd(); - + SetSelection(positionStart, positionEnd+1); if (positionStart >= 0) { MoveCaret(positionStart-1, true); - SetDefaultStyleToCursorStyle(); + SetDefaultStyleToCursorStyle(); } return true; @@ -2740,19 +2738,19 @@ bool wxRichTextCtrl::ApplyAlignmentToSelection(wxTextAttrAlignment alignment) } /// Apply a named style to the selection -void wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def) +bool wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def) { // Flags are defined within each definition, so only certain // attributes are applied. wxRichTextAttr attr(def->GetStyle()); - + int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE; // Make sure the attr has the style name if (def->IsKindOf(CLASSINFO(wxRichTextParagraphStyleDefinition))) { attr.SetParagraphStyleName(def->GetName()); - + // If applying a paragraph style, we only want the paragraph nodes to adopt these // attributes, and not the leaf nodes. This will allow the context (e.g. text) // to change its style independently. @@ -2762,9 +2760,12 @@ void wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def) attr.SetCharacterStyleName(def->GetName()); if (HasSelection()) - SetStyleEx(GetSelectionRange(), attr, flags); + return SetStyleEx(GetSelectionRange(), attr, flags); else + { SetAndShowDefaultStyle(attr); + return true; + } } /// Apply the style sheet to the buffer, for example if the styles have changed.