also fix handling of wxSP_ARROW_KEYS|wxSP_WRAP (see #10565)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59473 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -557,6 +557,7 @@ wxMSW:
|
|||||||
by modern apps.
|
by modern apps.
|
||||||
- Ellipsize long strings in wxStatusBar (Francesco Montorsi)
|
- Ellipsize long strings in wxStatusBar (Francesco Montorsi)
|
||||||
- Fix spurious repaint when changing tooltip text (Jonathan Liu).
|
- Fix spurious repaint when changing tooltip text (Jonathan Liu).
|
||||||
|
- Fix wxSP_WRAP and wxSP_ARROW_KEYS in wxSpinCtrlDouble (Andrew Radke).
|
||||||
|
|
||||||
wxX11:
|
wxX11:
|
||||||
|
|
||||||
|
@@ -110,8 +110,13 @@ protected:
|
|||||||
// Send the correct event type
|
// Send the correct event type
|
||||||
virtual void DoSendEvent() = 0;
|
virtual void DoSendEvent() = 0;
|
||||||
|
|
||||||
|
// check if the value is in range
|
||||||
bool InRange(double n) const { return (n >= m_min) && (n <= m_max); }
|
bool InRange(double n) const { return (n >= m_min) && (n <= m_max); }
|
||||||
|
|
||||||
|
// ensure that the value is in range wrapping it round if necessary
|
||||||
|
double AdjustToFitInRange(double value) const;
|
||||||
|
|
||||||
|
|
||||||
double m_value;
|
double m_value;
|
||||||
double m_min;
|
double m_min;
|
||||||
double m_max;
|
double m_max;
|
||||||
|
@@ -338,13 +338,7 @@ void wxSpinCtrlGenericBase::OnSpinButton(wxSpinEvent& event)
|
|||||||
if (((spin_value >= 0) && (m_spin_value >= 0)) || ((spin_value <= 0) && (m_spin_value <= 0)))
|
if (((spin_value >= 0) && (m_spin_value >= 0)) || ((spin_value <= 0) && (m_spin_value <= 0)))
|
||||||
step *= abs(spin_value - m_spin_value);
|
step *= abs(spin_value - m_spin_value);
|
||||||
|
|
||||||
double value = m_value + step*m_increment;
|
double value = AdjustToFitInRange(m_value + step*m_increment);
|
||||||
|
|
||||||
// Check for over/underflow wrapping around if necessary
|
|
||||||
if (value < m_min)
|
|
||||||
value = HasFlag(wxSP_WRAP) ? m_max : m_min;
|
|
||||||
if (value > m_max)
|
|
||||||
value = HasFlag(wxSP_WRAP) ? m_min : m_max;
|
|
||||||
|
|
||||||
// Ignore the edges when it wraps since the up/down event may be opposite
|
// Ignore the edges when it wraps since the up/down event may be opposite
|
||||||
// They are in GTK and Mac
|
// They are in GTK and Mac
|
||||||
@@ -356,7 +350,7 @@ void wxSpinCtrlGenericBase::OnSpinButton(wxSpinEvent& event)
|
|||||||
|
|
||||||
m_spin_value = spin_value;
|
m_spin_value = spin_value;
|
||||||
|
|
||||||
if (InRange(value) && DoSetValue(value))
|
if ( DoSetValue(value) )
|
||||||
DoSendEvent();
|
DoSendEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,6 +393,8 @@ void wxSpinCtrlGenericBase::OnTextChar(wxKeyEvent& event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
value = AdjustToFitInRange(value);
|
||||||
|
|
||||||
if ( m_textCtrl && m_textCtrl->IsModified() )
|
if ( m_textCtrl && m_textCtrl->IsModified() )
|
||||||
SyncSpinToText();
|
SyncSpinToText();
|
||||||
|
|
||||||
@@ -489,6 +485,16 @@ bool wxSpinCtrlGenericBase::DoSetValue(double val)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double wxSpinCtrlGenericBase::AdjustToFitInRange(double value) const
|
||||||
|
{
|
||||||
|
if (value < m_min)
|
||||||
|
value = HasFlag(wxSP_WRAP) ? m_max : m_min;
|
||||||
|
if (value > m_max)
|
||||||
|
value = HasFlag(wxSP_WRAP) ? m_min : m_max;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
void wxSpinCtrlGenericBase::DoSetRange(double min, double max)
|
void wxSpinCtrlGenericBase::DoSetRange(double min, double max)
|
||||||
{
|
{
|
||||||
m_min = min;
|
m_min = min;
|
||||||
|
Reference in New Issue
Block a user