]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed default style setting to take into account text boxes; fixed AddBoxStyle
authorJulian Smart <julian@anthemion.co.uk>
Sun, 8 Jan 2012 18:27:47 +0000 (18:27 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sun, 8 Jan 2012 18:27:47 +0000 (18:27 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70299 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/richtext/richtextctrl.cpp
src/richtext/richtextstyles.cpp

index f21e56c5d181fc101469825d35fb14a076710320..a0feef5dc74ea5cdc387c01fd8a666d9c8595f01 100644 (file)
@@ -4086,7 +4086,15 @@ bool wxRichTextCtrl::SetDefaultStyleToCursorStyle()
     // If at the start of a paragraph, use the next position.
     long pos = GetAdjustedCaretPosition(GetCaretPosition());
 
     // If at the start of a paragraph, use the next position.
     long pos = GetAdjustedCaretPosition(GetCaretPosition());
 
-    if (GetUncombinedStyle(pos, attr))
+    wxRichTextObject* obj = GetFocusObject()->GetLeafObjectAtPosition(pos);
+    if (obj && obj->IsTopLevel())
+    {
+        // Don't use the attributes of a top-level object, since they might apply
+        // to content of the object, e.g. background colour.
+        SetDefaultStyle(wxRichTextAttr());
+        return true;
+    }
+    else if (GetUncombinedStyle(pos, attr))
     {
         SetDefaultStyle(attr);
         return true;
     {
         SetDefaultStyle(attr);
         return true;
index 8484ce683b9107191184ae26b7041d423e139cb8..86e64ccfbb0b4e8a45e8d91a68c15d27dcb670de 100644 (file)
@@ -442,7 +442,7 @@ bool wxRichTextStyleSheet::AddListStyle(wxRichTextListStyleDefinition* def)
 /// Add a definition to the box style list
 bool wxRichTextStyleSheet::AddBoxStyle(wxRichTextBoxStyleDefinition* def)
 {
 /// Add a definition to the box style list
 bool wxRichTextStyleSheet::AddBoxStyle(wxRichTextBoxStyleDefinition* def)
 {
-    def->GetStyle().SetParagraphStyleName(def->GetName());
+    def->GetStyle().GetTextBoxAttr().SetBoxStyleName(def->GetName());
     return AddStyle(m_boxStyleDefinitions, def);
 }
 
     return AddStyle(m_boxStyleDefinitions, def);
 }