| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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() {} | 23 Accelerator() : menus::Accelerator() {} |
| 24 | 24 |
| 25 Accelerator(base::KeyboardCode keycode, int modifiers) |
| 26 : menus::Accelerator(keycode, modifiers) {} |
| 27 |
| 25 Accelerator(base::KeyboardCode keycode, | 28 Accelerator(base::KeyboardCode keycode, |
| 26 bool shift_pressed, bool ctrl_pressed, bool alt_pressed) { | 29 bool shift_pressed, bool ctrl_pressed, bool alt_pressed) { |
| 27 key_code_ = keycode; | 30 key_code_ = keycode; |
| 28 modifiers_ = 0; | 31 modifiers_ = 0; |
| 29 if (shift_pressed) | 32 if (shift_pressed) |
| 30 modifiers_ |= Event::EF_SHIFT_DOWN; | 33 modifiers_ |= Event::EF_SHIFT_DOWN; |
| 31 if (ctrl_pressed) | 34 if (ctrl_pressed) |
| 32 modifiers_ |= Event::EF_CONTROL_DOWN; | 35 modifiers_ |= Event::EF_CONTROL_DOWN; |
| 33 if (alt_pressed) | 36 if (alt_pressed) |
| 34 modifiers_ |= Event::EF_ALT_DOWN; | 37 modifiers_ |= Event::EF_ALT_DOWN; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 58 public: | 61 public: |
| 59 // This method should return true if the accelerator was processed. | 62 // This method should return true if the accelerator was processed. |
| 60 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; | 63 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; |
| 61 | 64 |
| 62 protected: | 65 protected: |
| 63 virtual ~AcceleratorTarget() {} | 66 virtual ~AcceleratorTarget() {} |
| 64 }; | 67 }; |
| 65 } | 68 } |
| 66 | 69 |
| 67 #endif // VIEWS_ACCELERATOR_H_ | 70 #endif // VIEWS_ACCELERATOR_H_ |
| OLD | NEW |