]> git.saurik.com Git - wxWidgets.git/blob - include/wx/valtext.h
added test for writing empty value to the config
[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
33 class WXDLLEXPORT wxTextValidator: public wxValidator
34 {
35 DECLARE_DYNAMIC_CLASS(wxTextValidator)
36 public:
37 wxTextValidator(long style = wxFILTER_NONE, wxString *val = (wxString *) NULL);
38 wxTextValidator(const wxTextValidator& val);
39
40 ~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(void) 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(void);
55
56 // Called to transfer data to the window
57 virtual bool TransferFromWindow(void);
58
59 // ACCESSORS
60 inline long GetStyle(void) const { return m_validatorStyle; }
61 inline void SetStyle(long style) { m_validatorStyle = style; }
62
63 void SetIncludeList(const wxStringList& list);
64 inline wxStringList& GetIncludeList(void) { return m_includeList; }
65
66 void SetExcludeList(const wxStringList& list);
67 inline wxStringList& GetExcludeList(void) { return m_excludeList; }
68
69 // Filter keystrokes
70 void OnChar(wxKeyEvent& event);
71
72 DECLARE_EVENT_TABLE()
73
74 protected:
75 long m_validatorStyle;
76 wxString * m_stringValue;
77 wxStringList m_includeList;
78 wxStringList m_excludeList;
79 };
80
81 #endif
82 // wxUSE_VALIDATORS
83
84 #endif
85 // _WX_VALTEXTH__