]> git.saurik.com Git - wxWidgets.git/blame - include/wx/validate.h
typo in dcclient.cpp corrected (wxUSE_SPLINE => wxUSE_SPLINES)
[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
f03fc89f 21class WXDLLEXPORT wxWindowBase;
c801d85f
KB
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.
a994f81b 33*/
c801d85f 34
a994f81b 35class WXDLLEXPORT wxValidator : public wxEvtHandler
c801d85f 36{
c801d85f 37public:
a994f81b 38 wxValidator();
f03fc89f 39 virtual ~wxValidator();
c801d85f 40
a994f81b
VZ
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).
ca298c88 45 virtual wxObject *Clone() const
a994f81b
VZ
46 { return (wxValidator *)NULL; }
47 bool Copy(const wxValidator& val)
48 { m_validatorWindow = val.m_validatorWindow; return TRUE; }
c801d85f 49
a994f81b
VZ
50 // Called when the value in the window must be validated.
51 // This function can pop up an error message.
f03fc89f 52 virtual bool Validate(wxWindowBase *WXUNUSED(parent)) { return FALSE; };
c801d85f 53
a994f81b
VZ
54 // Called to transfer data to the window
55 virtual bool TransferToWindow() { return FALSE; }
c801d85f 56
a994f81b
VZ
57 // Called to transfer data from the window
58 virtual bool TransferFromWindow() { return FALSE; };
c801d85f 59
a994f81b 60 // accessors
f03fc89f
VZ
61 wxWindowBase *GetWindow() const { return m_validatorWindow; }
62 void SetWindow(wxWindowBase *win) { m_validatorWindow = win; }
a994f81b
VZ
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; }
c801d85f
KB
68
69protected:
f03fc89f 70 wxWindowBase *m_validatorWindow;
a994f81b
VZ
71
72private:
73 static bool ms_isSilent;
74
75 DECLARE_DYNAMIC_CLASS(wxValidator)
c801d85f
KB
76};
77
78WXDLLEXPORT_DATA(extern const wxValidator) wxDefaultValidator;
79
80#endif
34138703 81 // _WX_VALIDATEH__