X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d2d0adc7765dfe904f0f7e97d85a2638c934a7d6..4b5ac600de03bec2a73610f7fa566aa2cf2ce9f8:/src/richtext/richtextstyledlg.cpp diff --git a/src/richtext/richtextstyledlg.cpp b/src/richtext/richtextstyledlg.cpp index 79080f7959..e31fbc1b03 100644 --- a/src/richtext/richtextstyledlg.cpp +++ b/src/richtext/richtextstyledlg.cpp @@ -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; @@ -189,7 +188,7 @@ void wxRichTextStyleOrganiserDialog::CreateControls() m_buttonSizerParent->Add(itemBoxSizer5, 1, wxGROW, 5); wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Styles:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); m_stylesListBox = new wxRichTextStyleListCtrl( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_STYLES, wxDefaultPosition, wxSize(200, 350), wxSIMPLE_BORDER|listCtrlStyle ); m_stylesListBox->SetHelpText(_("The available styles.")); @@ -201,7 +200,7 @@ void wxRichTextStyleOrganiserDialog::CreateControls() m_buttonSizerParent->Add(itemBoxSizer8, 0, wxGROW, 5); wxStaticText* itemStaticText9 = new wxStaticText( itemDialog1, wxID_STATIC, _(" "), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer8->Add(itemStaticText9, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + itemBoxSizer8->Add(itemStaticText9, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); m_previewCtrl = new wxRichTextCtrl( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_PREVIEW, wxEmptyString, wxDefaultPosition, wxSize(310, 200), wxSIMPLE_BORDER|wxTE_READONLY ); m_previewCtrl->SetHelpText(_("The style preview.")); @@ -213,7 +212,7 @@ void wxRichTextStyleOrganiserDialog::CreateControls() m_buttonSizerParent->Add(m_buttonSizer, 0, wxGROW, 5); wxStaticText* itemStaticText12 = new wxStaticText( itemDialog1, wxID_STATIC, _(" "), wxDefaultPosition, wxDefaultSize, 0 ); - m_buttonSizer->Add(itemStaticText12, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + m_buttonSizer->Add(itemStaticText12, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); m_newCharacter = new wxButton( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_CHAR, _("New &Character Style..."), wxDefaultPosition, wxDefaultSize, 0 ); m_newCharacter->SetHelpText(_("Click to create a new character style.")); @@ -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) @@ -733,7 +724,7 @@ void wxRichTextStyleOrganiserDialog::OnDeleteClick( wxCommandEvent& WXUNUSED(eve { wxRichTextStyleDefinition* def = m_stylesListBox->GetStyleListBox()->GetStyle(sel); wxString name(def->GetName()); - if (wxYES == wxMessageBox(wxString::Format(_("Delete style %s?"), (const wxChar*) name), _("Delete Style"), wxYES_NO|wxICON_QUESTION, this)) + if (wxYES == wxMessageBox(wxString::Format(_("Delete style %s?"), name), _("Delete Style"), wxYES_NO|wxICON_QUESTION, this)) { m_stylesListBox->GetStyleListBox()->SetItemCount(0); @@ -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(); + } } /*!