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