Made standard bullet names translatable

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61184 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2009-06-24 10:28:20 +00:00
parent 3c10f6db79
commit 04529b2af2
2 changed files with 39 additions and 7 deletions

View File

@@ -6489,10 +6489,10 @@ bool wxRichTextStdRenderer::DrawBitmapBullet(wxRichTextParagraph* WXUNUSED(parag
/// Enumerate the standard bullet names currently supported /// Enumerate the standard bullet names currently supported
bool wxRichTextStdRenderer::EnumerateStandardBulletNames(wxArrayString& bulletNames) bool wxRichTextStdRenderer::EnumerateStandardBulletNames(wxArrayString& bulletNames)
{ {
bulletNames.Add(wxT("standard/circle")); bulletNames.Add(wxTRANSLATE("standard/circle"));
bulletNames.Add(wxT("standard/square")); bulletNames.Add(wxTRANSLATE("standard/square"));
bulletNames.Add(wxT("standard/diamond")); bulletNames.Add(wxTRANSLATE("standard/diamond"));
bulletNames.Add(wxT("standard/triangle")); bulletNames.Add(wxTRANSLATE("standard/triangle"));
return true; return true;
} }

View File

@@ -301,7 +301,9 @@ void wxRichTextBulletsPage::CreateControls()
if (wxRichTextBuffer::GetRenderer()) if (wxRichTextBuffer::GetRenderer())
wxRichTextBuffer::GetRenderer()->EnumerateStandardBulletNames(standardBulletNames); 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(); wxArrayString facenames = wxRichTextCtrl::GetAvailableFontNames();
facenames.Sort(); facenames.Sort();
@@ -348,6 +350,21 @@ bool wxRichTextBulletsPage::TransferDataFromWindow()
else if (index == wxRICHTEXT_BULLETINDEX_STANDARD) else if (index == wxRICHTEXT_BULLETINDEX_STANDARD)
{ {
bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_STANDARD; bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_STANDARD;
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()); attr->SetBulletName(m_bulletNameCtrl->GetValue());
} }
@@ -466,7 +483,22 @@ bool wxRichTextBulletsPage::TransferDataToWindow()
m_numberCtrl->SetValue(0); m_numberCtrl->SetValue(0);
if (attr->HasBulletName()) if (attr->HasBulletName())
{
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()); m_bulletNameCtrl->SetValue(attr->GetBulletName());
}
else
m_bulletNameCtrl->SetValue(attr->GetBulletName());
}
else else
m_bulletNameCtrl->SetValue(wxEmptyString); m_bulletNameCtrl->SetValue(wxEmptyString);