| 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 // This class describe a keyboard accelerator (or keyboard shortcut). | 5 // This class describe a keyboard accelerator (or keyboard shortcut). |
| 6 // Keyboard accelerators are registered with the FocusManager. | 6 // Keyboard accelerators are registered with the FocusManager. |
| 7 // It has a copy constructor and assignment operator so that it can be copied. | 7 // It has a copy constructor and assignment operator so that it can be copied. |
| 8 // It also defines the < operator so that it can be used as a key in a std::map. | 8 // It also defines the < operator so that it can be used as a key in a std::map. |
| 9 // | 9 // |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // other than ui::ET_KEY_PRESSED. | 47 // other than ui::ET_KEY_PRESSED. |
| 48 void set_type(ui::EventType type) { type_ = type; } | 48 void set_type(ui::EventType type) { type_ = type; } |
| 49 ui::EventType type() const { return type_; } | 49 ui::EventType type() const { return type_; } |
| 50 | 50 |
| 51 int modifiers() const { return modifiers_; } | 51 int modifiers() const { return modifiers_; } |
| 52 | 52 |
| 53 bool IsShiftDown() const; | 53 bool IsShiftDown() const; |
| 54 bool IsCtrlDown() const; | 54 bool IsCtrlDown() const; |
| 55 bool IsAltDown() const; | 55 bool IsAltDown() const; |
| 56 bool IsCmdDown() const; | 56 bool IsCmdDown() const; |
| 57 bool IsRepeat() const; |
| 57 | 58 |
| 58 // Returns a string with the localized shortcut if any. | 59 // Returns a string with the localized shortcut if any. |
| 59 base::string16 GetShortcutText() const; | 60 base::string16 GetShortcutText() const; |
| 60 | 61 |
| 61 void set_platform_accelerator(scoped_ptr<PlatformAccelerator> p) { | 62 void set_platform_accelerator(scoped_ptr<PlatformAccelerator> p) { |
| 62 platform_accelerator_ = p.Pass(); | 63 platform_accelerator_ = p.Pass(); |
| 63 } | 64 } |
| 64 | 65 |
| 65 // This class keeps ownership of the returned object. | 66 // This class keeps ownership of the returned object. |
| 66 const PlatformAccelerator* platform_accelerator() const { | 67 const PlatformAccelerator* platform_accelerator() const { |
| 67 return platform_accelerator_.get(); | 68 return platform_accelerator_.get(); |
| 68 } | 69 } |
| 69 | 70 |
| 71 void set_is_repeat(bool is_repeat) { is_repeat_ = is_repeat; } |
| 70 | 72 |
| 71 protected: | 73 protected: |
| 72 // The keycode (VK_...). | 74 // The keycode (VK_...). |
| 73 KeyboardCode key_code_; | 75 KeyboardCode key_code_; |
| 74 | 76 |
| 75 // The event type (usually ui::ET_KEY_PRESSED). | 77 // The event type (usually ui::ET_KEY_PRESSED). |
| 76 EventType type_; | 78 EventType type_; |
| 77 | 79 |
| 78 // The state of the Shift/Ctrl/Alt keys. | 80 // The state of the Shift/Ctrl/Alt keys. |
| 79 int modifiers_; | 81 int modifiers_; |
| 80 | 82 |
| 83 // True if the accelerator is created for an auto repeated key event. |
| 84 bool is_repeat_; |
| 85 |
| 81 // Stores platform specific data. May be NULL. | 86 // Stores platform specific data. May be NULL. |
| 82 scoped_ptr<PlatformAccelerator> platform_accelerator_; | 87 scoped_ptr<PlatformAccelerator> platform_accelerator_; |
| 83 }; | 88 }; |
| 84 | 89 |
| 85 // An interface that classes that want to register for keyboard accelerators | 90 // An interface that classes that want to register for keyboard accelerators |
| 86 // should implement. | 91 // should implement. |
| 87 class UI_BASE_EXPORT AcceleratorTarget { | 92 class UI_BASE_EXPORT AcceleratorTarget { |
| 88 public: | 93 public: |
| 89 // Should return true if the accelerator was processed. | 94 // Should return true if the accelerator was processed. |
| 90 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; | 95 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 108 virtual bool GetAcceleratorForCommandId(int command_id, | 113 virtual bool GetAcceleratorForCommandId(int command_id, |
| 109 ui::Accelerator* accelerator) = 0; | 114 ui::Accelerator* accelerator) = 0; |
| 110 | 115 |
| 111 protected: | 116 protected: |
| 112 virtual ~AcceleratorProvider() {} | 117 virtual ~AcceleratorProvider() {} |
| 113 }; | 118 }; |
| 114 | 119 |
| 115 } // namespace ui | 120 } // namespace ui |
| 116 | 121 |
| 117 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_H_ | 122 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_H_ |
| OLD | NEW |