]> git.saurik.com Git - wxWidgets.git/blob - include/wx/valtext.h
fix a couple of typos
[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_VALTEXT_H_
13 #define _WX_VALTEXT_H_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_VALIDATORS && (wxUSE_TEXTCTRL || wxUSE_COMBOBOX)
18
19 class WXDLLIMPEXP_FWD_CORE wxTextEntry;
20
21 #include "wx/validate.h"
22
23 enum wxTextValidatorStyle
24 {
25 wxFILTER_NONE,
26 wxFILTER_ASCII,
27 wxFILTER_ALPHA,
28 wxFILTER_ALPHANUMERIC,
29 wxFILTER_NUMERIC,
30 wxFILTER_INCLUDE_LIST,
31 wxFILTER_EXCLUDE_LIST,
32 wxFILTER_INCLUDE_CHAR_LIST,
33 wxFILTER_EXCLUDE_CHAR_LIST
34 };
35
36 class WXDLLIMPEXP_CORE wxTextValidator: public wxValidator
37 {
38 public:
39 wxTextValidator(wxTextValidatorStyle style = wxFILTER_NONE, wxString *val = NULL);
40 #if WXWIN_COMPATIBILITY_2_8
41 wxDEPRECATED_CONSTRUCTOR( wxTextValidator(long style, wxString *val) );
42 #endif
43 wxTextValidator(const wxTextValidator& val);
44
45 virtual ~wxTextValidator(){}
46
47 // Make a clone of this validator (or return NULL) - currently necessary
48 // if you're passing a reference to a validator.
49 // Another possibility is to always pass a pointer to a new validator
50 // (so the calling code can use a copy constructor of the relevant class).
51 virtual wxObject *Clone() const { return new wxTextValidator(*this); }
52 bool Copy(const wxTextValidator& val);
53
54 // Called when the value in the window must be validated.
55 // This function can pop up an error message.
56 virtual bool Validate(wxWindow *parent);
57
58 // Called to transfer data to the window
59 virtual bool TransferToWindow();
60
61 // Called to transfer data from the window
62 virtual bool TransferFromWindow();
63
64 // ACCESSORS
65 inline wxTextValidatorStyle GetStyle() const { return m_validatorStyle; }
66 inline void SetStyle(wxTextValidatorStyle style) { m_validatorStyle = style; }
67 #if WXWIN_COMPATIBILITY_2_8
68 wxDEPRECATED( void SetStyle(long style) );
69 #endif
70
71 wxTextEntry *GetTextEntry();
72
73 void SetIncludes(const wxArrayString& includes) { m_includes = includes; }
74 inline wxArrayString& GetIncludes() { return m_includes; }
75
76 void SetExcludes(const wxArrayString& excludes) { m_excludes = excludes; }
77 inline wxArrayString& GetExcludes() { return m_excludes; }
78
79 bool IsInCharIncludes(const wxString& val);
80 bool IsNotInCharExcludes(const wxString& val);
81
82 // Filter keystrokes
83 void OnChar(wxKeyEvent& event);
84
85 protected:
86 wxTextValidatorStyle m_validatorStyle;
87 wxString * m_stringValue;
88 wxArrayString m_includes;
89 wxArrayString m_excludes;
90
91 private:
92 DECLARE_DYNAMIC_CLASS(wxTextValidator)
93 DECLARE_EVENT_TABLE()
94 // Cannot use
95 // DECLARE_NO_COPY_CLASS(wxTextValidator)
96 // because copy constructor is explicitly declared above;
97 // but no copy assignment operator is defined, so declare
98 // it private to prevent the compiler from defining it:
99 wxTextValidator& operator=(const wxTextValidator&);
100 };
101
102 #endif
103 // wxUSE_VALIDATORS && (wxUSE_TEXTCTRL || wxUSE_COMBOBOX)
104
105 #endif // _WX_VALTEXT_H_