]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextfontpage.cpp
Enable the correct code making sure that subwindows will always receive a wxSizeEvent...
[wxWidgets.git] / src / richtext / richtextfontpage.cpp
index 9766ff38f8426b00cc139781f283b756d1937994..87a3fb7830cac8839c841e051db099f876d955f3 100644 (file)
@@ -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 );
@@ -294,11 +314,11 @@ bool wxRichTextFontPage::TransferDataFromWindow()
 
     if (m_styleCtrl->GetSelection() != wxNOT_FOUND)
     {
-        int style;
+        wxFontStyle style;
         if (m_styleCtrl->GetStringSelection() == _("Italic"))
-            style = wxITALIC;
+            style = wxFONTSTYLE_ITALIC;
         else
-            style = wxNORMAL;
+            style = wxFONTSTYLE_NORMAL;
 
         attr->SetFontStyle(style);
     }
@@ -307,11 +327,11 @@ bool wxRichTextFontPage::TransferDataFromWindow()
 
     if (m_weightCtrl->GetSelection() != wxNOT_FOUND)
     {
-        int weight;
+        wxFontWeight weight;
         if (m_weightCtrl->GetStringSelection() == _("Bold"))
-            weight = wxBOLD;
+            weight = wxFONTWEIGHT_BOLD;
         else
-            weight = wxNORMAL;
+            weight = wxFONTWEIGHT_NORMAL;
 
         attr->SetFontWeight(weight);
     }
@@ -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();
+}