X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3638bb5c0d027f6bcf916836ccb114727b15f0f3..d8812c6e0e780fb2dae99bc352c5061f58793e14:/src/richtext/richtextfontpage.cpp diff --git a/src/richtext/richtextfontpage.cpp b/src/richtext/richtextfontpage.cpp index 9766ff38f8..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 } @@ -230,6 +236,20 @@ void wxRichTextFontPage::CreateControls() m_capitalsCtrl->SetToolTip(_("Check to show the text in capitals.")); itemBoxSizer26->Add(m_capitalsCtrl, 0, wxALIGN_CENTER_VERTICAL|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); + itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5); m_previewCtrl = new wxRichTextFontPreviewCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_PREVIEWCTRL, wxDefaultPosition, wxSize(100, 60), 0 ); @@ -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; } @@ -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(); +}