X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b68603d5359cdfa4a79fc1798d87959d5a578f51..2028c33ab5a39a12bd410ac953731a56ad6377ba:/src/richtext/richtextbulletspage.cpp?ds=sidebyside diff --git a/src/richtext/richtextbulletspage.cpp b/src/richtext/richtextbulletspage.cpp index 632fd213ec..61cad9f528 100644 --- a/src/richtext/richtextbulletspage.cpp +++ b/src/richtext/richtextbulletspage.cpp @@ -9,22 +9,12 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - #if wxUSE_RICHTEXT +#include "wx/spinctrl.h" +#include "wx/utils.h" #include "wx/richtext/richtextbulletspage.h" - -#ifndef WX_PRECOMP -#endif - #include "wx/richtext/richtextsymboldlg.h" -#include "wx/fontenum.h" /*! * wxRichTextBulletsPage type definition @@ -41,6 +31,17 @@ BEGIN_EVENT_TABLE( wxRichTextBulletsPage, wxPanel ) ////@begin wxRichTextBulletsPage event table entries EVT_LISTBOX( ID_RICHTEXTBULLETSPAGE_STYLELISTBOX, wxRichTextBulletsPage::OnStylelistboxSelected ) + EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_PERIODCTRL, wxRichTextBulletsPage::OnPeriodctrlClick ) + EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_PERIODCTRL, wxRichTextBulletsPage::OnPeriodctrlUpdate ) + + EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL, wxRichTextBulletsPage::OnParenthesesctrlClick ) + EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL, wxRichTextBulletsPage::OnParenthesesctrlUpdate ) + + EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_RIGHTPARENTHESISCTRL, wxRichTextBulletsPage::OnRightParenthesisCtrlClick ) + EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_RIGHTPARENTHESISCTRL, wxRichTextBulletsPage::OnRightParenthesisCtrlUpdate ) + + EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_BULLETALIGNMENTCTRL, wxRichTextBulletsPage::OnBulletAlignmentCtrlSelected ) + EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC, wxRichTextBulletsPage::OnSymbolstaticUpdate ) EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL, wxRichTextBulletsPage::OnSymbolctrlSelected ) @@ -54,6 +55,12 @@ BEGIN_EVENT_TABLE( wxRichTextBulletsPage, wxPanel ) EVT_TEXT( ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL, wxRichTextBulletsPage::OnSymbolfontctrlUpdated ) EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL, wxRichTextBulletsPage::OnSymbolfontctrlUIUpdate ) + EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NAMESTATIC, wxRichTextBulletsPage::OnNamestaticUpdate ) + + EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_NAMECTRL, wxRichTextBulletsPage::OnNamectrlSelected ) + EVT_TEXT( ID_RICHTEXTBULLETSPAGE_NAMECTRL, wxRichTextBulletsPage::OnNamectrlUpdated ) + EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NAMECTRL, wxRichTextBulletsPage::OnNamectrlUIUpdate ) + EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC, wxRichTextBulletsPage::OnNumberstaticUpdate ) EVT_SPINCTRL( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, wxRichTextBulletsPage::OnNumberctrlUpdated ) @@ -62,12 +69,6 @@ BEGIN_EVENT_TABLE( wxRichTextBulletsPage, wxPanel ) EVT_TEXT( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, wxRichTextBulletsPage::OnNumberctrlTextUpdated ) EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, wxRichTextBulletsPage::OnNumberctrlUpdate ) - EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL, wxRichTextBulletsPage::OnParenthesesctrlClick ) - EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL, wxRichTextBulletsPage::OnParenthesesctrlUpdate ) - - EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_PERIODCTRL, wxRichTextBulletsPage::OnPeriodctrlClick ) - EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_PERIODCTRL, wxRichTextBulletsPage::OnPeriodctrlUpdate ) - ////@end wxRichTextBulletsPage event table entries END_EVENT_TABLE() @@ -90,7 +91,7 @@ wxRichTextBulletsPage::wxRichTextBulletsPage( wxWindow* parent, wxWindowID id, c /*! * Initialise members */ - + void wxRichTextBulletsPage::Init() { m_hasBulletStyle = false; @@ -100,11 +101,14 @@ void wxRichTextBulletsPage::Init() ////@begin wxRichTextBulletsPage member initialisation m_styleListBox = NULL; + m_periodCtrl = NULL; + m_parenthesesCtrl = NULL; + m_rightParenthesisCtrl = NULL; + m_bulletAlignmentCtrl = NULL; m_symbolCtrl = NULL; m_symbolFontCtrl = NULL; + m_bulletNameCtrl = NULL; m_numberCtrl = NULL; - m_parenthesesCtrl = NULL; - m_periodCtrl = NULL; m_previewCtrl = NULL; ////@end wxRichTextBulletsPage member initialisation } @@ -150,114 +154,160 @@ 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, wxDefaultSize, 0, m_styleListBoxStrings, wxLB_SINGLE ); - itemBoxSizer5->Add(m_styleListBox, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + 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 (wxRichTextBulletsPage::ShowToolTips()) + m_styleListBox->SetToolTip(_("The available bullet styles.")); + itemBoxSizer5->Add(m_styleListBox, 1, wxGROW|wxALL, 5); - itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5); + wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer5->Add(itemBoxSizer8, 0, wxGROW, 5); - wxStaticLine* itemStaticLine9 = new wxStaticLine( itemPanel1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); - itemBoxSizer4->Add(itemStaticLine9, 0, wxGROW|wxALL, 5); + 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 (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 (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 (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, 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 (wxRichTextBulletsPage::ShowToolTips()) + m_bulletAlignmentCtrl->SetToolTip(_("The bullet character.")); + itemBoxSizer5->Add(m_bulletAlignmentCtrl, 0, wxGROW|wxALL|wxFIXED_MINSIZE, 5); itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5); - wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer4->Add(itemBoxSizer11, 0, wxGROW, 5); - - wxStaticText* itemStaticText12 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC, _("&Symbol:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer11->Add(itemStaticText12, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); - - wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer11->Add(itemBoxSizer13, 0, wxGROW, 5); - - wxString* m_symbolCtrlStrings = NULL; - m_symbolCtrl = new wxComboBox( itemPanel1, - ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL, - wxEmptyString, - wxDefaultPosition, - wxSize(60, wxDefaultCoord), - 0, - m_symbolCtrlStrings, - wxCB_DROPDOWN ); - itemBoxSizer13->Add(m_symbolCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxFIXED_MINSIZE, 5); - - wxButton* itemButton15 = new wxButton( itemPanel1, ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL, _("Ch&oose..."), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer13->Add(itemButton15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - - itemBoxSizer11->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); - - wxStaticText* itemStaticText17 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC, _("Symbol &font:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer11->Add(itemStaticText17, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); - - wxString* m_symbolFontCtrlStrings = NULL; - m_symbolFontCtrl = new wxComboBox( itemPanel1, - ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL, - wxEmptyString, - wxDefaultPosition, - wxDefaultSize, - 0, - m_symbolFontCtrlStrings, - wxCB_DROPDOWN ); - itemBoxSizer11->Add(m_symbolFontCtrl, 0, wxGROW|wxALL, 5); + wxStaticLine* itemStaticLine16 = new wxStaticLine( itemPanel1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); + itemBoxSizer4->Add(itemStaticLine16, 0, wxGROW|wxLEFT|wxRIGHT, 5); itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5); - wxStaticLine* itemStaticLine20 = new wxStaticLine( itemPanel1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); - itemBoxSizer4->Add(itemStaticLine20, 0, wxGROW|wxALL, 5); + wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer4->Add(itemBoxSizer18, 0, wxGROW, 5); - itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5); + wxBoxSizer* itemBoxSizer19 = new wxBoxSizer(wxHORIZONTAL); + itemBoxSizer18->Add(itemBoxSizer19, 0, wxGROW, 5); - wxBoxSizer* itemBoxSizer22 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer4->Add(itemBoxSizer22, 0, wxGROW, 5); + wxStaticText* itemStaticText20 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC, _("&Symbol:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer19->Add(itemStaticText20, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxStaticText* itemStaticText23 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC, _("&Number:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer22->Add(itemStaticText23, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + wxArrayString m_symbolCtrlStrings; + m_symbolCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL, wxT(""), wxDefaultPosition, wxSize(60, -1), m_symbolCtrlStrings, wxCB_DROPDOWN ); + m_symbolCtrl->SetHelpText(_("The bullet character.")); + if (wxRichTextBulletsPage::ShowToolTips()) + m_symbolCtrl->SetToolTip(_("The bullet character.")); + itemBoxSizer19->Add(m_symbolCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxFIXED_MINSIZE, 5); - m_numberCtrl = new wxSpinCtrl( itemPanel1, ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, _T("0"), wxDefaultPosition, wxSize(50, wxDefaultCoord), wxSP_ARROW_KEYS, 0, 100000, 0 ); - itemBoxSizer22->Add(m_numberCtrl, 0, wxGROW|wxALL, 5); + wxButton* itemButton22 = new wxButton( itemPanel1, ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL, _("Ch&oose..."), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton22->SetHelpText(_("Click to browse for a symbol.")); + if (wxRichTextBulletsPage::ShowToolTips()) + itemButton22->SetToolTip(_("Click to browse for a symbol.")); + itemBoxSizer19->Add(itemButton22, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - itemBoxSizer22->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + itemBoxSizer18->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5); - m_parenthesesCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL, _("&Parentheses"), wxDefaultPosition, wxDefaultSize, 0 ); - m_parenthesesCtrl->SetValue(false); - itemBoxSizer22->Add(m_parenthesesCtrl, 0, wxALIGN_LEFT|wxALL, 5); + wxStaticText* itemStaticText24 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC, _("Symbol &font:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer18->Add(itemStaticText24, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - m_periodCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_PERIODCTRL, _("Peri&od"), wxDefaultPosition, wxDefaultSize, 0 ); - m_periodCtrl->SetValue(false); - itemBoxSizer22->Add(m_periodCtrl, 0, wxALIGN_LEFT|wxALL, 5); + wxArrayString m_symbolFontCtrlStrings; + m_symbolFontCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL, wxT(""), wxDefaultPosition, wxDefaultSize, m_symbolFontCtrlStrings, wxCB_DROPDOWN ); + m_symbolFontCtrl->SetHelpText(_("Available fonts.")); + if (wxRichTextBulletsPage::ShowToolTips()) + m_symbolFontCtrl->SetToolTip(_("Available fonts.")); + itemBoxSizer18->Add(m_symbolFontCtrl, 0, wxGROW|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, 5); + + wxArrayString m_bulletNameCtrlStrings; + m_bulletNameCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_NAMECTRL, wxT(""), wxDefaultPosition, wxDefaultSize, m_bulletNameCtrlStrings, wxCB_DROPDOWN ); + m_bulletNameCtrl->SetHelpText(_("A standard bullet name.")); + 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, 5); + + wxStaticText* itemStaticText30 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC, _("&Number:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemBoxSizer18->Add(itemStaticText30, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - itemBoxSizer3->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + m_numberCtrl = new wxSpinCtrl( itemPanel1, ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, wxT("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.")); + itemBoxSizer18->Add(m_numberCtrl, 0, wxGROW|wxALL, 5); - m_previewCtrl = new wxRichTextCtrl( itemPanel1, ID_RICHTEXTBULLETSPAGE_PREVIEW_CTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 180), wxSUNKEN_BORDER ); + itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5); + + 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")); m_styleListBox->Append(_("Lower case letters")); m_styleListBox->Append(_("Upper case roman numerals")); m_styleListBox->Append(_("Lower case roman numerals")); + m_styleListBox->Append(_("Numbered outline")); 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(_("~")); - - wxFontEnumerator enumerator; - enumerator.EnumerateFacenames(); - wxArrayString facenames = enumerator.GetFacenames(); + + wxArrayString standardBulletNames; + if (wxRichTextBuffer::GetRenderer()) + wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames); + + size_t i; + for (i = 0; i < standardBulletNames.GetCount(); i++) + m_bulletNameCtrl->Append(wxGetTranslation(standardBulletNames[i])); + + wxArrayString facenames = wxRichTextCtrl::GetAvailableFontNames(); facenames.Sort(); - + m_symbolFontCtrl->Append(facenames); } @@ -266,33 +316,71 @@ bool wxRichTextBulletsPage::TransferDataFromWindow() { wxPanel::TransferDataFromWindow(); - wxTextAttrEx* attr = GetAttributes(); + wxTextAttr* attr = GetAttributes(); if (m_hasBulletStyle) { - long bulletStyle = 0; + long bulletStyle = wxRICHTEXT_BULLETINDEX_NONE; int index = m_styleListBox->GetSelection(); - if (index == 1) + if (index == wxRICHTEXT_BULLETINDEX_ARABIC) bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_ARABIC; - else if (index == 2) + + else if (index == wxRICHTEXT_BULLETINDEX_UPPER_CASE) bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER; - else if (index == 3) + + else if (index == wxRICHTEXT_BULLETINDEX_LOWER_CASE) bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER; - else if (index == 4) + + else if (index == wxRICHTEXT_BULLETINDEX_UPPER_CASE_ROMAN) bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER; - else if (index == 5) + + else if (index == wxRICHTEXT_BULLETINDEX_LOWER_CASE_ROMAN) bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER; - else if (index == 6) + + else if (index == wxRICHTEXT_BULLETINDEX_OUTLINE) + bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_OUTLINE; + + else if (index == wxRICHTEXT_BULLETINDEX_SYMBOL) bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_SYMBOL; - else if (index == 7) + + else if (index == wxRICHTEXT_BULLETINDEX_BITMAP) bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_BITMAP; + else if (index == wxRICHTEXT_BULLETINDEX_STANDARD) + { + bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_STANDARD; + wxArrayString standardBulletNames; + if (wxRichTextBuffer::GetRenderer() && m_bulletNameCtrl->GetSelection() != wxNOT_FOUND) + { + int sel = m_bulletNameCtrl->GetSelection(); + wxString selName = m_bulletNameCtrl->GetString(sel); + + // Try to get the untranslated name using the current selection index of the combobox. + // into account. + wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames); + if (sel < (int) standardBulletNames.GetCount() && m_bulletNameCtrl->GetValue() == selName) + attr->SetBulletName(standardBulletNames[sel]); + else + attr->SetBulletName(m_bulletNameCtrl->GetValue()); + } + else + attr->SetBulletName(m_bulletNameCtrl->GetValue()); + } + if (m_parenthesesCtrl->GetValue()) bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_PARENTHESES; + if (m_rightParenthesisCtrl->GetValue()) + 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 + attr->SetBulletStyle(bulletStyle); } @@ -303,12 +391,10 @@ bool wxRichTextBulletsPage::TransferDataFromWindow() if (m_hasBulletSymbol) { - wxChar c(wxT('*')); - if (m_symbolCtrl->GetValue().length() > 0) - c = m_symbolCtrl->GetValue()[0]; - attr->SetBulletSymbol(c); + attr->SetBulletText(m_symbolCtrl->GetValue()); attr->SetBulletFont(m_symbolFontCtrl->GetValue()); } + return true; } @@ -318,25 +404,40 @@ bool wxRichTextBulletsPage::TransferDataToWindow() wxPanel::TransferDataToWindow(); - wxTextAttrEx* attr = GetAttributes(); + wxTextAttr* attr = GetAttributes(); if (attr->HasBulletStyle()) { - int index = -1; + m_hasBulletStyle = true; + int index = wxRICHTEXT_BULLETINDEX_NONE; + if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ARABIC) - index = 1; + index = wxRICHTEXT_BULLETINDEX_ARABIC; + else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER) - index = 2; + index = wxRICHTEXT_BULLETINDEX_UPPER_CASE; + else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER) - index = 3; + index = wxRICHTEXT_BULLETINDEX_LOWER_CASE; + else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER) - index = 4; + index = wxRICHTEXT_BULLETINDEX_UPPER_CASE_ROMAN; + else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER) - index = 5; + index = wxRICHTEXT_BULLETINDEX_LOWER_CASE_ROMAN; + + else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_OUTLINE) + index = wxRICHTEXT_BULLETINDEX_OUTLINE; + else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL) - index = 6; + index = wxRICHTEXT_BULLETINDEX_SYMBOL; + else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_BITMAP) - index = 7; + index = wxRICHTEXT_BULLETINDEX_BITMAP; + + else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_STANDARD) + index = wxRICHTEXT_BULLETINDEX_STANDARD; + m_styleListBox->SetSelection(index); if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PARENTHESES) @@ -344,20 +445,33 @@ bool wxRichTextBulletsPage::TransferDataToWindow() else m_parenthesesCtrl->SetValue(false); + if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS) + m_rightParenthesisCtrl->SetValue(true); + else + m_rightParenthesisCtrl->SetValue(false); + if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PERIOD) m_periodCtrl->SetValue(true); else - m_periodCtrl->SetValue(false); + m_periodCtrl->SetValue(false); + + if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE) + m_bulletAlignmentCtrl->SetSelection(1); + else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT) + m_bulletAlignmentCtrl->SetSelection(2); + else + m_bulletAlignmentCtrl->SetSelection(0); } else + { + m_hasBulletStyle = false; m_styleListBox->SetSelection(-1); + m_bulletAlignmentCtrl->SetSelection(-1); + } - if (attr->HasBulletSymbol()) + if (attr->HasBulletText()) { - wxChar c = attr->GetBulletSymbol(); - wxString s; - s << c; - m_symbolCtrl->SetValue(s); + m_symbolCtrl->SetValue(attr->GetBulletText()); m_symbolFontCtrl->SetValue(attr->GetBulletFont()); } else @@ -368,6 +482,26 @@ bool wxRichTextBulletsPage::TransferDataToWindow() else m_numberCtrl->SetValue(0); + if (attr->HasBulletName()) + { + wxArrayString standardBulletNames; + if (wxRichTextBuffer::GetRenderer()) + { + // Try to set the control by index in order to take translated combo control strings + // into account. + wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames); + int idx = standardBulletNames.Index(attr->GetBulletName()); + if (idx != -1 && idx < (int) m_bulletNameCtrl->GetCount()) + m_bulletNameCtrl->SetSelection(idx); + else + m_bulletNameCtrl->SetValue(attr->GetBulletName()); + } + else + m_bulletNameCtrl->SetValue(attr->GetBulletName()); + } + else + m_bulletNameCtrl->SetValue(wxEmptyString); + UpdatePreview(); m_dontUpdate = false; @@ -379,18 +513,18 @@ 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_SYMBOL| + (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| wxTEXT_ATTR_LINE_SPACING)); @@ -398,19 +532,31 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); font.SetPointSize(9); m_previewCtrl->SetFont(font); - font.SetWeight(wxBOLD); - attr.SetFont(font); + wxTextAttr normalParaAttr; + normalParaAttr.SetFont(font); + normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY"))); + m_previewCtrl->Freeze(); m_previewCtrl->Clear(); + m_previewCtrl->BeginStyle(normalParaAttr); m_previewCtrl->WriteText(s_para1); + m_previewCtrl->EndStyle(); + m_previewCtrl->BeginStyle(attr); m_previewCtrl->WriteText(s_para2); m_previewCtrl->EndStyle(); + + 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); } @@ -421,7 +567,7 @@ wxTextAttrEx* wxRichTextBulletsPage::GetAttributes() bool wxRichTextBulletsPage::ShowToolTips() { - return true; + return wxRichTextFormattingDialog::ShowToolTips(); } /*! @@ -460,7 +606,7 @@ void wxRichTextBulletsPage::OnStylelistboxSelected( wxCommandEvent& WXUNUSED(eve { m_hasBulletStyle = true; - if (m_styleListBox->GetSelection() == 6) + if (m_styleListBox->GetSelection() == wxRICHTEXT_BULLETINDEX_SYMBOL) m_hasBulletSymbol = true; UpdatePreview(); @@ -583,7 +729,9 @@ void wxRichTextBulletsPage::OnParenthesesctrlClick( wxCommandEvent& WXUNUSED(eve void wxRichTextBulletsPage::OnParenthesesctrlUpdate( wxUpdateUIEvent& event ) { int sel = m_styleListBox->GetSelection(); - event.Enable(m_hasBulletStyle && (sel != 6 && sel != 7 && sel != 0)); + event.Enable(m_hasBulletStyle && (sel != wxRICHTEXT_BULLETINDEX_SYMBOL && + sel != wxRICHTEXT_BULLETINDEX_BITMAP && + sel != wxRICHTEXT_BULLETINDEX_NONE)); } /*! @@ -606,7 +754,9 @@ void wxRichTextBulletsPage::OnPeriodctrlClick( wxCommandEvent& WXUNUSED(event) ) void wxRichTextBulletsPage::OnPeriodctrlUpdate( wxUpdateUIEvent& event ) { int sel = m_styleListBox->GetSelection(); - event.Enable(m_hasBulletStyle && (sel != 6 && sel != 7 && sel != 0)); + event.Enable(m_hasBulletStyle && (sel != wxRICHTEXT_BULLETINDEX_SYMBOL && + sel != wxRICHTEXT_BULLETINDEX_BITMAP && + sel != wxRICHTEXT_BULLETINDEX_NONE)); } /*! @@ -616,7 +766,7 @@ void wxRichTextBulletsPage::OnPeriodctrlUpdate( wxUpdateUIEvent& event ) void wxRichTextBulletsPage::OnChooseSymbolClick( wxCommandEvent& WXUNUSED(event) ) { int sel = m_styleListBox->GetSelection(); - if (m_hasBulletStyle && sel == 6) + if (m_hasBulletStyle && sel == wxRICHTEXT_BULLETINDEX_SYMBOL) { wxString symbol = m_symbolCtrl->GetValue(); wxString fontName = m_symbolFontCtrl->GetValue(); @@ -625,10 +775,10 @@ void wxRichTextBulletsPage::OnChooseSymbolClick( wxCommandEvent& WXUNUSED(event) if (dlg.ShowModal() == wxID_OK) { m_dontUpdate = true; - + m_symbolCtrl->SetValue(dlg.GetSymbol()); m_symbolFontCtrl->SetValue(dlg.GetFontName()); - + UpdatePreview(); m_dontUpdate = false; @@ -680,16 +830,27 @@ void wxRichTextBulletsPage::OnSymbolfontctrlUIUpdate( wxUpdateUIEvent& event ) void wxRichTextBulletsPage::OnSymbolUpdate( wxUpdateUIEvent& event ) { int sel = m_styleListBox->GetSelection(); - event.Enable(m_hasBulletStyle && (sel == 6)); + event.Enable(m_hasBulletStyle && (sel == wxRICHTEXT_BULLETINDEX_SYMBOL)); } /// Update for number-related controls void wxRichTextBulletsPage::OnNumberUpdate( wxUpdateUIEvent& event ) { int sel = m_styleListBox->GetSelection(); - event.Enable( m_hasBulletStyle && (sel != 6 && sel != 7 && sel != 0)); + event.Enable( m_hasBulletStyle && (sel != wxRICHTEXT_BULLETINDEX_SYMBOL && + sel != wxRICHTEXT_BULLETINDEX_BITMAP && + sel != wxRICHTEXT_BULLETINDEX_STANDARD && + sel != wxRICHTEXT_BULLETINDEX_NONE)); +} + +/// Update for standard bullet-related controls +void wxRichTextBulletsPage::OnStandardBulletUpdate( wxUpdateUIEvent& event ) +{ + int sel = m_styleListBox->GetSelection(); + event.Enable( sel == wxRICHTEXT_BULLETINDEX_STANDARD ); } + /*! * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC */ @@ -709,4 +870,82 @@ void wxRichTextBulletsPage::OnNumberstaticUpdate( wxUpdateUIEvent& event ) OnNumberUpdate(event); } +/*! + * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NAMESTATIC + */ + +void wxRichTextBulletsPage::OnNamestaticUpdate( wxUpdateUIEvent& event ) +{ + OnStandardBulletUpdate(event); +} + + +/*! + * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL + */ + +void wxRichTextBulletsPage::OnNamectrlSelected( wxCommandEvent& WXUNUSED(event) ) +{ + if (m_dontUpdate) + return; + UpdatePreview(); +} + +/*! + * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL + */ + +void wxRichTextBulletsPage::OnNamectrlUpdated( wxCommandEvent& WXUNUSED(event) ) +{ + if (m_dontUpdate) + return; + UpdatePreview(); +} + +/*! + * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NAMECTRL + */ + +void wxRichTextBulletsPage::OnNamectrlUIUpdate( wxUpdateUIEvent& event ) +{ + OnStandardBulletUpdate(event); +} + #endif // wxUSE_RICHTEXT +/*! + * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_RIGHT_PARENTHESIS_CTRL + */ + +void wxRichTextBulletsPage::OnRightParenthesisCtrlClick( wxCommandEvent& WXUNUSED(event) ) +{ + if (!m_dontUpdate) + { + m_hasBulletStyle = true; + UpdatePreview(); + } +} + +/*! + * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_RIGHT_PARENTHESIS_CTRL + */ + +void wxRichTextBulletsPage::OnRightParenthesisCtrlUpdate( wxUpdateUIEvent& event ) +{ + int sel = m_styleListBox->GetSelection(); + event.Enable(m_hasBulletStyle && (sel != wxRICHTEXT_BULLETINDEX_SYMBOL && + sel != wxRICHTEXT_BULLETINDEX_BITMAP && + sel != wxRICHTEXT_BULLETINDEX_NONE)); +} + +/*! + * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX + */ + +void wxRichTextBulletsPage::OnBulletAlignmentCtrlSelected( wxCommandEvent& WXUNUSED(event) ) +{ + if (m_dontUpdate) + return; + UpdatePreview(); +} + +