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