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

Side by Side Diff: ui/base/accelerators/accelerator.cc

Issue 10399085: accelerators: Remove deprecated Accelerator ctor that takes booleans. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix aura_shell_unittests Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "ui/base/accelerators/accelerator.h" 5 #include "ui/base/accelerators/accelerator.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #elif defined(TOOLKIT_GTK) 9 #elif defined(TOOLKIT_GTK)
10 #include <gdk/gdk.h> 10 #include <gdk/gdk.h>
11 #endif 11 #endif
12 12
13 #include "base/i18n/rtl.h" 13 #include "base/i18n/rtl.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "grit/ui_strings.h" 17 #include "grit/ui_strings.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 19
20 #if !defined(OS_WIN) && defined(USE_AURA) 20 #if !defined(OS_WIN) && defined(USE_AURA)
21 #include "ui/base/keycodes/keyboard_code_conversion.h" 21 #include "ui/base/keycodes/keyboard_code_conversion.h"
22 #endif 22 #endif
23 23
24 namespace ui { 24 namespace ui {
25 25
26 Accelerator::Accelerator()
27 : key_code_(ui::VKEY_UNKNOWN),
28 type_(ui::ET_KEY_PRESSED),
29 modifiers_(0) {
30 }
31
32 Accelerator::Accelerator(KeyboardCode keycode, int modifiers)
33 : key_code_(keycode),
34 type_(ui::ET_KEY_PRESSED),
35 modifiers_(modifiers) {
36 }
37
38 Accelerator::Accelerator(const Accelerator& accelerator) {
39 key_code_ = accelerator.key_code_;
40 type_ = accelerator.type_;
41 modifiers_ = accelerator.modifiers_;
42 }
43
44 Accelerator::~Accelerator() {
45 }
46
47 Accelerator& Accelerator::operator=(const Accelerator& accelerator) {
48 if (this != &accelerator) {
49 key_code_ = accelerator.key_code_;
50 type_ = accelerator.type_;
51 modifiers_ = accelerator.modifiers_;
52 }
53 return *this;
54 }
55
56 bool Accelerator::operator <(const Accelerator& rhs) const {
57 if (key_code_ != rhs.key_code_)
58 return key_code_ < rhs.key_code_;
59 if (type_ != rhs.type_)
60 return type_ < rhs.type_;
61 return modifiers_ < rhs.modifiers_;
62 }
63
64 bool Accelerator::operator ==(const Accelerator& rhs) const {
65 return (key_code_ == rhs.key_code_) && (type_ == rhs.type_) &&
66 (modifiers_ == rhs.modifiers_);
67 }
68
69 bool Accelerator::operator !=(const Accelerator& rhs) const {
70 return !(*this == rhs);
71 }
72
73 bool Accelerator::IsShiftDown() const {
74 return (modifiers_ & EF_SHIFT_DOWN) == EF_SHIFT_DOWN;
75 }
76
77 bool Accelerator::IsCtrlDown() const {
78 return (modifiers_ & EF_CONTROL_DOWN) == EF_CONTROL_DOWN;
79 }
80
81 bool Accelerator::IsAltDown() const {
82 return (modifiers_ & EF_ALT_DOWN) == EF_ALT_DOWN;
83 }
84
26 string16 Accelerator::GetShortcutText() const { 85 string16 Accelerator::GetShortcutText() const {
27 int string_id = 0; 86 int string_id = 0;
28 switch(key_code_) { 87 switch(key_code_) {
29 case ui::VKEY_TAB: 88 case ui::VKEY_TAB:
30 string_id = IDS_APP_TAB_KEY; 89 string_id = IDS_APP_TAB_KEY;
31 break; 90 break;
32 case ui::VKEY_RETURN: 91 case ui::VKEY_RETURN:
33 string_id = IDS_APP_ENTER_KEY; 92 string_id = IDS_APP_ENTER_KEY;
34 break; 93 break;
35 case ui::VKEY_ESCAPE: 94 case ui::VKEY_ESCAPE:
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 222
164 // Subtracting the size of the shortcut key and 1 for the '+' sign. 223 // Subtracting the size of the shortcut key and 1 for the '+' sign.
165 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1); 224 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1);
166 shortcut.swap(shortcut_rtl); 225 shortcut.swap(shortcut_rtl);
167 } 226 }
168 227
169 return shortcut; 228 return shortcut;
170 } 229 }
171 230
172 } // namespace ui 231 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/accelerators/accelerator.h ('k') | ui/base/accelerators/accelerator_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698