OLD | NEW |
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 std::wstring Accelerator::GetShortcutText() const { | 22 std::wstring Accelerator::GetShortcutText() const { |
23 int string_id = 0; | 23 int string_id = 0; |
24 switch(key_code_) { | 24 switch(key_code_) { |
25 case base::VKEY_TAB: | 25 case app::VKEY_TAB: |
26 string_id = IDS_APP_TAB_KEY; | 26 string_id = IDS_APP_TAB_KEY; |
27 break; | 27 break; |
28 case base::VKEY_RETURN: | 28 case app::VKEY_RETURN: |
29 string_id = IDS_APP_ENTER_KEY; | 29 string_id = IDS_APP_ENTER_KEY; |
30 break; | 30 break; |
31 case base::VKEY_ESCAPE: | 31 case app::VKEY_ESCAPE: |
32 string_id = IDS_APP_ESC_KEY; | 32 string_id = IDS_APP_ESC_KEY; |
33 break; | 33 break; |
34 case base::VKEY_PRIOR: | 34 case app::VKEY_PRIOR: |
35 string_id = IDS_APP_PAGEUP_KEY; | 35 string_id = IDS_APP_PAGEUP_KEY; |
36 break; | 36 break; |
37 case base::VKEY_NEXT: | 37 case app::VKEY_NEXT: |
38 string_id = IDS_APP_PAGEDOWN_KEY; | 38 string_id = IDS_APP_PAGEDOWN_KEY; |
39 break; | 39 break; |
40 case base::VKEY_END: | 40 case app::VKEY_END: |
41 string_id = IDS_APP_END_KEY; | 41 string_id = IDS_APP_END_KEY; |
42 break; | 42 break; |
43 case base::VKEY_HOME: | 43 case app::VKEY_HOME: |
44 string_id = IDS_APP_HOME_KEY; | 44 string_id = IDS_APP_HOME_KEY; |
45 break; | 45 break; |
46 case base::VKEY_INSERT: | 46 case app::VKEY_INSERT: |
47 string_id = IDS_APP_INSERT_KEY; | 47 string_id = IDS_APP_INSERT_KEY; |
48 break; | 48 break; |
49 case base::VKEY_DELETE: | 49 case app::VKEY_DELETE: |
50 string_id = IDS_APP_DELETE_KEY; | 50 string_id = IDS_APP_DELETE_KEY; |
51 break; | 51 break; |
52 case base::VKEY_LEFT: | 52 case app::VKEY_LEFT: |
53 string_id = IDS_APP_LEFT_ARROW_KEY; | 53 string_id = IDS_APP_LEFT_ARROW_KEY; |
54 break; | 54 break; |
55 case base::VKEY_RIGHT: | 55 case app::VKEY_RIGHT: |
56 string_id = IDS_APP_RIGHT_ARROW_KEY; | 56 string_id = IDS_APP_RIGHT_ARROW_KEY; |
57 break; | 57 break; |
58 case base::VKEY_BACK: | 58 case app::VKEY_BACK: |
59 string_id = IDS_APP_BACKSPACE_KEY; | 59 string_id = IDS_APP_BACKSPACE_KEY; |
60 break; | 60 break; |
61 case base::VKEY_F1: | 61 case app::VKEY_F1: |
62 string_id = IDS_APP_F1_KEY; | 62 string_id = IDS_APP_F1_KEY; |
63 break; | 63 break; |
64 case base::VKEY_F11: | 64 case app::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 std::wstring shortcut; | 71 std::wstring 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 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 // Subtracting the size of the shortcut key and 1 for the '+' sign. | 147 // Subtracting the size of the shortcut key and 1 for the '+' sign. |
148 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1); | 148 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1); |
149 shortcut.swap(shortcut_rtl); | 149 shortcut.swap(shortcut_rtl); |
150 } | 150 } |
151 | 151 |
152 return shortcut; | 152 return shortcut; |
153 } | 153 } |
154 | 154 |
155 } // namespace views | 155 } // namespace views |
OLD | NEW |