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 21 matching lines...) Expand all Loading... |
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 protected: | 41 protected: |
| 42 // 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 |
| 44 // menu. |
| 45 virtual MenuItemView* AppendMenuItem(MenuItemView* menu, |
| 46 ui::MenuModel* model, |
| 47 int index); |
| 48 |
42 // views::MenuDelegate implementation. | 49 // views::MenuDelegate implementation. |
43 virtual void ExecuteCommand(int id) OVERRIDE; | 50 virtual void ExecuteCommand(int id) OVERRIDE; |
44 virtual void ExecuteCommand(int id, int mouse_event_flags) OVERRIDE; | 51 virtual void ExecuteCommand(int id, int mouse_event_flags) OVERRIDE; |
45 virtual bool IsTriggerableEvent(MenuItemView* source, | 52 virtual bool IsTriggerableEvent(MenuItemView* source, |
46 const ui::Event& e) OVERRIDE; | 53 const ui::Event& e) OVERRIDE; |
47 virtual bool GetAccelerator(int id, | 54 virtual bool GetAccelerator(int id, |
48 ui::Accelerator* accelerator) OVERRIDE; | 55 ui::Accelerator* accelerator) OVERRIDE; |
49 virtual string16 GetLabel(int id) const OVERRIDE; | 56 virtual string16 GetLabel(int id) const OVERRIDE; |
50 virtual const gfx::Font* GetLabelFont(int id) const OVERRIDE; | 57 virtual const gfx::Font* GetLabelFont(int id) const OVERRIDE; |
51 virtual bool IsCommandEnabled(int id) const OVERRIDE; | 58 virtual bool IsCommandEnabled(int id) const OVERRIDE; |
(...skipping 16 matching lines...) Expand all Loading... |
68 | 75 |
69 // Map MenuItems to MenuModels. Used to implement WillShowMenu(). | 76 // Map MenuItems to MenuModels. Used to implement WillShowMenu(). |
70 std::map<MenuItemView*, ui::MenuModel*> menu_map_; | 77 std::map<MenuItemView*, ui::MenuModel*> menu_map_; |
71 | 78 |
72 DISALLOW_COPY_AND_ASSIGN(MenuModelAdapter); | 79 DISALLOW_COPY_AND_ASSIGN(MenuModelAdapter); |
73 }; | 80 }; |
74 | 81 |
75 } // namespace views | 82 } // namespace views |
76 | 83 |
77 #endif // UI_VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ | 84 #endif // UI_VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ |
OLD | NEW |