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:
Artur Wieczorek
2020-07-11 21:01:46 +02:00
parent 845988e0ed
commit 776b28cba7
2 changed files with 14 additions and 4 deletions

View File

@@ -585,6 +585,12 @@ double wxSpinCtrlGenericBase::AdjustToFitInRange(double value) const
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 )
m_textCtrl->InvalidateBestSize();
@@ -632,6 +638,10 @@ bool wxSpinCtrl::SetBase(int base)
if ( base == m_base )
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
// to call DoTextToValue() before changing the base...
double val;