]> git.saurik.com Git - wxWidgets.git/blame - include/wx/valtext.h
wxX11:
[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
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_VALTEXTH__
13#define _WX_VALTEXTH__
c801d85f
KB
14
15#ifdef __GNUG__
16#pragma interface "valtext.h"
17#endif
18
ce4169a4
RR
19#include "wx/defs.h"
20
21#if wxUSE_VALIDATORS
88ac883a 22
c801d85f
KB
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
33class WXDLLEXPORT wxTextValidator: public wxValidator
34{
35DECLARE_DYNAMIC_CLASS(wxTextValidator)
36public:
c801d85f 37
33c5b54b
RL
38 wxTextValidator(long style = wxFILTER_NONE, wxString *val = 0);
39 wxTextValidator(const wxTextValidator& val);
c801d85f 40
33c5b54b 41 ~wxTextValidator();
c801d85f 42
33c5b54b
RL
43 // Make a clone of this validator (or return NULL) - currently necessary
44 // if you're passing a reference to a validator.
45 // Another possibility is to always pass a pointer to a new validator
46 // (so the calling code can use a copy constructor of the relevant class).
47 virtual wxObject *Clone() const { return new wxTextValidator(*this); }
48 bool Copy(const wxTextValidator& val);
c801d85f 49
33c5b54b
RL
50 // Called when the value in the window must be validated.
51 // This function can pop up an error message.
52 virtual bool Validate(wxWindow *parent);
c801d85f 53
33c5b54b
RL
54 // Called to transfer data to the window
55 virtual bool TransferToWindow();
c801d85f 56
33c5b54b
RL
57 // Called to transfer data to the window
58 virtual bool TransferFromWindow();
c801d85f 59
33c5b54b
RL
60 // ACCESSORS
61 inline long GetStyle() const { return m_validatorStyle; }
62 inline void SetStyle(long style) { m_validatorStyle = style; }
c801d85f 63
33c5b54b
RL
64 void SetIncludeList(const wxStringList& list);
65 inline wxStringList& GetIncludeList() { return m_includeList; }
c801d85f 66
33c5b54b
RL
67 void SetExcludeList(const wxStringList& list);
68 inline wxStringList& GetExcludeList() { return m_excludeList; }
69
70 // Filter keystrokes
71 void OnChar(wxKeyEvent& event);
c801d85f
KB
72
73DECLARE_EVENT_TABLE()
74
75protected:
76 long m_validatorStyle;
77 wxString * m_stringValue;
78 wxStringList m_includeList;
79 wxStringList m_excludeList;
33c5b54b
RL
80
81 bool CheckValidator() const
82 {
83 wxCHECK_MSG( m_validatorWindow, FALSE,
84 _T("No window associated with validator") );
85 wxCHECK_MSG( m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)), FALSE,
86 _T("wxTextValidator is only for wxTextCtrl's") );
87 wxCHECK_MSG( m_stringValue, FALSE,
88 _T("No variable storage for validator") );
89
90 return TRUE;
91 }
c801d85f
KB
92};
93
94#endif
ce4169a4
RR
95 // wxUSE_VALIDATORS
96
97#endif
98 // _WX_VALTEXTH__