| 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/views/controls/menu/native_menu_win.h" | 5 #include "ui/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" |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 SetMenuItemInfo(menu_, menu_index, MF_BYPOSITION, &mii); | 685 SetMenuItemInfo(menu_, menu_index, MF_BYPOSITION, &mii); |
| 686 } | 686 } |
| 687 | 687 |
| 688 void NativeMenuWin::UpdateMenuItemInfoForString(MENUITEMINFO* mii, | 688 void NativeMenuWin::UpdateMenuItemInfoForString(MENUITEMINFO* mii, |
| 689 int model_index, | 689 int model_index, |
| 690 const base::string16& label) { | 690 const base::string16& label) { |
| 691 base::string16 formatted = label; | 691 base::string16 formatted = label; |
| 692 ui::MenuModel::ItemType type = model_->GetTypeAt(model_index); | 692 ui::MenuModel::ItemType type = model_->GetTypeAt(model_index); |
| 693 // Strip out any tabs, otherwise they get interpreted as accelerators and can | 693 // Strip out any tabs, otherwise they get interpreted as accelerators and can |
| 694 // lead to weird behavior. | 694 // lead to weird behavior. |
| 695 ReplaceSubstringsAfterOffset(&formatted, 0, L"\t", L" "); | 695 base::ReplaceSubstringsAfterOffset(&formatted, 0, L"\t", L" "); |
| 696 if (type != ui::MenuModel::TYPE_SUBMENU) { | 696 if (type != ui::MenuModel::TYPE_SUBMENU) { |
| 697 // Add accelerator details to the label if provided. | 697 // Add accelerator details to the label if provided. |
| 698 ui::Accelerator accelerator(ui::VKEY_UNKNOWN, ui::EF_NONE); | 698 ui::Accelerator accelerator(ui::VKEY_UNKNOWN, ui::EF_NONE); |
| 699 if (model_->GetAcceleratorAt(model_index, &accelerator)) { | 699 if (model_->GetAcceleratorAt(model_index, &accelerator)) { |
| 700 formatted += L"\t"; | 700 formatted += L"\t"; |
| 701 formatted += accelerator.GetShortcutText(); | 701 formatted += accelerator.GetShortcutText(); |
| 702 } | 702 } |
| 703 } | 703 } |
| 704 | 704 |
| 705 // Update the owned string, since Windows will want us to keep this new | 705 // Update the owned string, since Windows will want us to keep this new |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 | 752 |
| 753 //////////////////////////////////////////////////////////////////////////////// | 753 //////////////////////////////////////////////////////////////////////////////// |
| 754 // MenuWrapper, public: | 754 // MenuWrapper, public: |
| 755 | 755 |
| 756 // static | 756 // static |
| 757 MenuWrapper* MenuWrapper::CreateWrapper(ui::MenuModel* model) { | 757 MenuWrapper* MenuWrapper::CreateWrapper(ui::MenuModel* model) { |
| 758 return new NativeMenuWin(model, NULL); | 758 return new NativeMenuWin(model, NULL); |
| 759 } | 759 } |
| 760 | 760 |
| 761 } // namespace views | 761 } // namespace views |
| OLD | NEW |