aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/views/SkEventSink.h
blob: 076ddb316d5359266fc8eaed9addafa9325462d2 (plain)
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

/*
 * Copyright 2006 The Android Open Source Project
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */


#ifndef SkEventSink_DEFINED
#define SkEventSink_DEFINED

#include "SkRefCnt.h"
#include "SkEvent.h"

/** \class SkEventSink

    SkEventSink is the base class for all objects that receive SkEvents.
*/
class SkEventSink : public SkRefCnt {
public:


             SkEventSink();
    virtual ~SkEventSink();

    /**
     *  Returns this eventsink's unique ID. Use this to post SkEvents to
     *  this eventsink.
     */
    SkEventSinkID getSinkID() const { return fID; }

    /**
     *  Call this to pass an event to this object for processing. Returns true if the
     *  event was handled.
     */
    bool doEvent(const SkEvent&);

    /** Returns true if the sink (or one of its subclasses) understands the event as a query.
        If so, the sink may modify the event to communicate its "answer".
    */
    bool doQuery(SkEvent* query);

    /**
     *  Returns the matching eventsink, or null if not found
     */
    static SkEventSink* FindSink(SkEventSinkID);

protected:
    /** Override this to handle events in your subclass. Be sure to call the inherited version
        for events that you don't handle.
    */
    virtual bool onEvent(const SkEvent&);
    virtual bool onQuery(SkEvent*);

private:
    SkEventSinkID   fID;

    // for our private link-list
    SkEventSink*    fNextSink;

    typedef SkRefCnt INHERITED;
};

#endif