]> git.saurik.com Git - wxWidgets.git/blame - include/wx/eventfilter.h
using Run of base class
[wxWidgets.git] / include / wx / eventfilter.h
CommitLineData
58cc1587
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/eventfilter.h
3// Purpose: wxEventFilter class declaration.
4// Author: Vadim Zeitlin
5// Created: 2011-11-21
58cc1587
VZ
6// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
7// Licence: wxWindows licence
8///////////////////////////////////////////////////////////////////////////////
9
10#ifndef _WX_EVENTFILTER_H_
11#define _WX_EVENTFILTER_H_
12
13#include "wx/defs.h"
14
15class WXDLLIMPEXP_FWD_BASE wxEvent;
16class WXDLLIMPEXP_FWD_BASE wxEvtHandler;
17
18// ----------------------------------------------------------------------------
19// wxEventFilter is used with wxEvtHandler::AddFilter() and ProcessEvent().
20// ----------------------------------------------------------------------------
21
22class wxEventFilter
23{
24public:
25 // Possible return values for FilterEvent().
26 //
27 // Notice that the values of these enum elements are fixed due to backwards
28 // compatibility constraints.
29 enum
30 {
31 // Process event as usual.
32 Event_Skip = -1,
33
34 // Don't process the event normally at all.
35 Event_Ignore = 0,
36
37 // Event was already handled, don't process it normally.
38 Event_Processed = 1
39 };
40
41 wxEventFilter()
42 {
43 m_next = NULL;
44 }
45
46 virtual ~wxEventFilter()
47 {
48 wxASSERT_MSG( !m_next, "Forgot to call wxEvtHandler::RemoveFilter()?" );
49 }
50
51 // This method allows to filter all the events processed by the program, so
52 // you should try to return quickly from it to avoid slowing down the
d9384bfb 53 // program to a crawl.
58cc1587
VZ
54 //
55 // Return value should be -1 to continue with the normal event processing,
56 // or true or false to stop further processing and pretend that the event
57 // had been already processed or won't be processed at all, respectively.
58 virtual int FilterEvent(wxEvent& event) = 0;
59
60private:
61 // Objects of this class are made to be stored in a linked list in
62 // wxEvtHandler so put the next node ponter directly in the class itself.
63 wxEventFilter* m_next;
64
65 // And provide access to it for wxEvtHandler [only].
66 friend class wxEvtHandler;
67
68 wxDECLARE_NO_COPY_CLASS(wxEventFilter);
69};
70
71#endif // _WX_EVENTFILTER_H_