X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/386af6a2fa349e16f9b8abd32e3fedf13f021686..6e13c1965f5fe259d4f9c6276cf90d2abe02c6cf:/src/common/valtext.cpp?ds=sidebyside diff --git a/src/common/valtext.cpp b/src/common/valtext.cpp index a14a082387..c3139ccfb6 100644 --- a/src/common/valtext.cpp +++ b/src/common/valtext.cpp @@ -34,6 +34,10 @@ #include #include +#ifdef __SALFORDC__ +#include +#endif + #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxTextValidator, wxValidator) @@ -134,6 +138,7 @@ bool wxTextValidator::Validate(wxWindow *parent) { if ( !m_includeList.Member(val) ) { + m_validatorWindow->SetFocus(); char buf[512]; sprintf(buf, _("%s is invalid."), (const char *)val); wxMessageBox(buf, _("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent); @@ -144,6 +149,7 @@ bool wxTextValidator::Validate(wxWindow *parent) { if ( m_excludeList.Member(val) ) { + m_validatorWindow->SetFocus(); char buf[512]; sprintf(buf, _("%s is invalid."), (const char *)val); wxMessageBox(buf, _("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent); @@ -152,6 +158,7 @@ bool wxTextValidator::Validate(wxWindow *parent) } if ( (m_validatorStyle & wxFILTER_ASCII) && !val.IsAscii() ) { + m_validatorWindow->SetFocus(); char buf[512]; sprintf(buf, _("%s should only contain ASCII characters."), (const char *)val); wxMessageBox(buf, _("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent); @@ -159,6 +166,7 @@ bool wxTextValidator::Validate(wxWindow *parent) } if ( (m_validatorStyle & wxFILTER_ALPHA) && !wxIsAlpha(val) ) { + m_validatorWindow->SetFocus(); char buf[512]; sprintf(buf, _("%s should only contain alphabetic characters."), (const char *)val); wxMessageBox(buf, _("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent); @@ -166,6 +174,7 @@ bool wxTextValidator::Validate(wxWindow *parent) } if ( (m_validatorStyle & wxFILTER_ALPHANUMERIC) && !wxIsAlphaNumeric(val)) { + m_validatorWindow->SetFocus(); char buf[512]; sprintf(buf, _("%s should only contain alphabetic or numeric characters."), (const char *)val); wxMessageBox(buf,_("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent); @@ -174,6 +183,7 @@ bool wxTextValidator::Validate(wxWindow *parent) if ( (m_validatorStyle & wxFILTER_NUMERIC) && !wxIsNumeric(val)) { + m_validatorWindow->SetFocus(); char buf[512]; sprintf(buf, _("%s should be numeric."), (const char *)val); wxMessageBox(buf, _("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent); @@ -264,7 +274,10 @@ void wxTextValidator::OnChar(wxKeyEvent& event) wxTextCtrl *textCtrl = (wxTextCtrl *)m_validatorWindow; int keyCode = event.KeyCode(); - if ( keyCode == WXK_DELETE || keyCode == WXK_RETURN || keyCode == WXK_BACK) + if (keyCode == WXK_DELETE || keyCode == WXK_RETURN || keyCode == WXK_BACK || + keyCode == WXK_HOME || keyCode == WXK_LEFT || keyCode == WXK_UP || + keyCode == WXK_RIGHT || keyCode == WXK_DOWN || keyCode == WXK_PRIOR || + keyCode == WXK_NEXT || keyCode == WXK_END || keyCode == WXK_HOME) { textCtrl->wxTextCtrl::OnChar(event); return ; @@ -285,7 +298,7 @@ void wxTextValidator::OnChar(wxKeyEvent& event) wxBell(); return; } - if ( (m_validatorStyle & wxFILTER_NUMERIC) && !isdigit(keyCode) && keyCode != '.' ) + if ( (m_validatorStyle & wxFILTER_NUMERIC) && !isdigit(keyCode) && keyCode != '.' && keyCode != '-') { wxBell(); return; @@ -300,6 +313,7 @@ static bool wxIsNumeric(const wxString& val) for ( i = 0; i < (int)val.Length(); i++) { if ((!isdigit(val[i])) && (val[i] != '.')) + if(!((i == 0) && (val[i] == '-'))) return FALSE; } return TRUE;