]> git.saurik.com Git - wxWidgets.git/commitdiff
Take basic style into account when showing style under cursor
authorJulian Smart <julian@anthemion.co.uk>
Sun, 27 Jan 2008 17:34:23 +0000 (17:34 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sun, 27 Jan 2008 17:34:23 +0000 (17:34 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51412 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/richtext/richtextstyles.cpp

index e5308329770959ea885aac82d6228da2ccd22db0..a171a8b60ad998f55132b72912e9618a3c9735de 100644 (file)
@@ -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;