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