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