OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "views/events/event.h" | 5 #include "views/events/event.h" |
6 | 6 |
7 #include "views/view.h" | 7 #include "views/view.h" |
8 #include "views/widget/root_view.h" | 8 #include "views/widget/root_view.h" |
9 | 9 |
10 namespace views { | 10 namespace views { |
(...skipping 20 matching lines...) Expand all Loading... |
31 : native_event_2_(native_event_2), | 31 : native_event_2_(native_event_2), |
32 type_(type), | 32 type_(type), |
33 time_stamp_(base::Time::NowFromSystemTime()), | 33 time_stamp_(base::Time::NowFromSystemTime()), |
34 flags_(flags) { | 34 flags_(flags) { |
35 InitWithNativeEvent2(native_event_2, from_native); | 35 InitWithNativeEvent2(native_event_2, from_native); |
36 } | 36 } |
37 | 37 |
38 //////////////////////////////////////////////////////////////////////////////// | 38 //////////////////////////////////////////////////////////////////////////////// |
39 // LocatedEvent, protected: | 39 // LocatedEvent, protected: |
40 | 40 |
| 41 // TODO(msw): Kill this legacy constructor when we update uses. |
41 LocatedEvent::LocatedEvent(ui::EventType type, const gfx::Point& location, | 42 LocatedEvent::LocatedEvent(ui::EventType type, const gfx::Point& location, |
42 int flags) | 43 int flags) |
43 : Event(type, flags), | 44 : Event(type, flags), |
44 location_(location) { | 45 location_(location) { |
45 } | 46 } |
46 | 47 |
47 LocatedEvent::LocatedEvent(const LocatedEvent& model, View* source, | 48 LocatedEvent::LocatedEvent(const LocatedEvent& model, View* source, |
48 View* target) | 49 View* target) |
49 : Event(model), | 50 : Event(model), |
50 location_(model.location_) { | 51 location_(model.location_) { |
51 if (target) | 52 if (target) |
52 View::ConvertPointToView(source, target, &location_); | 53 View::ConvertPointToView(source, target, &location_); |
53 } | 54 } |
54 | 55 |
55 //////////////////////////////////////////////////////////////////////////////// | |
56 // LocatedEvent, private: | |
57 | |
58 LocatedEvent::LocatedEvent(const LocatedEvent& model, RootView* root) | 56 LocatedEvent::LocatedEvent(const LocatedEvent& model, RootView* root) |
59 : Event(model), | 57 : Event(model), |
60 location_(model.location_) { | 58 location_(model.location_) { |
61 View::ConvertPointFromWidget(root, &location_); | 59 View::ConvertPointFromWidget(root, &location_); |
62 } | 60 } |
63 | 61 |
64 //////////////////////////////////////////////////////////////////////////////// | 62 //////////////////////////////////////////////////////////////////////////////// |
65 // KeyEvent, public: | 63 // KeyEvent, public: |
66 | 64 |
67 KeyEvent::KeyEvent(ui::EventType type, ui::KeyboardCode key_code, | 65 KeyEvent::KeyEvent(ui::EventType type, ui::KeyboardCode key_code, |
68 int event_flags) | 66 int event_flags) |
69 : Event(type, event_flags), | 67 : Event(type, event_flags), |
70 key_code_(key_code) { | 68 key_code_(key_code) { |
71 } | 69 } |
72 | 70 |
73 //////////////////////////////////////////////////////////////////////////////// | 71 //////////////////////////////////////////////////////////////////////////////// |
74 // MouseEvent, public: | 72 // MouseEvent, public: |
75 | 73 |
| 74 // TODO(msw): Kill this legacy constructor when we update uses. |
76 MouseEvent::MouseEvent(ui::EventType type, | 75 MouseEvent::MouseEvent(ui::EventType type, |
77 View* from, | 76 View* source, |
78 View* to, | 77 View* target, |
79 const gfx::Point &l, | 78 const gfx::Point &l, |
80 int flags) | 79 int flags) |
81 : LocatedEvent(MouseEvent(type, l.x(), l.y(), flags), from, to) { | 80 : LocatedEvent(MouseEvent(type, l.x(), l.y(), flags), source, target) { |
82 } | 81 } |
83 | 82 |
84 MouseEvent::MouseEvent(const MouseEvent& model, View* from, View* to) | 83 MouseEvent::MouseEvent(const MouseEvent& model, View* source, View* target) |
85 : LocatedEvent(model, from, to) { | 84 : LocatedEvent(model, source, target) { |
86 } | 85 } |
87 | 86 |
88 //////////////////////////////////////////////////////////////////////////////// | 87 //////////////////////////////////////////////////////////////////////////////// |
89 // TouchEvent, public: | 88 // TouchEvent, public: |
90 | 89 |
91 #if defined(TOUCH_UI) | 90 #if defined(TOUCH_UI) |
92 TouchEvent::TouchEvent(ui::EventType type, int x, int y, int flags, | 91 TouchEvent::TouchEvent(ui::EventType type, int x, int y, int flags, |
93 int touch_id) | 92 int touch_id) |
94 : LocatedEvent(type, gfx::Point(x, y), flags), | 93 : LocatedEvent(type, gfx::Point(x, y), flags), |
95 touch_id_(touch_id) { | 94 touch_id_(touch_id) { |
96 } | 95 } |
97 | 96 |
98 | 97 |
99 TouchEvent::TouchEvent(ui::EventType type, | 98 TouchEvent::TouchEvent(ui::EventType type, |
100 View* from, | 99 View* source, |
101 View* to, | 100 View* target, |
102 const gfx::Point& l, | 101 const gfx::Point& l, |
103 int flags, | 102 int flags, |
104 int touch_id) | 103 int touch_id) |
105 : LocatedEvent(TouchEvent(type, l.x(), l.y(), flags, touch_id), from, to), | 104 : LocatedEvent(TouchEvent(type, l.x(), l.y(), flags, touch_id), source, |
| 105 target), |
106 touch_id_(touch_id) { | 106 touch_id_(touch_id) { |
107 } | 107 } |
108 | 108 |
109 TouchEvent::TouchEvent(const TouchEvent& model, View* from, View* to) | 109 TouchEvent::TouchEvent(const TouchEvent& model, View* source, View* target) |
110 : LocatedEvent(model, from, to), | 110 : LocatedEvent(model, source, target), |
111 touch_id_(model.touch_id_) { | 111 touch_id_(model.touch_id_) { |
112 } | 112 } |
113 #endif | 113 #endif |
114 | 114 |
115 //////////////////////////////////////////////////////////////////////////////// | 115 //////////////////////////////////////////////////////////////////////////////// |
116 // MouseWheelEvent, public: | 116 // MouseWheelEvent, public: |
117 | 117 |
118 // This value matches windows WHEEL_DELTA. | 118 // This value matches windows WHEEL_DELTA. |
119 // static | 119 // static |
120 const int MouseWheelEvent::kWheelDelta = 120; | 120 const int MouseWheelEvent::kWheelDelta = 120; |
121 | 121 |
122 } // namespace views | 122 } // namespace views |
OLD | NEW |