From: Julian Smart Date: Wed, 4 Jan 2012 19:38:31 +0000 (+0000) Subject: Added box style functionality to style manager dialog X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/cd720353875d94cfabbbc120e6569bd08cf2d478 Added box style functionality to style manager dialog git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70267 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/richtext/richtextstyledlg.h b/include/wx/richtext/richtextstyledlg.h index 3dc8528ab8..ad21c024b1 100644 --- a/include/wx/richtext/richtextstyledlg.h +++ b/include/wx/richtext/richtextstyledlg.h @@ -67,7 +67,8 @@ class WXDLLIMPEXP_FWD_CORE wxCheckBox; #define wxRICHTEXT_ORGANISER_SHOW_CHARACTER 0x0100 #define wxRICHTEXT_ORGANISER_SHOW_PARAGRAPH 0x0200 #define wxRICHTEXT_ORGANISER_SHOW_LIST 0x0400 -#define wxRICHTEXT_ORGANISER_SHOW_ALL 0x0800 +#define wxRICHTEXT_ORGANISER_SHOW_BOX 0x0800 +#define wxRICHTEXT_ORGANISER_SHOW_ALL 0x1000 // Common combinations #define wxRICHTEXT_ORGANISER_ORGANISE (wxRICHTEXT_ORGANISER_SHOW_ALL|wxRICHTEXT_ORGANISER_DELETE_STYLES|wxRICHTEXT_ORGANISER_CREATE_STYLES|wxRICHTEXT_ORGANISER_APPLY_STYLES|wxRICHTEXT_ORGANISER_EDIT_STYLES|wxRICHTEXT_ORGANISER_RENAME_STYLES) @@ -160,6 +161,12 @@ public: /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_LIST void OnNewListUpdate( wxUpdateUIEvent& event ); + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_BOX + void OnNewBoxClick( wxCommandEvent& event ); + + /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_BOX + void OnNewBoxUpdate( wxUpdateUIEvent& event ); + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_APPLY void OnApplyClick( wxCommandEvent& event ); @@ -204,6 +211,7 @@ public: wxButton* m_newCharacter; wxButton* m_newParagraph; wxButton* m_newList; + wxButton* m_newBox; wxButton* m_applyStyle; wxButton* m_renameStyle; wxButton* m_editStyle; @@ -223,6 +231,7 @@ public: ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_CHAR = 10504, ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_PARA = 10505, ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_LIST = 10508, + ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_BOX = 10512, ID_RICHTEXTSTYLEORGANISERDIALOG_APPLY = 10503, ID_RICHTEXTSTYLEORGANISERDIALOG_RENAME = 10502, ID_RICHTEXTSTYLEORGANISERDIALOG_EDIT = 10506, diff --git a/src/richtext/richtextbulletspage.cpp b/src/richtext/richtextbulletspage.cpp index c43634c861..0f3be387d6 100644 --- a/src/richtext/richtextbulletspage.cpp +++ b/src/richtext/richtextbulletspage.cpp @@ -265,7 +265,7 @@ void wxRichTextBulletsPage::CreateControls() wxStaticText* itemStaticText30 = new wxStaticText( itemRichTextDialogPage1, ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC, _("&Number:"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer18->Add(itemStaticText30, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - m_numberCtrl = new wxSpinCtrl( itemRichTextDialogPage1, ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, wxT("0"), wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 0, 100000, 0 ); + m_numberCtrl = new wxSpinCtrl( itemRichTextDialogPage1, ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, _T("0"), wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 0, 100000, 0 ); m_numberCtrl->SetHelpText(_("The list item number.")); if (wxRichTextBulletsPage::ShowToolTips()) m_numberCtrl->SetToolTip(_("The list item number.")); @@ -273,7 +273,7 @@ void wxRichTextBulletsPage::CreateControls() itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5); - m_previewCtrl = new wxRichTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTBULLETSPAGE_PREVIEW_CTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 100), wxVSCROLL|wxTE_READONLY ); + m_previewCtrl = new wxRichTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTBULLETSPAGE_PREVIEW_CTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 100), wxBORDER_THEME|wxVSCROLL|wxTE_READONLY ); m_previewCtrl->SetHelpText(_("Shows a preview of the bullet settings.")); if (wxRichTextBulletsPage::ShowToolTips()) m_previewCtrl->SetToolTip(_("Shows a preview of the bullet settings.")); diff --git a/src/richtext/richtextdialogs.pjd b/src/richtext/richtextdialogs.pjd index 78eff2bb82..6cf9e64dd1 100644 --- a/src/richtext/richtextdialogs.pjd +++ b/src/richtext/richtextdialogs.pjd @@ -306,6 +306,14 @@ "wbBoxSizerProxy" "Vertical" "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 0 0 0 @@ -2208,14 +2216,6 @@ "wbBoxSizerProxy" "Vertical" "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 0 0 0 @@ -4504,7 +4504,7 @@ 0 0 0 - 0 + 1 0 0 0 @@ -5373,14 +5373,6 @@ "wbBoxSizerProxy" "Vertical" "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 0 0 0 @@ -6934,7 +6926,7 @@ 0 0 0 - 0 + 1 0 0 0 @@ -7061,14 +7053,6 @@ "wbBoxSizerProxy" "Vertical" "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 0 0 0 @@ -8929,14 +8913,6 @@ "wbBoxSizerProxy" "Vertical" "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 0 0 0 @@ -9295,7 +9271,7 @@ 0 0 0 - 0 + 1 0 0 0 @@ -9627,6 +9603,73 @@ "" "" + + "wxButton: ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_BOX" + "dialog-control-document" + "" + "dialogcontrol" + 0 + 1 + 0 + 0 + "wbButtonProxy" + "wxEVT_COMMAND_BUTTON_CLICKED|OnNewBoxClick|||wxRichTextStyleOrganiserDialog" + "wxEVT_UPDATE_UI|OnNewBoxUpdate|||wxRichTextStyleOrganiserDialog" + "ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_BOX" + 10512 + "" + "wxButton" + "wxButton" + 1 + 0 + "" + "" + "m_newBox" + "New &Box Style..." + 0 + "Click to create a new box style." + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + "" + "" + "Spacer" "dialog-control-document" @@ -10432,14 +10475,6 @@ "wbBoxSizerProxy" "Vertical" "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 0 0 0 @@ -14461,14 +14496,6 @@ "wbBoxSizerProxy" "Vertical" "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 0 0 0 @@ -14566,14 +14593,6 @@ "wbBoxSizerProxy" "Vertical" "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 0 0 0 @@ -16853,14 +16872,6 @@ "wbBoxSizerProxy" "Vertical" "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 0 0 0 @@ -23803,14 +23814,6 @@ "wbBoxSizerProxy" "Vertical" "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 0 0 0 diff --git a/src/richtext/richtextindentspage.cpp b/src/richtext/richtextindentspage.cpp index 604476ae3e..b7afe7325e 100644 --- a/src/richtext/richtextindentspage.cpp +++ b/src/richtext/richtextindentspage.cpp @@ -324,7 +324,7 @@ void wxRichTextIndentsSpacingPage::CreateControls() itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5); - m_previewCtrl = new wxRichTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 100), wxVSCROLL|wxTE_READONLY ); + m_previewCtrl = new wxRichTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 100), wxBORDER_THEME|wxVSCROLL|wxTE_READONLY ); m_previewCtrl->SetHelpText(_("Shows a preview of the paragraph settings.")); if (wxRichTextIndentsSpacingPage::ShowToolTips()) m_previewCtrl->SetToolTip(_("Shows a preview of the paragraph settings.")); diff --git a/src/richtext/richtextstyledlg.cpp b/src/richtext/richtextstyledlg.cpp index 6979d66f9e..5341902826 100644 --- a/src/richtext/richtextstyledlg.cpp +++ b/src/richtext/richtextstyledlg.cpp @@ -51,6 +51,9 @@ BEGIN_EVENT_TABLE( wxRichTextStyleOrganiserDialog, wxDialog ) 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 ) @@ -105,6 +108,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; @@ -161,6 +165,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; @@ -205,7 +214,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.")); @@ -235,6 +244,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 ); @@ -289,8 +304,8 @@ void wxRichTextStyleOrganiserDialog::CreateControls() m_cancelButton = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); m_stdButtonSizer->AddButton(m_cancelButton); - wxButton* itemButton28 = new wxButton( itemDialog1, wxID_HELP, _("&Help"), wxDefaultPosition, wxDefaultSize, 0 ); - m_stdButtonSizer->AddButton(itemButton28); + wxButton* itemButton29 = new wxButton( itemDialog1, wxID_HELP, _("&Help"), wxDefaultPosition, wxDefaultSize, 0 ); + m_stdButtonSizer->AddButton(itemButton29); m_stdButtonSizer->Realize(); @@ -308,6 +323,7 @@ void wxRichTextStyleOrganiserDialog::CreateControls() 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) { @@ -432,8 +448,8 @@ 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) @@ -456,10 +472,9 @@ 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++) @@ -472,14 +487,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(); @@ -511,12 +544,20 @@ bool wxRichTextStyleOrganiserDialog::ApplyStyle(wxRichTextCtrl* ctrl) wxRichTextStyleDefinition* def = m_stylesListBox->GetStyleListBox()->GetStyle(sel); wxRichTextListStyleDefinition* listDef = wxDynamicCast(def, wxRichTextListStyleDefinition); + wxRichTextBoxStyleDefinition* boxDef = wxDynamicCast(def, wxRichTextBoxStyleDefinition); if (listDef && m_restartNumberingCtrl->GetValue()) { wxRichTextRange range = ctrl->GetSelectionRange(); return ctrl->SetListStyle(range, listDef, wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_RENUMBER); } + else if (boxDef) + { + if (!ctrl->GetFocusObject() || (ctrl->GetFocusObject() && (ctrl->GetFocusObject() == & ctrl->GetBuffer()))) + return false; + ctrl->SetStyle(ctrl->GetFocusObject(), def->GetStyleMergedWithBase(m_stylesListBox->GetStyleSheet())); + return true; + } else { return ctrl->ApplyStyle(def); @@ -689,6 +730,10 @@ void wxRichTextStyleOrganiserDialog::OnEditClick( wxCommandEvent& WXUNUSED(event { pages |= wxRICHTEXT_FORMAT_FONT|wxRICHTEXT_FORMAT_INDENTS_SPACING|wxRICHTEXT_FORMAT_TABS|wxRICHTEXT_FORMAT_BULLETS; } + else if (def->IsKindOf(CLASSINFO(wxRichTextBoxStyleDefinition))) + { + pages |= wxRICHTEXT_FORMAT_MARGINS|wxRICHTEXT_FORMAT_SIZE|wxRICHTEXT_FORMAT_BORDERS|wxRICHTEXT_FORMAT_BACKGROUND; + } wxRichTextFormattingDialog formatDlg; formatDlg.SetStyleDefinition(*def, GetStyleSheet()); @@ -699,6 +744,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) { @@ -708,6 +754,10 @@ void wxRichTextStyleOrganiserDialog::OnEditClick( wxCommandEvent& WXUNUSED(event { (*((wxRichTextParagraphStyleDefinition* ) def)) = (*paraDef); } + else if (boxDef) + { + (*((wxRichTextBoxStyleDefinition* ) def)) = (*boxDef); + } else { (*((wxRichTextCharacterStyleDefinition* ) def)) = (*charDef); @@ -751,6 +801,8 @@ void wxRichTextStyleOrganiserDialog::OnDeleteClick( wxCommandEvent& WXUNUSED(eve GetStyleSheet()->RemoveParagraphStyle((wxRichTextParagraphStyleDefinition*) def, true); else if (def->IsKindOf(CLASSINFO(wxRichTextCharacterStyleDefinition))) GetStyleSheet()->RemoveCharacterStyle((wxRichTextCharacterStyleDefinition*) def, true); + else if (def->IsKindOf(CLASSINFO(wxRichTextBoxStyleDefinition))) + GetStyleSheet()->RemoveBoxStyle((wxRichTextBoxStyleDefinition*) def, true); m_stylesListBox->UpdateStyles(); @@ -856,7 +908,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; @@ -885,6 +937,52 @@ void wxRichTextStyleOrganiserDialog::OnListSelection(wxCommandEvent& event) event.Skip(); } +/*! + * wxEVT_COMMAND_BUTTON_CLICKED 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); +} + #endif // wxUSE_RICHTEXT -