]> git.saurik.com Git - wxWidgets.git/commitdiff
Made standard bullet names translatable
authorJulian Smart <julian@anthemion.co.uk>
Wed, 24 Jun 2009 10:28:20 +0000 (10:28 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Wed, 24 Jun 2009 10:28:20 +0000 (10:28 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61184 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/richtext/richtextbuffer.cpp
src/richtext/richtextbulletspage.cpp

index 7ac71cfc9f83495c530da56f1e19f2ee6102cd4a..53853c6ef9f18b6dcaa7dacbdb938d0b9a5922a2 100644 (file)
@@ -6489,10 +6489,10 @@ bool wxRichTextStdRenderer::DrawBitmapBullet(wxRichTextParagraph* WXUNUSED(parag
 /// Enumerate the standard bullet names currently supported
 bool wxRichTextStdRenderer::EnumerateStandardBulletNames(wxArrayString& bulletNames)
 {
-    bulletNames.Add(wxT("standard/circle"));
-    bulletNames.Add(wxT("standard/square"));
-    bulletNames.Add(wxT("standard/diamond"));
-    bulletNames.Add(wxT("standard/triangle"));
+    bulletNames.Add(wxTRANSLATE("standard/circle"));
+    bulletNames.Add(wxTRANSLATE("standard/square"));
+    bulletNames.Add(wxTRANSLATE("standard/diamond"));
+    bulletNames.Add(wxTRANSLATE("standard/triangle"));
 
     return true;
 }
index 1ba53c80a5d903e2164994125853da09727581ee..e8a1ff6101fc5ba4da1872f18d0133c372345005 100644 (file)
@@ -301,7 +301,9 @@ void wxRichTextBulletsPage::CreateControls()
     if (wxRichTextBuffer::GetRenderer())
         wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames);
 
-    m_bulletNameCtrl->Append(standardBulletNames);
+    size_t i;
+    for (i = 0; i < standardBulletNames.GetCount(); i++)
+        m_bulletNameCtrl->Append(wxGetTranslation(standardBulletNames[i]));
 
     wxArrayString facenames = wxRichTextCtrl::GetAvailableFontNames();
     facenames.Sort();
@@ -348,7 +350,22 @@ bool wxRichTextBulletsPage::TransferDataFromWindow()
         else if (index == wxRICHTEXT_BULLETINDEX_STANDARD)
         {
             bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_STANDARD;
-            attr->SetBulletName(m_bulletNameCtrl->GetValue());
+            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())
@@ -466,7 +483,22 @@ bool wxRichTextBulletsPage::TransferDataToWindow()
         m_numberCtrl->SetValue(0);
 
     if (attr->HasBulletName())
-        m_bulletNameCtrl->SetValue(attr->GetBulletName());
+    {
+        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);