]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: validate.h | |
3 | // Purpose: wxValidator 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 | ||
12 | #ifndef _WX_VALIDATEH__ | |
13 | #define _WX_VALIDATEH__ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "validate.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/event.h" | |
20 | ||
21 | class WXDLLEXPORT wxWindowBase; | |
22 | ||
23 | /* | |
24 | A validator has up to three purposes: | |
25 | ||
26 | 1) To validate the data in the window that's associated | |
27 | with the validator. | |
28 | 2) To transfer data to and from the window. | |
29 | 3) To filter input, using its role as a wxEvtHandler | |
30 | to intercept e.g. OnChar. | |
31 | ||
32 | Note that wxValidator and derived classes use reference counting. | |
33 | */ | |
34 | ||
35 | class WXDLLEXPORT wxValidator : public wxEvtHandler | |
36 | { | |
37 | public: | |
38 | wxValidator(); | |
39 | virtual ~wxValidator(); | |
40 | ||
41 | // Make a clone of this validator (or return NULL) - currently necessary | |
42 | // if you're passing a reference to a validator. | |
43 | // Another possibility is to always pass a pointer to a new validator | |
44 | // (so the calling code can use a copy constructor of the relevant class). | |
45 | virtual wxObject *Clone() const | |
46 | { return (wxValidator *)NULL; } | |
47 | bool Copy(const wxValidator& val) | |
48 | { m_validatorWindow = val.m_validatorWindow; return TRUE; } | |
49 | ||
50 | // Called when the value in the window must be validated. | |
51 | // This function can pop up an error message. | |
52 | virtual bool Validate(wxWindowBase *WXUNUSED(parent)) { return FALSE; }; | |
53 | ||
54 | // Called to transfer data to the window | |
55 | virtual bool TransferToWindow() { return FALSE; } | |
56 | ||
57 | // Called to transfer data from the window | |
58 | virtual bool TransferFromWindow() { return FALSE; }; | |
59 | ||
60 | // accessors | |
61 | wxWindowBase *GetWindow() const { return m_validatorWindow; } | |
62 | void SetWindow(wxWindowBase *win) { m_validatorWindow = win; } | |
63 | ||
64 | // validators beep by default if invalid key is pressed, these functions | |
65 | // allow to change it | |
66 | static bool IsSilent() { return ms_isSilent; } | |
67 | static void SetBellOnError(bool doIt = TRUE) { ms_isSilent = doIt; } | |
68 | ||
69 | protected: | |
70 | wxWindowBase *m_validatorWindow; | |
71 | ||
72 | private: | |
73 | static bool ms_isSilent; | |
74 | ||
75 | DECLARE_DYNAMIC_CLASS(wxValidator) | |
76 | }; | |
77 | ||
78 | WXDLLEXPORT_DATA(extern const wxValidator) wxDefaultValidator; | |
79 | ||
80 | #endif | |
81 | // _WX_VALIDATEH__ |