| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 |
| 11 #ifndef VIEWS_ACCELERATOR_H_ | 11 #ifndef VIEWS_ACCELERATOR_H_ |
| 12 #define VIEWS_ACCELERATOR_H_ | 12 #define VIEWS_ACCELERATOR_H_ |
| 13 | 13 |
| 14 #include <string> | 14 #include <string> |
| 15 | 15 |
| 16 #include "app/menus/accelerator.h" | 16 #include "app/menus/accelerator.h" |
| 17 #include "views/event.h" | 17 #include "views/event.h" |
| 18 | 18 |
| 19 namespace views { | 19 namespace views { |
| 20 | 20 |
| 21 class Accelerator : public menus::Accelerator { | 21 class Accelerator : public menus::Accelerator { |
| 22 public: | 22 public: |
| 23 Accelerator() : menus::Accelerator() {} |
| 24 |
| 23 Accelerator(base::KeyboardCode keycode, | 25 Accelerator(base::KeyboardCode keycode, |
| 24 bool shift_pressed, bool ctrl_pressed, bool alt_pressed) { | 26 bool shift_pressed, bool ctrl_pressed, bool alt_pressed) { |
| 25 key_code_ = keycode; | 27 key_code_ = keycode; |
| 26 modifiers_ = 0; | 28 modifiers_ = 0; |
| 27 if (shift_pressed) | 29 if (shift_pressed) |
| 28 modifiers_ |= Event::EF_SHIFT_DOWN; | 30 modifiers_ |= Event::EF_SHIFT_DOWN; |
| 29 if (ctrl_pressed) | 31 if (ctrl_pressed) |
| 30 modifiers_ |= Event::EF_CONTROL_DOWN; | 32 modifiers_ |= Event::EF_CONTROL_DOWN; |
| 31 if (alt_pressed) | 33 if (alt_pressed) |
| 32 modifiers_ |= Event::EF_ALT_DOWN; | 34 modifiers_ |= Event::EF_ALT_DOWN; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 56 public: | 58 public: |
| 57 // This method should return true if the accelerator was processed. | 59 // This method should return true if the accelerator was processed. |
| 58 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; | 60 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; |
| 59 | 61 |
| 60 protected: | 62 protected: |
| 61 virtual ~AcceleratorTarget() {} | 63 virtual ~AcceleratorTarget() {} |
| 62 }; | 64 }; |
| 63 } | 65 } |
| 64 | 66 |
| 65 #endif // VIEWS_ACCELERATOR_H_ | 67 #endif // VIEWS_ACCELERATOR_H_ |
| OLD | NEW |