From 20c7421a67d07bb954088c4154a69e792e325e85 Mon Sep 17 00:00:00 2001 From: Vsevolod V Gromov Date: Wed, 10 Apr 2019 15:31:46 +0300 Subject: [PATCH] Add Get{Min,Max,Range}() to numeric validator classes Just provide accessors matching the existing setters. Closes https://github.com/wxWidgets/wxWidgets/pull/1287, https://github.com/wxWidgets/wxWidgets/pull/1288 --- include/wx/valnum.h | 20 ++++++++++++++++++++ interface/wx/valnum.h | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/wx/valnum.h b/include/wx/valnum.h index 2e05bc6b15..024c383875 100644 --- a/include/wx/valnum.h +++ b/include/wx/valnum.h @@ -157,17 +157,33 @@ public: this->DoSetMin(min); } + ValueType GetMin() const + { + return static_cast(this->DoGetMin()); + } + void SetMax(ValueType max) { this->DoSetMax(max); } + ValueType GetMax() const + { + return static_cast(this->DoGetMax()); + } + void SetRange(ValueType min, ValueType max) { SetMin(min); SetMax(max); } + void GetRange(ValueType& min, ValueType& max) const + { + min = GetMin(); + max = GetMax(); + } + virtual bool TransferToWindow() wxOVERRIDE { if ( m_value ) @@ -288,7 +304,9 @@ protected: static bool FromString(const wxString& s, LongestValueType *value); void DoSetMin(LongestValueType min) { m_min = min; } + LongestValueType DoGetMin() const { return m_min; } void DoSetMax(LongestValueType max) { m_max = max; } + LongestValueType DoGetMax() const { return m_max; } bool IsInRange(LongestValueType value) const { @@ -390,7 +408,9 @@ protected: bool FromString(const wxString& s, LongestValueType *value) const; void DoSetMin(LongestValueType min) { m_min = min; } + LongestValueType DoGetMin() const { return m_min; } void DoSetMax(LongestValueType max) { m_max = max; } + LongestValueType DoGetMax() const { return m_max; } bool IsInRange(LongestValueType value) const { diff --git a/interface/wx/valnum.h b/interface/wx/valnum.h index 0fb243b4f5..a2fa0290ee 100644 --- a/interface/wx/valnum.h +++ b/interface/wx/valnum.h @@ -89,6 +89,13 @@ public: */ void SetMin(ValueType min); + /** + Gets the minimal value accepted by the validator. + + @since 3.1.3 + */ + ValueType GetMin() const; + /** Sets the maximal value accepted by the validator. @@ -96,6 +103,13 @@ public: */ void SetMax(ValueType max); + /** + Gets the maximum value accepted by the validator. + + @since 3.1.3 + */ + ValueType GetMax() const; + /** Sets both minimal and maximal values accepted by the validator. @@ -103,6 +117,12 @@ public: */ void SetRange(ValueType min, ValueType max); + /** + Gets both minimal and maximal values accepted by the validator. + + @since 3.1.3 + */ + void GetRange(ValueType& min, ValueType& max) const; /** Change the validator style.