Ensure initial value of generic wxSpinCtrl is always valid

Under MSW creating a wxSpinCtrl with a range of, say, 1..10 and the
default initial value of 0 sets its initial value to 1 (i.e. the closest
valid value) as expected, but the generic version still set it to the
invalid value of 0, which was unexpected, inconsistent and not useful.

Fix the generic version to follow MSW behaviour now and add a test
checking for this.
This commit is contained in:
Vadim Zeitlin
2021-08-17 22:05:49 +02:00
parent b66656fbec
commit ac1fa83c20
3 changed files with 31 additions and 7 deletions

View File

@@ -145,6 +145,9 @@ protected:
// check if the value is in range
bool InRange(double n) const { return (n >= m_min) && (n <= m_max); }
// adjust the value to fit the range and snap it to ticks if necessary
double AdjustAndSnap(double value) const;
// ensure that the value is in range wrapping it round if necessary
double AdjustToFitInRange(double value) const;