]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/valtext.cpp
Changed the "delete win" to the more proper "win->Destroy()" in
[wxWidgets.git] / src / common / valtext.cpp
index 117efff3153876a13947bf8cf04833d846040b76..7da74055f5c58e23358f79885b06c6da4b847937 100644 (file)
@@ -24,7 +24,8 @@
 #include <stdio.h>
 #include "wx/textctrl.h"
 #include "wx/utils.h"
 #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"
 #endif
 
 #include "wx/valtext.h"
@@ -41,6 +42,8 @@ BEGIN_EVENT_TABLE(wxTextValidator, wxValidator)
 END_EVENT_TABLE()
 #endif
 
 END_EVENT_TABLE()
 #endif
 
+static bool wxIsNumeric(const wxString& val);
+
 wxTextValidator::wxTextValidator(long style, wxString *val)
 {
        m_validatorStyle = style ;
 wxTextValidator::wxTextValidator(long style, wxString *val)
 {
        m_validatorStyle = style ;
@@ -131,9 +134,10 @@ bool wxTextValidator::Validate(wxWindow *parent)
        {
                if ( !m_includeList.Member(val) )
                {
        {
                if ( !m_includeList.Member(val) )
                {
+            m_validatorWindow->SetFocus();
                        char buf[512];
                        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;
                }
        }
                        return FALSE;
                }
        }
@@ -141,38 +145,44 @@ bool wxTextValidator::Validate(wxWindow *parent)
        {
                if ( m_excludeList.Member(val) )
                {
        {
                if ( m_excludeList.Member(val) )
                {
+            m_validatorWindow->SetFocus();
                        char buf[512];
                        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() )
        {
                        return FALSE;
                }
        }
        if ( (m_validatorStyle & wxFILTER_ASCII) && !val.IsAscii() )
        {
+            m_validatorWindow->SetFocus();
                        char buf[512];
                        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) )
        {
                        return FALSE;
        }
        if ( (m_validatorStyle & wxFILTER_ALPHA) && !wxIsAlpha(val) )
        {
+            m_validatorWindow->SetFocus();
                        char buf[512];
                        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))
        {
                        return FALSE;
        }
        if ( (m_validatorStyle & wxFILTER_ALPHANUMERIC) && !wxIsAlphaNumeric(val))
        {
+            m_validatorWindow->SetFocus();
                        char buf[512];
                        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;
        }
                        return FALSE;
        }
-       if ( (m_validatorStyle & wxFILTER_NUMERIC) && !val.IsNumber())
+       if ( (m_validatorStyle & wxFILTER_NUMERIC) && !wxIsNumeric(val))
+
        {
        {
+            m_validatorWindow->SetFocus();
                        char buf[512];
                        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;
        }
 
                        return FALSE;
        }
 
@@ -290,4 +300,14 @@ void wxTextValidator::OnChar(wxKeyEvent& event)
        textCtrl->wxTextCtrl::OnChar(event);
 }
 
        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] != '.'))
+                       return FALSE;
+       }
+       return TRUE;
+}