From 3f239e37605aa38b26b3954565b865600a4152aa Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 27 Jan 2008 17:34:23 +0000 Subject: [PATCH] Take basic style into account when showing style under cursor git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51412 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/richtext/richtextstyles.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/richtext/richtextstyles.cpp b/src/richtext/richtextstyles.cpp index e530832977..a171a8b60a 100644 --- a/src/richtext/richtextstyles.cpp +++ b/src/richtext/richtextstyles.cpp @@ -714,17 +714,14 @@ wxString wxRichTextStyleListBox::GetStyleToShowInIdleTime(wxRichTextCtrl* ctrl, { int adjustedCaretPos = ctrl->GetAdjustedCaretPosition(ctrl->GetCaretPosition()); - wxRichTextParagraph* para = ctrl->GetBuffer().GetParagraphAtPosition(adjustedCaretPos); - wxRichTextObject* obj = ctrl->GetBuffer().GetLeafObjectAtPosition(adjustedCaretPos); - wxString styleName; + wxTextAttr attr; + ctrl->GetStyle(adjustedCaretPos, attr); + // Take into account current default style just chosen by user if (ctrl->IsDefaultStyleShowing()) { - wxTextAttr attr; - - ctrl->GetStyle(adjustedCaretPos, attr); wxRichTextApplyStyle(attr, ctrl->GetDefaultStyleEx()); if ((styleType == wxRICHTEXT_STYLE_ALL || styleType == wxRICHTEXT_STYLE_CHARACTER) && @@ -737,20 +734,20 @@ wxString wxRichTextStyleListBox::GetStyleToShowInIdleTime(wxRichTextCtrl* ctrl, !attr.GetListStyleName().IsEmpty()) styleName = attr.GetListStyleName(); } - else if (obj && (styleType == wxRICHTEXT_STYLE_ALL || styleType == wxRICHTEXT_STYLE_CHARACTER) && - !obj->GetAttributes().GetCharacterStyleName().IsEmpty()) + else if ((styleType == wxRICHTEXT_STYLE_ALL || styleType == wxRICHTEXT_STYLE_CHARACTER) && + !attr.GetCharacterStyleName().IsEmpty()) { - styleName = obj->GetAttributes().GetCharacterStyleName(); + styleName = attr.GetCharacterStyleName(); } - else if (para && (styleType == wxRICHTEXT_STYLE_ALL || styleType == wxRICHTEXT_STYLE_PARAGRAPH) && - !para->GetAttributes().GetParagraphStyleName().IsEmpty()) + else if ((styleType == wxRICHTEXT_STYLE_ALL || styleType == wxRICHTEXT_STYLE_PARAGRAPH) && + !attr.GetParagraphStyleName().IsEmpty()) { - styleName = para->GetAttributes().GetParagraphStyleName(); + styleName = attr.GetParagraphStyleName(); } - else if (para && (styleType == wxRICHTEXT_STYLE_ALL || styleType == wxRICHTEXT_STYLE_LIST) && - !para->GetAttributes().GetListStyleName().IsEmpty()) + else if ((styleType == wxRICHTEXT_STYLE_ALL || styleType == wxRICHTEXT_STYLE_LIST) && + !attr.GetListStyleName().IsEmpty()) { - styleName = para->GetAttributes().GetListStyleName(); + styleName = attr.GetListStyleName(); } return styleName; -- 2.45.2