From d07f2e19181bc5caf29eb2338ce513be6fa42405 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 12 Sep 2012 18:58:30 +0000 Subject: [PATCH] Added support for wxTEXT_ATTR_EFFECT_SMALL_CAPITALS. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72465 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/richtext/richtextfontpage.h | 32 +++---- src/richtext/richtextbuffer.cpp | 18 +++- src/richtext/richtextdialogs.pjd | 112 +++++++++++++++++++------ src/richtext/richtextfontpage.cpp | 41 +++++++++ 4 files changed, 162 insertions(+), 41 deletions(-) diff --git a/include/wx/richtext/richtextfontpage.h b/include/wx/richtext/richtextfontpage.h index 7573391cce..087f0ad9f6 100644 --- a/include/wx/richtext/richtextfontpage.h +++ b/include/wx/richtext/richtextfontpage.h @@ -158,6 +158,7 @@ public: wxRichTextColourSwatchCtrl* m_bgColourCtrl; wxCheckBox* m_strikethroughCtrl; wxCheckBox* m_capitalsCtrl; + wxCheckBox* m_smallCapitalsCtrl; wxCheckBox* m_superscriptCtrl; wxCheckBox* m_subscriptCtrl; wxRichTextFontPreviewCtrl* m_previewCtrl; @@ -165,23 +166,24 @@ public: enum { ID_RICHTEXTFONTPAGE = 10000, ID_RICHTEXTFONTPAGE_FACETEXTCTRL = 10001, - ID_RICHTEXTFONTPAGE_SIZETEXTCTRL = 10005, - ID_RICHTEXTFONTPAGE_SPINBUTTONS = 10018, - ID_RICHTEXTFONTPAGE_SIZE_UNITS = 10017, - ID_RICHTEXTFONTPAGE_FACELISTBOX = 10002, + ID_RICHTEXTFONTPAGE_SIZETEXTCTRL = 10002, + ID_RICHTEXTFONTPAGE_SPINBUTTONS = 10003, + ID_RICHTEXTFONTPAGE_SIZE_UNITS = 10004, + ID_RICHTEXTFONTPAGE_FACELISTBOX = 10005, ID_RICHTEXTFONTPAGE_SIZELISTBOX = 10006, ID_RICHTEXTFONTPAGE_STYLECTRL = 10007, - ID_RICHTEXTFONTPAGE_WEIGHTCTRL = 10004, - ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL = 10008, - ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL = 10015, - ID_RICHTEXTFONTPAGE_COLOURCTRL = 10009, - ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL = 10016, - ID_RICHTEXTFONTPAGE_BGCOLOURCTRL = 10014, - ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL = 10010, - ID_RICHTEXTFONTPAGE_CAPSCTRL = 10011, - ID_RICHTEXTFONTPAGE_SUPERSCRIPT = 10012, - ID_RICHTEXTFONTPAGE_SUBSCRIPT = 10013, - ID_RICHTEXTFONTPAGE_PREVIEWCTRL = 10003 + ID_RICHTEXTFONTPAGE_WEIGHTCTRL = 10008, + ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL = 10009, + ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL = 10010, + ID_RICHTEXTFONTPAGE_COLOURCTRL = 10011, + ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL = 10012, + ID_RICHTEXTFONTPAGE_BGCOLOURCTRL = 10013, + ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL = 10014, + ID_RICHTEXTFONTPAGE_CAPSCTRL = 10015, + ID_RICHTEXTFONTPAGE_SMALLCAPSCTRL = 10016, + ID_RICHTEXTFONTPAGE_SUPERSCRIPT = 10017, + ID_RICHTEXTFONTPAGE_SUBSCRIPT = 10018, + ID_RICHTEXTFONTPAGE_PREVIEWCTRL = 10019 }; ////@end wxRichTextFontPage member variables diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index ff4505b10c..dbeab138df 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -6280,7 +6280,7 @@ bool wxRichTextPlainText::Draw(wxDC& dc, wxRichTextDrawingContext& context, cons wxString str = m_text; wxString toRemove = wxRichTextLineBreakChar; str.Replace(toRemove, wxT(" ")); - if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_CAPITALS)) + if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & (wxTEXT_ATTR_EFFECT_CAPITALS|wxTEXT_ATTR_EFFECT_SMALL_CAPITALS))) str.MakeUpper(); long len = range.GetLength(); @@ -6296,6 +6296,13 @@ bool wxRichTextPlainText::Draw(wxDC& dc, wxRichTextDrawingContext& context, cons int x, y; if ( textFont.IsOk() ) { + if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_SMALL_CAPITALS)) + { + textFont.SetPointSize((int) (textFont.GetPointSize()*0.75)); + wxCheckSetFont(dc, textFont); + charHeight = dc.GetCharHeight(); + } + if ( textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_SUPERSCRIPT) ) { if (textFont.IsUsingSizeInPixels()) @@ -6634,6 +6641,13 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz wxCheckSetFont(dc, textFont); bScript = true; } + else if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_SMALL_CAPITALS)) + { + wxFont textFont = font; + textFont.SetPointSize((int) (textFont.GetPointSize()*0.75)); + wxCheckSetFont(dc, textFont); + bScript = true; + } else { wxCheckSetFont(dc, font); @@ -6650,7 +6664,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz wxString stringChunk = str.Mid(startPos, (size_t) len); - if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_CAPITALS)) + if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & (wxTEXT_ATTR_EFFECT_CAPITALS|wxTEXT_ATTR_EFFECT_SMALL_CAPITALS))) stringChunk.MakeUpper(); wxCoord w, h; diff --git a/src/richtext/richtextdialogs.pjd b/src/richtext/richtextdialogs.pjd index f8a4d16e04..31eae6998b 100644 --- a/src/richtext/richtextdialogs.pjd +++ b/src/richtext/richtextdialogs.pjd @@ -308,14 +308,6 @@ "wbBoxSizerProxy" "Vertical" "" - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 0 0 0 @@ -683,7 +675,7 @@ "wbTextCtrlProxy" "wxEVT_COMMAND_TEXT_UPDATED|OnSizeTextCtrlUpdated" "ID_RICHTEXTFONTPAGE_SIZETEXTCTRL" - 10005 + 10002 "" "wxTextCtrl" "wxTextCtrl" @@ -767,7 +759,7 @@ "wxEVT_SCROLL_LINEUP|OnRichtextfontpageSpinbuttonsUp|NONE||wxRichTextFontPage" "wxEVT_SCROLL_LINEDOWN|OnRichtextfontpageSpinbuttonsDown|NONE||wxRichTextFontPage" "ID_RICHTEXTFONTPAGE_SPINBUTTONS" - 10018 + 10003 "" "wxSpinButton" "wxSpinButton" @@ -839,7 +831,7 @@ "wbChoiceProxy" "wxEVT_COMMAND_CHOICE_SELECTED|OnRichtextfontpageSizeUnitsSelected|NONE||wxRichTextFontPage" "ID_RICHTEXTFONTPAGE_SIZE_UNITS" - 10017 + 10004 "" "wxChoice" "wxChoice" @@ -925,7 +917,7 @@ 0 "wbForeignCtrlProxy" "ID_RICHTEXTFONTPAGE_FACELISTBOX" - 10002 + 10005 "" "wxRichTextFontListBox" "wxWindow" @@ -1356,7 +1348,7 @@ "wbComboBoxProxy" "wxEVT_COMMAND_COMBOBOX_SELECTED|OnWeightCtrlSelected" "ID_RICHTEXTFONTPAGE_WEIGHTCTRL" - 10004 + 10008 "" "wxComboBox" "wxComboBox" @@ -1519,7 +1511,7 @@ "wbComboBoxProxy" "wxEVT_COMMAND_COMBOBOX_SELECTED|OnUnderliningCtrlSelected" "ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL" - 10008 + 10009 "" "wxComboBox" "wxComboBox" @@ -1635,7 +1627,7 @@ "wbCheckBoxProxy" "wxEVT_COMMAND_CHECKBOX_CLICKED|OnUnderliningCtrlSelected|NONE||wxRichTextFontPage" "ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL" - 10015 + 10010 "" "wxCheckBox" "wxCheckBox" @@ -1699,7 +1691,7 @@ "2/10/2006" "wbForeignCtrlProxy" "ID_RICHTEXTFONTPAGE_COLOURCTRL" - 10009 + 10011 "" "wxRichTextColourSwatchCtrl" "wxWindow" @@ -1795,7 +1787,7 @@ "wbCheckBoxProxy" "wxEVT_COMMAND_CHECKBOX_CLICKED|OnUnderliningCtrlSelected|NONE||wxRichTextFontPage" "ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL" - 10016 + 10012 "" "wxCheckBox" "wxCheckBox" @@ -1858,7 +1850,7 @@ 0 "wbForeignCtrlProxy" "ID_RICHTEXTFONTPAGE_BGCOLOURCTRL" - 10014 + 10013 "" "wxRichTextColourSwatchCtrl" "wxWindow" @@ -1955,9 +1947,9 @@ 0 "8/11/2006" "wbCheckBoxProxy" - "wxEVT_COMMAND_CHECKBOX_CLICKED|OnStrikethroughctrlClick" + "wxEVT_COMMAND_CHECKBOX_CLICKED|OnStrikethroughctrlClick|||wxRichTextFontPage" "ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL" - 10010 + 10014 "" "wxCheckBox" "wxCheckBox" @@ -2022,7 +2014,7 @@ "wbCheckBoxProxy" "wxEVT_COMMAND_CHECKBOX_CLICKED|OnCapsctrlClick" "ID_RICHTEXTFONTPAGE_CAPSCTRL" - 10011 + 10015 "" "wxCheckBox" "wxCheckBox" @@ -2074,6 +2066,70 @@ "" "" + + "wxCheckBox: ID_RICHTEXTFONTPAGE_SMALLCAPSCTRL" + "dialog-control-document" + "" + "checkbox" + 0 + 1 + 0 + 0 + "wbCheckBoxProxy" + "wxEVT_COMMAND_CHECKBOX_CLICKED|OnCapsctrlClick|||wxRichTextFontPage" + "ID_RICHTEXTFONTPAGE_SMALLCAPSCTRL" + 10016 + "" + "wxCheckBox" + "wxCheckBox" + 1 + 0 + "" + "" + "m_smallCapitalsCtrl" + "Small C&apitals" + 0 + "Check to show the text in small capitals." + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + 0 + 1 + "<Any platform>" + 0 + 0 + 1 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + "wxCheckBox: ID_RICHTEXTFONTPAGE_SUPERSCRIPT" "dialog-control-document" @@ -2087,7 +2143,7 @@ "wbCheckBoxProxy" "wxEVT_COMMAND_CHECKBOX_CLICKED|OnRichtextfontpageSuperscriptClick|NONE||wxRichTextFontPage" "ID_RICHTEXTFONTPAGE_SUPERSCRIPT" - 10012 + 10017 "" "wxCheckBox" "wxCheckBox" @@ -2152,7 +2208,7 @@ "wbCheckBoxProxy" "wxEVT_COMMAND_CHECKBOX_CLICKED|OnRichtextfontpageSubscriptClick|NONE||wxRichTextFontPage" "ID_RICHTEXTFONTPAGE_SUBSCRIPT" - 10013 + 10018 "" "wxCheckBox" "wxCheckBox" @@ -2243,7 +2299,7 @@ "2/10/2006" "wbForeignCtrlProxy" "ID_RICHTEXTFONTPAGE_PREVIEWCTRL" - 10003 + 10019 "" "wxRichTextFontPreviewCtrl" "wxWindow" @@ -14824,6 +14880,14 @@ "wbBoxSizerProxy" "Vertical" "" + "Centre" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 0 0 0 diff --git a/src/richtext/richtextfontpage.cpp b/src/richtext/richtextfontpage.cpp index 32427ab2ba..d90e5024b6 100644 --- a/src/richtext/richtextfontpage.cpp +++ b/src/richtext/richtextfontpage.cpp @@ -54,6 +54,8 @@ BEGIN_EVENT_TABLE( wxRichTextFontPage, wxRichTextDialogPage ) EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_CAPSCTRL, wxRichTextFontPage::OnCapsctrlClick ) + EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SMALLCAPSCTRL, wxRichTextFontPage::OnCapsctrlClick ) + EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SUPERSCRIPT, wxRichTextFontPage::OnRichtextfontpageSuperscriptClick ) EVT_CHECKBOX( ID_RICHTEXTFONTPAGE_SUBSCRIPT, wxRichTextFontPage::OnRichtextfontpageSubscriptClick ) @@ -105,6 +107,7 @@ void wxRichTextFontPage::Init() m_bgColourCtrl = NULL; m_strikethroughCtrl = NULL; m_capitalsCtrl = NULL; + m_smallCapitalsCtrl = NULL; m_superscriptCtrl = NULL; m_subscriptCtrl = NULL; m_previewCtrl = NULL; @@ -293,6 +296,13 @@ void wxRichTextFontPage::CreateControls() m_capitalsCtrl->SetToolTip(_("Check to show the text in capitals.")); itemBoxSizer34->Add(m_capitalsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + m_smallCapitalsCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SMALLCAPSCTRL, _("Small C&apitals"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER ); + m_smallCapitalsCtrl->SetValue(false); + m_smallCapitalsCtrl->SetHelpText(_("Check to show the text in small capitals.")); + if (wxRichTextFontPage::ShowToolTips()) + m_smallCapitalsCtrl->SetToolTip(_("Check to show the text in small capitals.")); + itemBoxSizer34->Add(m_smallCapitalsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + m_superscriptCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SUPERSCRIPT, _("Supe&rscript"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER ); m_superscriptCtrl->SetValue(false); m_superscriptCtrl->SetHelpText(_("Check to show the text in superscript.")); @@ -455,6 +465,21 @@ bool wxRichTextFontPage::TransferDataFromWindow() attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_CAPITALS); } + if (m_smallCapitalsCtrl->Get3StateValue() != wxCHK_UNDETERMINED) + { + attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SMALL_CAPITALS); + + if (m_smallCapitalsCtrl->Get3StateValue() == wxCHK_CHECKED) + attr->SetTextEffects(attr->GetTextEffects() | wxTEXT_ATTR_EFFECT_SMALL_CAPITALS); + else + attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SMALL_CAPITALS); + } + else + { + attr->SetTextEffectFlags(attr->GetTextEffectFlags() & ~wxTEXT_ATTR_EFFECT_SMALL_CAPITALS); + attr->SetTextEffects(attr->GetTextEffects() & ~wxTEXT_ATTR_EFFECT_SMALL_CAPITALS); + } + if (m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED) { attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SUPERSCRIPT); @@ -602,6 +627,16 @@ bool wxRichTextFontPage::TransferDataToWindow() else m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED); + if (attr->GetTextEffectFlags() & wxTEXT_ATTR_EFFECT_SMALL_CAPITALS) + { + if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_SMALL_CAPITALS) + m_smallCapitalsCtrl->Set3StateValue(wxCHK_CHECKED); + else + m_smallCapitalsCtrl->Set3StateValue(wxCHK_UNCHECKED); + } + else + m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED); + if ( attr->GetTextEffectFlags() & (wxTEXT_ATTR_EFFECT_SUPERSCRIPT | wxTEXT_ATTR_EFFECT_SUBSCRIPT) ) { if (attr->GetTextEffects() & wxTEXT_ATTR_EFFECT_SUPERSCRIPT) @@ -630,6 +665,7 @@ bool wxRichTextFontPage::TransferDataToWindow() { m_strikethroughCtrl->Set3StateValue(wxCHK_UNDETERMINED); m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED); + m_smallCapitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED); m_superscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED); m_subscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED); } @@ -740,6 +776,11 @@ void wxRichTextFontPage::UpdatePreview() textEffects |= wxTEXT_ATTR_EFFECT_CAPITALS; } + if (m_smallCapitalsCtrl->Get3StateValue() == wxCHK_CHECKED) + { + textEffects |= wxTEXT_ATTR_EFFECT_SMALL_CAPITALS; + } + if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED ) textEffects |= wxTEXT_ATTR_EFFECT_SUPERSCRIPT; else if ( m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED )