X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e5cda2df16e32f9fa4a8d932f7fc41162a28d8e6..12bb29f5432174ecbd65549bda832d70d34a98ae:/src/richtext/richtextstyledlg.cpp diff --git a/src/richtext/richtextstyledlg.cpp b/src/richtext/richtextstyledlg.cpp index 5c7c85af92..e4c2f009fb 100644 --- a/src/richtext/richtextstyledlg.cpp +++ b/src/richtext/richtextstyledlg.cpp @@ -44,29 +44,27 @@ BEGIN_EVENT_TABLE( wxRichTextStyleOrganiserDialog, wxDialog ) ////@begin wxRichTextStyleOrganiserDialog event table entries EVT_BUTTON( ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_CHAR, wxRichTextStyleOrganiserDialog::OnNewCharClick ) EVT_UPDATE_UI( ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_CHAR, wxRichTextStyleOrganiserDialog::OnNewCharUpdate ) - EVT_BUTTON( ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_PARA, wxRichTextStyleOrganiserDialog::OnNewParaClick ) EVT_UPDATE_UI( ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_PARA, wxRichTextStyleOrganiserDialog::OnNewParaUpdate ) - EVT_BUTTON( ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_LIST, wxRichTextStyleOrganiserDialog::OnNewListClick ) EVT_UPDATE_UI( ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_LIST, wxRichTextStyleOrganiserDialog::OnNewListUpdate ) - + EVT_BUTTON( ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_BOX, wxRichTextStyleOrganiserDialog::OnNewBoxClick ) + EVT_UPDATE_UI( ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_BOX, wxRichTextStyleOrganiserDialog::OnNewBoxUpdate ) EVT_BUTTON( ID_RICHTEXTSTYLEORGANISERDIALOG_APPLY, wxRichTextStyleOrganiserDialog::OnApplyClick ) EVT_UPDATE_UI( ID_RICHTEXTSTYLEORGANISERDIALOG_APPLY, wxRichTextStyleOrganiserDialog::OnApplyUpdate ) - EVT_BUTTON( ID_RICHTEXTSTYLEORGANISERDIALOG_RENAME, wxRichTextStyleOrganiserDialog::OnRenameClick ) EVT_UPDATE_UI( ID_RICHTEXTSTYLEORGANISERDIALOG_RENAME, wxRichTextStyleOrganiserDialog::OnRenameUpdate ) - EVT_BUTTON( ID_RICHTEXTSTYLEORGANISERDIALOG_EDIT, wxRichTextStyleOrganiserDialog::OnEditClick ) EVT_UPDATE_UI( ID_RICHTEXTSTYLEORGANISERDIALOG_EDIT, wxRichTextStyleOrganiserDialog::OnEditUpdate ) - EVT_BUTTON( ID_RICHTEXTSTYLEORGANISERDIALOG_DELETE, wxRichTextStyleOrganiserDialog::OnDeleteClick ) EVT_UPDATE_UI( ID_RICHTEXTSTYLEORGANISERDIALOG_DELETE, wxRichTextStyleOrganiserDialog::OnDeleteUpdate ) - + EVT_BUTTON( wxID_HELP, wxRichTextStyleOrganiserDialog::OnHelpClick ) ////@end wxRichTextStyleOrganiserDialog event table entries END_EVENT_TABLE() +IMPLEMENT_HELP_PROVISION(wxRichTextStyleOrganiserDialog) + /*! * wxRichTextStyleOrganiserDialog constructors */ @@ -103,6 +101,7 @@ void wxRichTextStyleOrganiserDialog::Init() m_newCharacter = NULL; m_newParagraph = NULL; m_newList = NULL; + m_newBox = NULL; m_applyStyle = NULL; m_renameStyle = NULL; m_editStyle = NULL; @@ -110,6 +109,7 @@ void wxRichTextStyleOrganiserDialog::Init() m_closeButton = NULL; m_bottomButtonSizer = NULL; m_restartNumberingCtrl = NULL; + m_stdButtonSizer = NULL; m_okButton = NULL; m_cancelButton = NULL; ////@end wxRichTextStyleOrganiserDialog member initialisation @@ -145,6 +145,10 @@ bool wxRichTextStyleOrganiserDialog::Create( int flags, wxRichTextStyleSheet* sh void wxRichTextStyleOrganiserDialog::CreateControls() { +#ifdef __WXMAC__ + SetWindowVariant(wxWINDOW_VARIANT_SMALL); +#endif + bool hideTypeSelector = false; wxRichTextStyleListBox::wxRichTextStyleType typesToShow = wxRichTextStyleListBox::wxRICHTEXT_STYLE_ALL; @@ -158,6 +162,11 @@ void wxRichTextStyleOrganiserDialog::CreateControls() typesToShow = wxRichTextStyleListBox::wxRICHTEXT_STYLE_PARAGRAPH; hideTypeSelector = true; } + else if ((m_flags & wxRICHTEXT_ORGANISER_SHOW_BOX) != 0) + { + typesToShow = wxRichTextStyleListBox::wxRICHTEXT_STYLE_BOX; + hideTypeSelector = true; + } else if ((m_flags & wxRICHTEXT_ORGANISER_SHOW_LIST) != 0) { typesToShow = wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST; @@ -202,7 +211,7 @@ void wxRichTextStyleOrganiserDialog::CreateControls() wxStaticText* itemStaticText9 = new wxStaticText( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_CURRENT_STYLE, _(" "), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer8->Add(itemStaticText9, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); - m_previewCtrl = new wxRichTextCtrl( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_PREVIEW, wxEmptyString, wxDefaultPosition, wxSize(250, 200), wxVSCROLL|wxTE_READONLY ); + m_previewCtrl = new wxRichTextCtrl( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_PREVIEW, wxEmptyString, wxDefaultPosition, wxSize(250, 200), wxBORDER_THEME|wxVSCROLL|wxTE_READONLY ); m_previewCtrl->SetHelpText(_("The style preview.")); if (wxRichTextStyleOrganiserDialog::ShowToolTips()) m_previewCtrl->SetToolTip(_("The style preview.")); @@ -232,6 +241,12 @@ void wxRichTextStyleOrganiserDialog::CreateControls() m_newList->SetToolTip(_("Click to create a new list style.")); m_buttonSizer->Add(m_newList, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + m_newBox = new wxButton( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_BOX, _("New &Box Style..."), wxDefaultPosition, wxDefaultSize, 0 ); + m_newBox->SetHelpText(_("Click to create a new box style.")); + if (wxRichTextStyleOrganiserDialog::ShowToolTips()) + m_newBox->SetToolTip(_("Click to create a new box style.")); + m_buttonSizer->Add(m_newBox, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); + m_buttonSizer->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); m_applyStyle = new wxButton( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_APPLY, _("&Apply Style"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -277,28 +292,35 @@ void wxRichTextStyleOrganiserDialog::CreateControls() m_restartNumberingCtrl->SetToolTip(_("Check to restart numbering.")); m_bottomButtonSizer->Add(m_restartNumberingCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - m_bottomButtonSizer->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); + m_stdButtonSizer = new wxStdDialogButtonSizer; + m_bottomButtonSizer->Add(m_stdButtonSizer, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_okButton = new wxButton( itemDialog1, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); - m_okButton->SetDefault(); - m_okButton->SetHelpText(_("Click to confirm your selection.")); - if (wxRichTextStyleOrganiserDialog::ShowToolTips()) - m_okButton->SetToolTip(_("Click to confirm your selection.")); - m_bottomButtonSizer->Add(m_okButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + m_stdButtonSizer->AddButton(m_okButton); m_cancelButton = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - m_cancelButton->SetHelpText(_("Click to cancel this window.")); - if (wxRichTextStyleOrganiserDialog::ShowToolTips()) - m_cancelButton->SetToolTip(_("Click to cancel this window.")); - m_bottomButtonSizer->Add(m_cancelButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + m_stdButtonSizer->AddButton(m_cancelButton); + + wxButton* itemButton29 = new wxButton( itemDialog1, wxID_HELP, _("&Help"), wxDefaultPosition, wxDefaultSize, 0 ); + m_stdButtonSizer->AddButton(itemButton29); + + m_stdButtonSizer->Realize(); ////@end wxRichTextStyleOrganiserDialog content construction + if (GetHelpId() == -1) + { + wxWindow* button = FindWindowById(wxID_HELP); + if (button) + m_stdButtonSizer->Show(button, false); + } + if ((m_flags & wxRICHTEXT_ORGANISER_CREATE_STYLES) == 0) { m_buttonSizer->Show(m_newCharacter, false); m_buttonSizer->Show(m_newParagraph, false); m_buttonSizer->Show(m_newList, false); + m_buttonSizer->Show(m_newBox, false); } if ((m_flags & wxRICHTEXT_ORGANISER_DELETE_STYLES) == 0) { @@ -323,8 +345,8 @@ void wxRichTextStyleOrganiserDialog::CreateControls() if ((m_flags & wxRICHTEXT_ORGANISER_OK_CANCEL) == 0) { - m_bottomButtonSizer->Show(m_okButton, false); - m_bottomButtonSizer->Show(m_cancelButton, false); + m_stdButtonSizer->Show(m_okButton, false); + m_stdButtonSizer->Show(m_cancelButton, false); } else { @@ -423,20 +445,20 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); } wxRichTextStyleDefinition* def = m_stylesListBox->GetStyleListBox()->GetStyle(sel); - wxRichTextListStyleDefinition* listDef = wxDynamicCast(def, wxRichTextListStyleDefinition); + wxRichTextBoxStyleDefinition* boxDef = wxDynamicCast(def, wxRichTextBoxStyleDefinition); wxStaticText* labelCtrl = (wxStaticText*) FindWindow(ID_RICHTEXTSTYLEORGANISERDIALOG_CURRENT_STYLE); if (labelCtrl) labelCtrl->SetLabel(def->GetName() + wxT(":")); - wxTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet())); + wxRichTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet())); wxFont font(m_previewCtrl->GetFont()); font.SetPointSize(9); m_previewCtrl->SetFont(font); - wxTextAttr normalParaAttr; + wxRichTextAttr normalParaAttr; normalParaAttr.SetFont(font); normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY"))); @@ -447,15 +469,14 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); m_previewCtrl->WriteText(s_para1); m_previewCtrl->EndStyle(); - m_previewCtrl->BeginStyle(attr); - if (listDef) { + m_previewCtrl->BeginStyle(attr); long listStart = m_previewCtrl->GetInsertionPoint() + 1; int i; for (i = 0; i < 10; i++) { - wxTextAttr levelAttr = * listDef->GetLevelAttributes(i); + wxRichTextAttr levelAttr = * listDef->GetLevelAttributes(i); levelAttr.SetBulletNumber(1); m_previewCtrl->BeginStyle(levelAttr); m_previewCtrl->WriteText(wxString::Format(wxT("List level %d. "), i+1) + s_para2List); @@ -463,14 +484,32 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); } long listEnd = m_previewCtrl->GetInsertionPoint(); m_previewCtrl->NumberList(wxRichTextRange(listStart, listEnd), listDef); + m_previewCtrl->EndStyle(); + } + else if (boxDef) + { + wxRichTextAttr cellParaAttr; + cellParaAttr.SetFont(font); + cellParaAttr.SetTextColour(*wxBLACK); + + wxRichTextBox* textBox = m_previewCtrl->WriteTextBox(attr); + m_previewCtrl->SetFocusObject(textBox); + m_previewCtrl->BeginStyle(cellParaAttr); + wxString text(s_para2); + text.Replace(wxT("\n"), wxEmptyString); + m_previewCtrl->WriteText(text); + m_previewCtrl->EndStyle(); + m_previewCtrl->SetFocusObject(NULL); // Set the focus back to the main buffer + m_previewCtrl->SetInsertionPointEnd(); + m_previewCtrl->SetDefaultStyle(wxRichTextAttr()); } else { + m_previewCtrl->BeginStyle(attr); m_previewCtrl->WriteText(s_para2); + m_previewCtrl->EndStyle(); } - m_previewCtrl->EndStyle(); - m_previewCtrl->BeginStyle(normalParaAttr); m_previewCtrl->WriteText(s_para3); m_previewCtrl->EndStyle(); @@ -496,14 +535,11 @@ bool wxRichTextStyleOrganiserDialog::ApplyStyle(wxRichTextCtrl* ctrl) ctrl = GetRichTextCtrl(); if (!ctrl) return false; - if (!ctrl->HasSelection()) - return false; - wxRichTextStyleDefinition* def = m_stylesListBox->GetStyleListBox()->GetStyle(sel); wxRichTextListStyleDefinition* listDef = wxDynamicCast(def, wxRichTextListStyleDefinition); - if (listDef && m_restartNumberingCtrl->GetValue()) + if (listDef && m_restartNumberingCtrl->GetValue() && ctrl->HasSelection()) { wxRichTextRange range = ctrl->GetSelectionRange(); return ctrl->SetListStyle(range, listDef, wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_RENUMBER); @@ -541,7 +577,7 @@ wxIcon wxRichTextStyleOrganiserDialog::GetIconResource( const wxString& name ) } /*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_APPLY + * wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_APPLY */ void wxRichTextStyleOrganiserDialog::OnApplyClick( wxCommandEvent& WXUNUSED(event) ) @@ -560,7 +596,7 @@ void wxRichTextStyleOrganiserDialog::OnApplyUpdate( wxUpdateUIEvent& event ) /*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_CHAR + * wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_CHAR */ void wxRichTextStyleOrganiserDialog::OnNewCharClick( wxCommandEvent& WXUNUSED(event) ) @@ -608,7 +644,7 @@ void wxRichTextStyleOrganiserDialog::OnNewCharUpdate( wxUpdateUIEvent& event ) /*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_PARA + * wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_PARA */ void wxRichTextStyleOrganiserDialog::OnNewParaClick( wxCommandEvent& WXUNUSED(event) ) @@ -656,7 +692,7 @@ void wxRichTextStyleOrganiserDialog::OnNewParaUpdate( wxUpdateUIEvent& event ) /*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_EDIT + * wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_EDIT */ void wxRichTextStyleOrganiserDialog::OnEditClick( wxCommandEvent& WXUNUSED(event) ) @@ -668,18 +704,22 @@ void wxRichTextStyleOrganiserDialog::OnEditClick( wxCommandEvent& WXUNUSED(event int pages = wxRICHTEXT_FORMAT_STYLE_EDITOR; - if (def->IsKindOf(CLASSINFO(wxRichTextCharacterStyleDefinition))) + if (wxDynamicCast(def, wxRichTextCharacterStyleDefinition)) { pages |= wxRICHTEXT_FORMAT_FONT; } - else if (def->IsKindOf(CLASSINFO(wxRichTextListStyleDefinition))) + else if (wxDynamicCast(def, wxRichTextListStyleDefinition)) { pages |= wxRICHTEXT_FORMAT_LIST_STYLE|wxRICHTEXT_FORMAT_FONT|wxRICHTEXT_FORMAT_INDENTS_SPACING; } - else if (def->IsKindOf(CLASSINFO(wxRichTextParagraphStyleDefinition))) + else if (wxDynamicCast(def, wxRichTextParagraphStyleDefinition)) { pages |= wxRICHTEXT_FORMAT_FONT|wxRICHTEXT_FORMAT_INDENTS_SPACING|wxRICHTEXT_FORMAT_TABS|wxRICHTEXT_FORMAT_BULLETS; } + else if (wxDynamicCast(def, wxRichTextBoxStyleDefinition)) + { + pages |= wxRICHTEXT_FORMAT_MARGINS|wxRICHTEXT_FORMAT_SIZE|wxRICHTEXT_FORMAT_BORDERS|wxRICHTEXT_FORMAT_BACKGROUND; + } wxRichTextFormattingDialog formatDlg; formatDlg.SetStyleDefinition(*def, GetStyleSheet()); @@ -690,6 +730,7 @@ void wxRichTextStyleOrganiserDialog::OnEditClick( wxCommandEvent& WXUNUSED(event wxRichTextParagraphStyleDefinition* paraDef = wxDynamicCast(formatDlg.GetStyleDefinition(), wxRichTextParagraphStyleDefinition); wxRichTextCharacterStyleDefinition* charDef = wxDynamicCast(formatDlg.GetStyleDefinition(), wxRichTextCharacterStyleDefinition); wxRichTextListStyleDefinition* listDef = wxDynamicCast(formatDlg.GetStyleDefinition(), wxRichTextListStyleDefinition); + wxRichTextBoxStyleDefinition* boxDef = wxDynamicCast(formatDlg.GetStyleDefinition(), wxRichTextBoxStyleDefinition); if (listDef) { @@ -699,6 +740,10 @@ void wxRichTextStyleOrganiserDialog::OnEditClick( wxCommandEvent& WXUNUSED(event { (*((wxRichTextParagraphStyleDefinition* ) def)) = (*paraDef); } + else if (boxDef) + { + (*((wxRichTextBoxStyleDefinition* ) def)) = (*boxDef); + } else { (*((wxRichTextCharacterStyleDefinition* ) def)) = (*charDef); @@ -722,7 +767,7 @@ void wxRichTextStyleOrganiserDialog::OnEditUpdate( wxUpdateUIEvent& event ) /*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_DELETE + * wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_DELETE */ void wxRichTextStyleOrganiserDialog::OnDeleteClick( wxCommandEvent& WXUNUSED(event) ) @@ -736,12 +781,14 @@ void wxRichTextStyleOrganiserDialog::OnDeleteClick( wxCommandEvent& WXUNUSED(eve { m_stylesListBox->GetStyleListBox()->SetItemCount(0); - if (def->IsKindOf(CLASSINFO(wxRichTextListStyleDefinition))) + if (wxDynamicCast(def, wxRichTextListStyleDefinition)) GetStyleSheet()->RemoveListStyle((wxRichTextListStyleDefinition*) def, true); - else if (def->IsKindOf(CLASSINFO(wxRichTextParagraphStyleDefinition))) + else if (wxDynamicCast(def, wxRichTextParagraphStyleDefinition)) GetStyleSheet()->RemoveParagraphStyle((wxRichTextParagraphStyleDefinition*) def, true); - else if (def->IsKindOf(CLASSINFO(wxRichTextCharacterStyleDefinition))) + else if (wxDynamicCast(def, wxRichTextCharacterStyleDefinition)) GetStyleSheet()->RemoveCharacterStyle((wxRichTextCharacterStyleDefinition*) def, true); + else if (wxDynamicCast(def, wxRichTextBoxStyleDefinition)) + GetStyleSheet()->RemoveBoxStyle((wxRichTextBoxStyleDefinition*) def, true); m_stylesListBox->UpdateStyles(); @@ -763,7 +810,7 @@ void wxRichTextStyleOrganiserDialog::OnDeleteUpdate( wxUpdateUIEvent& event ) } /*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_LIST + * wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_LIST */ void wxRichTextStyleOrganiserDialog::OnNewListClick( wxCommandEvent& WXUNUSED(event) ) @@ -829,7 +876,7 @@ void wxRichTextStyleOrganiserDialog::OnNewListUpdate( wxUpdateUIEvent& event ) } /*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_RENAME + * wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_RENAME */ void wxRichTextStyleOrganiserDialog::OnRenameClick( wxCommandEvent& WXUNUSED(event) ) @@ -847,7 +894,7 @@ void wxRichTextStyleOrganiserDialog::OnRenameClick( wxCommandEvent& WXUNUSED(eve if (styleName == def->GetName()) return; - if (GetStyleSheet()->FindParagraphStyle(styleName) || GetStyleSheet()->FindCharacterStyle(styleName) || GetStyleSheet()->FindListStyle(styleName)) + if (GetStyleSheet()->FindParagraphStyle(styleName) || GetStyleSheet()->FindCharacterStyle(styleName) || GetStyleSheet()->FindListStyle(styleName) || GetStyleSheet()->FindBoxStyle(styleName)) { wxMessageBox(_("Sorry, that name is taken. Please choose another."), _("New Style"), wxICON_EXCLAMATION|wxOK, this); return; @@ -876,6 +923,62 @@ void wxRichTextStyleOrganiserDialog::OnListSelection(wxCommandEvent& event) event.Skip(); } +/*! + * wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_BOX + */ + +void wxRichTextStyleOrganiserDialog::OnNewBoxClick( wxCommandEvent& WXUNUSED(event) ) +{ + wxString styleName = wxGetTextFromUser(_("Enter a box style name"), _("New Style")); + if (!styleName.IsEmpty()) + { + if (GetStyleSheet()->FindBoxStyle(styleName)) + { + wxMessageBox(_("Sorry, that name is taken. Please choose another."), _("New Style"), wxICON_EXCLAMATION|wxOK, this); + return; + } + + wxRichTextBoxStyleDefinition* style = new wxRichTextBoxStyleDefinition(styleName); + + int pages = wxRICHTEXT_FORMAT_MARGINS|wxRICHTEXT_FORMAT_SIZE|wxRICHTEXT_FORMAT_BORDERS|wxRICHTEXT_FORMAT_BACKGROUND; + wxRichTextFormattingDialog formatDlg; + formatDlg.SetStyleDefinition(*style, GetStyleSheet()); + formatDlg.Create(pages, this); + + if (formatDlg.ShowModal() == wxID_OK) + { + wxRichTextBoxStyleDefinition* boxDef = wxDynamicCast(formatDlg.GetStyleDefinition(), wxRichTextBoxStyleDefinition); + + (*((wxRichTextBoxStyleDefinition* ) style)) = (*boxDef); + + GetStyleSheet()->AddBoxStyle(style); + + m_stylesListBox->UpdateStyles(); + ShowPreview(); + } + else + delete style; + } +} + +/*! + * wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_BOX + */ + +void wxRichTextStyleOrganiserDialog::OnNewBoxUpdate( wxUpdateUIEvent& event ) +{ + event.Enable((GetFlags() & wxRICHTEXT_ORGANISER_CREATE_STYLES) != 0); +} + +/*! + * wxEVT_BUTTON event handler for wxID_HELP + */ + +void wxRichTextStyleOrganiserDialog::OnHelpClick( wxCommandEvent& WXUNUSED(event) ) +{ + if ((GetHelpId() != -1) && GetUICustomization()) + ShowHelp(this); +} + #endif // wxUSE_RICHTEXT -