]> git.saurik.com Git - wxWidgets.git/commitdiff
1. validator fixes: don't eat TAB. Added new SetBellOnError() function to
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 25 Feb 1999 14:47:18 +0000 (14:47 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 25 Feb 1999 14:47:18 +0000 (14:47 +0000)
   suppress _annoying_ bell.
2. Docs and samples updated to reflect this.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1791 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/validatr.tex
include/wx/gtk/listbox.h
include/wx/gtk1/listbox.h
include/wx/validate.h
samples/validate/validate.cpp
samples/validate/validate.h
src/common/validate.cpp
src/common/valtext.cpp

index 2bbb2f7dd39ba9e2d89fd4d63867e310db096a7e..b6319b0a39dfafb8b688d598e0a8e3f996b2d3ac 100644 (file)
@@ -64,6 +64,13 @@ This base function returns NULL.
 
 Returns the window associated with the validator.
 
+\membersection{wxValidator::SetBellOnError}{wxvalidatorsetbellonerror}
+
+\func{void}{SetBellOnError}{\param{bool}{ doIt = TRUE}}
+
+This functions switches on or turns off the error sound produced by the
+validators if an invalid key is pressed.
+
 \membersection{wxValidator::SetWindow}\label{wxvalidatorsetwindow}
 
 \func{void}{SetWindow}{\param{wxWindow*}{ window}}
index 2a5f428da1a75343b65a1c9b29383639908df0d6..6fa8de11cdbaa67835feb199d6e7ec7c82c81359 100644 (file)
@@ -68,6 +68,8 @@ public:
     void Append( const wxString &item, void* clientData );
     void Append( const wxString &item, wxClientData* clientData );
 
+    void InsertItems(int nItems, const wxString items[], int pos);
+
     void SetClientData( int n, void* clientData );
     void* GetClientData( int n );
     void SetClientObject( int n, wxClientData* clientData );
index 2a5f428da1a75343b65a1c9b29383639908df0d6..6fa8de11cdbaa67835feb199d6e7ec7c82c81359 100644 (file)
@@ -68,6 +68,8 @@ public:
     void Append( const wxString &item, void* clientData );
     void Append( const wxString &item, wxClientData* clientData );
 
+    void InsertItems(int nItems, const wxString items[], int pos);
+
     void SetClientData( int n, void* clientData );
     void* GetClientData( int n );
     void SetClientObject( int n, wxClientData* clientData );
index a67d9cba9b88463a9d769224b409a81af8daeb1c..1cb97fe6049adecddd6e99f8973689059f9826d9 100644 (file)
@@ -6,14 +6,14 @@
 // Created:     29/01/98
 // RCS-ID:      $Id$
 // Copyright:   (c) 1998 Julian Smart
-// Licence:    wxWindows license
+// Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
 #ifndef _WX_VALIDATEH__
 #define _WX_VALIDATEH__
 
 #ifdef __GNUG__
-#pragma interface "validate.h"
+    #pragma interface "validate.h"
 #endif
 
 #include "wx/event.h"
@@ -30,38 +30,49 @@ class WXDLLEXPORT wxWindow;
     to intercept e.g. OnChar.
 
  Note that wxValidator and derived classes use reference counting.
- */
+*/
 
-class WXDLLEXPORT wxValidator: public wxEvtHandler
+class WXDLLEXPORT wxValidator : public wxEvtHandler
 {
-DECLARE_DYNAMIC_CLASS(wxValidator)
 public:
-  wxValidator(void);
-  ~wxValidator();
+    wxValidator();
+    ~wxValidator();
 
-  // Make a clone of this validator (or return NULL) - currently necessary
-  // if you're passing a reference to a validator.
-  // Another possibility is to always pass a pointer to a new validator
-  // (so the calling code can use a copy constructor of the relevant class).
-  virtual wxValidator *Clone(void) const { return (wxValidator *) NULL; }
-  inline bool Copy(const wxValidator& val) { m_validatorWindow = val.m_validatorWindow; return TRUE; }
+    // Make a clone of this validator (or return NULL) - currently necessary
+    // if you're passing a reference to a validator.
+    // Another possibility is to always pass a pointer to a new validator
+    // (so the calling code can use a copy constructor of the relevant class).
+    virtual wxValidator *Clone() const
+        { return (wxValidator *)NULL; }
+    bool Copy(const wxValidator& val)
+        { m_validatorWindow = val.m_validatorWindow; return TRUE; }
 
-  // Called when the value in the window must be validated.
-  // This function can pop up an error message.
-  virtual bool Validate(wxWindow *WXUNUSED(parent)) { return FALSE; };
+    // Called when the value in the window must be validated.
+    // This function can pop up an error message.
+    virtual bool Validate(wxWindow *WXUNUSED(parent)) { return FALSE; };
 
-  // Called to transfer data to the window
-  virtual bool TransferToWindow(void) { return FALSE; }
+    // Called to transfer data to the window
+    virtual bool TransferToWindow() { return FALSE; }
 
-  // Called to transfer data from the window
-  virtual bool TransferFromWindow(void) { return FALSE; };
+    // Called to transfer data from the window
+    virtual bool TransferFromWindow() { return FALSE; };
 
-  // ACCESSORS
-  inline wxWindow *GetWindow(void) const { return m_validatorWindow; }
-  inline void SetWindow(wxWindow *win) { m_validatorWindow = win; }
+    // accessors
+    wxWindow *GetWindow() const { return m_validatorWindow; }
+    void SetWindow(wxWindow *win) { m_validatorWindow = win; }
+
+    // validators beep by default if invalid key is pressed, these functions
+    // allow to change it
+    static bool IsSilent() { return ms_isSilent; }
+    static void SetBellOnError(bool doIt = TRUE) { ms_isSilent = doIt; }
 
 protected:
     wxWindow *m_validatorWindow;
+
+private:
+    static bool ms_isSilent;
+
+    DECLARE_DYNAMIC_CLASS(wxValidator)
 };
 
 WXDLLEXPORT_DATA(extern const wxValidator) wxDefaultValidator;
index 334150af31db059c632f2e5fc411c072b7c79fc8..6049dac8caa2e267edb0ecc2d0a25755382ef85b 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     04/01/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart and Markus Holzem
-// Licence:    wxWindows license
+// Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
 #ifdef __GNUG__
 #include "validate.h"
 
 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
-       EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
-       EVT_MENU(VALIDATE_TEST_DIALOG, MyFrame::OnTestDialog)
+    EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
+    EVT_MENU(VALIDATE_TEST_DIALOG, MyFrame::OnTestDialog)
+    EVT_MENU(VALIDATE_SILENT, MyFrame::OnSilent)
 END_EVENT_TABLE()
 
 IMPLEMENT_APP(MyApp)
 
-MyData g_data;
+MyData g_data;
 
-bool MyApp::OnInit(void)
+bool MyApp::OnInit()
 {
   // Create the main frame window
-  MyFrame *frame = new MyFrame((wxFrame *) NULL, (char *) "Validation Test", 50, 50, 300, 250);
+  MyFrame *frame = new MyFrame((wxFrame *) NULL, "Validation Test", 50, 50, 300, 250);
 
+  // Show the frame
+  frame->Show(TRUE);
+
+  SetTopWindow(frame);
+
+  return TRUE;
+}
+
+// My frame constructor
+MyFrame::MyFrame(wxFrame *frame, const char *title, int x, int y, int w, int h)
+       : wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
+{
   // Give it an icon
 #ifdef __WXMSW__
-  frame->SetIcon(wxIcon("mondrian"));
+  SetIcon(wxIcon("mondrian"));
 #endif
 #ifdef __X__
-  frame->SetIcon(wxIcon("aiai.xbm"));
+  SetIcon(wxIcon("aiai.xbm"));
 #endif
 
   // Make a menubar
   wxMenu *file_menu = new wxMenu;
 
-  file_menu->Append(VALIDATE_TEST_DIALOG, "&Test dialog");
+  file_menu->Append(VALIDATE_TEST_DIALOG, "&Test dialog", "Show example dialog");
+  file_menu->Append(VALIDATE_SILENT, "&Bell on error", "Toggle bell on error", TRUE);
+  file_menu->AppendSeparator();
   file_menu->Append(wxID_EXIT, "E&xit");
-  wxMenuBar *menu_bar = new wxMenuBar;
-  menu_bar->Append(file_menu, "File");
-  frame->SetMenuBar(menu_bar);
-
-  frame->CreateStatusBar(1);
 
-  // Show the frame
-  frame->Show(TRUE);
+  file_menu->Check(VALIDATE_SILENT, wxValidator::IsSilent());
 
-  SetTopWindow(frame);
+  wxMenuBar *menu_bar = new wxMenuBar;
+  menu_bar->Append(file_menu, "File");
+  SetMenuBar(menu_bar);
 
-  return TRUE;  
+  CreateStatusBar(1);
 }
 
-// My frame constructor
-MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h):
-  wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
-{}
-
 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
 {
-  Close(TRUE);
+    Close(TRUE);
 }
 
 void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event))
 {
-       MyDialog dialog(this, "Validation test dialog", wxPoint(100, 100), wxSize(340, 170));
+    MyDialog dialog(this, "Validation test dialog", wxPoint(100, 100), wxSize(340, 170));
+
+    dialog.ShowModal();
+}
+
+void MyFrame::OnSilent(wxCommandEvent& event)
+{
+    static bool s_silent = FALSE;
+
+    s_silent = !s_silent;
+    wxValidator::SetBellOnError(s_silent);
 
-       dialog.ShowModal();
+    event.Skip();
 }
 
-MyDialog::MyDialog( wxWindow *parent, const wxString& title, 
+MyDialog::MyDialog( wxWindow *parent, const wxString& title,
                     const wxPoint& pos, const wxSize& size, const long WXUNUSED(style) ) :
-       wxDialog(parent, VALIDATE_DIALOG_ID, title, pos, size, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL)
+    wxDialog(parent, VALIDATE_DIALOG_ID, title, pos, size, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL)
 {
   wxButton *but1 = new wxButton(this, wxID_OK, "OK", wxPoint(250, 10), wxSize(80, 30));
   (void)new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(250, 60), wxSize(80, 30));
index 5b761fd32151567adf7484164de988c831d1dc44..cdb560303c83c1ab7410a1c64cea70312a6f5795 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     04/01/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart and Markus Holzem
-// Licence:    wxWindows license
+// Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
 #ifdef __GNUG__
 #endif
 
 // Define a new application type
-class MyApp: public wxApp
-{ public:
-    bool OnInit(void);
+class MyApp : public wxApp
+{
+public:
+    bool OnInit();
 };
 
 // Define a new frame type
-class MyFrame: public wxFrame
-{ public:
-    MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h);
-    
- public:
+class MyFrame : public wxFrame
+{
+public:
+    MyFrame(wxFrame *frame, const char *title, int x, int y, int w, int h);
+
     void OnQuit(wxCommandEvent& event);
     void OnTestDialog(wxCommandEvent& event);
+    void OnSilent(wxCommandEvent& event);
 
-   DECLARE_EVENT_TABLE()
-    
+    DECLARE_EVENT_TABLE()
 };
 
-class MyDialog: public wxDialog
+class MyDialog : public wxDialog
 {
 public:
     MyDialog(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size,
-           const long style = wxDEFAULT_DIALOG_STYLE);
+            const long style = wxDEFAULT_DIALOG_STYLE);
 };
 
 class MyData
 {
- public:
+public:
     wxString m_string;
 
     MyData() { m_string = "My string"; }
@@ -50,5 +51,6 @@ class MyData
 #define VALIDATE_DIALOG_ID      200
 
 #define VALIDATE_TEST_DIALOG    2
+#define VALIDATE_SILENT         3
 #define VALIDATE_TEXT           101
 
index fe0ec85316afacdb4639fb6f39b92285564b4e6c..6932875a5c8d7dcf7336d16c6df2a22f218622da 100644 (file)
@@ -6,22 +6,22 @@
 // Created:     04/01/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart and Markus Holzem
-// Licence:    wxWindows license
+// Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
 #ifdef __GNUG__
-#pragma implementation "validate.h"
+    #pragma implementation "validate.h"
 #endif
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
-#pragma hdrstop
+    #pragma hdrstop
 #endif
 
 #ifndef WX_PRECOMP
-#include "wx/wx.h"
+    #include "wx/wx.h"
 #endif
 
 #include "wx/validate.h"
 const wxValidator wxDefaultValidator;
 
 #if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxValidator, wxEvtHandler)
+    IMPLEMENT_DYNAMIC_CLASS(wxValidator, wxEvtHandler)
 #endif
 
-wxValidator::wxValidator(void)
+// VZ: personally, I think TRUE would be more appropriate - these bells are
+//     _annoying_
+bool wxValidator::ms_isSilent = FALSE;
+
+wxValidator::wxValidator()
 {
   m_validatorWindow = (wxWindow *) NULL;
 }
index c3139ccfb6d404471f2c297dd23ea243a201535b..259b201326f81b6295cd5ea2abb49879276bd3ad 100644 (file)
@@ -6,26 +6,26 @@
 // Created:     04/01/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart and Markus Holzem
-// Licence:    wxWindows license
+// Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
 #ifdef __GNUG__
-#pragma implementation "valtext.h"
+    #pragma implementation "valtext.h"
 #endif
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
-#pragma hdrstop
+    #pragma hdrstop
 #endif
 
 #ifndef WX_PRECOMP
-#include <stdio.h>
-#include "wx/textctrl.h"
-#include "wx/utils.h"
-#include "wx/msgdlg.h"
-#include "wx/intl.h"
+    #include <stdio.h>
+    #include "wx/textctrl.h"
+    #include "wx/utils.h"
+    #include "wx/msgdlg.h"
+    #include "wx/intl.h"
 #endif
 
 #include "wx/valtext.h"
 #include <stdlib.h>
 
 #ifdef __SALFORDC__
-#include <clib.h>
+    #include <clib.h>
 #endif
 
 #if !USE_SHARED_LIBRARY
 IMPLEMENT_DYNAMIC_CLASS(wxTextValidator, wxValidator)
 
 BEGIN_EVENT_TABLE(wxTextValidator, wxValidator)
-       EVT_CHAR(wxTextValidator::OnChar)
+    EVT_CHAR(wxTextValidator::OnChar)
 END_EVENT_TABLE()
 #endif
 
@@ -50,13 +50,13 @@ static bool wxIsNumeric(const wxString& val);
 
 wxTextValidator::wxTextValidator(long style, wxString *val)
 {
-       m_validatorStyle = style ;
-       m_stringValue = val ;
+    m_validatorStyle = style ;
+    m_stringValue = val ;
 /*
     m_refData = new wxVTextRefData;
 
-       M_VTEXTDATA->m_validatorStyle = style ;
-       M_VTEXTDATA->m_stringValue = val ;
+    M_VTEXTDATA->m_validatorStyle = style ;
+    M_VTEXTDATA->m_stringValue = val ;
 */
 }
 
@@ -69,23 +69,23 @@ bool wxTextValidator::Copy(const wxTextValidator& val)
 {
     wxValidator::Copy(val);
 
-       m_validatorStyle = val.m_validatorStyle ;
-       m_stringValue = val.m_stringValue ;
-
-       wxNode *node = val.m_includeList.First() ;
-       while ( node )
-       {
-               char *s = (char *)node->Data();
-               m_includeList.Add(s);
-               node = node->Next();
-       }
-       node = val.m_excludeList.First() ;
-       while ( node )
-       {
-               char *s = (char *)node->Data();
-               m_excludeList.Add(s);
-               node = node->Next();
-       }
+    m_validatorStyle = val.m_validatorStyle ;
+    m_stringValue = val.m_stringValue ;
+
+    wxNode *node = val.m_includeList.First() ;
+    while ( node )
+    {
+        char *s = (char *)node->Data();
+        m_includeList.Add(s);
+        node = node->Next();
+    }
+    node = val.m_excludeList.First() ;
+    while ( node )
+    {
+        char *s = (char *)node->Data();
+        m_excludeList.Add(s);
+        node = node->Next();
+    }
     return TRUE;
 }
 
@@ -95,227 +95,214 @@ wxTextValidator::~wxTextValidator()
 
 static bool wxIsAlpha(const wxString& val)
 {
-       int i;
-       for ( i = 0; i < (int)val.Length(); i++)
-       {
-               if (!isalpha(val[i]))
-                       return FALSE;
-       }
-       return TRUE;
+    int i;
+    for ( i = 0; i < (int)val.Length(); i++)
+    {
+        if (!isalpha(val[i]))
+            return FALSE;
+    }
+    return TRUE;
 }
 
 static bool wxIsAlphaNumeric(const wxString& val)
 {
-       int i;
-       for ( i = 0; i < (int)val.Length(); i++)
-       {
-               if (!isalnum(val[i]))
-                       return FALSE;
-       }
-       return TRUE;
+    int i;
+    for ( i = 0; i < (int)val.Length(); i++)
+    {
+        if (!isalnum(val[i]))
+            return FALSE;
+    }
+    return TRUE;
 }
 
 // Called when the value in the window must be validated.
 // This function can pop up an error message.
 bool wxTextValidator::Validate(wxWindow *parent)
 {
-       if ( !m_validatorWindow )
-               return FALSE;
-       if ( !m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) )
-               return FALSE;
-       if ( !m_stringValue )
-               return FALSE;
-
-       wxTextCtrl *control = (wxTextCtrl *) m_validatorWindow ;
-
-       // If window is disabled, don't validate
-       if ( !control->Enabled() )
-               return FALSE;
-
-       wxString val(control->GetValue());
-
-       if ( m_validatorStyle & wxFILTER_INCLUDE_LIST )
-       {
-               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);
-                       return FALSE;
-               }
-       }
-       if ( m_validatorStyle & wxFILTER_EXCLUDE_LIST )
-       {
-               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);
-                       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);
-                       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);
-                       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);
-                       return FALSE;
-       }
-       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);
-                       return FALSE;
-       }
-
-       return TRUE ;
+    if ( !m_validatorWindow )
+        return FALSE;
+    if ( !m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) )
+        return FALSE;
+    if ( !m_stringValue )
+        return FALSE;
+
+    wxTextCtrl *control = (wxTextCtrl *) m_validatorWindow ;
+
+    // If window is disabled, don't validate
+    if ( !control->Enabled() )
+        return FALSE;
+
+    wxString val(control->GetValue());
+
+    bool ok = true;
+
+    // this format string should contian exactly one '%s'
+    const char *errormsg = _("'%s' is invalid");
+
+    if ( m_validatorStyle & wxFILTER_INCLUDE_LIST )
+    {
+        if ( !m_includeList.Member(val) )
+        {
+            ok = false;
+        }
+    }
+    else if ( m_validatorStyle & wxFILTER_EXCLUDE_LIST )
+    {
+        if ( m_excludeList.Member(val) )
+        {
+            ok = false;
+        }
+    }
+    else if ( (m_validatorStyle & wxFILTER_ASCII) && !val.IsAscii() )
+    {
+        ok = false;
+
+        errormsg = _("'%s' should only contain ASCII characters.");
+    }
+    else if ( (m_validatorStyle & wxFILTER_ALPHA) && !wxIsAlpha(val) )
+    {
+        ok = false;
+
+        errormsg = _("'%s' should only contain alphabetic characters.");
+    }
+    else if ( (m_validatorStyle & wxFILTER_ALPHANUMERIC) && !wxIsAlphaNumeric(val))
+    {
+        ok = false;
+
+        errormsg = _("'%s' should only contain alphabetic or numeric characters.");
+    }
+    else if ( (m_validatorStyle & wxFILTER_NUMERIC) && !wxIsNumeric(val))
+    {
+        ok = false;
+
+        errormsg = _("'%s' should be numeric.");
+    }
+
+    if ( !ok )
+    {
+        m_validatorWindow->SetFocus();
+
+        wxString buf;
+        buf.Printf(errormsg, val.c_str());
+
+        wxMessageBox(buf, _("Validation conflict"),
+                     wxOK | wxICON_EXCLAMATION, parent);
+    }
+
+    return ok;
 }
 
 // Called to transfer data to the window
 bool wxTextValidator::TransferToWindow(void)
 {
-       if ( !m_validatorWindow )
-               return FALSE;
-       if ( !m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) )
-               return FALSE;
-       if ( !m_stringValue )
-               return FALSE;
+    if ( !m_validatorWindow )
+        return FALSE;
+    if ( !m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) )
+        return FALSE;
+    if ( !m_stringValue )
+        return FALSE;
 
-       wxTextCtrl *control = (wxTextCtrl *) m_validatorWindow ;
-       control->SetValue(* m_stringValue) ;
+    wxTextCtrl *control = (wxTextCtrl *) m_validatorWindow ;
+    control->SetValue(* m_stringValue) ;
 
-       return TRUE;
+    return TRUE;
 }
 
 // Called to transfer data to the window
 bool wxTextValidator::TransferFromWindow(void)
 {
-       if ( !m_validatorWindow )
-               return FALSE;
-       if ( !m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) )
-               return FALSE;
-       if ( !m_stringValue )
-               return FALSE;
+    if ( !m_validatorWindow )
+        return FALSE;
+    if ( !m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) )
+        return FALSE;
+    if ( !m_stringValue )
+        return FALSE;
 
-       wxTextCtrl *control = (wxTextCtrl *) m_validatorWindow ;
-       * m_stringValue = control->GetValue() ;
+    wxTextCtrl *control = (wxTextCtrl *) m_validatorWindow ;
+    * m_stringValue = control->GetValue() ;
 
-       return TRUE;
+    return TRUE;
 }
 
 void wxTextValidator::SetIncludeList(const wxStringList& list)
 {
 /*
-       if ( !M_VTEXTDATA )
-               return;
+    if ( !M_VTEXTDATA )
+        return;
 */
 
-       m_includeList.Clear();
-       // TODO: replace with =
-       wxNode *node = list.First() ;
-       while ( node )
-       {
-               char *s = (char *)node->Data();
-               m_includeList.Add(s);
-               node = node->Next();
-       }
+    m_includeList.Clear();
+    // TODO: replace with =
+    wxNode *node = list.First() ;
+    while ( node )
+    {
+        char *s = (char *)node->Data();
+        m_includeList.Add(s);
+        node = node->Next();
+    }
 }
 
 void wxTextValidator::SetExcludeList(const wxStringList& list)
 {
 /*
-       if ( !M_VTEXTDATA )
-               return;
+    if ( !M_VTEXTDATA )
+        return;
 */
 
-       m_excludeList.Clear();
-       // TODO: replace with =
-       wxNode *node = list.First() ;
-       while ( node )
-       {
-               char *s = (char *)node->Data();
-               m_excludeList.Add(s);
-               node = node->Next();
-       }
+    m_excludeList.Clear();
+    // TODO: replace with =
+    wxNode *node = list.First() ;
+    while ( node )
+    {
+        char *s = (char *)node->Data();
+        m_excludeList.Add(s);
+        node = node->Next();
+    }
 }
 
 void wxTextValidator::OnChar(wxKeyEvent& event)
 {
 /*
-       if ( !M_VTEXTDATA )
-               return;
+    if ( !M_VTEXTDATA )
+        return;
 */
 
-       if ( !m_validatorWindow )
-               return;
-
-       wxTextCtrl *textCtrl = (wxTextCtrl *)m_validatorWindow;
-
-       int keyCode = event.KeyCode();
-       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 ;
-       }
-
-       if ( (m_validatorStyle & wxFILTER_ASCII) && !isascii(keyCode) )
-       {
-               wxBell();
-               return;
-       }
-       if ( (m_validatorStyle & wxFILTER_ALPHA) && !isalpha(keyCode) )
-       {
-               wxBell();
-               return;
-       }
-       if ( (m_validatorStyle & wxFILTER_ALPHANUMERIC) && !isalnum(keyCode) )
-       {
-               wxBell();
-               return;
-       }
-       if ( (m_validatorStyle & wxFILTER_NUMERIC) && !isdigit(keyCode) && keyCode != '.' && keyCode != '-')
-       {
-               wxBell();
-               return;
-       }
-
-       textCtrl->wxTextCtrl::OnChar(event);
+    if ( m_validatorWindow )
+    {
+        int keyCode = event.KeyCode();
+
+        // we don't filter special keys and Delete
+        if (
+             !(keyCode < WXK_SPACE || keyCode == WXK_DELETE || keyCode > WXK_START) &&
+             (
+              ((m_validatorStyle & wxFILTER_ASCII) && !isascii(keyCode)) ||
+              ((m_validatorStyle & wxFILTER_ALPHA) && !isalpha(keyCode)) ||
+              ((m_validatorStyle & wxFILTER_ALPHANUMERIC) && !isalnum(keyCode)) ||
+              ((m_validatorStyle & wxFILTER_NUMERIC) && !isdigit(keyCode)
+                                && keyCode != '.' && keyCode != '-')
+             )
+           )
+        {
+            if ( !wxValidator::IsSilent() )
+                wxBell();
+
+            // eat message
+            return;
+        }
+    }
+
+    event.Skip();
 }
 
 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;
+    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;
 }