| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/keyboard_codes.h" | |
| 8 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 9 #include "app/l10n_util_win.h" | 8 #include "app/l10n_util_win.h" |
| 10 #include "app/win/hwnd_util.h" | 9 #include "app/win/hwnd_util.h" |
| 11 #include "base/logging.h" | 10 #include "base/logging.h" |
| 12 #include "base/stl_util-inl.h" | 11 #include "base/stl_util-inl.h" |
| 13 #include "gfx/canvas_skia.h" | 12 #include "gfx/canvas_skia.h" |
| 14 #include "gfx/font.h" | 13 #include "gfx/font.h" |
| 15 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 #include "ui/base/keycodes/keyboard_codes.h" |
| 16 #include "views/accelerator.h" | 16 #include "views/accelerator.h" |
| 17 #include "views/controls/menu/menu_2.h" | 17 #include "views/controls/menu/menu_2.h" |
| 18 | 18 |
| 19 namespace views { | 19 namespace views { |
| 20 | 20 |
| 21 // The width of an icon, including the pixels between the icon and | 21 // The width of an icon, including the pixels between the icon and |
| 22 // the item label. | 22 // the item label. |
| 23 static const int kIconWidth = 23; | 23 static const int kIconWidth = 23; |
| 24 // Margins between the top of the item and the label. | 24 // Margins between the top of the item and the label. |
| 25 static const int kItemTopMargin = 3; | 25 static const int kItemTopMargin = 3; |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 } | 547 } |
| 548 | 548 |
| 549 void NativeMenuWin::UpdateMenuItemInfoForString( | 549 void NativeMenuWin::UpdateMenuItemInfoForString( |
| 550 MENUITEMINFO* mii, | 550 MENUITEMINFO* mii, |
| 551 int model_index, | 551 int model_index, |
| 552 const std::wstring& label) { | 552 const std::wstring& label) { |
| 553 std::wstring formatted = label; | 553 std::wstring formatted = label; |
| 554 menus::MenuModel::ItemType type = model_->GetTypeAt(model_index); | 554 menus::MenuModel::ItemType type = model_->GetTypeAt(model_index); |
| 555 if (type != menus::MenuModel::TYPE_SUBMENU) { | 555 if (type != menus::MenuModel::TYPE_SUBMENU) { |
| 556 // Add accelerator details to the label if provided. | 556 // Add accelerator details to the label if provided. |
| 557 views::Accelerator accelerator(app::VKEY_UNKNOWN, false, false, false); | 557 views::Accelerator accelerator(ui::VKEY_UNKNOWN, false, false, false); |
| 558 if (model_->GetAcceleratorAt(model_index, &accelerator)) { | 558 if (model_->GetAcceleratorAt(model_index, &accelerator)) { |
| 559 formatted += L"\t"; | 559 formatted += L"\t"; |
| 560 formatted += accelerator.GetShortcutText(); | 560 formatted += accelerator.GetShortcutText(); |
| 561 } | 561 } |
| 562 } | 562 } |
| 563 | 563 |
| 564 // Update the owned string, since Windows will want us to keep this new | 564 // Update the owned string, since Windows will want us to keep this new |
| 565 // version around. | 565 // version around. |
| 566 items_[model_index]->label = formatted; | 566 items_[model_index]->label = formatted; |
| 567 | 567 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 | 626 |
| 627 //////////////////////////////////////////////////////////////////////////////// | 627 //////////////////////////////////////////////////////////////////////////////// |
| 628 // MenuWrapper, public: | 628 // MenuWrapper, public: |
| 629 | 629 |
| 630 // static | 630 // static |
| 631 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { | 631 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { |
| 632 return new NativeMenuWin(menu->model(), NULL); | 632 return new NativeMenuWin(menu->model(), NULL); |
| 633 } | 633 } |
| 634 | 634 |
| 635 } // namespace views | 635 } // namespace views |
| OLD | NEW |