]> git.saurik.com Git - wxWidgets.git/blame - include/wx/valtext.h
added wxConvFileName which is a variable, not define as wxConvFile; added comments...
[wxWidgets.git] / include / wx / valtext.h
CommitLineData
c801d85f
KB
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
cab1a605 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_VALTEXTH__
13#define _WX_VALTEXTH__
c801d85f 14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
c801d85f
KB
16#pragma interface "valtext.h"
17#endif
18
ce4169a4
RR
19#include "wx/defs.h"
20
d7260478 21#if wxUSE_VALIDATORS && wxUSE_TEXTCTRL
88ac883a 22
0078f87f 23#include "wx/textctrl.h"
c801d85f
KB
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
aaae8296
JS
33#define wxFILTER_INCLUDE_CHAR_LIST 0x0040
34#define wxFILTER_EXCLUDE_CHAR_LIST 0x0080
c801d85f
KB
35
36class WXDLLEXPORT wxTextValidator: public wxValidator
37{
38DECLARE_DYNAMIC_CLASS(wxTextValidator)
39public:
c801d85f 40
33c5b54b
RL
41 wxTextValidator(long style = wxFILTER_NONE, wxString *val = 0);
42 wxTextValidator(const wxTextValidator& val);
c801d85f 43
1b941f2d 44 ~wxTextValidator(){}
c801d85f 45
33c5b54b
RL
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);
c801d85f 52
33c5b54b
RL
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);
c801d85f 56
33c5b54b
RL
57 // Called to transfer data to the window
58 virtual bool TransferToWindow();
c801d85f 59
33c5b54b
RL
60 // Called to transfer data to the window
61 virtual bool TransferFromWindow();
c801d85f 62
33c5b54b
RL
63 // ACCESSORS
64 inline long GetStyle() const { return m_validatorStyle; }
65 inline void SetStyle(long style) { m_validatorStyle = style; }
c801d85f 66
f94a790d
RN
67#if WXWIN_COMPATIBILITY_2_4
68 wxDEPRECATED( void SetIncludeList(const wxStringList& list) );
69 wxDEPRECATED( inline wxStringList& GetIncludeList() );
c801d85f 70
f94a790d
RN
71 wxDEPRECATED( void SetExcludeList(const wxStringList& list) );
72 wxDEPRECATED( inline wxStringList& GetExcludeList() );
73
74 wxDEPRECATED( bool IsInCharIncludeList(const wxString& val) );
75 wxDEPRECATED( bool IsNotInCharExcludeList(const wxString& val) );
76#endif
77
78 void SetIncludes(const wxArrayString& includes) { m_includes = includes; }
79 inline wxArrayString& GetIncludes() { return m_includes; }
80
81 void SetExcludes(const wxArrayString& excludes) { m_excludes = excludes; }
82 inline wxArrayString& GetExcludes() { return m_excludes; }
83
84 bool IsInCharIncludes(const wxString& val);
85 bool IsNotInCharExcludes(const wxString& val);
33c5b54b
RL
86
87 // Filter keystrokes
88 void OnChar(wxKeyEvent& event);
c801d85f 89
aaae8296 90
c801d85f
KB
91DECLARE_EVENT_TABLE()
92
93protected:
94 long m_validatorStyle;
95 wxString * m_stringValue;
f94a790d 96#if WXWIN_COMPATIBILITY_2_4
c801d85f
KB
97 wxStringList m_includeList;
98 wxStringList m_excludeList;
f94a790d
RN
99#endif
100 wxArrayString m_includes;
101 wxArrayString m_excludes;
33c5b54b
RL
102
103 bool CheckValidator() const
104 {
cab1a605 105 wxCHECK_MSG( m_validatorWindow, false,
33c5b54b 106 _T("No window associated with validator") );
cab1a605 107 wxCHECK_MSG( m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)), false,
33c5b54b 108 _T("wxTextValidator is only for wxTextCtrl's") );
cab1a605 109 wxCHECK_MSG( m_stringValue, false,
33c5b54b
RL
110 _T("No variable storage for validator") );
111
cab1a605 112 return true;
33c5b54b 113 }
22f3361e
VZ
114
115private:
116// Cannot use
117// DECLARE_NO_COPY_CLASS(wxTextValidator)
118// because copy constructor is explicitly declared above;
119// but no copy assignment operator is defined, so declare
120// it private to prevent the compiler from defining it:
121 wxTextValidator& operator=(const wxTextValidator&);
c801d85f
KB
122};
123
124#endif
d7260478 125 // wxUSE_VALIDATORS && wxUSE_TEXTCTRL
ce4169a4
RR
126
127#endif
128 // _WX_VALTEXTH__