]> git.saurik.com Git - wxWidgets.git/blame - include/wx/validate.h
removed mark #pragmas
[wxWidgets.git] / include / wx / validate.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
ac8d0c11 2// Name: wx/validate.h
c801d85f
KB
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
371a5b4e 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
ac8d0c11
VZ
12#ifndef _WX_VALIDATE_H_
13#define _WX_VALIDATE_H_
c801d85f 14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
a994f81b 16 #pragma interface "validate.h"
c801d85f
KB
17#endif
18
ac8d0c11
VZ
19#include "wx/defs.h"
20
21#if wxUSE_VALIDATORS
88ac883a 22
674ac8b9
VZ
23#include "wx/event.h"
24
764a3a49 25class WXDLLEXPORT wxWindow;
f03fc89f 26class WXDLLEXPORT wxWindowBase;
c801d85f
KB
27
28/*
29 A validator has up to three purposes:
30
31 1) To validate the data in the window that's associated
32 with the validator.
33 2) To transfer data to and from the window.
34 3) To filter input, using its role as a wxEvtHandler
35 to intercept e.g. OnChar.
36
37 Note that wxValidator and derived classes use reference counting.
a994f81b 38*/
c801d85f 39
a994f81b 40class WXDLLEXPORT wxValidator : public wxEvtHandler
c801d85f 41{
c801d85f 42public:
a994f81b 43 wxValidator();
f03fc89f 44 virtual ~wxValidator();
c801d85f 45
a994f81b
VZ
46 // Make a clone of this validator (or return NULL) - currently necessary
47 // if you're passing a reference to a validator.
48 // Another possibility is to always pass a pointer to a new validator
49 // (so the calling code can use a copy constructor of the relevant class).
ca298c88 50 virtual wxObject *Clone() const
a994f81b
VZ
51 { return (wxValidator *)NULL; }
52 bool Copy(const wxValidator& val)
53 { m_validatorWindow = val.m_validatorWindow; return TRUE; }
c801d85f 54
a994f81b
VZ
55 // Called when the value in the window must be validated.
56 // This function can pop up an error message.
764a3a49 57 virtual bool Validate(wxWindow *WXUNUSED(parent)) { return FALSE; };
c801d85f 58
a994f81b
VZ
59 // Called to transfer data to the window
60 virtual bool TransferToWindow() { return FALSE; }
c801d85f 61
a994f81b
VZ
62 // Called to transfer data from the window
63 virtual bool TransferFromWindow() { return FALSE; };
c801d85f 64
a994f81b 65 // accessors
764a3a49 66 wxWindow *GetWindow() const { return (wxWindow *)m_validatorWindow; }
f03fc89f 67 void SetWindow(wxWindowBase *win) { m_validatorWindow = win; }
a994f81b
VZ
68
69 // validators beep by default if invalid key is pressed, these functions
70 // allow to change it
71 static bool IsSilent() { return ms_isSilent; }
72 static void SetBellOnError(bool doIt = TRUE) { ms_isSilent = doIt; }
c801d85f
KB
73
74protected:
f03fc89f 75 wxWindowBase *m_validatorWindow;
a994f81b
VZ
76
77private:
78 static bool ms_isSilent;
79
80 DECLARE_DYNAMIC_CLASS(wxValidator)
be52b341 81 DECLARE_NO_COPY_CLASS(wxValidator)
c801d85f
KB
82};
83
84WXDLLEXPORT_DATA(extern const wxValidator) wxDefaultValidator;
85
ac8d0c11
VZ
86#define wxVALIDATOR_PARAM(val) val
87
88#else // !wxUSE_VALIDATORS
89 // wxWindows is compiled without support for wxValidator, but we still
90 // want to be able to pass wxDefaultValidator to the functions which take
91 // a wxValidator parameter to avoid using "#if wxUSE_VALIDATORS"
92 // everywhere
93 class WXDLLEXPORT wxValidator;
94 #define wxDefaultValidator (*((wxValidator *)NULL))
95
96 // this macro allows to avoid warnings about unused parameters when
97 // wxUSE_VALIDATORS == 0
98 #define wxVALIDATOR_PARAM(val)
99#endif // wxUSE_VALIDATORS/!wxUSE_VALIDATORS
100
101#endif // _WX_VALIDATE_H_
88ac883a 102