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

Side by Side Diff: views/accelerator.cc

Issue 113612: Make views/ use strings from app_strings. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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
« no previous file with comments | « chrome/chrome.sln ('k') | views/controls/button/button_dropdown.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 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "grit/generated_resources.h" 12 #include "grit/app_strings.h"
13 13
14 namespace views { 14 namespace views {
15 15
16 std::wstring Accelerator::GetShortcutText() const { 16 std::wstring Accelerator::GetShortcutText() const {
17 int string_id = 0; 17 int string_id = 0;
18 switch(key_code_) { 18 switch(key_code_) {
19 case VK_TAB: 19 case VK_TAB:
20 string_id = IDS_TAB_KEY; 20 string_id = IDS_APP_TAB_KEY;
21 break; 21 break;
22 case VK_RETURN: 22 case VK_RETURN:
23 string_id = IDS_ENTER_KEY; 23 string_id = IDS_APP_ENTER_KEY;
24 break; 24 break;
25 case VK_ESCAPE: 25 case VK_ESCAPE:
26 string_id = IDS_ESC_KEY; 26 string_id = IDS_APP_ESC_KEY;
27 break; 27 break;
28 case VK_PRIOR: 28 case VK_PRIOR:
29 string_id = IDS_PAGEUP_KEY; 29 string_id = IDS_APP_PAGEUP_KEY;
30 break; 30 break;
31 case VK_NEXT: 31 case VK_NEXT:
32 string_id = IDS_PAGEDOWN_KEY; 32 string_id = IDS_APP_PAGEDOWN_KEY;
33 break; 33 break;
34 case VK_END: 34 case VK_END:
35 string_id = IDS_END_KEY; 35 string_id = IDS_APP_END_KEY;
36 break; 36 break;
37 case VK_HOME: 37 case VK_HOME:
38 string_id = IDS_HOME_KEY; 38 string_id = IDS_APP_HOME_KEY;
39 break; 39 break;
40 case VK_INSERT: 40 case VK_INSERT:
41 string_id = IDS_INSERT_KEY; 41 string_id = IDS_APP_INSERT_KEY;
42 break; 42 break;
43 case VK_DELETE: 43 case VK_DELETE:
44 string_id = IDS_DELETE_KEY; 44 string_id = IDS_APP_DELETE_KEY;
45 break; 45 break;
46 case VK_F1: 46 case VK_F1:
47 string_id = IDS_F1_KEY; 47 string_id = IDS_APP_F1_KEY;
48 break; 48 break;
49 case VK_F11: 49 case VK_F11:
50 string_id = IDS_F11_KEY; 50 string_id = IDS_APP_F11_KEY;
51 break; 51 break;
52 } 52 }
53 53
54 std::wstring shortcut; 54 std::wstring shortcut;
55 if (!string_id) { 55 if (!string_id) {
56 // Our fallback is to try translate the key code to a regular character 56 // Our fallback is to try translate the key code to a regular character
57 // unless it is one of digits (VK_0 to VK_9). Some keyboard 57 // unless it is one of digits (VK_0 to VK_9). Some keyboard
58 // layouts have characters other than digits assigned in 58 // layouts have characters other than digits assigned in
59 // an unshifted mode (e.g. French AZERY layout has 'a with grave 59 // an unshifted mode (e.g. French AZERY layout has 'a with grave
60 // accent' for '0'). For display in the menu (e.g. Ctrl-0 for the 60 // accent' for '0'). For display in the menu (e.g. Ctrl-0 for the
(...skipping 16 matching lines...) Expand all
77 bool adjust_shortcut_for_rtl = false; 77 bool adjust_shortcut_for_rtl = false;
78 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT && 78 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT &&
79 shortcut.length() == 1 && 79 shortcut.length() == 1 &&
80 !IsAsciiAlpha(shortcut.at(0)) && 80 !IsAsciiAlpha(shortcut.at(0)) &&
81 !IsAsciiDigit(shortcut.at(0))) { 81 !IsAsciiDigit(shortcut.at(0))) {
82 adjust_shortcut_for_rtl = true; 82 adjust_shortcut_for_rtl = true;
83 shortcut_rtl.assign(shortcut); 83 shortcut_rtl.assign(shortcut);
84 } 84 }
85 85
86 if (IsShiftDown()) 86 if (IsShiftDown())
87 shortcut = l10n_util::GetStringF(IDS_SHIFT_MODIFIER, shortcut); 87 shortcut = l10n_util::GetStringF(IDS_APP_SHIFT_MODIFIER, shortcut);
88 88
89 // Note that we use 'else-if' in order to avoid using Ctrl+Alt as a shortcut. 89 // Note that we use 'else-if' in order to avoid using Ctrl+Alt as a shortcut.
90 // See http://blogs.msdn.com/oldnewthing/archive/2004/03/29/101121.aspx for 90 // See http://blogs.msdn.com/oldnewthing/archive/2004/03/29/101121.aspx for
91 // more information. 91 // more information.
92 if (IsCtrlDown()) 92 if (IsCtrlDown())
93 shortcut = l10n_util::GetStringF(IDS_CONTROL_MODIFIER, shortcut); 93 shortcut = l10n_util::GetStringF(IDS_APP_CONTROL_MODIFIER, shortcut);
94 else if (IsAltDown()) 94 else if (IsAltDown())
95 shortcut = l10n_util::GetStringF(IDS_ALT_MODIFIER, shortcut); 95 shortcut = l10n_util::GetStringF(IDS_APP_ALT_MODIFIER, shortcut);
96 96
97 // For some reason, menus in Windows ignore standard Unicode directionality 97 // For some reason, menus in Windows ignore standard Unicode directionality
98 // marks (such as LRE, PDF, etc.). On RTL locales, we use RTL menus and 98 // marks (such as LRE, PDF, etc.). On RTL locales, we use RTL menus and
99 // therefore any text we draw for the menu items is drawn in an RTL context. 99 // therefore any text we draw for the menu items is drawn in an RTL context.
100 // Thus, the text "Ctrl++" (which we currently use for the Zoom In option) 100 // Thus, the text "Ctrl++" (which we currently use for the Zoom In option)
101 // appears as "++Ctrl" in RTL because the Unicode BiDi algorithm puts 101 // appears as "++Ctrl" in RTL because the Unicode BiDi algorithm puts
102 // punctuations on the left when the context is right-to-left. Shortcuts that 102 // punctuations on the left when the context is right-to-left. Shortcuts that
103 // do not end with a punctuation mark (such as "Ctrl+H" do not have this 103 // do not end with a punctuation mark (such as "Ctrl+H" do not have this
104 // problem). 104 // problem).
105 // 105 //
(...skipping 15 matching lines...) Expand all
121 121
122 // Subtracting the size of the shortcut key and 1 for the '+' sign. 122 // Subtracting the size of the shortcut key and 1 for the '+' sign.
123 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1); 123 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1);
124 shortcut.swap(shortcut_rtl); 124 shortcut.swap(shortcut_rtl);
125 } 125 }
126 126
127 return shortcut; 127 return shortcut;
128 } 128 }
129 129
130 } // namespace views 130 } // namespace views
OLDNEW
« no previous file with comments | « chrome/chrome.sln ('k') | views/controls/button/button_dropdown.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698