]> git.saurik.com Git - wxWidgets.git/blob - include/wx/valtext.h
fixed typo
[wxWidgets.git] / include / wx / valtext.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: valtext.h
3 // Purpose: wxTextValidator class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 29/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_VALTEXTH__
13 #define _WX_VALTEXTH__
14
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "valtext.h"
17 #endif
18
19 #include "wx/defs.h"
20
21 #if wxUSE_VALIDATORS
22
23 #include "wx/textctrl.h"
24 #include "wx/validate.h"
25
26 #define wxFILTER_NONE 0x0000
27 #define wxFILTER_ASCII 0x0001
28 #define wxFILTER_ALPHA 0x0002
29 #define wxFILTER_ALPHANUMERIC 0x0004
30 #define wxFILTER_NUMERIC 0x0008
31 #define wxFILTER_INCLUDE_LIST 0x0010
32 #define wxFILTER_EXCLUDE_LIST 0x0020
33 #define wxFILTER_INCLUDE_CHAR_LIST 0x0040
34 #define wxFILTER_EXCLUDE_CHAR_LIST 0x0080
35
36 class WXDLLEXPORT wxTextValidator: public wxValidator
37 {
38 DECLARE_DYNAMIC_CLASS(wxTextValidator)
39 public:
40
41 wxTextValidator(long style = wxFILTER_NONE, wxString *val = 0);
42 wxTextValidator(const wxTextValidator& val);
43
44 ~wxTextValidator();
45
46 // Make a clone of this validator (or return NULL) - currently necessary
47 // if you're passing a reference to a validator.
48 // Another possibility is to always pass a pointer to a new validator
49 // (so the calling code can use a copy constructor of the relevant class).
50 virtual wxObject *Clone() const { return new wxTextValidator(*this); }
51 bool Copy(const wxTextValidator& val);
52
53 // Called when the value in the window must be validated.
54 // This function can pop up an error message.
55 virtual bool Validate(wxWindow *parent);
56
57 // Called to transfer data to the window
58 virtual bool TransferToWindow();
59
60 // Called to transfer data to the window
61 virtual bool TransferFromWindow();
62
63 // ACCESSORS
64 inline long GetStyle() const { return m_validatorStyle; }
65 inline void SetStyle(long style) { m_validatorStyle = style; }
66
67 void SetIncludeList(const wxStringList& list);
68 inline wxStringList& GetIncludeList() { return m_includeList; }
69
70 void SetExcludeList(const wxStringList& list);
71 inline wxStringList& GetExcludeList() { return m_excludeList; }
72
73 // Filter keystrokes
74 void OnChar(wxKeyEvent& event);
75
76 bool IsInCharIncludeList(const wxString& val);
77 bool IsNotInCharExcludeList(const wxString& val);
78
79 DECLARE_EVENT_TABLE()
80
81 protected:
82 long m_validatorStyle;
83 wxString * m_stringValue;
84 wxStringList m_includeList;
85 wxStringList m_excludeList;
86
87 bool CheckValidator() const
88 {
89 wxCHECK_MSG( m_validatorWindow, FALSE,
90 _T("No window associated with validator") );
91 wxCHECK_MSG( m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)), FALSE,
92 _T("wxTextValidator is only for wxTextCtrl's") );
93 wxCHECK_MSG( m_stringValue, FALSE,
94 _T("No variable storage for validator") );
95
96 return TRUE;
97 }
98
99 private:
100 // Cannot use
101 // DECLARE_NO_COPY_CLASS(wxTextValidator)
102 // because copy constructor is explicitly declared above;
103 // but no copy assignment operator is defined, so declare
104 // it private to prevent the compiler from defining it:
105 wxTextValidator& operator=(const wxTextValidator&);
106 };
107
108 #endif
109 // wxUSE_VALIDATORS
110
111 #endif
112 // _WX_VALTEXTH__