Corrected wxRTC font dialog spin button behaviour

This commit is contained in:
JulianSmart
2015-08-18 16:42:45 +01:00
parent 51e766093e
commit 2611aeca04

View File

@@ -326,6 +326,8 @@ void wxRichTextFontPage::CreateControls()
////@end wxRichTextFontPage content construction
m_fontSizeSpinButtons->SetRange(0, 999);
m_faceListBox->UpdateFonts();
m_styleCtrl->Append(_("(none)"));
@@ -527,6 +529,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
{
wxString strSize = wxString::Format(wxT("%d"), attr->GetFontSize());
m_sizeTextCtrl->SetValue(strSize);
m_fontSizeSpinButtons->SetValue(attr->GetFontSize());
m_sizeUnitsCtrl->SetSelection(0);
if (m_sizeListBox->FindString(strSize) != wxNOT_FOUND)
m_sizeListBox->SetStringSelection(strSize);
@@ -535,6 +538,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
{
wxString strSize = wxString::Format(wxT("%d"), attr->GetFontSize());
m_sizeTextCtrl->SetValue(strSize);
m_fontSizeSpinButtons->SetValue(attr->GetFontSize());
m_sizeUnitsCtrl->SetSelection(1);
m_sizeListBox->SetSelection(wxNOT_FOUND);
}
@@ -870,9 +874,16 @@ void wxRichTextFontPage::OnSizeTextCtrlUpdated( wxCommandEvent& WXUNUSED(event)
if (m_dontUpdate)
return;
m_dontUpdate = true;
wxString strSize = m_sizeTextCtrl->GetValue();
if (!strSize.IsEmpty() && m_sizeListBox->FindString(strSize) != wxNOT_FOUND)
m_sizeListBox->SetStringSelection(strSize);
if (!strSize.IsEmpty())
m_fontSizeSpinButtons->SetValue(wxAtoi(strSize));
m_dontUpdate = false;
UpdatePreview();
}
@@ -887,6 +898,8 @@ void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent& event )
m_dontUpdate = true;
m_sizeTextCtrl->SetValue(event.GetString());
if (!event.GetString().IsEmpty())
m_fontSizeSpinButtons->SetValue(wxAtoi(event.GetString()));
m_dontUpdate = oldDontUpdate;
@@ -1047,17 +1060,33 @@ void wxRichTextFontPage::OnRichtextfontpageSizeUnitsSelected( wxCommandEvent& WX
void wxRichTextFontPage::OnRichtextfontpageSpinbuttonsUp( wxSpinEvent& WXUNUSED(event) )
{
if (m_dontUpdate)
return;
m_dontUpdate = true;
wxString text = m_sizeTextCtrl->GetValue();
int size = 12;
if (!text.IsEmpty())
{
int size = wxAtoi(text);
if (size > 0)
{
size ++;
m_sizeTextCtrl->SetValue(wxString::Format(wxT("%d"), size));
UpdatePreview();
}
size = wxAtoi(text);
size ++;
}
if (size < 1 || size > 999)
size = 12;
if (m_fontSizeSpinButtons->GetValue() != size)
m_fontSizeSpinButtons->SetValue(size);
wxString newText(wxString::Format(wxT("%d"), size));
m_sizeTextCtrl->SetValue(newText);
if (!newText.IsEmpty() && m_sizeListBox->FindString(newText) != wxNOT_FOUND)
m_sizeListBox->SetStringSelection(newText);
UpdatePreview();
m_dontUpdate = false;
}
/*!
@@ -1066,17 +1095,34 @@ void wxRichTextFontPage::OnRichtextfontpageSpinbuttonsUp( wxSpinEvent& WXUNUSED(
void wxRichTextFontPage::OnRichtextfontpageSpinbuttonsDown( wxSpinEvent& WXUNUSED(event) )
{
if (m_dontUpdate)
return;
m_dontUpdate = true;
wxString text = m_sizeTextCtrl->GetValue();
int size = 12;
if (!text.IsEmpty())
{
int size = wxAtoi(text);
if (size > 0)
{
size = wxAtoi(text);
if (size > 1)
size --;
m_sizeTextCtrl->SetValue(wxString::Format(wxT("%d"), size));
UpdatePreview();
}
}
if (size < 1 || size > 999)
size = 12;
if (m_fontSizeSpinButtons->GetValue() != size)
m_fontSizeSpinButtons->SetValue(size);
wxString newText(wxString::Format(wxT("%d"), size));
m_sizeTextCtrl->SetValue(newText);
if (!newText.IsEmpty() && m_sizeListBox->FindString(newText) != wxNOT_FOUND)
m_sizeListBox->SetStringSelection(newText);
UpdatePreview();
m_dontUpdate = false;
}
/*!