X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d2d0adc7765dfe904f0f7e97d85a2638c934a7d6..6756186271a8394db23bc817e1aa36c27c52076a:/src/richtext/richtextbulletspage.cpp?ds=inline diff --git a/src/richtext/richtextbulletspage.cpp b/src/richtext/richtextbulletspage.cpp index 17057047b2..1ba53c80a5 100644 --- a/src/richtext/richtextbulletspage.cpp +++ b/src/richtext/richtextbulletspage.cpp @@ -11,8 +11,9 @@ #if wxUSE_RICHTEXT +#include "wx/spinctrl.h" +#include "wx/utils.h" #include "wx/richtext/richtextbulletspage.h" - #include "wx/richtext/richtextsymboldlg.h" /*! @@ -153,12 +154,12 @@ void wxRichTextBulletsPage::CreateControls() itemBoxSizer4->Add(itemBoxSizer5, 0, wxGROW, 5); wxStaticText* itemStaticText6 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Bullet style:"), 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); - wxString* m_styleListBoxStrings = NULL; - m_styleListBox = new wxListBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_STYLELISTBOX, wxDefaultPosition, wxSize(-1, 140), 0, m_styleListBoxStrings, wxLB_SINGLE ); + wxArrayString m_styleListBoxStrings; + m_styleListBox = new wxListBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_STYLELISTBOX, wxDefaultPosition, wxSize(-1, 90), m_styleListBoxStrings, wxLB_SINGLE ); m_styleListBox->SetHelpText(_("The available bullet styles.")); - if (ShowToolTips()) + if (wxRichTextBulletsPage::ShowToolTips()) m_styleListBox->SetToolTip(_("The available bullet styles.")); itemBoxSizer5->Add(m_styleListBox, 1, wxGROW|wxALL, 5); @@ -168,38 +169,37 @@ void wxRichTextBulletsPage::CreateControls() m_periodCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_PERIODCTRL, _("Peri&od"), wxDefaultPosition, wxDefaultSize, 0 ); m_periodCtrl->SetValue(false); m_periodCtrl->SetHelpText(_("Check to add a period after the bullet.")); - if (ShowToolTips()) + if (wxRichTextBulletsPage::ShowToolTips()) m_periodCtrl->SetToolTip(_("Check to add a period after the bullet.")); itemBoxSizer8->Add(m_periodCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_parenthesesCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL, _("(*)"), wxDefaultPosition, wxDefaultSize, 0 ); m_parenthesesCtrl->SetValue(false); m_parenthesesCtrl->SetHelpText(_("Check to enclose the bullet in parentheses.")); - if (ShowToolTips()) + if (wxRichTextBulletsPage::ShowToolTips()) m_parenthesesCtrl->SetToolTip(_("Check to enclose the bullet in parentheses.")); itemBoxSizer8->Add(m_parenthesesCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_rightParenthesisCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_RIGHTPARENTHESISCTRL, _("*)"), wxDefaultPosition, wxDefaultSize, 0 ); m_rightParenthesisCtrl->SetValue(false); m_rightParenthesisCtrl->SetHelpText(_("Check to add a right parenthesis.")); - if (ShowToolTips()) + if (wxRichTextBulletsPage::ShowToolTips()) m_rightParenthesisCtrl->SetToolTip(_("Check to add a right parenthesis.")); itemBoxSizer8->Add(m_rightParenthesisCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer5->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5); wxStaticText* itemStaticText13 = new wxStaticText( itemPanel1, wxID_STATIC, _("Bullet &Alignment:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer5->Add(itemStaticText13, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); - - wxString m_bulletAlignmentCtrlStrings[] = { - _("Left"), - _("Centre"), - _("Right") - }; - m_bulletAlignmentCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_BULLETALIGNMENTCTRL, _("Left"), wxDefaultPosition, wxSize(60, -1), 3, m_bulletAlignmentCtrlStrings, wxCB_READONLY ); + itemBoxSizer5->Add(itemStaticText13, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); + + wxArrayString m_bulletAlignmentCtrlStrings; + m_bulletAlignmentCtrlStrings.Add(_("Left")); + m_bulletAlignmentCtrlStrings.Add(_("Centre")); + m_bulletAlignmentCtrlStrings.Add(_("Right")); + m_bulletAlignmentCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_BULLETALIGNMENTCTRL, _("Left"), wxDefaultPosition, wxSize(60, -1), m_bulletAlignmentCtrlStrings, wxCB_READONLY ); m_bulletAlignmentCtrl->SetStringSelection(_("Left")); m_bulletAlignmentCtrl->SetHelpText(_("The bullet character.")); - if (ShowToolTips()) + if (wxRichTextBulletsPage::ShowToolTips()) m_bulletAlignmentCtrl->SetToolTip(_("The bullet character.")); itemBoxSizer5->Add(m_bulletAlignmentCtrl, 0, wxGROW|wxALL|wxFIXED_MINSIZE, 5); @@ -213,70 +213,73 @@ void wxRichTextBulletsPage::CreateControls() wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxVERTICAL); itemBoxSizer4->Add(itemBoxSizer18, 0, wxGROW, 5); - wxStaticText* itemStaticText19 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC, _("&Symbol:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer18->Add(itemStaticText19, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + wxBoxSizer* itemBoxSizer19 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer18->Add(itemBoxSizer19, 0, wxGROW, 5); - wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer18->Add(itemBoxSizer20, 0, wxGROW, 5); + wxStaticText* itemStaticText20 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC, _("&Symbol:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer19->Add(itemStaticText20, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxString* m_symbolCtrlStrings = NULL; - m_symbolCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL, _T(""), wxDefaultPosition, wxSize(60, -1), 0, m_symbolCtrlStrings, wxCB_DROPDOWN ); + wxArrayString m_symbolCtrlStrings; + m_symbolCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL, _T(""), wxDefaultPosition, wxSize(60, -1), m_symbolCtrlStrings, wxCB_DROPDOWN ); m_symbolCtrl->SetHelpText(_("The bullet character.")); - if (ShowToolTips()) + if (wxRichTextBulletsPage::ShowToolTips()) m_symbolCtrl->SetToolTip(_("The bullet character.")); - itemBoxSizer20->Add(m_symbolCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxFIXED_MINSIZE, 5); + itemBoxSizer19->Add(m_symbolCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxFIXED_MINSIZE, 5); wxButton* itemButton22 = new wxButton( itemPanel1, ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL, _("Ch&oose..."), wxDefaultPosition, wxDefaultSize, 0 ); itemButton22->SetHelpText(_("Click to browse for a symbol.")); - if (ShowToolTips()) + if (wxRichTextBulletsPage::ShowToolTips()) itemButton22->SetToolTip(_("Click to browse for a symbol.")); - itemBoxSizer20->Add(itemButton22, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemBoxSizer19->Add(itemButton22, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer18->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5); wxStaticText* itemStaticText24 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC, _("Symbol &font:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer18->Add(itemStaticText24, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + itemBoxSizer18->Add(itemStaticText24, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - wxString* m_symbolFontCtrlStrings = NULL; - m_symbolFontCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_symbolFontCtrlStrings, wxCB_DROPDOWN ); + wxArrayString m_symbolFontCtrlStrings; + m_symbolFontCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, m_symbolFontCtrlStrings, wxCB_DROPDOWN ); m_symbolFontCtrl->SetHelpText(_("Available fonts.")); - if (ShowToolTips()) + if (wxRichTextBulletsPage::ShowToolTips()) m_symbolFontCtrl->SetToolTip(_("Available fonts.")); itemBoxSizer18->Add(m_symbolFontCtrl, 0, wxGROW|wxALL, 5); - itemBoxSizer18->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + itemBoxSizer18->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL, 5); wxStaticText* itemStaticText27 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_NAMESTATIC, _("S&tandard bullet name:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer18->Add(itemStaticText27, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + itemBoxSizer18->Add(itemStaticText27, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - wxString* m_bulletNameCtrlStrings = NULL; - m_bulletNameCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_NAMECTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_bulletNameCtrlStrings, wxCB_DROPDOWN ); + wxArrayString m_bulletNameCtrlStrings; + m_bulletNameCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_NAMECTRL, _T(""), wxDefaultPosition, wxDefaultSize, m_bulletNameCtrlStrings, wxCB_DROPDOWN ); m_bulletNameCtrl->SetHelpText(_("A standard bullet name.")); - if (ShowToolTips()) + if (wxRichTextBulletsPage::ShowToolTips()) m_bulletNameCtrl->SetToolTip(_("A standard bullet name.")); itemBoxSizer18->Add(m_bulletNameCtrl, 0, wxGROW|wxALL, 5); - itemBoxSizer18->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + itemBoxSizer18->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL, 5); wxStaticText* itemStaticText30 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC, _("&Number:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer18->Add(itemStaticText30, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + itemBoxSizer18->Add(itemStaticText30, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); m_numberCtrl = new wxSpinCtrl( itemPanel1, ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, _T("0"), wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 0, 100000, 0 ); m_numberCtrl->SetHelpText(_("The list item number.")); - if (ShowToolTips()) + if (wxRichTextBulletsPage::ShowToolTips()) m_numberCtrl->SetToolTip(_("The list item number.")); itemBoxSizer18->Add(m_numberCtrl, 0, wxGROW|wxALL, 5); - itemBoxSizer3->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5); - m_previewCtrl = new wxRichTextCtrl( itemPanel1, ID_RICHTEXTBULLETSPAGE_PREVIEW_CTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 180), wxSUNKEN_BORDER ); + m_previewCtrl = new wxRichTextCtrl( itemPanel1, ID_RICHTEXTBULLETSPAGE_PREVIEW_CTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 100), wxVSCROLL|wxTE_READONLY ); m_previewCtrl->SetHelpText(_("Shows a preview of the bullet settings.")); - if (ShowToolTips()) + if (wxRichTextBulletsPage::ShowToolTips()) m_previewCtrl->SetToolTip(_("Shows a preview of the bullet settings.")); - itemBoxSizer3->Add(m_previewCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + itemBoxSizer3->Add(m_previewCtrl, 1, wxGROW|wxALL, 5); ////@end wxRichTextBulletsPage content construction + if (wxGetDisplaySize().y < 600) + m_previewCtrl->SetMinSize(wxSize(350, 50)); + m_styleListBox->Append(_("(None)")); m_styleListBox->Append(_("Arabic")); m_styleListBox->Append(_("Upper case letters")); @@ -287,13 +290,13 @@ void wxRichTextBulletsPage::CreateControls() m_styleListBox->Append(_("Symbol")); m_styleListBox->Append(_("Bitmap")); m_styleListBox->Append(_("Standard")); - + m_symbolCtrl->Append(_("*")); m_symbolCtrl->Append(_("-")); m_symbolCtrl->Append(_(">")); m_symbolCtrl->Append(_("+")); m_symbolCtrl->Append(_("~")); - + wxArrayString standardBulletNames; if (wxRichTextBuffer::GetRenderer()) wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames); @@ -311,7 +314,7 @@ bool wxRichTextBulletsPage::TransferDataFromWindow() { wxPanel::TransferDataFromWindow(); - wxTextAttrEx* attr = GetAttributes(); + wxTextAttr* attr = GetAttributes(); if (m_hasBulletStyle) { @@ -354,12 +357,12 @@ bool wxRichTextBulletsPage::TransferDataFromWindow() bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS; if (m_periodCtrl->GetValue()) bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_PERIOD; - + if (m_bulletAlignmentCtrl->GetSelection() == 1) bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE; else if (m_bulletAlignmentCtrl->GetSelection() == 2) bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT; - // Left is implied + // Left is implied attr->SetBulletStyle(bulletStyle); } @@ -374,7 +377,7 @@ bool wxRichTextBulletsPage::TransferDataFromWindow() attr->SetBulletText(m_symbolCtrl->GetValue()); attr->SetBulletFont(m_symbolFontCtrl->GetValue()); } - + return true; } @@ -384,7 +387,7 @@ bool wxRichTextBulletsPage::TransferDataToWindow() wxPanel::TransferDataToWindow(); - wxTextAttrEx* attr = GetAttributes(); + wxTextAttr* attr = GetAttributes(); if (attr->HasBulletStyle()) { @@ -478,16 +481,16 @@ bool wxRichTextBulletsPage::TransferDataToWindow() void wxRichTextBulletsPage::UpdatePreview() { 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_para2 = wxT("\nDuis pharetra consequat dui. Cum sociis natoque penatibus \ -et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum."); + 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.\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"); TransferDataFromWindow(); - wxTextAttrEx attr(*GetAttributes()); + wxTextAttr attr(*GetAttributes()); attr.SetFlags(attr.GetFlags() & (wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT|wxTEXT_ATTR_BULLET_NAME| wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER| @@ -497,7 +500,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); font.SetPointSize(9); m_previewCtrl->SetFont(font); - wxTextAttrEx normalParaAttr; + wxTextAttr normalParaAttr; normalParaAttr.SetFont(font); normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY"))); @@ -515,13 +518,13 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); m_previewCtrl->BeginStyle(normalParaAttr); m_previewCtrl->WriteText(s_para3); m_previewCtrl->EndStyle(); - + m_previewCtrl->NumberList(wxRichTextRange(0, m_previewCtrl->GetLastPosition()+1)); m_previewCtrl->Thaw(); } -wxTextAttrEx* wxRichTextBulletsPage::GetAttributes() +wxTextAttr* wxRichTextBulletsPage::GetAttributes() { return wxRichTextFormattingDialog::GetDialogAttributes(this); }