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

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
40 DISALLOW_COPY_AND_ASSIGN(DispatcherApi);
41 };
42
27 // For testing. 43 // For testing.
28 class TestApi { 44 class TestApi {
29 public: 45 public:
30 explicit TestApi(Event* event) : event_(event) {} 46 explicit TestApi(Event* event) : event_(event) {}
31 47
32 void set_time_stamp(const base::TimeDelta& time_stamp) { 48 void set_time_stamp(const base::TimeDelta& time_stamp) {
33 event_->time_stamp_ = time_stamp; 49 event_->time_stamp_ = time_stamp;
34 } 50 }
35 51
36 private: 52 private:
37 TestApi(); 53 TestApi();
38 Event* event_; 54 Event* event_;
39 }; 55 };
40 56
41 const base::NativeEvent& native_event() const { return native_event_; } 57 const base::NativeEvent& native_event() const { return native_event_; }
42 EventType type() const { return type_; } 58 EventType type() const { return type_; }
43 // time_stamp represents time since machine was booted. 59 // time_stamp represents time since machine was booted.
44 const base::TimeDelta& time_stamp() const { return time_stamp_; } 60 const base::TimeDelta& time_stamp() const { return time_stamp_; }
45 int flags() const { return flags_; } 61 int flags() const { return flags_; }
46 62
47 // This is only intended to be used externally by classes that are modifying 63 // This is only intended to be used externally by classes that are modifying
48 // events in EventFilter::PreHandleKeyEvent(). 64 // events in EventFilter::PreHandleKeyEvent().
49 void set_flags(int flags) { flags_ = flags; } 65 void set_flags(int flags) { flags_ = flags; }
50 66
67 EventTarget* target() const { return target_; }
68
51 // The following methods return true if the respective keys were pressed at 69 // The following methods return true if the respective keys were pressed at
52 // the time the event was created. 70 // the time the event was created.
53 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; } 71 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; }
54 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; } 72 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; }
55 bool IsCapsLockDown() const { return (flags_ & EF_CAPS_LOCK_DOWN) != 0; } 73 bool IsCapsLockDown() const { return (flags_ & EF_CAPS_LOCK_DOWN) != 0; }
56 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; } 74 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; }
57 75
58 bool IsKeyEvent() const { 76 bool IsKeyEvent() const {
59 return type_ == ET_KEY_PRESSED || 77 return type_ == ET_KEY_PRESSED ||
60 type_ == ET_KEY_RELEASED || 78 type_ == ET_KEY_RELEASED ||
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 163
146 // Safely initializes the native event members of this class. 164 // Safely initializes the native event members of this class.
147 void Init(); 165 void Init();
148 void InitWithNativeEvent(const base::NativeEvent& native_event); 166 void InitWithNativeEvent(const base::NativeEvent& native_event);
149 167
150 base::NativeEvent native_event_; 168 base::NativeEvent native_event_;
151 EventType type_; 169 EventType type_;
152 base::TimeDelta time_stamp_; 170 base::TimeDelta time_stamp_;
153 int flags_; 171 int flags_;
154 bool delete_native_event_; 172 bool delete_native_event_;
173 EventTarget* target_;
155 }; 174 };
156 175
157 class UI_EXPORT LocatedEvent : public Event { 176 class UI_EXPORT LocatedEvent : public Event {
158 public: 177 public:
159 // For testing. 178 // For testing.
160 class TestApi : public Event::TestApi { 179 class TestApi : public Event::TestApi {
161 public: 180 public:
162 explicit TestApi(LocatedEvent* located_event) 181 explicit TestApi(LocatedEvent* located_event)
163 : Event::TestApi(located_event), 182 : Event::TestApi(located_event),
164 located_event_(located_event) {} 183 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, 614 // 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. 615 // but we currently don't need more than 32 touches at a time.
597 const unsigned int touch_ids_bitfield_; 616 const unsigned int touch_ids_bitfield_;
598 617
599 DISALLOW_COPY_AND_ASSIGN(GestureEvent); 618 DISALLOW_COPY_AND_ASSIGN(GestureEvent);
600 }; 619 };
601 620
602 } // namespace ui 621 } // namespace ui
603 622
604 #endif // UI_BASE_EVENTS_EVENT_CONSTANTS_EVENT_H_ 623 #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