]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextstyledlg.cpp
Fixed a confusion between window and client size that could lead to
[wxWidgets.git] / src / richtext / richtextstyledlg.cpp
index 79080f7959176dffa9271ee602d54bf778c3b4a6..bdc7637ed5d20f7ec9e31fc48fbb0c36f9bbd265 100644 (file)
@@ -109,7 +109,6 @@ void wxRichTextStyleOrganiserDialog::Init()
     m_deleteStyle = NULL;
     m_closeButton = NULL;
     m_bottomButtonSizer = NULL;
-
     m_restartNumberingCtrl = NULL;
     m_okButton = NULL;
     m_cancelButton = NULL;
@@ -426,16 +425,8 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
     wxRichTextStyleDefinition* def = m_stylesListBox->GetStyleListBox()->GetStyle(sel);
 
     wxRichTextListStyleDefinition* listDef = wxDynamicCast(def, wxRichTextListStyleDefinition);
-    //wxRichTextParagraphStyleDefinition* paraDef = wxDynamicCast(def, wxRichTextParagraphStyleDefinition);
-    //wxRichTextCharacterStyleDefinition* charDef = wxDynamicCast(def, wxRichTextCharacterStyleDefinition);
-
-    wxTextAttrEx attr(def->GetStyle());
-#if 0
-    attr.SetFlags(attr.GetFlags() &
-      (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|
-       wxTEXT_ATTR_LINE_SPACING|
-       wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_SYMBOL));
-#endif
+
+    wxTextAttrEx attr(def->GetStyleMergedWithBase(GetStyleSheet()));
 
     wxFont font(m_previewCtrl->GetFont());
     font.SetPointSize(9);
@@ -486,7 +477,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
 /// Clears the preview
 void wxRichTextStyleOrganiserDialog::ClearPreview()
 {
-    m_richTextCtrl->Clear();
+    m_previewCtrl->Clear();
 }
 
 bool wxRichTextStyleOrganiserDialog::ApplyStyle(wxRichTextCtrl* ctrl)
@@ -835,6 +826,28 @@ void wxRichTextStyleOrganiserDialog::OnNewListUpdate( wxUpdateUIEvent& event )
 
 void wxRichTextStyleOrganiserDialog::OnRenameClick( wxCommandEvent& WXUNUSED(event) )
 {
+    int sel = m_stylesListBox->GetStyleListBox()->GetSelection();
+    if (sel == -1)
+        return;
+    wxRichTextStyleDefinition* def = m_stylesListBox->GetStyleListBox()->GetStyle(sel);
+    if (!def)
+        return;
+
+    wxString styleName = wxGetTextFromUser(_("Enter a new style name"), _("New Style"), def->GetName());
+    if (!styleName.IsEmpty())
+    {
+        if (styleName == def->GetName())
+            return;
+
+        if (GetStyleSheet()->FindParagraphStyle(styleName) || GetStyleSheet()->FindCharacterStyle(styleName) || GetStyleSheet()->FindListStyle(styleName))
+        {
+            wxMessageBox(_("Sorry, that name is taken. Please choose another."), _("New Style"), wxICON_EXCLAMATION|wxOK, this);
+            return;
+        }
+
+        def->SetName(styleName);
+        m_stylesListBox->UpdateStyles();
+    }
 }
 
 /*!