#include <stdio.h>
#include "wx/textctrl.h"
#include "wx/utils.h"
-#include "wx/msgbxdlg.h"
+#include "wx/msgdlg.h"
+#include "wx/intl.h"
#endif
#include "wx/valtext.h"
#include <string.h>
#include <stdlib.h>
+#ifdef __SALFORDC__
+#include <clib.h>
+#endif
+
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxTextValidator, wxValidator)
END_EVENT_TABLE()
#endif
+static bool wxIsNumeric(const wxString& val);
+
wxTextValidator::wxTextValidator(long style, wxString *val)
{
m_validatorStyle = style ;
{
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);
+ sprintf(buf, _("%s is invalid."), (const char *)val);
+ wxMessageBox(buf, _("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent);
return FALSE;
}
}
{
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);
+ sprintf(buf, _("%s is invalid."), (const char *)val);
+ wxMessageBox(buf, _("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent);
return FALSE;
}
}
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);
+ sprintf(buf, _("%s should only contain ASCII characters."), (const char *)val);
+ wxMessageBox(buf, _("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent);
return FALSE;
}
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);
+ sprintf(buf, _("%s should only contain alphabetic characters."), (const char *)val);
+ wxMessageBox(buf, _("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent);
return FALSE;
}
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);
+ sprintf(buf, _("%s should only contain alphabetic or numeric characters."), (const char *)val);
+ wxMessageBox(buf,_("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent);
return FALSE;
}
- if ( (m_validatorStyle & wxFILTER_NUMERIC) && !val.IsNumber())
+ 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);
+ sprintf(buf, _("%s should be numeric."), (const char *)val);
+ wxMessageBox(buf, _("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent);
return FALSE;
}
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 ;
wxBell();
return;
}
- if ( (m_validatorStyle & wxFILTER_NUMERIC) && !isdigit(keyCode) && keyCode != '.' )
+ if ( (m_validatorStyle & wxFILTER_NUMERIC) && !isdigit(keyCode) && keyCode != '.' && keyCode != '-')
{
wxBell();
return;
textCtrl->wxTextCtrl::OnChar(event);
}
+static bool wxIsNumeric(const wxString& val)
+{
+ int i;
+ for ( i = 0; i < (int)val.Length(); i++)
+ {
+ if ((!isdigit(val[i])) && (val[i] != '.'))
+ if(!((i == 0) && (val[i] == '-')))
+ return FALSE;
+ }
+ return TRUE;
+}