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