| 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 #ifndef VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ | 5 #ifndef VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ |
| 6 #define VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ | 6 #define VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| 11 #include "views/controls/menu/menu_delegate.h" | 11 #include "views/controls/menu/menu_delegate.h" |
| 12 | 12 |
| 13 namespace ui { | 13 namespace ui { |
| 14 class MenuModel; | 14 class MenuModel; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace views { | 17 namespace views { |
| 18 class MenuItemView; | 18 class MenuItemView; |
| 19 | 19 |
| 20 // This class wraps an instance of ui::MenuModel with the | 20 // This class wraps an instance of ui::MenuModel with the |
| 21 // views::MenuDelegate interface required by views::MenuItemView. | 21 // views::MenuDelegate interface required by views::MenuItemView. |
| 22 class MenuModelAdapter : public MenuDelegate { | 22 class MenuModelAdapter : public MenuDelegate { |
| 23 public: | 23 public: |
| 24 // The caller retains ownership of the ui::MenuModel instance and | 24 // The caller retains ownership of the ui::MenuModel instance and |
| 25 // must ensure it exists for the lifetime of the adapter. The | 25 // must ensure it exists for the lifetime of the adapter. The |
| 26 // base_id argument is the command id for the first menu item. | 26 // base_id argument is the command id for the first menu item. |
| 27 explicit MenuModelAdapter(ui::MenuModel* menu_model); | 27 explicit MenuModelAdapter(ui::MenuModel* menu_model); |
| 28 virtual ~MenuModelAdapter(); |
| 28 | 29 |
| 29 // Populate a MenuItemView menu with the ui::MenuModel items | 30 // Populate a MenuItemView menu with the ui::MenuModel items |
| 30 // (including submenus). | 31 // (including submenus). |
| 31 virtual void BuildMenu(MenuItemView* menu); | 32 virtual void BuildMenu(MenuItemView* menu); |
| 32 | 33 |
| 33 protected: | 34 protected: |
| 34 // views::MenuDelegate implementation. | 35 // views::MenuDelegate implementation. |
| 35 virtual void ExecuteCommand(int id) OVERRIDE; | 36 virtual void ExecuteCommand(int id) OVERRIDE; |
| 36 virtual void ExecuteCommand(int id, int mouse_event_flags) OVERRIDE; | 37 virtual void ExecuteCommand(int id, int mouse_event_flags) OVERRIDE; |
| 37 virtual bool GetAccelerator(int id, | 38 virtual bool GetAccelerator(int id, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 56 | 57 |
| 57 // Map MenuItems to MenuModels. Used to implement WillShowMenu(). | 58 // Map MenuItems to MenuModels. Used to implement WillShowMenu(). |
| 58 std::map<MenuItemView*, ui::MenuModel*> menu_map_; | 59 std::map<MenuItemView*, ui::MenuModel*> menu_map_; |
| 59 | 60 |
| 60 DISALLOW_COPY_AND_ASSIGN(MenuModelAdapter); | 61 DISALLOW_COPY_AND_ASSIGN(MenuModelAdapter); |
| 61 }; | 62 }; |
| 62 | 63 |
| 63 } // namespace views | 64 } // namespace views |
| 64 | 65 |
| 65 #endif // VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ | 66 #endif // VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ |
| OLD | NEW |