]>
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"
19 #if defined(wxUSE_VALIDATORS) && !wxUSE_VALIDATORS
20 // wxWindows is compiled without support for wxValidator, but we still
21 // want to be able to pass wxDefaultValidator to the functions which take
22 // a wxValidator parameter to avoid using "#if wxUSE_VALIDATORS"
24 class WXDLLEXPORT wxValidator
;
25 #define wxDefaultValidator (*((wxValidator *)NULL))
26 #else // wxUSE_VALIDATORS
30 class WXDLLEXPORT wxWindow
;
31 class WXDLLEXPORT wxWindowBase
;
34 A validator has up to three purposes:
36 1) To validate the data in the window that's associated
38 2) To transfer data to and from the window.
39 3) To filter input, using its role as a wxEvtHandler
40 to intercept e.g. OnChar.
42 Note that wxValidator and derived classes use reference counting.
45 class WXDLLEXPORT wxValidator
: public wxEvtHandler
49 virtual ~wxValidator();
51 // Make a clone of this validator (or return NULL) - currently necessary
52 // if you're passing a reference to a validator.
53 // Another possibility is to always pass a pointer to a new validator
54 // (so the calling code can use a copy constructor of the relevant class).
55 virtual wxObject
*Clone() const
56 { return (wxValidator
*)NULL
; }
57 bool Copy(const wxValidator
& val
)
58 { m_validatorWindow
= val
.m_validatorWindow
; return TRUE
; }
60 // Called when the value in the window must be validated.
61 // This function can pop up an error message.
62 virtual bool Validate(wxWindow
*WXUNUSED(parent
)) { return FALSE
; };
64 // Called to transfer data to the window
65 virtual bool TransferToWindow() { return FALSE
; }
67 // Called to transfer data from the window
68 virtual bool TransferFromWindow() { return FALSE
; };
71 wxWindow
*GetWindow() const { return (wxWindow
*)m_validatorWindow
; }
72 void SetWindow(wxWindowBase
*win
) { m_validatorWindow
= win
; }
74 // validators beep by default if invalid key is pressed, these functions
76 static bool IsSilent() { return ms_isSilent
; }
77 static void SetBellOnError(bool doIt
= TRUE
) { ms_isSilent
= doIt
; }
80 wxWindowBase
*m_validatorWindow
;
83 static bool ms_isSilent
;
85 DECLARE_DYNAMIC_CLASS(wxValidator
)
88 WXDLLEXPORT_DATA(extern const wxValidator
) wxDefaultValidator
;
90 #endif // wxUSE_VALIDATORS