]> git.saurik.com Git - wxWidgets.git/blame - include/wx/validate.h
Corrected miniframe.
[wxWidgets.git] / include / wx / validate.h
CommitLineData
c801d85f
KB
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
a994f81b 9// Licence: wxWindows license
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_VALIDATEH__
13#define _WX_VALIDATEH__
c801d85f
KB
14
15#ifdef __GNUG__
a994f81b 16 #pragma interface "validate.h"
c801d85f
KB
17#endif
18
19#include "wx/event.h"
20
88ac883a
VZ
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
764a3a49 27class WXDLLEXPORT wxWindow;
f03fc89f 28class WXDLLEXPORT wxWindowBase;
c801d85f
KB
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.
a994f81b 40*/
c801d85f 41
a994f81b 42class WXDLLEXPORT wxValidator : public wxEvtHandler
c801d85f 43{
c801d85f 44public:
a994f81b 45 wxValidator();
f03fc89f 46 virtual ~wxValidator();
c801d85f 47
a994f81b
VZ
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).
ca298c88 52 virtual wxObject *Clone() const
a994f81b
VZ
53 { return (wxValidator *)NULL; }
54 bool Copy(const wxValidator& val)
55 { m_validatorWindow = val.m_validatorWindow; return TRUE; }
c801d85f 56
a994f81b
VZ
57 // Called when the value in the window must be validated.
58 // This function can pop up an error message.
764a3a49 59 virtual bool Validate(wxWindow *WXUNUSED(parent)) { return FALSE; };
c801d85f 60
a994f81b
VZ
61 // Called to transfer data to the window
62 virtual bool TransferToWindow() { return FALSE; }
c801d85f 63
a994f81b
VZ
64 // Called to transfer data from the window
65 virtual bool TransferFromWindow() { return FALSE; };
c801d85f 66
a994f81b 67 // accessors
764a3a49 68 wxWindow *GetWindow() const { return (wxWindow *)m_validatorWindow; }
f03fc89f 69 void SetWindow(wxWindowBase *win) { m_validatorWindow = win; }
a994f81b
VZ
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; }
c801d85f
KB
75
76protected:
f03fc89f 77 wxWindowBase *m_validatorWindow;
a994f81b
VZ
78
79private:
80 static bool ms_isSilent;
81
82 DECLARE_DYNAMIC_CLASS(wxValidator)
c801d85f
KB
83};
84
85WXDLLEXPORT_DATA(extern const wxValidator) wxDefaultValidator;
86
88ac883a
VZ
87#endif // wxUSE_VALIDATORS
88
c801d85f 89#endif
34138703 90 // _WX_VALIDATEH__