X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/336d8ae9a3feae7b2c3ecd8f64fe0e16984edfe7..2028c33ab5a39a12bd410ac953731a56ad6377ba:/src/richtext/richtextstyledlg.cpp?ds=inline diff --git a/src/richtext/richtextstyledlg.cpp b/src/richtext/richtextstyledlg.cpp index bdc7637ed5..5c7c85af92 100644 --- a/src/richtext/richtextstyledlg.cpp +++ b/src/richtext/richtextstyledlg.cpp @@ -126,7 +126,7 @@ bool wxRichTextStyleOrganiserDialog::Create( int flags, wxRichTextStyleSheet* sh m_flags = flags; ////@begin wxRichTextStyleOrganiserDialog creation - SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS|wxDIALOG_EX_CONTEXTHELP); + SetExtraStyle(wxWS_EX_BLOCK_EVENTS|wxDIALOG_EX_CONTEXTHELP); wxDialog::Create( parent, id, caption, pos, size, style ); CreateControls(); @@ -188,23 +188,23 @@ 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 = new wxRichTextStyleListCtrl( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_STYLES, wxDefaultPosition, wxSize(280, 260), listCtrlStyle ); m_stylesListBox->SetHelpText(_("The available styles.")); - if (ShowToolTips()) + if (wxRichTextStyleOrganiserDialog::ShowToolTips()) m_stylesListBox->SetToolTip(_("The available styles.")); itemBoxSizer5->Add(m_stylesListBox, 1, wxGROW|wxALL, 5); wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); 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); + 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(310, 200), wxSIMPLE_BORDER|wxTE_READONLY ); + m_previewCtrl = new wxRichTextCtrl( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_PREVIEW, wxEmptyString, wxDefaultPosition, wxSize(250, 200), wxVSCROLL|wxTE_READONLY ); m_previewCtrl->SetHelpText(_("The style preview.")); - if (ShowToolTips()) + if (wxRichTextStyleOrganiserDialog::ShowToolTips()) m_previewCtrl->SetToolTip(_("The style preview.")); itemBoxSizer8->Add(m_previewCtrl, 1, wxGROW|wxALL, 5); @@ -212,23 +212,23 @@ 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.")); - if (ShowToolTips()) + if (wxRichTextStyleOrganiserDialog::ShowToolTips()) m_newCharacter->SetToolTip(_("Click to create a new character style.")); m_buttonSizer->Add(m_newCharacter, 0, wxGROW|wxALL, 5); m_newParagraph = new wxButton( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_PARA, _("New &Paragraph Style..."), wxDefaultPosition, wxDefaultSize, 0 ); m_newParagraph->SetHelpText(_("Click to create a new paragraph style.")); - if (ShowToolTips()) + if (wxRichTextStyleOrganiserDialog::ShowToolTips()) m_newParagraph->SetToolTip(_("Click to create a new paragraph style.")); m_buttonSizer->Add(m_newParagraph, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); m_newList = new wxButton( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_LIST, _("New &List Style..."), wxDefaultPosition, wxDefaultSize, 0 ); m_newList->SetHelpText(_("Click to create a new list style.")); - if (ShowToolTips()) + if (wxRichTextStyleOrganiserDialog::ShowToolTips()) m_newList->SetToolTip(_("Click to create a new list style.")); m_buttonSizer->Add(m_newList, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); @@ -236,25 +236,25 @@ void wxRichTextStyleOrganiserDialog::CreateControls() m_applyStyle = new wxButton( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_APPLY, _("&Apply Style"), wxDefaultPosition, wxDefaultSize, 0 ); m_applyStyle->SetHelpText(_("Click to apply the selected style.")); - if (ShowToolTips()) + if (wxRichTextStyleOrganiserDialog::ShowToolTips()) m_applyStyle->SetToolTip(_("Click to apply the selected style.")); m_buttonSizer->Add(m_applyStyle, 0, wxGROW|wxALL, 5); m_renameStyle = new wxButton( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_RENAME, _("&Rename Style..."), wxDefaultPosition, wxDefaultSize, 0 ); m_renameStyle->SetHelpText(_("Click to rename the selected style.")); - if (ShowToolTips()) + if (wxRichTextStyleOrganiserDialog::ShowToolTips()) m_renameStyle->SetToolTip(_("Click to rename the selected style.")); m_buttonSizer->Add(m_renameStyle, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); m_editStyle = new wxButton( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_EDIT, _("&Edit Style..."), wxDefaultPosition, wxDefaultSize, 0 ); m_editStyle->SetHelpText(_("Click to edit the selected style.")); - if (ShowToolTips()) + if (wxRichTextStyleOrganiserDialog::ShowToolTips()) m_editStyle->SetToolTip(_("Click to edit the selected style.")); m_buttonSizer->Add(m_editStyle, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); m_deleteStyle = new wxButton( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_DELETE, _("&Delete Style..."), wxDefaultPosition, wxDefaultSize, 0 ); m_deleteStyle->SetHelpText(_("Click to delete the selected style.")); - if (ShowToolTips()) + if (wxRichTextStyleOrganiserDialog::ShowToolTips()) m_deleteStyle->SetToolTip(_("Click to delete the selected style.")); m_buttonSizer->Add(m_deleteStyle, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); @@ -263,7 +263,7 @@ void wxRichTextStyleOrganiserDialog::CreateControls() m_closeButton = new wxButton( itemDialog1, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); m_closeButton->SetDefault(); m_closeButton->SetHelpText(_("Click to close this window.")); - if (ShowToolTips()) + if (wxRichTextStyleOrganiserDialog::ShowToolTips()) m_closeButton->SetToolTip(_("Click to close this window.")); m_buttonSizer->Add(m_closeButton, 0, wxGROW|wxALL, 5); @@ -273,7 +273,7 @@ void wxRichTextStyleOrganiserDialog::CreateControls() m_restartNumberingCtrl = new wxCheckBox( itemDialog1, ID_RICHTEXTSTYLEORGANISERDIALOG_RESTART_NUMBERING, _("&Restart numbering"), wxDefaultPosition, wxDefaultSize, 0 ); m_restartNumberingCtrl->SetValue(false); m_restartNumberingCtrl->SetHelpText(_("Check to restart numbering.")); - if (ShowToolTips()) + if (wxRichTextStyleOrganiserDialog::ShowToolTips()) m_restartNumberingCtrl->SetToolTip(_("Check to restart numbering.")); m_bottomButtonSizer->Add(m_restartNumberingCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); @@ -282,13 +282,13 @@ void wxRichTextStyleOrganiserDialog::CreateControls() m_okButton = new wxButton( itemDialog1, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); m_okButton->SetDefault(); m_okButton->SetHelpText(_("Click to confirm your selection.")); - if (ShowToolTips()) + if (wxRichTextStyleOrganiserDialog::ShowToolTips()) m_okButton->SetToolTip(_("Click to confirm your selection.")); m_bottomButtonSizer->Add(m_okButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_cancelButton = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); m_cancelButton->SetHelpText(_("Click to cancel this window.")); - if (ShowToolTips()) + if (wxRichTextStyleOrganiserDialog::ShowToolTips()) m_cancelButton->SetToolTip(_("Click to cancel this window.")); m_bottomButtonSizer->Add(m_cancelButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); @@ -405,14 +405,14 @@ bool wxRichTextStyleOrganiserDialog::TransferDataToWindow() void wxRichTextStyleOrganiserDialog::ShowPreview(int sel) { static const wxChar* s_para1 = wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \ -Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus."); +Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.\n"); - static const wxChar* s_para2List = wxT("Duis pharetra consequat dui. Nullam vitae justo id mauris lobortis interdum."); + static const wxChar* s_para2List = wxT("Duis pharetra consequat dui. Nullam vitae justo id mauris lobortis interdum.\n"); static const wxChar* s_para2 = wxT("Duis pharetra consequat dui. Cum sociis natoque penatibus \ -et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum."); +et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.\n"); - static const wxChar* s_para3 = wxT("\nInteger convallis dolor at augue \ + static const wxChar* s_para3 = wxT("Integer convallis dolor at augue \ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); if (sel == -1) @@ -426,13 +426,17 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); wxRichTextListStyleDefinition* listDef = wxDynamicCast(def, wxRichTextListStyleDefinition); - wxTextAttrEx attr(def->GetStyleMergedWithBase(GetStyleSheet())); + wxStaticText* labelCtrl = (wxStaticText*) FindWindow(ID_RICHTEXTSTYLEORGANISERDIALOG_CURRENT_STYLE); + if (labelCtrl) + labelCtrl->SetLabel(def->GetName() + wxT(":")); + + wxTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet())); wxFont font(m_previewCtrl->GetFont()); font.SetPointSize(9); m_previewCtrl->SetFont(font); - wxTextAttrEx normalParaAttr; + wxTextAttr normalParaAttr; normalParaAttr.SetFont(font); normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY"))); @@ -451,10 +455,10 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); int i; for (i = 0; i < 10; i++) { - wxTextAttrEx levelAttr = * listDef->GetLevelAttributes(i); + wxTextAttr levelAttr = * listDef->GetLevelAttributes(i); levelAttr.SetBulletNumber(1); m_previewCtrl->BeginStyle(levelAttr); - m_previewCtrl->WriteText(wxString::Format(wxT("\nList level %d. "), i+1) + s_para2List); + m_previewCtrl->WriteText(wxString::Format(wxT("List level %d. "), i+1) + s_para2List); m_previewCtrl->EndStyle(); } long listEnd = m_previewCtrl->GetInsertionPoint(); @@ -462,7 +466,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); } else { - m_previewCtrl->WriteText(wxString(wxT("\n")) + s_para2); + m_previewCtrl->WriteText(s_para2); } m_previewCtrl->EndStyle(); @@ -478,6 +482,9 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); void wxRichTextStyleOrganiserDialog::ClearPreview() { m_previewCtrl->Clear(); + wxStaticText* labelCtrl = (wxStaticText*) FindWindow(ID_RICHTEXTSTYLEORGANISERDIALOG_CURRENT_STYLE); + if (labelCtrl) + labelCtrl->SetLabel(wxEmptyString); } bool wxRichTextStyleOrganiserDialog::ApplyStyle(wxRichTextCtrl* ctrl) @@ -698,6 +705,7 @@ void wxRichTextStyleOrganiserDialog::OnEditClick( wxCommandEvent& WXUNUSED(event } m_stylesListBox->UpdateStyles(); + m_stylesListBox->GetStyleListBox()->SetSelection(sel); ShowPreview(); } } @@ -724,7 +732,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); @@ -870,4 +878,4 @@ void wxRichTextStyleOrganiserDialog::OnListSelection(wxCommandEvent& event) #endif // wxUSE_RICHTEXT - +