]> git.saurik.com Git - wxWidgets.git/blame - include/wx/validate.h
Add the possibility to disable invisible wxDataViewCtrl items.
[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
65571936 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
ac8d0c11
VZ
12#ifndef _WX_VALIDATE_H_
13#define _WX_VALIDATE_H_
c801d85f 14
ac8d0c11
VZ
15#include "wx/defs.h"
16
17#if wxUSE_VALIDATORS
88ac883a 18
674ac8b9
VZ
19#include "wx/event.h"
20
b5dbe15d
VS
21class WXDLLIMPEXP_FWD_CORE wxWindow;
22class WXDLLIMPEXP_FWD_CORE 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
53a2db12 36class WXDLLIMPEXP_CORE 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
d3b9f782 47 { return NULL; }
a994f81b 48 bool Copy(const wxValidator& val)
cab1a605 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.
47b378bd 53 virtual bool Validate(wxWindow *WXUNUSED(parent)) { return false; }
c801d85f 54
a994f81b 55 // Called to transfer data to the window
cab1a605 56 virtual bool TransferToWindow() { return false; }
c801d85f 57
a994f81b 58 // Called to transfer data from the window
47b378bd 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 64
c27181d1
VZ
65 // validators beep by default if invalid key is pressed, this function
66 // allows to change this
67 static void SuppressBellOnError(bool suppress = true)
68 { ms_isSilent = suppress; }
69
70 // test if beep is currently disabled
a994f81b 71 static bool IsSilent() { return ms_isSilent; }
c27181d1
VZ
72
73 // this function is deprecated because it handled its parameter
74 // unnaturally: it disabled the bell when it was true, not false as could
75 // be expected; use SuppressBellOnError() instead
76#if WXWIN_COMPATIBILITY_2_8
77 wxDEPRECATED_INLINE(
78 static void SetBellOnError(bool doIt = true),
79 ms_isSilent = doIt;
80 )
81#endif
c801d85f
KB
82
83protected:
f03fc89f 84 wxWindowBase *m_validatorWindow;
a994f81b
VZ
85
86private:
87 static bool ms_isSilent;
88
89 DECLARE_DYNAMIC_CLASS(wxValidator)
c0c133e1 90 wxDECLARE_NO_COPY_CLASS(wxValidator);
c801d85f
KB
91};
92
53a2db12 93extern WXDLLIMPEXP_DATA_CORE(const wxValidator) wxDefaultValidator;
c801d85f 94
ac8d0c11
VZ
95#define wxVALIDATOR_PARAM(val) val
96
97#else // !wxUSE_VALIDATORS
77ffb593 98 // wxWidgets is compiled without support for wxValidator, but we still
ac8d0c11
VZ
99 // want to be able to pass wxDefaultValidator to the functions which take
100 // a wxValidator parameter to avoid using "#if wxUSE_VALIDATORS"
101 // everywhere
b5dbe15d 102 class WXDLLIMPEXP_FWD_CORE wxValidator;
b4bde7a7 103 #define wxDefaultValidator (*reinterpret_cast<wxValidator*>(NULL))
ac8d0c11
VZ
104
105 // this macro allows to avoid warnings about unused parameters when
106 // wxUSE_VALIDATORS == 0
107 #define wxVALIDATOR_PARAM(val)
108#endif // wxUSE_VALIDATORS/!wxUSE_VALIDATORS
109
110#endif // _WX_VALIDATE_H_
88ac883a 111