+// -----------------------------------------------------------------------
+// wxNumericPropertyValidator
+// -----------------------------------------------------------------------
+
+#if wxUSE_VALIDATORS
+
+wxNumericPropertyValidator::
+ wxNumericPropertyValidator( NumericType numericType, int base )
+ : wxTextValidator(wxFILTER_INCLUDE_CHAR_LIST)
+{
+ wxArrayString arr;
+ arr.Add(wxS("0"));
+ arr.Add(wxS("1"));
+ arr.Add(wxS("2"));
+ arr.Add(wxS("3"));
+ arr.Add(wxS("4"));
+ arr.Add(wxS("5"));
+ arr.Add(wxS("6"));
+ arr.Add(wxS("7"));
+
+ if ( base >= 10 )
+ {
+ arr.Add(wxS("8"));
+ arr.Add(wxS("9"));
+ if ( base >= 16 )
+ {
+ arr.Add(wxS("a")); arr.Add(wxS("A"));
+ arr.Add(wxS("b")); arr.Add(wxS("B"));
+ arr.Add(wxS("c")); arr.Add(wxS("C"));
+ arr.Add(wxS("d")); arr.Add(wxS("D"));
+ arr.Add(wxS("e")); arr.Add(wxS("E"));
+ arr.Add(wxS("f")); arr.Add(wxS("F"));
+ }
+ }
+
+ if ( numericType == Signed )
+ {
+ arr.Add(wxS("+"));
+ arr.Add(wxS("-"));
+ }
+ else if ( numericType == Float )
+ {
+ arr.Add(wxS("+"));
+ arr.Add(wxS("-"));
+ arr.Add(wxS("e"));
+
+ // Use locale-specific decimal point
+ arr.Add(wxString::Format("%g", 1.1)[1]);
+ }
+
+ SetIncludes(arr);
+}
+
+bool wxNumericPropertyValidator::Validate(wxWindow* parent)
+{
+ if ( !wxTextValidator::Validate(parent) )
+ return false;
+
+ wxWindow* wnd = GetWindow();
+ if ( !wnd->IsKindOf(CLASSINFO(wxTextCtrl)) )
+ return true;
+
+ // Do not allow zero-length string
+ wxTextCtrl* tc = static_cast<wxTextCtrl*>(wnd);
+ wxString text = tc->GetValue();
+
+ if ( !text.length() )
+ return false;
+
+ return true;
+}
+
+#endif // wxUSE_VALIDATORS
+