]> git.saurik.com Git - wxWidgets.git/blob - include/wx/valtext.h
add more virtual border drawing functions used by frame decorations code
[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 #include "wx/defs.h"
16
17 #if wxUSE_VALIDATORS && wxUSE_TEXTCTRL
18
19 #include "wx/textctrl.h"
20 #include "wx/validate.h"
21
22 #define wxFILTER_NONE 0x0000
23 #define wxFILTER_ASCII 0x0001
24 #define wxFILTER_ALPHA 0x0002
25 #define wxFILTER_ALPHANUMERIC 0x0004
26 #define wxFILTER_NUMERIC 0x0008
27 #define wxFILTER_INCLUDE_LIST 0x0010
28 #define wxFILTER_EXCLUDE_LIST 0x0020
29 #define wxFILTER_INCLUDE_CHAR_LIST 0x0040
30 #define wxFILTER_EXCLUDE_CHAR_LIST 0x0080
31
32 class WXDLLEXPORT wxTextValidator: public wxValidator
33 {
34 DECLARE_DYNAMIC_CLASS(wxTextValidator)
35 public:
36
37 wxTextValidator(long style = wxFILTER_NONE, wxString *val = 0);
38 wxTextValidator(const wxTextValidator& val);
39
40 virtual ~wxTextValidator(){}
41
42 // Make a clone of this validator (or return NULL) - currently necessary
43 // if you're passing a reference to a validator.
44 // Another possibility is to always pass a pointer to a new validator
45 // (so the calling code can use a copy constructor of the relevant class).
46 virtual wxObject *Clone() const { return new wxTextValidator(*this); }
47 bool Copy(const wxTextValidator& val);
48
49 // Called when the value in the window must be validated.
50 // This function can pop up an error message.
51 virtual bool Validate(wxWindow *parent);
52
53 // Called to transfer data to the window
54 virtual bool TransferToWindow();
55
56 // Called to transfer data from the window
57 virtual bool TransferFromWindow();
58
59 // ACCESSORS
60 inline long GetStyle() const { return m_validatorStyle; }
61 inline void SetStyle(long style) { m_validatorStyle = style; }
62
63 #if WXWIN_COMPATIBILITY_2_4
64 wxDEPRECATED( void SetIncludeList(const wxStringList& list) );
65 wxDEPRECATED( wxStringList& GetIncludeList() );
66
67 wxDEPRECATED( void SetExcludeList(const wxStringList& list) );
68 wxDEPRECATED( wxStringList& GetExcludeList() );
69
70 wxDEPRECATED( bool IsInCharIncludeList(const wxString& val) );
71 wxDEPRECATED( bool IsNotInCharExcludeList(const wxString& val) );
72 #endif
73
74 void SetIncludes(const wxArrayString& includes) { m_includes = includes; }
75 inline wxArrayString& GetIncludes() { return m_includes; }
76
77 void SetExcludes(const wxArrayString& excludes) { m_excludes = excludes; }
78 inline wxArrayString& GetExcludes() { return m_excludes; }
79
80 bool IsInCharIncludes(const wxString& val);
81 bool IsNotInCharExcludes(const wxString& val);
82
83 // Filter keystrokes
84 void OnChar(wxKeyEvent& event);
85
86
87 DECLARE_EVENT_TABLE()
88
89 protected:
90 long m_validatorStyle;
91 wxString * m_stringValue;
92 #if WXWIN_COMPATIBILITY_2_4
93 wxStringList m_includeList;
94 wxStringList m_excludeList;
95 #endif
96 wxArrayString m_includes;
97 wxArrayString m_excludes;
98
99 bool CheckValidator() const
100 {
101 wxCHECK_MSG( m_validatorWindow, false,
102 _T("No window associated with validator") );
103 wxCHECK_MSG( m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)), false,
104 _T("wxTextValidator is only for wxTextCtrl's") );
105
106 return true;
107 }
108
109 private:
110 // Cannot use
111 // DECLARE_NO_COPY_CLASS(wxTextValidator)
112 // because copy constructor is explicitly declared above;
113 // but no copy assignment operator is defined, so declare
114 // it private to prevent the compiler from defining it:
115 wxTextValidator& operator=(const wxTextValidator&);
116 };
117
118 #endif
119 // wxUSE_VALIDATORS && wxUSE_TEXTCTRL
120
121 #endif
122 // _WX_VALTEXTH__