2011-07-28 14:26:00 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2006 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
#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:
|
2017-10-09 19:45:33 +00:00
|
|
|
|
2012-08-16 14:58:06 +00:00
|
|
|
|
|
|
|
SkEventSink();
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual ~SkEventSink();
|
|
|
|
|
2011-08-04 13:50:17 +00:00
|
|
|
/**
|
|
|
|
* Returns this eventsink's unique ID. Use this to post SkEvents to
|
|
|
|
* this eventsink.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
SkEventSinkID getSinkID() const { return fID; }
|
|
|
|
|
2011-08-04 13:50:17 +00:00
|
|
|
/**
|
|
|
|
* Call this to pass an event to this object for processing. Returns true if the
|
|
|
|
* event was handled.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
bool doEvent(const SkEvent&);
|
2011-08-04 13:50:17 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** 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);
|
|
|
|
|
2011-08-04 13:50:17 +00:00
|
|
|
/**
|
|
|
|
* Returns the matching eventsink, or null if not found
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
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;
|
2012-08-16 14:58:06 +00:00
|
|
|
|
|
|
|
typedef SkRefCnt INHERITED;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|