OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_BASE_ACCELERATORS_ACCELERATOR_H_ | 11 #ifndef UI_BASE_ACCELERATORS_ACCELERATOR_H_ |
12 #define UI_BASE_ACCELERATORS_ACCELERATOR_H_ | 12 #define UI_BASE_ACCELERATORS_ACCELERATOR_H_ |
13 | 13 |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
16 #include "ui/base/accelerators/platform_accelerator.h" | 16 #include "ui/base/accelerators/platform_accelerator.h" |
17 #include "ui/base/ui_export.h" | 17 #include "ui/base/ui_base_export.h" |
18 #include "ui/events/event_constants.h" | 18 #include "ui/events/event_constants.h" |
19 #include "ui/events/keycodes/keyboard_codes.h" | 19 #include "ui/events/keycodes/keyboard_codes.h" |
20 | 20 |
21 namespace ui { | 21 namespace ui { |
22 | 22 |
23 class PlatformAccelerator; | 23 class PlatformAccelerator; |
24 | 24 |
25 // This is a cross-platform class for accelerator keys used in menus. | 25 // This is a cross-platform class for accelerator keys used in menus. |
26 // |platform_accelerator| should be used to store platform specific data. | 26 // |platform_accelerator| should be used to store platform specific data. |
27 class UI_EXPORT Accelerator { | 27 class UI_BASE_EXPORT Accelerator { |
28 public: | 28 public: |
29 Accelerator(); | 29 Accelerator(); |
30 Accelerator(ui::KeyboardCode keycode, int modifiers); | 30 Accelerator(ui::KeyboardCode keycode, int modifiers); |
31 Accelerator(const Accelerator& accelerator); | 31 Accelerator(const Accelerator& accelerator); |
32 ~Accelerator(); | 32 ~Accelerator(); |
33 | 33 |
34 Accelerator& operator=(const Accelerator& accelerator); | 34 Accelerator& operator=(const Accelerator& accelerator); |
35 | 35 |
36 // Define the < operator so that the KeyboardShortcut can be used as a key in | 36 // Define the < operator so that the KeyboardShortcut can be used as a key in |
37 // a std::map. | 37 // a std::map. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 // The state of the Shift/Ctrl/Alt keys. | 78 // The state of the Shift/Ctrl/Alt keys. |
79 int modifiers_; | 79 int modifiers_; |
80 | 80 |
81 // Stores platform specific data. May be NULL. | 81 // Stores platform specific data. May be NULL. |
82 scoped_ptr<PlatformAccelerator> platform_accelerator_; | 82 scoped_ptr<PlatformAccelerator> platform_accelerator_; |
83 }; | 83 }; |
84 | 84 |
85 // An interface that classes that want to register for keyboard accelerators | 85 // An interface that classes that want to register for keyboard accelerators |
86 // should implement. | 86 // should implement. |
87 class UI_EXPORT AcceleratorTarget { | 87 class UI_BASE_EXPORT AcceleratorTarget { |
88 public: | 88 public: |
89 // Should return true if the accelerator was processed. | 89 // Should return true if the accelerator was processed. |
90 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; | 90 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; |
91 | 91 |
92 // Should return true if the target can handle the accelerator events. The | 92 // Should return true if the target can handle the accelerator events. The |
93 // AcceleratorPressed method is invoked only for targets for which | 93 // AcceleratorPressed method is invoked only for targets for which |
94 // CanHandleAccelerators returns true. | 94 // CanHandleAccelerators returns true. |
95 virtual bool CanHandleAccelerators() const = 0; | 95 virtual bool CanHandleAccelerators() const = 0; |
96 | 96 |
97 protected: | 97 protected: |
(...skipping 10 matching lines...) Expand all Loading... |
108 virtual bool GetAcceleratorForCommandId(int command_id, | 108 virtual bool GetAcceleratorForCommandId(int command_id, |
109 ui::Accelerator* accelerator) = 0; | 109 ui::Accelerator* accelerator) = 0; |
110 | 110 |
111 protected: | 111 protected: |
112 virtual ~AcceleratorProvider() {} | 112 virtual ~AcceleratorProvider() {} |
113 }; | 113 }; |
114 | 114 |
115 } // namespace ui | 115 } // namespace ui |
116 | 116 |
117 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_H_ | 117 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_H_ |
OLD | NEW |