]> git.saurik.com Git - wxWidgets.git/blame - include/wx/valtext.h
compilation fix
[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
ce4169a4
RR
15#include "wx/defs.h"
16
d7260478 17#if wxUSE_VALIDATORS && wxUSE_TEXTCTRL
88ac883a 18
0078f87f 19#include "wx/textctrl.h"
c801d85f
KB
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
aaae8296
JS
29#define wxFILTER_INCLUDE_CHAR_LIST 0x0040
30#define wxFILTER_EXCLUDE_CHAR_LIST 0x0080
c801d85f
KB
31
32class WXDLLEXPORT wxTextValidator: public wxValidator
33{
34DECLARE_DYNAMIC_CLASS(wxTextValidator)
35public:
c801d85f 36
33c5b54b
RL
37 wxTextValidator(long style = wxFILTER_NONE, wxString *val = 0);
38 wxTextValidator(const wxTextValidator& val);
c801d85f 39
d3c7fc99 40 virtual ~wxTextValidator(){}
c801d85f 41
33c5b54b
RL
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);
c801d85f 48
33c5b54b
RL
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);
c801d85f 52
33c5b54b
RL
53 // Called to transfer data to the window
54 virtual bool TransferToWindow();
c801d85f 55
4deaa8db 56 // Called to transfer data from the window
33c5b54b 57 virtual bool TransferFromWindow();
c801d85f 58
33c5b54b
RL
59 // ACCESSORS
60 inline long GetStyle() const { return m_validatorStyle; }
61 inline void SetStyle(long style) { m_validatorStyle = style; }
c801d85f 62
f94a790d
RN
63
64 void SetIncludes(const wxArrayString& includes) { m_includes = includes; }
65 inline wxArrayString& GetIncludes() { return m_includes; }
66
67 void SetExcludes(const wxArrayString& excludes) { m_excludes = excludes; }
68 inline wxArrayString& GetExcludes() { return m_excludes; }
69
70 bool IsInCharIncludes(const wxString& val);
71 bool IsNotInCharExcludes(const wxString& val);
33c5b54b
RL
72
73 // Filter keystrokes
74 void OnChar(wxKeyEvent& event);
c801d85f 75
aaae8296 76
c801d85f
KB
77DECLARE_EVENT_TABLE()
78
79protected:
80 long m_validatorStyle;
81 wxString * m_stringValue;
f94a790d
RN
82 wxArrayString m_includes;
83 wxArrayString m_excludes;
33c5b54b
RL
84
85 bool CheckValidator() const
86 {
cab1a605 87 wxCHECK_MSG( m_validatorWindow, false,
33c5b54b 88 _T("No window associated with validator") );
cab1a605 89 wxCHECK_MSG( m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)), false,
33c5b54b 90 _T("wxTextValidator is only for wxTextCtrl's") );
33c5b54b 91
cab1a605 92 return true;
33c5b54b 93 }
22f3361e
VZ
94
95private:
96// Cannot use
97// DECLARE_NO_COPY_CLASS(wxTextValidator)
98// because copy constructor is explicitly declared above;
99// but no copy assignment operator is defined, so declare
100// it private to prevent the compiler from defining it:
101 wxTextValidator& operator=(const wxTextValidator&);
c801d85f
KB
102};
103
104#endif
d7260478 105 // wxUSE_VALIDATORS && wxUSE_TEXTCTRL
ce4169a4
RR
106
107#endif
108 // _WX_VALTEXTH__