Use enum class to represent NumericType
This is for better type safety.
This commit is contained in:
parent
e7ab6a6d53
commit
3cb3d62212
4 changed files with 19 additions and 10 deletions
|
|
@ -162,13 +162,22 @@ constexpr wxPGNumericValidationMode wxPG_PROPERTY_VALIDATION_WRAP { wxPGNumericV
|
||||||
class WXDLLIMPEXP_PROPGRID wxNumericPropertyValidator : public wxTextValidator
|
class WXDLLIMPEXP_PROPGRID wxNumericPropertyValidator : public wxTextValidator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum NumericType
|
enum class NumericType
|
||||||
{
|
{
|
||||||
Signed = 0,
|
Signed,
|
||||||
Unsigned,
|
Unsigned,
|
||||||
Float
|
Float
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY_3_2
|
||||||
|
wxDEPRECATED_MSG("use NumericType::Signed instead")
|
||||||
|
static const NumericType Signed = NumericType::Signed;
|
||||||
|
wxDEPRECATED_MSG("use NumericType::Unsigned instead")
|
||||||
|
static const NumericType Unsigned = NumericType::Unsigned;
|
||||||
|
wxDEPRECATED_MSG("use NumericType::Float instead")
|
||||||
|
static const NumericType Float = NumericType::Float;
|
||||||
|
#endif // WXWIN_COMPATIBILITY_3_2
|
||||||
|
|
||||||
wxNumericPropertyValidator( NumericType numericType, int base = 10 );
|
wxNumericPropertyValidator( NumericType numericType, int base = 10 );
|
||||||
virtual ~wxNumericPropertyValidator() = default;
|
virtual ~wxNumericPropertyValidator() = default;
|
||||||
virtual bool Validate(wxWindow* parent) override;
|
virtual bool Validate(wxWindow* parent) override;
|
||||||
|
|
|
||||||
|
|
@ -86,9 +86,9 @@ enum class wxPGNumericValidationMode
|
||||||
class wxNumericPropertyValidator : public wxTextValidator
|
class wxNumericPropertyValidator : public wxTextValidator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum NumericType
|
enum class NumericType
|
||||||
{
|
{
|
||||||
Signed = 0,
|
Signed,
|
||||||
Unsigned,
|
Unsigned,
|
||||||
Float
|
Float
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -632,7 +632,7 @@ wxValidator* wxArrayDoubleProperty::DoGetValidator() const
|
||||||
WX_PG_DOGETVALIDATOR_ENTRY()
|
WX_PG_DOGETVALIDATOR_ENTRY()
|
||||||
|
|
||||||
wxTextValidator* validator =
|
wxTextValidator* validator =
|
||||||
new wxNumericPropertyValidator(wxNumericPropertyValidator::Float);
|
new wxNumericPropertyValidator(wxNumericPropertyValidator::NumericType::Float);
|
||||||
|
|
||||||
// Accept also a delimiter and space character
|
// Accept also a delimiter and space character
|
||||||
validator->AddCharIncludes(m_delimiter);
|
validator->AddCharIncludes(m_delimiter);
|
||||||
|
|
|
||||||
|
|
@ -159,11 +159,11 @@ wxNumericPropertyValidator::
|
||||||
style |= wxFILTER_DIGITS;
|
style |= wxFILTER_DIGITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( numericType == Signed )
|
if ( numericType == NumericType::Signed )
|
||||||
{
|
{
|
||||||
allowedChars += wxS("-+");
|
allowedChars += wxS("-+");
|
||||||
}
|
}
|
||||||
else if ( numericType == Float )
|
else if ( numericType == NumericType::Float )
|
||||||
{
|
{
|
||||||
allowedChars += wxS("-+eE");
|
allowedChars += wxS("-+eE");
|
||||||
|
|
||||||
|
|
@ -515,7 +515,7 @@ wxValidator* wxIntProperty::GetClassValidator()
|
||||||
WX_PG_DOGETVALIDATOR_ENTRY()
|
WX_PG_DOGETVALIDATOR_ENTRY()
|
||||||
|
|
||||||
wxValidator* validator = new wxNumericPropertyValidator(
|
wxValidator* validator = new wxNumericPropertyValidator(
|
||||||
wxNumericPropertyValidator::Signed);
|
wxNumericPropertyValidator::NumericType::Signed);
|
||||||
|
|
||||||
WX_PG_DOGETVALIDATOR_EXIT(validator)
|
WX_PG_DOGETVALIDATOR_EXIT(validator)
|
||||||
#else
|
#else
|
||||||
|
|
@ -776,7 +776,7 @@ wxValidator* wxUIntProperty::DoGetValidator() const
|
||||||
WX_PG_DOGETVALIDATOR_ENTRY()
|
WX_PG_DOGETVALIDATOR_ENTRY()
|
||||||
|
|
||||||
wxValidator* validator = new wxNumericPropertyValidator(
|
wxValidator* validator = new wxNumericPropertyValidator(
|
||||||
wxNumericPropertyValidator::Unsigned,
|
wxNumericPropertyValidator::NumericType::Unsigned,
|
||||||
m_realBase);
|
m_realBase);
|
||||||
|
|
||||||
WX_PG_DOGETVALIDATOR_EXIT(validator)
|
WX_PG_DOGETVALIDATOR_EXIT(validator)
|
||||||
|
|
@ -1006,7 +1006,7 @@ wxFloatProperty::GetClassValidator()
|
||||||
WX_PG_DOGETVALIDATOR_ENTRY()
|
WX_PG_DOGETVALIDATOR_ENTRY()
|
||||||
|
|
||||||
wxValidator* validator = new wxNumericPropertyValidator(
|
wxValidator* validator = new wxNumericPropertyValidator(
|
||||||
wxNumericPropertyValidator::Float);
|
wxNumericPropertyValidator::NumericType::Float);
|
||||||
|
|
||||||
WX_PG_DOGETVALIDATOR_EXIT(validator)
|
WX_PG_DOGETVALIDATOR_EXIT(validator)
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue