Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: ui/base/events/event.h

Issue 10908127: events: Move EventTarget into Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/event_unittest.cc ('k') | ui/base/events/event.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_BASE_EVENTS_EVENT_CONSTANTS_EVENT_H_ 5 #ifndef UI_BASE_EVENTS_EVENT_CONSTANTS_EVENT_H_
6 #define UI_BASE_EVENTS_EVENT_CONSTANTS_EVENT_H_ 6 #define UI_BASE_EVENTS_EVENT_CONSTANTS_EVENT_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/event_types.h" 10 #include "base/event_types.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "ui/base/dragdrop/os_exchange_data.h" 13 #include "ui/base/dragdrop/os_exchange_data.h"
14 #include "ui/base/events/event_constants.h" 14 #include "ui/base/events/event_constants.h"
15 #include "ui/base/gestures/gesture_types.h" 15 #include "ui/base/gestures/gesture_types.h"
16 #include "ui/base/keycodes/keyboard_codes.h" 16 #include "ui/base/keycodes/keyboard_codes.h"
17 #include "ui/base/ui_export.h" 17 #include "ui/base/ui_export.h"
18 #include "ui/gfx/point.h" 18 #include "ui/gfx/point.h"
19 19
20 namespace ui { 20 namespace ui {
21 class Transform; 21 class Transform;
22 class EventTarget;
22 23
23 class UI_EXPORT Event { 24 class UI_EXPORT Event {
24 public: 25 public:
25 virtual ~Event(); 26 virtual ~Event();
26 27
28 class DispatcherApi {
29 public:
30 explicit DispatcherApi(Event* event) : event_(event) {}
31
32 void set_target(EventTarget* target) {
33 event_->target_ = target;
34 }
35
36 private:
37 DispatcherApi();
38 Event* event_;
39 };
Ben Goodger (Google) 2012/09/06 22:19:57 disallow_copy..
sadrul 2012/09/06 23:04:46 Done.
40
27 // For testing. 41 // For testing.
28 class TestApi { 42 class TestApi {
29 public: 43 public:
30 explicit TestApi(Event* event) : event_(event) {} 44 explicit TestApi(Event* event) : event_(event) {}
31 45
32 void set_time_stamp(const base::TimeDelta& time_stamp) { 46 void set_time_stamp(const base::TimeDelta& time_stamp) {
33 event_->time_stamp_ = time_stamp; 47 event_->time_stamp_ = time_stamp;
34 } 48 }
35 49
36 private: 50 private:
37 TestApi(); 51 TestApi();
38 Event* event_; 52 Event* event_;
39 }; 53 };
40 54
41 const base::NativeEvent& native_event() const { return native_event_; } 55 const base::NativeEvent& native_event() const { return native_event_; }
42 EventType type() const { return type_; } 56 EventType type() const { return type_; }
43 // time_stamp represents time since machine was booted. 57 // time_stamp represents time since machine was booted.
44 const base::TimeDelta& time_stamp() const { return time_stamp_; } 58 const base::TimeDelta& time_stamp() const { return time_stamp_; }
45 int flags() const { return flags_; } 59 int flags() const { return flags_; }
46 60
47 // This is only intended to be used externally by classes that are modifying 61 // This is only intended to be used externally by classes that are modifying
48 // events in EventFilter::PreHandleKeyEvent(). 62 // events in EventFilter::PreHandleKeyEvent().
49 void set_flags(int flags) { flags_ = flags; } 63 void set_flags(int flags) { flags_ = flags; }
50 64
65 EventTarget* target() const { return target_; }
66
51 // The following methods return true if the respective keys were pressed at 67 // The following methods return true if the respective keys were pressed at
52 // the time the event was created. 68 // the time the event was created.
53 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; } 69 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; }
54 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; } 70 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; }
55 bool IsCapsLockDown() const { return (flags_ & EF_CAPS_LOCK_DOWN) != 0; } 71 bool IsCapsLockDown() const { return (flags_ & EF_CAPS_LOCK_DOWN) != 0; }
56 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; } 72 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; }
57 73
58 bool IsKeyEvent() const { 74 bool IsKeyEvent() const {
59 return type_ == ET_KEY_PRESSED || 75 return type_ == ET_KEY_PRESSED ||
60 type_ == ET_KEY_RELEASED || 76 type_ == ET_KEY_RELEASED ||
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 161
146 // Safely initializes the native event members of this class. 162 // Safely initializes the native event members of this class.
147 void Init(); 163 void Init();
148 void InitWithNativeEvent(const base::NativeEvent& native_event); 164 void InitWithNativeEvent(const base::NativeEvent& native_event);
149 165
150 base::NativeEvent native_event_; 166 base::NativeEvent native_event_;
151 EventType type_; 167 EventType type_;
152 base::TimeDelta time_stamp_; 168 base::TimeDelta time_stamp_;
153 int flags_; 169 int flags_;
154 bool delete_native_event_; 170 bool delete_native_event_;
171 EventTarget* target_;
155 }; 172 };
156 173
157 class UI_EXPORT LocatedEvent : public Event { 174 class UI_EXPORT LocatedEvent : public Event {
158 public: 175 public:
159 // For testing. 176 // For testing.
160 class TestApi : public Event::TestApi { 177 class TestApi : public Event::TestApi {
161 public: 178 public:
162 explicit TestApi(LocatedEvent* located_event) 179 explicit TestApi(LocatedEvent* located_event)
163 : Event::TestApi(located_event), 180 : Event::TestApi(located_event),
164 located_event_(located_event) {} 181 located_event_(located_event) {}
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 // This value is stored as a bitfield because the number of touch ids varies, 612 // This value is stored as a bitfield because the number of touch ids varies,
596 // but we currently don't need more than 32 touches at a time. 613 // but we currently don't need more than 32 touches at a time.
597 const unsigned int touch_ids_bitfield_; 614 const unsigned int touch_ids_bitfield_;
598 615
599 DISALLOW_COPY_AND_ASSIGN(GestureEvent); 616 DISALLOW_COPY_AND_ASSIGN(GestureEvent);
600 }; 617 };
601 618
602 } // namespace ui 619 } // namespace ui
603 620
604 #endif // UI_BASE_EVENTS_EVENT_CONSTANTS_EVENT_H_ 621 #endif // UI_BASE_EVENTS_EVENT_CONSTANTS_EVENT_H_
OLDNEW
« no previous file with comments | « ui/base/event_unittest.cc ('k') | ui/base/events/event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698