Roll src/third_party/skia 591a2ca:b3fe1b8
[chromium-blink-merge.git] / ui / events / event_handler.h
blob088c3f84253b8e1bbc65d3526f9ff05da76fe898
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_EVENT_HANDLER_H_
6 #define UI_EVENTS_EVENT_HANDLER_H_
8 #include <stack>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "ui/events/event_constants.h"
13 #include "ui/events/events_export.h"
15 namespace ui {
17 class CancelModeEvent;
18 class Event;
19 class EventDispatcher;
20 class EventTarget;
21 class GestureEvent;
22 class KeyEvent;
23 class MouseEvent;
24 class ScrollEvent;
25 class TouchEvent;
27 // Dispatches events to appropriate targets. The default implementations of
28 // all of the specific handlers (e.g. OnKeyEvent, OnMouseEvent) do nothing.
29 class EVENTS_EXPORT EventHandler {
30 public:
31 EventHandler();
32 virtual ~EventHandler();
34 // This is called for all events. The default implementation routes the event
35 // to one of the event-specific callbacks (OnKeyEvent, OnMouseEvent etc.). If
36 // this is overridden, then normally, the override should chain into the
37 // default implementation for un-handled events.
38 virtual void OnEvent(Event* event);
40 virtual void OnKeyEvent(KeyEvent* event);
42 virtual void OnMouseEvent(MouseEvent* event);
44 virtual void OnScrollEvent(ScrollEvent* event);
46 virtual void OnTouchEvent(TouchEvent* event);
48 virtual void OnGestureEvent(GestureEvent* event);
50 virtual void OnCancelMode(CancelModeEvent* event);
52 private:
53 friend class EventDispatcher;
55 // EventDispatcher pushes itself on the top of this stack while dispatching
56 // events to this then pops itself off when done.
57 std::stack<EventDispatcher*> dispatchers_;
59 DISALLOW_COPY_AND_ASSIGN(EventHandler);
62 typedef std::vector<EventHandler*> EventHandlerList;
64 } // namespace ui
66 #endif // UI_EVENTS_EVENT_HANDLER_H_