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

Side by Side Diff: views/accelerator.cc

Issue 6246001: Move app/key* to ui/base/keycodes/* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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
« no previous file with comments | « views/accelerator.h ('k') | views/controls/button/custom_button.cc » ('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) 2006-2008 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 #include "views/accelerator.h" 5 #include "views/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(OS_LINUX) 9 #elif defined(OS_LINUX)
10 #include <gdk/gdk.h> 10 #include <gdk/gdk.h>
11 #endif 11 #endif
12 12
13 #include "app/l10n_util.h" 13 #include "app/l10n_util.h"
14 #include "base/i18n/rtl.h" 14 #include "base/i18n/rtl.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "grit/app_strings.h" 18 #include "grit/app_strings.h"
19 19
20 namespace views { 20 namespace views {
21 21
22 string16 Accelerator::GetShortcutText() const { 22 string16 Accelerator::GetShortcutText() const {
23 int string_id = 0; 23 int string_id = 0;
24 switch(key_code_) { 24 switch(key_code_) {
25 case app::VKEY_TAB: 25 case ui::VKEY_TAB:
26 string_id = IDS_APP_TAB_KEY; 26 string_id = IDS_APP_TAB_KEY;
27 break; 27 break;
28 case app::VKEY_RETURN: 28 case ui::VKEY_RETURN:
29 string_id = IDS_APP_ENTER_KEY; 29 string_id = IDS_APP_ENTER_KEY;
30 break; 30 break;
31 case app::VKEY_ESCAPE: 31 case ui::VKEY_ESCAPE:
32 string_id = IDS_APP_ESC_KEY; 32 string_id = IDS_APP_ESC_KEY;
33 break; 33 break;
34 case app::VKEY_PRIOR: 34 case ui::VKEY_PRIOR:
35 string_id = IDS_APP_PAGEUP_KEY; 35 string_id = IDS_APP_PAGEUP_KEY;
36 break; 36 break;
37 case app::VKEY_NEXT: 37 case ui::VKEY_NEXT:
38 string_id = IDS_APP_PAGEDOWN_KEY; 38 string_id = IDS_APP_PAGEDOWN_KEY;
39 break; 39 break;
40 case app::VKEY_END: 40 case ui::VKEY_END:
41 string_id = IDS_APP_END_KEY; 41 string_id = IDS_APP_END_KEY;
42 break; 42 break;
43 case app::VKEY_HOME: 43 case ui::VKEY_HOME:
44 string_id = IDS_APP_HOME_KEY; 44 string_id = IDS_APP_HOME_KEY;
45 break; 45 break;
46 case app::VKEY_INSERT: 46 case ui::VKEY_INSERT:
47 string_id = IDS_APP_INSERT_KEY; 47 string_id = IDS_APP_INSERT_KEY;
48 break; 48 break;
49 case app::VKEY_DELETE: 49 case ui::VKEY_DELETE:
50 string_id = IDS_APP_DELETE_KEY; 50 string_id = IDS_APP_DELETE_KEY;
51 break; 51 break;
52 case app::VKEY_LEFT: 52 case ui::VKEY_LEFT:
53 string_id = IDS_APP_LEFT_ARROW_KEY; 53 string_id = IDS_APP_LEFT_ARROW_KEY;
54 break; 54 break;
55 case app::VKEY_RIGHT: 55 case ui::VKEY_RIGHT:
56 string_id = IDS_APP_RIGHT_ARROW_KEY; 56 string_id = IDS_APP_RIGHT_ARROW_KEY;
57 break; 57 break;
58 case app::VKEY_BACK: 58 case ui::VKEY_BACK:
59 string_id = IDS_APP_BACKSPACE_KEY; 59 string_id = IDS_APP_BACKSPACE_KEY;
60 break; 60 break;
61 case app::VKEY_F1: 61 case ui::VKEY_F1:
62 string_id = IDS_APP_F1_KEY; 62 string_id = IDS_APP_F1_KEY;
63 break; 63 break;
64 case app::VKEY_F11: 64 case ui::VKEY_F11:
65 string_id = IDS_APP_F11_KEY; 65 string_id = IDS_APP_F11_KEY;
66 break; 66 break;
67 default: 67 default:
68 break; 68 break;
69 } 69 }
70 70
71 string16 shortcut; 71 string16 shortcut;
72 if (!string_id) { 72 if (!string_id) {
73 #if defined(OS_WIN) 73 #if defined(OS_WIN)
74 // Our fallback is to try translate the key code to a regular character 74 // Our fallback is to try translate the key code to a regular character
75 // unless it is one of digits (VK_0 to VK_9). Some keyboard 75 // unless it is one of digits (VK_0 to VK_9). Some keyboard
76 // layouts have characters other than digits assigned in 76 // layouts have characters other than digits assigned in
77 // an unshifted mode (e.g. French AZERY layout has 'a with grave 77 // an unshifted mode (e.g. French AZERY layout has 'a with grave
78 // accent' for '0'). For display in the menu (e.g. Ctrl-0 for the 78 // accent' for '0'). For display in the menu (e.g. Ctrl-0 for the
79 // default zoom level), we leave VK_[0-9] alone without translation. 79 // default zoom level), we leave VK_[0-9] alone without translation.
80 wchar_t key; 80 wchar_t key;
81 if (key_code_ >= '0' && key_code_ <= '9') 81 if (key_code_ >= '0' && key_code_ <= '9')
82 key = key_code_; 82 key = key_code_;
83 else 83 else
84 key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR)); 84 key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR));
85 shortcut += key; 85 shortcut += key;
86 #elif defined(OS_LINUX) 86 #elif defined(OS_LINUX)
87 const gchar* name = NULL; 87 const gchar* name = NULL;
88 switch (key_code_) { 88 switch (key_code_) {
89 case app::VKEY_OEM_2: 89 case ui::VKEY_OEM_2:
90 name = static_cast<const gchar*>("/"); 90 name = static_cast<const gchar*>("/");
91 break; 91 break;
92 default: 92 default:
93 name = gdk_keyval_name(gdk_keyval_to_lower(key_code_)); 93 name = gdk_keyval_name(gdk_keyval_to_lower(key_code_));
94 break; 94 break;
95 } 95 }
96 if (name) { 96 if (name) {
97 if (name[0] != 0 && name[1] == 0) 97 if (name[0] != 0 && name[1] == 0)
98 shortcut += static_cast<string16::value_type>(g_ascii_toupper(name[0])); 98 shortcut += static_cast<string16::value_type>(g_ascii_toupper(name[0]));
99 else 99 else
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 // Subtracting the size of the shortcut key and 1 for the '+' sign. 155 // Subtracting the size of the shortcut key and 1 for the '+' sign.
156 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1); 156 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1);
157 shortcut.swap(shortcut_rtl); 157 shortcut.swap(shortcut_rtl);
158 } 158 }
159 159
160 return shortcut; 160 return shortcut;
161 } 161 }
162 162
163 } // namespace views 163 } // namespace views
OLDNEW
« no previous file with comments | « views/accelerator.h ('k') | views/controls/button/custom_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698