From 58d415807b33b7f44cfb9a0e47f70d30f664484f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 11 Nov 2014 00:58:52 +0000 Subject: [PATCH] Set the initial text value of wxSpinCtrlGeneric correctly. The text control was left empty if the string value was not specified, but it should use the numeric initial value instead in this case. This notably affected wxSpinCtrlDouble under non-GTK platforms. Closes #16621. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@78117 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/generic/spinctlg.cpp | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 0a09cd51f9..f2b0cd09c1 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -590,6 +590,7 @@ wxMSW: - Fix compilation with C++Builder XE compiler (Nichka). - Fix best height of wxSlider with labels but without ticks (Artur Wieczorek). +- Fix initial text value of wxSpinCtrlDouble (Laurent Poujoulat). 3.0.2: (released 2014-10-06) diff --git a/src/generic/spinctlg.cpp b/src/generic/spinctlg.cpp index 3da88c9404..8209a30ae4 100644 --- a/src/generic/spinctlg.cpp +++ b/src/generic/spinctlg.cpp @@ -210,16 +210,6 @@ bool wxSpinCtrlGenericBase::Create(wxWindow *parent, m_max = max; m_increment = increment; - m_textCtrl = new wxSpinCtrlTextGeneric(this, value, style); - m_spinButton = new wxSpinCtrlButtonGeneric(this, style); - -#if wxUSE_TOOLTIPS - m_textCtrl->SetToolTip(GetToolTipText()); - m_spinButton->SetToolTip(GetToolTipText()); -#endif // wxUSE_TOOLTIPS - - m_spin_value = m_spinButton->GetValue(); - // the string value overrides the numeric one (for backwards compatibility // reasons and also because it is simpler to satisfy the string value which // comes much sooner in the list of arguments and leave the initial @@ -228,12 +218,19 @@ bool wxSpinCtrlGenericBase::Create(wxWindow *parent, { double d; if ( DoTextToValue(value, &d) ) - { m_value = d; - m_textCtrl->ChangeValue(DoValueToText(m_value)); - } } + m_textCtrl = new wxSpinCtrlTextGeneric(this, DoValueToText(m_value), style); + m_spinButton = new wxSpinCtrlButtonGeneric(this, style); + +#if wxUSE_TOOLTIPS + m_textCtrl->SetToolTip(GetToolTipText()); + m_spinButton->SetToolTip(GetToolTipText()); +#endif // wxUSE_TOOLTIPS + + m_spin_value = m_spinButton->GetValue(); + SetInitialSize(size); Move(pos);