| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 29 modifiers_ |= Event::EF_CONTROL_DOWN; | 29 modifiers_ |= Event::EF_CONTROL_DOWN; |
| 30 if (alt_pressed) | 30 if (alt_pressed) |
| 31 modifiers_ |= Event::EF_ALT_DOWN; | 31 modifiers_ |= Event::EF_ALT_DOWN; |
| 32 } | 32 } |
| 33 | 33 |
| 34 Accelerator(const Accelerator& accelerator) { | 34 Accelerator(const Accelerator& accelerator) { |
| 35 key_code_ = accelerator.key_code_; | 35 key_code_ = accelerator.key_code_; |
| 36 modifiers_ = accelerator.modifiers_; | 36 modifiers_ = accelerator.modifiers_; |
| 37 } | 37 } |
| 38 | 38 |
| 39 ~Accelerator() {}; | 39 ~Accelerator() { }; |
| 40 | 40 |
| 41 Accelerator& operator=(const Accelerator& accelerator) { | 41 Accelerator& operator=(const Accelerator& accelerator) { |
| 42 if (this != &accelerator) { | 42 if (this != &accelerator) { |
| 43 key_code_ = accelerator.key_code_; | 43 key_code_ = accelerator.key_code_; |
| 44 modifiers_ = accelerator.modifiers_; | 44 modifiers_ = accelerator.modifiers_; |
| 45 } | 45 } |
| 46 return *this; | 46 return *this; |
| 47 } | 47 } |
| 48 | 48 |
| 49 // We define the < operator so that the KeyboardShortcut can be used as a key | 49 // We define the < operator so that the KeyboardShortcut can be used as a key |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // The state of the Shift/Ctrl/Alt keys (see event.h). | 88 // The state of the Shift/Ctrl/Alt keys (see event.h). |
| 89 int modifiers_; | 89 int modifiers_; |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 // An interface that classes that want to register for keyboard accelerators | 92 // An interface that classes that want to register for keyboard accelerators |
| 93 // should implement. | 93 // should implement. |
| 94 class AcceleratorTarget { | 94 class AcceleratorTarget { |
| 95 public: | 95 public: |
| 96 // This method should return true if the accelerator was processed. | 96 // This method should return true if the accelerator was processed. |
| 97 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; | 97 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; |
| 98 protected: | |
| 99 ~AcceleratorTarget() {} | |
| 100 }; | 98 }; |
| 101 } | 99 } |
| 102 | 100 |
| 103 #endif // VIEWS_ACCELERATOR_H_ | 101 #endif // VIEWS_ACCELERATOR_H_ |
| OLD | NEW |