X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/41a852156fab5ee6075b3ab92f8230989547daac..4b5ac600de03bec2a73610f7fa566aa2cf2ce9f8:/src/richtext/richtextstyledlg.cpp?ds=sidebyside diff --git a/src/richtext/richtextstyledlg.cpp b/src/richtext/richtextstyledlg.cpp index 0f6d2ebcc2..e31fbc1b03 100644 --- a/src/richtext/richtextstyledlg.cpp +++ b/src/richtext/richtextstyledlg.cpp @@ -16,19 +16,15 @@ #pragma hdrstop #endif +#if wxUSE_RICHTEXT + #ifndef WX_PRECOMP #include "wx/wx.h" #endif -////@begin includes -////@end includes - #include "wx/richtext/richtextstyledlg.h" #include "wx/richtext/richtextformatdlg.h" -////@begin XPM images -////@end XPM images - /*! * wxRichTextStyleOrganiserDialog type definition */ @@ -113,7 +109,6 @@ void wxRichTextStyleOrganiserDialog::Init() m_deleteStyle = NULL; m_closeButton = NULL; m_bottomButtonSizer = NULL; - m_restartNumberingCtrl = NULL; m_okButton = NULL; m_cancelButton = NULL; @@ -193,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.")); @@ -205,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.")); @@ -217,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.")); @@ -430,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); @@ -460,6 +447,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); if (listDef) { + long listStart = m_previewCtrl->GetInsertionPoint() + 1; int i; for (i = 0; i < 10; i++) { @@ -469,6 +457,8 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); m_previewCtrl->WriteText(wxString::Format(wxT("\nList level %d. "), i+1) + s_para2List); m_previewCtrl->EndStyle(); } + long listEnd = m_previewCtrl->GetInsertionPoint(); + m_previewCtrl->NumberList(wxRichTextRange(listStart, listEnd), listDef); } else { @@ -487,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) @@ -734,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); @@ -836,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(); + } } /*! @@ -855,3 +867,7 @@ void wxRichTextStyleOrganiserDialog::OnListSelection(wxCommandEvent& event) else event.Skip(); } + +#endif + // wxUSE_RICHTEXT +