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 "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 bool IsTriggerableEvent(MenuItemView* source, const ui::Event& e) override; | 71 bool IsTriggerableEvent(MenuItemView* source, const ui::Event& e) override; |
72 bool GetAccelerator(int id, ui::Accelerator* accelerator) const override; | 72 bool GetAccelerator(int id, ui::Accelerator* accelerator) const override; |
73 base::string16 GetLabel(int id) const override; | 73 base::string16 GetLabel(int id) const override; |
74 const gfx::FontList* GetLabelFontList(int id) const override; | 74 const gfx::FontList* GetLabelFontList(int id) const override; |
75 bool IsCommandEnabled(int id) const override; | 75 bool IsCommandEnabled(int id) const override; |
76 bool IsCommandVisible(int id) const override; | 76 bool IsCommandVisible(int id) const override; |
77 bool IsItemChecked(int id) const override; | 77 bool IsItemChecked(int id) const override; |
78 void SelectionChanged(MenuItemView* menu) override; | 78 void SelectionChanged(MenuItemView* menu) override; |
79 void WillShowMenu(MenuItemView* menu) override; | 79 void WillShowMenu(MenuItemView* menu) override; |
80 void WillHideMenu(MenuItemView* menu) override; | 80 void WillHideMenu(MenuItemView* menu) override; |
81 void OnMenuClosed(MenuItemView* menu, MenuRunner::RunResult result) override; | 81 void OnMenuClosed(MenuItemView* menu) override; |
82 | 82 |
83 private: | 83 private: |
84 // Implementation of BuildMenu(). | 84 // Implementation of BuildMenu(). |
85 void BuildMenuImpl(MenuItemView* menu, ui::MenuModel* model); | 85 void BuildMenuImpl(MenuItemView* menu, ui::MenuModel* model); |
86 | 86 |
87 // Container of ui::MenuModel pointers as encountered by preorder | 87 // Container of ui::MenuModel pointers as encountered by preorder |
88 // traversal. The first element is always the top-level model | 88 // traversal. The first element is always the top-level model |
89 // passed to the constructor. | 89 // passed to the constructor. |
90 ui::MenuModel* menu_model_; | 90 ui::MenuModel* menu_model_; |
91 | 91 |
92 // Mouse event flags which can trigger menu actions. | 92 // Mouse event flags which can trigger menu actions. |
93 int triggerable_event_flags_; | 93 int triggerable_event_flags_; |
94 | 94 |
95 // Map MenuItems to MenuModels. Used to implement WillShowMenu(). | 95 // Map MenuItems to MenuModels. Used to implement WillShowMenu(). |
96 std::map<MenuItemView*, ui::MenuModel*> menu_map_; | 96 std::map<MenuItemView*, ui::MenuModel*> menu_map_; |
97 | 97 |
98 // Optional callback triggered during OnMenuClosed(). | 98 // Optional callback triggered during OnMenuClosed(). |
99 base::Closure on_menu_closed_callback_; | 99 base::Closure on_menu_closed_callback_; |
100 | 100 |
101 DISALLOW_COPY_AND_ASSIGN(MenuModelAdapter); | 101 DISALLOW_COPY_AND_ASSIGN(MenuModelAdapter); |
102 }; | 102 }; |
103 | 103 |
104 } // namespace views | 104 } // namespace views |
105 | 105 |
106 #endif // UI_VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ | 106 #endif // UI_VIEWS_CONTROLS_MENU_MENU_MODEL_ADAPTER_H_ |
OLD | NEW |