X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/44cc96a80c09c8572e1315be66d29f6d610cbf78..13cfc51d63509eb0da7d1cc1b9b291a4a701119f:/src/richtext/richtextfontpage.cpp diff --git a/src/richtext/richtextfontpage.cpp b/src/richtext/richtextfontpage.cpp index b47f370468..83215b5068 100644 --- a/src/richtext/richtextfontpage.cpp +++ b/src/richtext/richtextfontpage.cpp @@ -42,6 +42,10 @@ BEGIN_EVENT_TABLE( wxRichTextFontPage, wxPanel ) EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_CAPSCTRL, wxRichTextFontPage::OnCapsctrlClick ) + EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SUPERSCRIPT, wxRichTextFontPage::OnRichtextfontpageSuperscriptClick ) + + EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SUBSCRIPT, wxRichTextFontPage::OnRichtextfontpageSubscriptClick ) + ////@end wxRichTextFontPage event table entries END_EVENT_TABLE() @@ -81,6 +85,8 @@ void wxRichTextFontPage::Init() m_colourCtrl = NULL; m_strikethroughCtrl = NULL; m_capitalsCtrl = NULL; + m_superscriptCtrl = NULL; + m_subscriptCtrl = NULL; m_previewCtrl = NULL; ////@end wxRichTextFontPage member initialisation } @@ -130,13 +136,13 @@ void wxRichTextFontPage::CreateControls() m_faceTextCtrl = new wxTextCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_FACETEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); m_faceTextCtrl->SetHelpText(_("Type a font name.")); - if (ShowToolTips()) + if (wxRichTextFontPage::ShowToolTips()) m_faceTextCtrl->SetToolTip(_("Type a font name.")); itemBoxSizer5->Add(m_faceTextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); - m_faceListBox = new wxRichTextFontListBox( itemPanel1, ID_RICHTEXTFONTPAGE_FACELISTBOX, wxDefaultPosition, wxSize(200, 140), wxSIMPLE_BORDER ); + m_faceListBox = new wxRichTextFontListBox( itemPanel1, ID_RICHTEXTFONTPAGE_FACELISTBOX, wxDefaultPosition, wxSize(200, 100), 0 ); m_faceListBox->SetHelpText(_("Lists the available fonts.")); - if (ShowToolTips()) + if (wxRichTextFontPage::ShowToolTips()) m_faceListBox->SetToolTip(_("Lists the available fonts.")); itemBoxSizer5->Add(m_faceListBox, 1, wxGROW|wxALL|wxFIXED_MINSIZE, 5); @@ -148,14 +154,14 @@ void wxRichTextFontPage::CreateControls() m_sizeTextCtrl = new wxTextCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, _T(""), wxDefaultPosition, wxSize(50, -1), 0 ); m_sizeTextCtrl->SetHelpText(_("Type a size in points.")); - if (ShowToolTips()) + if (wxRichTextFontPage::ShowToolTips()) m_sizeTextCtrl->SetToolTip(_("Type a size in points.")); itemBoxSizer9->Add(m_sizeTextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); - wxString* m_sizeListBoxStrings = NULL; - m_sizeListBox = new wxListBox( itemPanel1, ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxDefaultPosition, wxSize(50, -1), 0, m_sizeListBoxStrings, wxLB_SINGLE ); + wxArrayString m_sizeListBoxStrings; + m_sizeListBox = new wxListBox( itemPanel1, ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxDefaultPosition, wxSize(50, -1), m_sizeListBoxStrings, wxLB_SINGLE ); m_sizeListBox->SetHelpText(_("Lists font sizes in points.")); - if (ShowToolTips()) + if (wxRichTextFontPage::ShowToolTips()) m_sizeListBox->SetToolTip(_("Lists font sizes in points.")); itemBoxSizer9->Add(m_sizeListBox, 1, wxALIGN_CENTER_HORIZONTAL|wxALL|wxFIXED_MINSIZE, 5); @@ -168,10 +174,10 @@ void wxRichTextFontPage::CreateControls() wxStaticText* itemStaticText15 = new wxStaticText( itemPanel1, wxID_STATIC, _("Font st&yle:"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer14->Add(itemStaticText15, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - wxString* m_styleCtrlStrings = NULL; - m_styleCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTFONTPAGE_STYLECTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_styleCtrlStrings, wxCB_READONLY ); + wxArrayString m_styleCtrlStrings; + m_styleCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTFONTPAGE_STYLECTRL, _T(""), wxDefaultPosition, wxDefaultSize, m_styleCtrlStrings, wxCB_READONLY ); m_styleCtrl->SetHelpText(_("Select regular or italic style.")); - if (ShowToolTips()) + if (wxRichTextFontPage::ShowToolTips()) m_styleCtrl->SetToolTip(_("Select regular or italic style.")); itemBoxSizer14->Add(m_styleCtrl, 0, wxGROW|wxALL, 5); @@ -181,10 +187,10 @@ void wxRichTextFontPage::CreateControls() wxStaticText* itemStaticText18 = new wxStaticText( itemPanel1, wxID_STATIC, _("Font &weight:"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer17->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - wxString* m_weightCtrlStrings = NULL; - m_weightCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTFONTPAGE_WEIGHTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_weightCtrlStrings, wxCB_READONLY ); + wxArrayString m_weightCtrlStrings; + m_weightCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTFONTPAGE_WEIGHTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, m_weightCtrlStrings, wxCB_READONLY ); m_weightCtrl->SetHelpText(_("Select regular or bold.")); - if (ShowToolTips()) + if (wxRichTextFontPage::ShowToolTips()) m_weightCtrl->SetToolTip(_("Select regular or bold.")); itemBoxSizer17->Add(m_weightCtrl, 0, wxGROW|wxALL, 5); @@ -194,10 +200,10 @@ void wxRichTextFontPage::CreateControls() wxStaticText* itemStaticText21 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Underlining:"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer20->Add(itemStaticText21, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); - wxString* m_underliningCtrlStrings = NULL; - m_underliningCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_underliningCtrlStrings, wxCB_READONLY ); + wxArrayString m_underliningCtrlStrings; + m_underliningCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, _T(""), wxDefaultPosition, wxDefaultSize, m_underliningCtrlStrings, wxCB_READONLY ); m_underliningCtrl->SetHelpText(_("Select underlining or no underlining.")); - if (ShowToolTips()) + if (wxRichTextFontPage::ShowToolTips()) m_underliningCtrl->SetToolTip(_("Select underlining or no underlining.")); itemBoxSizer20->Add(m_underliningCtrl, 0, wxGROW|wxALL, 5); @@ -209,7 +215,7 @@ void wxRichTextFontPage::CreateControls() m_colourCtrl = new wxRichTextColourSwatchCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_COLOURCTRL, wxDefaultPosition, wxSize(40, 20), wxSIMPLE_BORDER ); m_colourCtrl->SetHelpText(_("Click to change the text colour.")); - if (ShowToolTips()) + if (wxRichTextFontPage::ShowToolTips()) m_colourCtrl->SetToolTip(_("Click to change the text colour.")); itemBoxSizer23->Add(m_colourCtrl, 0, wxALIGN_LEFT|wxALL, 5); @@ -219,22 +225,36 @@ void wxRichTextFontPage::CreateControls() m_strikethroughCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL, _("&Strikethrough"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE ); m_strikethroughCtrl->SetValue(false); m_strikethroughCtrl->SetHelpText(_("Check to show a line through the text.")); - if (ShowToolTips()) + if (wxRichTextFontPage::ShowToolTips()) m_strikethroughCtrl->SetToolTip(_("Check to show a line through the text.")); itemBoxSizer26->Add(m_strikethroughCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_capitalsCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTFONTPAGE_CAPSCTRL, _("Ca&pitals"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE ); m_capitalsCtrl->SetValue(false); m_capitalsCtrl->SetHelpText(_("Check to show the text in capitals.")); - if (ShowToolTips()) + if (wxRichTextFontPage::ShowToolTips()) m_capitalsCtrl->SetToolTip(_("Check to show the text in capitals.")); itemBoxSizer26->Add(m_capitalsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + m_superscriptCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTFONTPAGE_SUPERSCRIPT, _("Supe&rscript"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE ); + m_superscriptCtrl->SetValue(false); + m_superscriptCtrl->SetHelpText(_("Check to show the text in superscript.")); + if (wxRichTextFontPage::ShowToolTips()) + m_superscriptCtrl->SetToolTip(_("Check to show the text in superscript.")); + itemBoxSizer26->Add(m_superscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + m_subscriptCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTFONTPAGE_SUBSCRIPT, _("Subscrip&t"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE ); + m_subscriptCtrl->SetValue(false); + m_subscriptCtrl->SetHelpText(_("Check to show the text in subscript.")); + if (wxRichTextFontPage::ShowToolTips()) + m_subscriptCtrl->SetToolTip(_("Check to show the text in subscript.")); + itemBoxSizer26->Add(m_subscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - m_previewCtrl = new wxRichTextFontPreviewCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_PREVIEWCTRL, wxDefaultPosition, wxSize(100, 80), wxSIMPLE_BORDER ); + itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5); + + m_previewCtrl = new wxRichTextFontPreviewCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_PREVIEWCTRL, wxDefaultPosition, wxSize(100, 60), 0 ); m_previewCtrl->SetHelpText(_("Shows a preview of the font settings.")); - if (ShowToolTips()) + if (wxRichTextFontPage::ShowToolTips()) m_previewCtrl->SetToolTip(_("Shows a preview of the font settings.")); itemBoxSizer3->Add(m_previewCtrl, 0, wxGROW|wxALL, 5); @@ -358,6 +378,25 @@ bool wxRichTextFontPage::TransferDataFromWindow() attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_CAPITALS); } + if (m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED) + { + attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SUPERSCRIPT); + attr->SetTextEffects(attr->GetTextEffects() | wxTEXT_ATTR_EFFECT_SUPERSCRIPT); + attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SUBSCRIPT); + } + else if (m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED) + { + attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SUBSCRIPT); + attr->SetTextEffects(attr->GetTextEffects() | wxTEXT_ATTR_EFFECT_SUBSCRIPT); + attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SUPERSCRIPT); + } + else + { + // If they are undetermined, we don't want to include these flags in the text effects - the objects + // should retain their original style. + attr->SetTextEffectFlags(attr->GetTextEffectFlags() & ~(wxTEXT_ATTR_EFFECT_SUBSCRIPT|wxTEXT_ATTR_EFFECT_SUPERSCRIPT) ); + } + return true; } @@ -430,7 +469,7 @@ bool wxRichTextFontPage::TransferDataToWindow() if (attr->HasTextColour()) { - m_colourCtrl->SetBackgroundColour(attr->GetTextColour()); + m_colourCtrl->SetColour(attr->GetTextColour()); m_colourPresent = true; } @@ -455,11 +494,37 @@ bool wxRichTextFontPage::TransferDataToWindow() } else m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED); + + if ( attr->GetTextEffectFlags() & (wxTEXT_ATTR_EFFECT_SUPERSCRIPT | wxTEXT_ATTR_EFFECT_SUBSCRIPT) ) + { + if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_SUPERSCRIPT) + { + m_superscriptCtrl->Set3StateValue(wxCHK_CHECKED); + m_subscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); + } + else if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_SUBSCRIPT) + { + m_superscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); + m_subscriptCtrl->Set3StateValue(wxCHK_CHECKED); + } + else + { + m_superscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); + m_subscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); + } + } + else + { + m_superscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED); + m_subscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED); + } } else { m_strikethroughCtrl->Set3StateValue(wxCHK_UNDETERMINED); m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED); + m_superscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED); + m_subscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED); } UpdatePreview(); @@ -541,6 +606,11 @@ void wxRichTextFontPage::UpdatePreview() textEffects |= wxTEXT_ATTR_EFFECT_CAPITALS; } + if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED ) + textEffects |= wxTEXT_ATTR_EFFECT_SUPERSCRIPT; + else if ( m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED ) + textEffects |= wxTEXT_ATTR_EFFECT_SUBSCRIPT; + m_previewCtrl->SetFont(font); m_previewCtrl->SetTextEffects(textEffects); m_previewCtrl->Refresh(); @@ -715,4 +785,26 @@ void wxRichTextFontPage::OnCapsctrlClick( wxCommandEvent& WXUNUSED(event) ) UpdatePreview(); } +/*! + * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_SUPERSCRIPT + */ + +void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent& WXUNUSED(event) ) +{ + if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED) + m_subscriptCtrl->Set3StateValue( wxCHK_UNCHECKED ); + + UpdatePreview(); +} + +/*! + * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTFONTPAGE_SUBSCRIPT + */ + +void wxRichTextFontPage::OnRichtextfontpageSubscriptClick( wxCommandEvent& WXUNUSED(event) ) +{ + if ( m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED) + m_superscriptCtrl->Set3StateValue( wxCHK_UNCHECKED ); + UpdatePreview(); +}