OLD | NEW |
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_AURA_EVENT_H_ | 5 #ifndef UI_AURA_EVENT_H_ |
6 #define UI_AURA_EVENT_H_ | 6 #define UI_AURA_EVENT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/event_types.h" | 10 #include "base/event_types.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 TestApi(); | 40 TestApi(); |
41 Event* event_; | 41 Event* event_; |
42 }; | 42 }; |
43 | 43 |
44 const base::NativeEvent& native_event() const { return native_event_; } | 44 const base::NativeEvent& native_event() const { return native_event_; } |
45 ui::EventType type() const { return type_; } | 45 ui::EventType type() const { return type_; } |
46 // time_stamp represents time since machine was booted. | 46 // time_stamp represents time since machine was booted. |
47 const base::TimeDelta& time_stamp() const { return time_stamp_; } | 47 const base::TimeDelta& time_stamp() const { return time_stamp_; } |
48 int flags() const { return flags_; } | 48 int flags() const { return flags_; } |
49 | 49 |
| 50 // This is only intended to be used externally by classes that are modifying |
| 51 // events in EventFilter::PreHandleKeyEvent(). |
| 52 void set_flags(int flags) { flags_ = flags; } |
| 53 |
50 // The following methods return true if the respective keys were pressed at | 54 // The following methods return true if the respective keys were pressed at |
51 // the time the event was created. | 55 // the time the event was created. |
52 bool IsShiftDown() const { return (flags_ & ui::EF_SHIFT_DOWN) != 0; } | 56 bool IsShiftDown() const { return (flags_ & ui::EF_SHIFT_DOWN) != 0; } |
53 bool IsControlDown() const { return (flags_ & ui::EF_CONTROL_DOWN) != 0; } | 57 bool IsControlDown() const { return (flags_ & ui::EF_CONTROL_DOWN) != 0; } |
54 bool IsCapsLockDown() const { return (flags_ & ui::EF_CAPS_LOCK_DOWN) != 0; } | 58 bool IsCapsLockDown() const { return (flags_ & ui::EF_CAPS_LOCK_DOWN) != 0; } |
55 bool IsAltDown() const { return (flags_ & ui::EF_ALT_DOWN) != 0; } | 59 bool IsAltDown() const { return (flags_ & ui::EF_ALT_DOWN) != 0; } |
56 | 60 |
57 // Returns true if the event has a valid |native_event_|. | 61 // Returns true if the event has a valid |native_event_|. |
58 bool HasNativeEvent() const; | 62 bool HasNativeEvent() const; |
59 | 63 |
60 protected: | 64 protected: |
61 Event(ui::EventType type, int flags); | 65 Event(ui::EventType type, int flags); |
62 Event(const base::NativeEvent& native_event, ui::EventType type, int flags); | 66 Event(const base::NativeEvent& native_event, ui::EventType type, int flags); |
63 Event(const Event& copy); | 67 Event(const Event& copy); |
64 void set_type(ui::EventType type) { type_ = type; } | 68 void set_type(ui::EventType type) { type_ = type; } |
65 void set_flags(int flags) { flags_ = flags; } | |
66 void set_delete_native_event(bool delete_native_event) { | 69 void set_delete_native_event(bool delete_native_event) { |
67 delete_native_event_ = delete_native_event; | 70 delete_native_event_ = delete_native_event; |
68 } | 71 } |
69 void set_time_stamp(base::TimeDelta time_stamp) { time_stamp_ = time_stamp; } | 72 void set_time_stamp(base::TimeDelta time_stamp) { time_stamp_ = time_stamp; } |
70 | 73 |
71 private: | 74 private: |
72 void operator=(const Event&); | 75 void operator=(const Event&); |
73 | 76 |
74 // Safely initializes the native event members of this class. | 77 // Safely initializes the native event members of this class. |
75 void Init(); | 78 void Init(); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // Gets the character generated by this key event ignoring concurrently-held | 246 // Gets the character generated by this key event ignoring concurrently-held |
244 // modifiers (except shift). | 247 // modifiers (except shift). |
245 uint16 GetUnmodifiedCharacter() const; | 248 uint16 GetUnmodifiedCharacter() const; |
246 | 249 |
247 // Returns the copy of this key event. Used in NativeWebKeyboardEvent. | 250 // Returns the copy of this key event. Used in NativeWebKeyboardEvent. |
248 KeyEvent* Copy(); | 251 KeyEvent* Copy(); |
249 | 252 |
250 ui::KeyboardCode key_code() const { return key_code_; } | 253 ui::KeyboardCode key_code() const { return key_code_; } |
251 bool is_char() const { return is_char_; } | 254 bool is_char() const { return is_char_; } |
252 | 255 |
| 256 // This is only intended to be used externally by classes that are modifying |
| 257 // events in EventFilter::PreHandleKeyEvent(). set_character() should also be |
| 258 // called. |
| 259 void set_key_code(ui::KeyboardCode key_code) { key_code_ = key_code; } |
| 260 |
253 private: | 261 private: |
254 ui::KeyboardCode key_code_; | 262 ui::KeyboardCode key_code_; |
255 // True if this is a translated character event (vs. a raw key down). Both | 263 // True if this is a translated character event (vs. a raw key down). Both |
256 // share the same type: ui::ET_KEY_PRESSED. | 264 // share the same type: ui::ET_KEY_PRESSED. |
257 bool is_char_; | 265 bool is_char_; |
258 | 266 |
259 uint16 character_; | 267 uint16 character_; |
260 uint16 unmodified_character_; | 268 uint16 unmodified_character_; |
261 }; | 269 }; |
262 | 270 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 // This value is stored as a bitfield because the number of touch ids varies, | 368 // This value is stored as a bitfield because the number of touch ids varies, |
361 // but we currently don't need more than 32 touches at a time. | 369 // but we currently don't need more than 32 touches at a time. |
362 const unsigned int touch_ids_bitfield_; | 370 const unsigned int touch_ids_bitfield_; |
363 | 371 |
364 DISALLOW_COPY_AND_ASSIGN(GestureEvent); | 372 DISALLOW_COPY_AND_ASSIGN(GestureEvent); |
365 }; | 373 }; |
366 | 374 |
367 } // namespace aura | 375 } // namespace aura |
368 | 376 |
369 #endif // UI_AURA_EVENT_H_ | 377 #endif // UI_AURA_EVENT_H_ |
OLD | NEW |