OLD | NEW |
1 // Copyright (c) 2006-2008 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 | 8 |
9 namespace views { | 9 namespace views { |
10 | 10 |
| 11 //////////////////////////////////////////////////////////////////////////////// |
| 12 // Event, protected: |
| 13 |
11 Event::Event(ui::EventType type, int flags) | 14 Event::Event(ui::EventType type, int flags) |
12 : type_(type), | 15 : type_(type), |
13 time_stamp_(base::Time::NowFromSystemTime()), | 16 time_stamp_(base::Time::NowFromSystemTime()), |
14 flags_(flags) { | 17 flags_(flags) { |
| 18 Init(); |
15 } | 19 } |
16 | 20 |
| 21 Event::Event(NativeEvent native_event, ui::EventType type, int flags) |
| 22 : type_(type), |
| 23 time_stamp_(base::Time::NowFromSystemTime()), |
| 24 flags_(flags) { |
| 25 InitWithNativeEvent(native_event); |
| 26 } |
| 27 |
| 28 Event::Event(NativeEvent2 native_event_2, ui::EventType type, int flags, |
| 29 FromNativeEvent2 from_native) |
| 30 : native_event_2_(native_event_2), |
| 31 type_(type), |
| 32 time_stamp_(base::Time::NowFromSystemTime()), |
| 33 flags_(flags) { |
| 34 InitWithNativeEvent2(native_event_2, from_native); |
| 35 } |
| 36 |
| 37 //////////////////////////////////////////////////////////////////////////////// |
| 38 // LocatedEvent, public: |
| 39 |
17 LocatedEvent::LocatedEvent(const LocatedEvent& model, View* from, View* to) | 40 LocatedEvent::LocatedEvent(const LocatedEvent& model, View* from, View* to) |
18 : Event(model), | 41 : Event(model), |
19 location_(model.location_) { | 42 location_(model.location_) { |
20 if (to) | 43 if (to) |
21 View::ConvertPointToView(from, to, &location_); | 44 View::ConvertPointToView(from, to, &location_); |
22 } | 45 } |
23 | 46 |
| 47 //////////////////////////////////////////////////////////////////////////////// |
| 48 // KeyEvent, public: |
| 49 |
24 KeyEvent::KeyEvent(ui::EventType type, ui::KeyboardCode key_code, | 50 KeyEvent::KeyEvent(ui::EventType type, ui::KeyboardCode key_code, |
25 int event_flags, int repeat_count, int message_flags) | 51 int event_flags) |
26 : Event(type, event_flags), | 52 : Event(type, event_flags), |
27 key_code_(key_code), | 53 key_code_(key_code) { |
28 repeat_count_(repeat_count), | |
29 message_flags_(message_flags) { | |
30 } | 54 } |
31 | 55 |
| 56 //////////////////////////////////////////////////////////////////////////////// |
| 57 // MouseEvent, public: |
| 58 |
32 MouseEvent::MouseEvent(ui::EventType type, | 59 MouseEvent::MouseEvent(ui::EventType type, |
33 View* from, | 60 View* from, |
34 View* to, | 61 View* to, |
35 const gfx::Point &l, | 62 const gfx::Point &l, |
36 int flags) | 63 int flags) |
37 : LocatedEvent(LocatedEvent(type, gfx::Point(l.x(), l.y()), flags), | 64 : LocatedEvent(LocatedEvent(type, gfx::Point(l.x(), l.y()), flags), |
38 from, | 65 from, |
39 to) { | 66 to) { |
40 }; | 67 }; |
41 | 68 |
42 MouseEvent::MouseEvent(const MouseEvent& model, View* from, View* to) | 69 MouseEvent::MouseEvent(const MouseEvent& model, View* from, View* to) |
43 : LocatedEvent(model, from, to) { | 70 : LocatedEvent(model, from, to) { |
44 } | 71 } |
45 | 72 |
| 73 //////////////////////////////////////////////////////////////////////////////// |
| 74 // TouchEvent, public: |
| 75 |
46 #if defined(TOUCH_UI) | 76 #if defined(TOUCH_UI) |
47 TouchEvent::TouchEvent(ui::EventType type, int x, int y, int flags, int touch_id
) | 77 TouchEvent::TouchEvent(ui::EventType type, int x, int y, int flags, int touch_id
) |
48 : LocatedEvent(type, gfx::Point(x, y), flags), | 78 : LocatedEvent(type, gfx::Point(x, y), flags), |
49 touch_id_(touch_id) { | 79 touch_id_(touch_id) { |
50 } | 80 } |
51 | 81 |
52 | 82 |
53 TouchEvent::TouchEvent(ui::EventType type, | 83 TouchEvent::TouchEvent(ui::EventType type, |
54 View* from, | 84 View* from, |
55 View* to, | 85 View* to, |
56 const gfx::Point& l, | 86 const gfx::Point& l, |
57 int flags, | 87 int flags, |
58 int touch_id) | 88 int touch_id) |
59 : LocatedEvent(LocatedEvent(type, gfx::Point(l.x(), l.y()), flags), | 89 : LocatedEvent(LocatedEvent(type, gfx::Point(l.x(), l.y()), flags), |
60 from, | 90 from, |
61 to), | 91 to), |
62 touch_id_(touch_id) { | 92 touch_id_(touch_id) { |
63 } | 93 } |
64 | 94 |
65 TouchEvent::TouchEvent(const TouchEvent& model, View* from, View* to) | 95 TouchEvent::TouchEvent(const TouchEvent& model, View* from, View* to) |
66 : LocatedEvent(model, from, to), | 96 : LocatedEvent(model, from, to), |
67 touch_id_(model.touch_id_) { | 97 touch_id_(model.touch_id_) { |
68 } | 98 } |
69 #endif | 99 #endif |
70 | 100 |
71 } // namespace views | 101 } // namespace views |
OLD | NEW |