Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: app/menus/accelerator.h

Issue 2833013: Tweaks for the merged menu: (Closed)
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | views/accelerator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef APP_MENUS_ACCELERATOR_H_ 5 #ifndef APP_MENUS_ACCELERATOR_H_
6 #define APP_MENUS_ACCELERATOR_H_ 6 #define APP_MENUS_ACCELERATOR_H_
7 7
8 #include "base/keyboard_codes.h" 8 #include "base/keyboard_codes.h"
9 9
10 namespace menus { 10 namespace menus {
11 11
12 // This is a cross-platform base class for accelerator keys used in menus. It is 12 // This is a cross-platform base class for accelerator keys used in menus. It is
13 // meant to be subclassed for concrete toolkit implementations. 13 // meant to be subclassed for concrete toolkit implementations.
14 14
15 class Accelerator { 15 class Accelerator {
16 public: 16 public:
17 Accelerator() : key_code_(base::VKEY_UNKNOWN), modifiers_(0) { } 17 Accelerator() : key_code_(base::VKEY_UNKNOWN), modifiers_(0) {}
18 virtual ~Accelerator() { } 18
19 Accelerator(base::KeyboardCode keycode, int modifiers)
20 : key_code_(keycode),
21 modifiers_(modifiers) {}
22
19 Accelerator(const Accelerator& accelerator) { 23 Accelerator(const Accelerator& accelerator) {
20 key_code_ = accelerator.key_code_; 24 key_code_ = accelerator.key_code_;
21 modifiers_ = accelerator.modifiers_; 25 modifiers_ = accelerator.modifiers_;
22 } 26 }
23 27
28 virtual ~Accelerator() {}
29
24 Accelerator& operator=(const Accelerator& accelerator) { 30 Accelerator& operator=(const Accelerator& accelerator) {
25 if (this != &accelerator) { 31 if (this != &accelerator) {
26 key_code_ = accelerator.key_code_; 32 key_code_ = accelerator.key_code_;
27 modifiers_ = accelerator.modifiers_; 33 modifiers_ = accelerator.modifiers_;
28 } 34 }
29 return *this; 35 return *this;
30 } 36 }
31 37
32 // We define the < operator so that the KeyboardShortcut can be used as a key 38 // We define the < operator so that the KeyboardShortcut can be used as a key
33 // in a std::map. 39 // in a std::map.
(...skipping 13 matching lines...) Expand all
47 53
48 base::KeyboardCode GetKeyCode() const { 54 base::KeyboardCode GetKeyCode() const {
49 return key_code_; 55 return key_code_;
50 } 56 }
51 57
52 int modifiers() const { 58 int modifiers() const {
53 return modifiers_; 59 return modifiers_;
54 } 60 }
55 61
56 protected: 62 protected:
57 // The window keycode (VK_...). 63 // The keycode (VK_...).
58 base::KeyboardCode key_code_; 64 base::KeyboardCode key_code_;
59 65
60 // The state of the Shift/Ctrl/Alt keys (platform-dependent). 66 // The state of the Shift/Ctrl/Alt keys (platform-dependent).
61 int modifiers_; 67 int modifiers_;
62 }; 68 };
63 69
64 } 70 }
65 71
66 #endif // APP_MENUS_ACCELERATOR_H_ 72 #endif // APP_MENUS_ACCELERATOR_H_
67 73
OLDNEW
« no previous file with comments | « no previous file | views/accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698