| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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) || defined(OS_MACOSX)) |
| 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() | 26 Accelerator::Accelerator() |
| 27 : key_code_(ui::VKEY_UNKNOWN), | 27 : key_code_(ui::VKEY_UNKNOWN), |
| 28 type_(ui::ET_KEY_PRESSED), | 28 type_(ui::ET_KEY_PRESSED), |
| 29 modifiers_(0) { | 29 modifiers_(0) { |
| 30 } | 30 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // layouts have characters other than digits assigned in | 139 // layouts have characters other than digits assigned in |
| 140 // an unshifted mode (e.g. French AZERY layout has 'a with grave | 140 // an unshifted mode (e.g. French AZERY layout has 'a with grave |
| 141 // accent' for '0'). For display in the menu (e.g. Ctrl-0 for the | 141 // accent' for '0'). For display in the menu (e.g. Ctrl-0 for the |
| 142 // default zoom level), we leave VK_[0-9] alone without translation. | 142 // default zoom level), we leave VK_[0-9] alone without translation. |
| 143 wchar_t key; | 143 wchar_t key; |
| 144 if (key_code_ >= '0' && key_code_ <= '9') | 144 if (key_code_ >= '0' && key_code_ <= '9') |
| 145 key = key_code_; | 145 key = key_code_; |
| 146 else | 146 else |
| 147 key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR)); | 147 key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR)); |
| 148 shortcut += key; | 148 shortcut += key; |
| 149 #elif defined(USE_AURA) | 149 #elif defined(USE_AURA) || defined(OS_MACOSX) |
| 150 const uint16 c = GetCharacterFromKeyCode(key_code_, false); | 150 const uint16 c = GetCharacterFromKeyCode(key_code_, false); |
| 151 if (c != 0) { | 151 if (c != 0) |
| 152 shortcut += static_cast<string16::value_type>(base::ToUpperASCII(c)); | 152 shortcut += static_cast<string16::value_type>(base::ToUpperASCII(c)); |
| 153 } | |
| 154 #elif defined(TOOLKIT_GTK) | 153 #elif defined(TOOLKIT_GTK) |
| 155 const gchar* name = NULL; | 154 const gchar* name = NULL; |
| 156 switch (key_code_) { | 155 switch (key_code_) { |
| 157 case ui::VKEY_OEM_2: | 156 case ui::VKEY_OEM_2: |
| 158 name = static_cast<const gchar*>("/"); | 157 name = static_cast<const gchar*>("/"); |
| 159 break; | 158 break; |
| 160 default: | 159 default: |
| 161 name = gdk_keyval_name(gdk_keyval_to_lower(key_code_)); | 160 name = gdk_keyval_name(gdk_keyval_to_lower(key_code_)); |
| 162 break; | 161 break; |
| 163 } | 162 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 221 |
| 223 // Subtracting the size of the shortcut key and 1 for the '+' sign. | 222 // Subtracting the size of the shortcut key and 1 for the '+' sign. |
| 224 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1); | 223 shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1); |
| 225 shortcut.swap(shortcut_rtl); | 224 shortcut.swap(shortcut_rtl); |
| 226 } | 225 } |
| 227 | 226 |
| 228 return shortcut; | 227 return shortcut; |
| 229 } | 228 } |
| 230 | 229 |
| 231 } // namespace ui | 230 } // namespace ui |
| OLD | NEW |