]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/validate.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxValidator class
4 // Author: Julian Smart
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_VALIDATEH__
13 #define _WX_VALIDATEH__
16 #pragma interface "validate.h"
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
27 class WXDLLEXPORT wxWindow
;
28 class WXDLLEXPORT wxWindowBase
;
31 A validator has up to three purposes:
33 1) To validate the data in the window that's associated
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.
39 Note that wxValidator and derived classes use reference counting.
42 class WXDLLEXPORT wxValidator
: public wxEvtHandler
46 virtual ~wxValidator();
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
; }
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
; };
61 // Called to transfer data to the window
62 virtual bool TransferToWindow() { return FALSE
; }
64 // Called to transfer data from the window
65 virtual bool TransferFromWindow() { return FALSE
; };
68 wxWindow
*GetWindow() const { return (wxWindow
*)m_validatorWindow
; }
69 void SetWindow(wxWindowBase
*win
) { m_validatorWindow
= win
; }
71 // validators beep by default if invalid key is pressed, these functions
73 static bool IsSilent() { return ms_isSilent
; }
74 static void SetBellOnError(bool doIt
= TRUE
) { ms_isSilent
= doIt
; }
77 wxWindowBase
*m_validatorWindow
;
80 static bool ms_isSilent
;
82 DECLARE_DYNAMIC_CLASS(wxValidator
)
85 WXDLLEXPORT_DATA(extern const wxValidator
) wxDefaultValidator
;
87 #endif // wxUSE_VALIDATORS