Don't allow wxSpinCtrl range to include negative values if base != 10 (wxOSX)
For the sake of consistency with another ports only unsigned hexadecimal numbers should be supported. To do so we need to prevent: - Setting a range including negative values if base == 16. - Setting base != 10 if current range includes negative values. Closes #18805.
This commit is contained in:
@@ -149,8 +149,8 @@ public:
|
|||||||
the numbers in the specified base when they are changed using the spin
|
the numbers in the specified base when they are changed using the spin
|
||||||
control arrows.
|
control arrows.
|
||||||
|
|
||||||
@note Under wxMSW and wxGTK setting a base to 16 is allowed only if
|
@note Setting a base to 16 is allowed only if current range does not
|
||||||
current range does not include negative values.
|
include negative values.
|
||||||
|
|
||||||
@param base
|
@param base
|
||||||
Numeric base, currently only 10 and 16 are supported.
|
Numeric base, currently only 10 and 16 are supported.
|
||||||
@@ -171,8 +171,8 @@ public:
|
|||||||
it is less than it now. However no @c wxEVT_SPINCTRL
|
it is less than it now. However no @c wxEVT_SPINCTRL
|
||||||
event is generated, even if it the value does change.
|
event is generated, even if it the value does change.
|
||||||
|
|
||||||
@note Under wxMSW and wxGTK setting a range including negative values
|
@note Setting a range including negative values is silently ignored
|
||||||
is silently ignored if current base is set to 16.
|
if current base is set to 16.
|
||||||
*/
|
*/
|
||||||
void SetRange(int minVal, int maxVal);
|
void SetRange(int minVal, int maxVal);
|
||||||
|
|
||||||
|
|||||||
@@ -585,6 +585,12 @@ double wxSpinCtrlGenericBase::AdjustToFitInRange(double value) const
|
|||||||
|
|
||||||
void wxSpinCtrlGenericBase::DoSetRange(double min, double max)
|
void wxSpinCtrlGenericBase::DoSetRange(double min, double max)
|
||||||
{
|
{
|
||||||
|
// Negative values in the range are allowed only if base == 10
|
||||||
|
if ( !wxSpinCtrlImpl::IsBaseCompatibleWithRange(min, max, GetBase()) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( min != m_min || max != m_max )
|
if ( min != m_min || max != m_max )
|
||||||
m_textCtrl->InvalidateBestSize();
|
m_textCtrl->InvalidateBestSize();
|
||||||
|
|
||||||
@@ -632,6 +638,10 @@ bool wxSpinCtrl::SetBase(int base)
|
|||||||
if ( base == m_base )
|
if ( base == m_base )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// For negative values in the range only base == 10 is allowed
|
||||||
|
if ( !wxSpinCtrlImpl::IsBaseCompatibleWithRange(m_min, m_max, base) )
|
||||||
|
return false;
|
||||||
|
|
||||||
// Update the current control contents to show in the new base: be careful
|
// Update the current control contents to show in the new base: be careful
|
||||||
// to call DoTextToValue() before changing the base...
|
// to call DoTextToValue() before changing the base...
|
||||||
double val;
|
double val;
|
||||||
|
|||||||
Reference in New Issue
Block a user