]> git.saurik.com Git - wxWidgets.git/blob - include/wx/valtext.h
added a few virtual keywords for consistency (no real changes) (patch 543922)
[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 license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_VALTEXTH__
13 #define _WX_VALTEXTH__
14
15 #ifdef __GNUG__
16 #pragma interface "valtext.h"
17 #endif
18
19 #include "wx/defs.h"
20
21 #if wxUSE_VALIDATORS
22
23 #include "wx/validate.h"
24
25 #define wxFILTER_NONE 0x0000
26 #define wxFILTER_ASCII 0x0001
27 #define wxFILTER_ALPHA 0x0002
28 #define wxFILTER_ALPHANUMERIC 0x0004
29 #define wxFILTER_NUMERIC 0x0008
30 #define wxFILTER_INCLUDE_LIST 0x0010
31 #define wxFILTER_EXCLUDE_LIST 0x0020
32 #define wxFILTER_INCLUDE_CHAR_LIST 0x0040
33 #define wxFILTER_EXCLUDE_CHAR_LIST 0x0080
34
35 class WXDLLEXPORT wxTextValidator: public wxValidator
36 {
37 DECLARE_DYNAMIC_CLASS(wxTextValidator)
38 public:
39
40 wxTextValidator(long style = wxFILTER_NONE, wxString *val = 0);
41 wxTextValidator(const wxTextValidator& val);
42
43 ~wxTextValidator();
44
45 // Make a clone of this validator (or return NULL) - currently necessary
46 // if you're passing a reference to a validator.
47 // Another possibility is to always pass a pointer to a new validator
48 // (so the calling code can use a copy constructor of the relevant class).
49 virtual wxObject *Clone() const { return new wxTextValidator(*this); }
50 bool Copy(const wxTextValidator& val);
51
52 // Called when the value in the window must be validated.
53 // This function can pop up an error message.
54 virtual bool Validate(wxWindow *parent);
55
56 // Called to transfer data to the window
57 virtual bool TransferToWindow();
58
59 // Called to transfer data to the window
60 virtual bool TransferFromWindow();
61
62 // ACCESSORS
63 inline long GetStyle() const { return m_validatorStyle; }
64 inline void SetStyle(long style) { m_validatorStyle = style; }
65
66 void SetIncludeList(const wxStringList& list);
67 inline wxStringList& GetIncludeList() { return m_includeList; }
68
69 void SetExcludeList(const wxStringList& list);
70 inline wxStringList& GetExcludeList() { return m_excludeList; }
71
72 // Filter keystrokes
73 void OnChar(wxKeyEvent& event);
74
75 bool IsInCharIncludeList(const wxString& val);
76 bool IsNotInCharExcludeList(const wxString& val);
77
78 DECLARE_EVENT_TABLE()
79
80 protected:
81 long m_validatorStyle;
82 wxString * m_stringValue;
83 wxStringList m_includeList;
84 wxStringList m_excludeList;
85
86 bool CheckValidator() const
87 {
88 wxCHECK_MSG( m_validatorWindow, FALSE,
89 _T("No window associated with validator") );
90 wxCHECK_MSG( m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)), FALSE,
91 _T("wxTextValidator is only for wxTextCtrl's") );
92 wxCHECK_MSG( m_stringValue, FALSE,
93 _T("No variable storage for validator") );
94
95 return TRUE;
96 }
97 };
98
99 #endif
100 // wxUSE_VALIDATORS
101
102 #endif
103 // _WX_VALTEXTH__