From cad632b9b066af6e71966e2aa6735f8eaee42008 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sun, 29 Oct 2017 21:12:08 -0400 Subject: [PATCH] Allow specification of range in the constructor arguments for brevity --- src/widgets/valnum.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/widgets/valnum.h b/src/widgets/valnum.h index 3a318790c..c24f9bb5b 100644 --- a/src/widgets/valnum.h +++ b/src/widgets/valnum.h @@ -168,13 +168,13 @@ public: void SetMin(ValueType min) { this->DoSetMin(min); - BaseValidator::m_minSet = true; + BaseValidator::m_minSet = (min != std::numeric_limits::min()); } void SetMax(ValueType max) { this->DoSetMax(max); - BaseValidator::m_maxSet = true; + BaseValidator::m_maxSet = (max != std::numeric_limits::max()); } void SetRange(ValueType min, ValueType max) @@ -342,11 +342,14 @@ public: // // Sets the range appropriately for the type, including setting 0 as the // minimal value for the unsigned types. - IntegerValidator(ValueType *value = NULL, int style = NUM_VAL_DEFAULT) + IntegerValidator( + ValueType *value = NULL, + int style = NUM_VAL_DEFAULT, + ValueType min = std::numeric_limits::min(), + ValueType max = std::numeric_limits::max()) : Base(value, style) { - this->DoSetMin(std::numeric_limits::min()); - this->DoSetMax(std::numeric_limits::max()); + this->SetRange(min, max); } // Clone is required by wxwidgets; implemented via copy constructor @@ -451,10 +454,12 @@ public: // Ctor specifying an explicit precision. FloatingPointValidator(int precision, ValueType *value = NULL, - int style = NUM_VAL_DEFAULT) + int style = NUM_VAL_DEFAULT, + ValueType min = -std::numeric_limits::max(), + ValueType max = std::numeric_limits::max()) : Base(value, style) { - DoSetMinMax(); + this->SetRange( min, max ); this->SetPrecision(precision); }