| OLD | NEW |
| 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 "views/controls/menu/native_menu_win.h" | 5 #include "views/controls/menu/native_menu_win.h" |
| 6 | 6 |
| 7 #include <Windowsx.h> | 7 #include <Windowsx.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/win/wrapped_window_proc.h" | 14 #include "base/win/wrapped_window_proc.h" |
| 15 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
| 16 #include "ui/base/keycodes/keyboard_codes.h" | 16 #include "ui/base/keycodes/keyboard_codes.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 18 #include "ui/base/l10n/l10n_util_win.h" | 18 #include "ui/base/l10n/l10n_util_win.h" |
| 19 #include "ui/base/models/accelerator.h" |
| 19 #include "ui/base/win/hwnd_util.h" | 20 #include "ui/base/win/hwnd_util.h" |
| 20 #include "ui/gfx/canvas_skia.h" | 21 #include "ui/gfx/canvas_skia.h" |
| 21 #include "ui/gfx/font.h" | 22 #include "ui/gfx/font.h" |
| 22 #include "ui/gfx/native_theme.h" | 23 #include "ui/gfx/native_theme.h" |
| 23 #include "ui/gfx/rect.h" | 24 #include "ui/gfx/rect.h" |
| 24 #include "views/accelerator.h" | |
| 25 #include "views/controls/menu/menu_2.h" | 25 #include "views/controls/menu/menu_2.h" |
| 26 #include "views/controls/menu/menu_config.h" | 26 #include "views/controls/menu/menu_config.h" |
| 27 #include "views/controls/menu/menu_listener.h" | 27 #include "views/controls/menu/menu_listener.h" |
| 28 | 28 |
| 29 using gfx::NativeTheme; | 29 using gfx::NativeTheme; |
| 30 | 30 |
| 31 namespace views { | 31 namespace views { |
| 32 | 32 |
| 33 // The width of an icon, including the pixels between the icon and | 33 // The width of an icon, including the pixels between the icon and |
| 34 // the item label. | 34 // the item label. |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 void NativeMenuWin::UpdateMenuItemInfoForString(MENUITEMINFO* mii, | 677 void NativeMenuWin::UpdateMenuItemInfoForString(MENUITEMINFO* mii, |
| 678 int model_index, | 678 int model_index, |
| 679 const string16& label) { | 679 const string16& label) { |
| 680 string16 formatted = label; | 680 string16 formatted = label; |
| 681 ui::MenuModel::ItemType type = model_->GetTypeAt(model_index); | 681 ui::MenuModel::ItemType type = model_->GetTypeAt(model_index); |
| 682 // Strip out any tabs, otherwise they get interpreted as accelerators and can | 682 // Strip out any tabs, otherwise they get interpreted as accelerators and can |
| 683 // lead to weird behavior. | 683 // lead to weird behavior. |
| 684 ReplaceSubstringsAfterOffset(&formatted, 0, L"\t", L" "); | 684 ReplaceSubstringsAfterOffset(&formatted, 0, L"\t", L" "); |
| 685 if (type != ui::MenuModel::TYPE_SUBMENU) { | 685 if (type != ui::MenuModel::TYPE_SUBMENU) { |
| 686 // Add accelerator details to the label if provided. | 686 // Add accelerator details to the label if provided. |
| 687 views::Accelerator accelerator(ui::VKEY_UNKNOWN, false, false, false); | 687 ui::Accelerator accelerator(ui::VKEY_UNKNOWN, false, false, false); |
| 688 if (model_->GetAcceleratorAt(model_index, &accelerator)) { | 688 if (model_->GetAcceleratorAt(model_index, &accelerator)) { |
| 689 formatted += L"\t"; | 689 formatted += L"\t"; |
| 690 formatted += accelerator.GetShortcutText(); | 690 formatted += accelerator.GetShortcutText(); |
| 691 } | 691 } |
| 692 } | 692 } |
| 693 | 693 |
| 694 // Update the owned string, since Windows will want us to keep this new | 694 // Update the owned string, since Windows will want us to keep this new |
| 695 // version around. | 695 // version around. |
| 696 items_[model_index]->label = formatted; | 696 items_[model_index]->label = formatted; |
| 697 | 697 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 | 756 |
| 757 //////////////////////////////////////////////////////////////////////////////// | 757 //////////////////////////////////////////////////////////////////////////////// |
| 758 // MenuWrapper, public: | 758 // MenuWrapper, public: |
| 759 | 759 |
| 760 // static | 760 // static |
| 761 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { | 761 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { |
| 762 return new NativeMenuWin(menu->model(), NULL); | 762 return new NativeMenuWin(menu->model(), NULL); |
| 763 } | 763 } |
| 764 | 764 |
| 765 } // namespace views | 765 } // namespace views |
| OLD | NEW |