]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/valtext.h
Use correct reload flags on all platforms to avoid compilation errors
[wxWidgets.git] / include / wx / valtext.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/valtext.h
3// Purpose: wxTextValidator class
4// Author: Julian Smart
5// Modified by: Francesco Montorsi
6// Created: 29/01/98
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_VALTEXT_H_
13#define _WX_VALTEXT_H_
14
15#include "wx/defs.h"
16
17#if wxUSE_VALIDATORS && (wxUSE_TEXTCTRL || wxUSE_COMBOBOX)
18
19class WXDLLIMPEXP_FWD_CORE wxTextEntry;
20
21#include "wx/validate.h"
22
23enum wxTextValidatorStyle
24{
25 wxFILTER_NONE = 0x0,
26 wxFILTER_EMPTY = 0x1,
27 wxFILTER_ASCII = 0x2,
28 wxFILTER_ALPHA = 0x4,
29 wxFILTER_ALPHANUMERIC = 0x8,
30 wxFILTER_DIGITS = 0x10,
31 wxFILTER_NUMERIC = 0x20,
32 wxFILTER_INCLUDE_LIST = 0x40,
33 wxFILTER_INCLUDE_CHAR_LIST = 0x80,
34 wxFILTER_EXCLUDE_LIST = 0x100,
35 wxFILTER_EXCLUDE_CHAR_LIST = 0x200
36};
37
38class WXDLLIMPEXP_CORE wxTextValidator: public wxValidator
39{
40public:
41 wxTextValidator(long style = wxFILTER_NONE, wxString *val = NULL);
42 wxTextValidator(const wxTextValidator& val);
43
44 virtual ~wxTextValidator(){}
45
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);
52
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);
56
57 // Called to transfer data to the window
58 virtual bool TransferToWindow();
59
60 // Called to transfer data from the window
61 virtual bool TransferFromWindow();
62
63 // Filter keystrokes
64 void OnChar(wxKeyEvent& event);
65
66 // ACCESSORS
67 inline long GetStyle() const { return m_validatorStyle; }
68 void SetStyle(long style);
69
70 wxTextEntry *GetTextEntry();
71
72 void SetCharIncludes(const wxString& chars);
73 void SetIncludes(const wxArrayString& includes) { m_includes = includes; }
74 inline wxArrayString& GetIncludes() { return m_includes; }
75
76 void SetCharExcludes(const wxString& chars);
77 void SetExcludes(const wxArrayString& excludes) { m_excludes = excludes; }
78 inline wxArrayString& GetExcludes() { return m_excludes; }
79
80 bool HasFlag(wxTextValidatorStyle style) const
81 { return (m_validatorStyle & style) != 0; }
82
83protected:
84
85 // returns true if all characters of the given string are present in m_includes
86 bool ContainsOnlyIncludedCharacters(const wxString& val) const;
87
88 // returns true if at least one character of the given string is present in m_excludes
89 bool ContainsExcludedCharacters(const wxString& val) const;
90
91 // returns the error message if the contents of 'val' are invalid
92 virtual wxString IsValid(const wxString& val) const;
93
94protected:
95 long m_validatorStyle;
96 wxString* m_stringValue;
97 wxArrayString m_includes;
98 wxArrayString m_excludes;
99
100private:
101 wxDECLARE_NO_ASSIGN_CLASS(wxTextValidator);
102 DECLARE_DYNAMIC_CLASS(wxTextValidator)
103 DECLARE_EVENT_TABLE()
104};
105
106#endif
107 // wxUSE_VALIDATORS && (wxUSE_TEXTCTRL || wxUSE_COMBOBOX)
108
109#endif // _WX_VALTEXT_H_