1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTextValidator class
4 // Author: Julian Smart
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_VALTEXTH__
13 #define _WX_VALTEXTH__
17 #if wxUSE_VALIDATORS && (wxUSE_TEXTCTRL || wxUSE_COMBOBOX)
19 #include "wx/validate.h"
21 #define wxFILTER_NONE 0x0000
22 #define wxFILTER_ASCII 0x0001
23 #define wxFILTER_ALPHA 0x0002
24 #define wxFILTER_ALPHANUMERIC 0x0004
25 #define wxFILTER_NUMERIC 0x0008
26 #define wxFILTER_INCLUDE_LIST 0x0010
27 #define wxFILTER_EXCLUDE_LIST 0x0020
28 #define wxFILTER_INCLUDE_CHAR_LIST 0x0040
29 #define wxFILTER_EXCLUDE_CHAR_LIST 0x0080
31 class WXDLLEXPORT wxTextValidator
: public wxValidator
33 DECLARE_DYNAMIC_CLASS(wxTextValidator
)
36 wxTextValidator(long style
= wxFILTER_NONE
, wxString
*val
= 0);
37 wxTextValidator(const wxTextValidator
& val
);
39 virtual ~wxTextValidator(){}
41 // Make a clone of this validator (or return NULL) - currently necessary
42 // if you're passing a reference to a validator.
43 // Another possibility is to always pass a pointer to a new validator
44 // (so the calling code can use a copy constructor of the relevant class).
45 virtual wxObject
*Clone() const { return new wxTextValidator(*this); }
46 bool Copy(const wxTextValidator
& val
);
48 // Called when the value in the window must be validated.
49 // This function can pop up an error message.
50 virtual bool Validate(wxWindow
*parent
);
52 // Called to transfer data to the window
53 virtual bool TransferToWindow();
55 // Called to transfer data from the window
56 virtual bool TransferFromWindow();
59 inline long GetStyle() const { return m_validatorStyle
; }
60 inline void SetStyle(long style
) { m_validatorStyle
= style
; }
62 wxTextEntry
*GetTextEntry();
64 void SetIncludes(const wxArrayString
& includes
) { m_includes
= includes
; }
65 inline wxArrayString
& GetIncludes() { return m_includes
; }
67 void SetExcludes(const wxArrayString
& excludes
) { m_excludes
= excludes
; }
68 inline wxArrayString
& GetExcludes() { return m_excludes
; }
70 bool IsInCharIncludes(const wxString
& val
);
71 bool IsNotInCharExcludes(const wxString
& val
);
74 void OnChar(wxKeyEvent
& event
);
79 long m_validatorStyle
;
80 wxString
* m_stringValue
;
81 wxArrayString m_includes
;
82 wxArrayString m_excludes
;
86 // DECLARE_NO_COPY_CLASS(wxTextValidator)
87 // because copy constructor is explicitly declared above;
88 // but no copy assignment operator is defined, so declare
89 // it private to prevent the compiler from defining it:
90 wxTextValidator
& operator=(const wxTextValidator
&);
94 // wxUSE_VALIDATORS && (wxUSE_TEXTCTRL || wxUSE_COMBOBOX)