File: eventfilter.h

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (71 lines) | stat: -rw-r--r-- 2,247 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
///////////////////////////////////////////////////////////////////////////////
// Name:        wx/eventfilter.h
// Purpose:     wxEventFilter class declaration.
// Author:      Vadim Zeitlin
// Created:     2011-11-21
// Copyright:   (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence:     wxWindows licence
///////////////////////////////////////////////////////////////////////////////

#ifndef _WX_EVENTFILTER_H_
#define _WX_EVENTFILTER_H_

#include "wx/defs.h"

class WXDLLIMPEXP_FWD_BASE wxEvent;
class WXDLLIMPEXP_FWD_BASE wxEvtHandler;

// ----------------------------------------------------------------------------
// wxEventFilter is used with wxEvtHandler::AddFilter() and ProcessEvent().
// ----------------------------------------------------------------------------

class wxEventFilter
{
public:
    // Possible return values for FilterEvent().
    //
    // Notice that the values of these enum elements are fixed due to backwards
    // compatibility constraints.
    enum
    {
        // Process event as usual.
        Event_Skip = -1,

        // Don't process the event normally at all.
        Event_Ignore = 0,

        // Event was already handled, don't process it normally.
        Event_Processed = 1
    };

    wxEventFilter()
    {
        m_next = NULL;
    }

    virtual ~wxEventFilter()
    {
        wxASSERT_MSG( !m_next, "Forgot to call wxEvtHandler::RemoveFilter()?" );
    }

    // This method allows to filter all the events processed by the program, so
    // you should try to return quickly from it to avoid slowing down the
    // program to a crawl.
    //
    // Return value should be -1 to continue with the normal event processing,
    // or true or false to stop further processing and pretend that the event
    // had been already processed or won't be processed at all, respectively.
    virtual int FilterEvent(wxEvent& event) = 0;

private:
    // Objects of this class are made to be stored in a linked list in
    // wxEvtHandler so put the next node ponter directly in the class itself.
    wxEventFilter* m_next;

    // And provide access to it for wxEvtHandler [only].
    friend class wxEvtHandler;

    wxDECLARE_NO_COPY_CLASS(wxEventFilter);
};

#endif // _WX_EVENTFILTER_H_