| 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 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ | 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ |
| 6 #define UI_VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ | 6 #define UI_VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "ui/views/controls/menu/menu_delegate.h" | 10 #include "ui/views/controls/menu/menu_delegate.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 // Convenience for creating and populating a menu. The caller owns the | 32 // Convenience for creating and populating a menu. The caller owns the |
| 33 // returned MenuItemView. | 33 // returned MenuItemView. |
| 34 MenuItemView* CreateMenu(); | 34 MenuItemView* CreateMenu(); |
| 35 | 35 |
| 36 void set_triggerable_event_flags(int triggerable_event_flags) { | 36 void set_triggerable_event_flags(int triggerable_event_flags) { |
| 37 triggerable_event_flags_ = triggerable_event_flags; | 37 triggerable_event_flags_ = triggerable_event_flags; |
| 38 } | 38 } |
| 39 int triggerable_event_flags() const { return triggerable_event_flags_; } | 39 int triggerable_event_flags() const { return triggerable_event_flags_; } |
| 40 | 40 |
| 41 // Creates a menu item for the specified entry in the model and adds it as |
| 42 // a child to |menu| at the specified |menu_index|. |
| 43 static MenuItemView* AddMenuItemFromModelAt(ui::MenuModel* model, |
| 44 int model_index, |
| 45 MenuItemView* menu, |
| 46 int menu_index, |
| 47 int item_id); |
| 48 |
| 49 // Creates a menu item for the specified entry in the model and appends it as |
| 50 // a child to |menu|. |
| 51 static MenuItemView* AppendMenuItemFromModel(ui::MenuModel* model, |
| 52 int model_index, |
| 53 MenuItemView* menu, |
| 54 int item_id); |
| 55 |
| 41 protected: | 56 protected: |
| 42 // Create and add a menu item to |menu| for the item at index |index| in | 57 // Create and add a menu item to |menu| for the item at index |index| in |
| 43 // |model|. Subclasses override this to allow custom items to be added to the | 58 // |model|. Subclasses override this to allow custom items to be added to the |
| 44 // menu. | 59 // menu. |
| 45 virtual MenuItemView* AppendMenuItem(MenuItemView* menu, | 60 virtual MenuItemView* AppendMenuItem(MenuItemView* menu, |
| 46 ui::MenuModel* model, | 61 ui::MenuModel* model, |
| 47 int index); | 62 int index); |
| 48 | 63 |
| 49 // views::MenuDelegate implementation. | 64 // views::MenuDelegate implementation. |
| 50 virtual void ExecuteCommand(int id) OVERRIDE; | 65 virtual void ExecuteCommand(int id) OVERRIDE; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 75 | 90 |
| 76 // Map MenuItems to MenuModels. Used to implement WillShowMenu(). | 91 // Map MenuItems to MenuModels. Used to implement WillShowMenu(). |
| 77 std::map<MenuItemView*, ui::MenuModel*> menu_map_; | 92 std::map<MenuItemView*, ui::MenuModel*> menu_map_; |
| 78 | 93 |
| 79 DISALLOW_COPY_AND_ASSIGN(MenuModelAdapter); | 94 DISALLOW_COPY_AND_ASSIGN(MenuModelAdapter); |
| 80 }; | 95 }; |
| 81 | 96 |
| 82 } // namespace views | 97 } // namespace views |
| 83 | 98 |
| 84 #endif // UI_VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ | 99 #endif // UI_VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ |
| OLD | NEW |