| OLD | NEW |
| 1 // Copyright (c) 2010 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 #pragma once | 13 #pragma once |
| 14 | 14 |
| 15 #include <string> | 15 #include <string> |
| 16 | 16 |
| 17 #include "app/menus/accelerator.h" | 17 #include "app/menus/accelerator.h" |
| 18 #include "views/event.h" | 18 #include "views/event.h" |
| 19 | 19 |
| 20 namespace views { | 20 namespace views { |
| 21 | 21 |
| 22 class Accelerator : public menus::Accelerator { | 22 class Accelerator : public menus::Accelerator { |
| 23 public: | 23 public: |
| 24 Accelerator() : menus::Accelerator() {} | 24 Accelerator() : menus::Accelerator() {} |
| 25 | 25 |
| 26 Accelerator(base::KeyboardCode keycode, int modifiers) | 26 Accelerator(app::KeyboardCode keycode, int modifiers) |
| 27 : menus::Accelerator(keycode, modifiers) {} | 27 : menus::Accelerator(keycode, modifiers) {} |
| 28 | 28 |
| 29 Accelerator(base::KeyboardCode keycode, | 29 Accelerator(app::KeyboardCode keycode, |
| 30 bool shift_pressed, bool ctrl_pressed, bool alt_pressed) { | 30 bool shift_pressed, bool ctrl_pressed, bool alt_pressed) { |
| 31 key_code_ = keycode; | 31 key_code_ = keycode; |
| 32 modifiers_ = 0; | 32 modifiers_ = 0; |
| 33 if (shift_pressed) | 33 if (shift_pressed) |
| 34 modifiers_ |= Event::EF_SHIFT_DOWN; | 34 modifiers_ |= Event::EF_SHIFT_DOWN; |
| 35 if (ctrl_pressed) | 35 if (ctrl_pressed) |
| 36 modifiers_ |= Event::EF_CONTROL_DOWN; | 36 modifiers_ |= Event::EF_CONTROL_DOWN; |
| 37 if (alt_pressed) | 37 if (alt_pressed) |
| 38 modifiers_ |= Event::EF_ALT_DOWN; | 38 modifiers_ |= Event::EF_ALT_DOWN; |
| 39 } | 39 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 62 public: | 62 public: |
| 63 // This method should return true if the accelerator was processed. | 63 // This method should return true if the accelerator was processed. |
| 64 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; | 64 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; |
| 65 | 65 |
| 66 protected: | 66 protected: |
| 67 virtual ~AcceleratorTarget() {} | 67 virtual ~AcceleratorTarget() {} |
| 68 }; | 68 }; |
| 69 } | 69 } |
| 70 | 70 |
| 71 #endif // VIEWS_ACCELERATOR_H_ | 71 #endif // VIEWS_ACCELERATOR_H_ |
| OLD | NEW |