| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "ui/base/accelerators/accelerator.h" | 10 #include "ui/base/accelerators/accelerator.h" |
| 11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
| 12 #include "ui/base/l10n/l10n_util_win.h" | 12 #include "ui/base/l10n/l10n_util_win.h" |
| 13 #include "ui/base/models/menu_model.h" | 13 #include "ui/base/models/menu_model.h" |
| 14 #include "ui/views/controls/menu/menu_insertion_delegate_win.h" | 14 #include "ui/views/controls/menu/menu_insertion_delegate_win.h" |
| 15 | 15 |
| 16 namespace views { | 16 namespace views { |
| 17 | 17 |
| 18 struct NativeMenuWin::ItemData { | 18 struct NativeMenuWin::ItemData { |
| 19 // The Windows API requires that whoever creates the menus must own the | 19 // The Windows API requires that whoever creates the menus must own the |
| 20 // strings used for labels, and keep them around for the lifetime of the | 20 // strings used for labels, and keep them around for the lifetime of the |
| 21 // created menu. So be it. | 21 // created menu. So be it. |
| 22 base::string16 label; | 22 base::string16 label; |
| 23 | 23 |
| 24 // Someone needs to own submenus, it may as well be us. | 24 // Someone needs to own submenus, it may as well be us. |
| 25 scoped_ptr<NativeMenuWin> submenu; | 25 std::unique_ptr<NativeMenuWin> submenu; |
| 26 | 26 |
| 27 // We need a pointer back to the containing menu in various circumstances. | 27 // We need a pointer back to the containing menu in various circumstances. |
| 28 NativeMenuWin* native_menu_win; | 28 NativeMenuWin* native_menu_win; |
| 29 | 29 |
| 30 // The index of the item within the menu's model. | 30 // The index of the item within the menu's model. |
| 31 int model_index; | 31 int model_index; |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 // Returns the NativeMenuWin for a particular HMENU. | 34 // Returns the NativeMenuWin for a particular HMENU. |
| 35 static NativeMenuWin* GetNativeMenuWinFromHMENU(HMENU hmenu) { | 35 static NativeMenuWin* GetNativeMenuWinFromHMENU(HMENU hmenu) { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 MENUINFO mi = {0}; | 226 MENUINFO mi = {0}; |
| 227 mi.cbSize = sizeof(mi); | 227 mi.cbSize = sizeof(mi); |
| 228 mi.fMask = MIM_STYLE | MIM_MENUDATA; | 228 mi.fMask = MIM_STYLE | MIM_MENUDATA; |
| 229 mi.dwStyle = MNS_NOTIFYBYPOS; | 229 mi.dwStyle = MNS_NOTIFYBYPOS; |
| 230 mi.dwMenuData = reinterpret_cast<ULONG_PTR>(this); | 230 mi.dwMenuData = reinterpret_cast<ULONG_PTR>(this); |
| 231 SetMenuInfo(menu_, &mi); | 231 SetMenuInfo(menu_, &mi); |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 | 234 |
| 235 } // namespace views | 235 } // namespace views |
| OLD | NEW |