| 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_BASE_MODELS_SIMPLE_MENU_MODEL_H_ | 5 #ifndef UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ |
| 6 #define UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ | 6 #define UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // Notifies the delegate that the menu is about to show. | 63 // Notifies the delegate that the menu is about to show. |
| 64 virtual void MenuWillShow(SimpleMenuModel* source); | 64 virtual void MenuWillShow(SimpleMenuModel* source); |
| 65 | 65 |
| 66 // Notifies the delegate that the menu has closed. | 66 // Notifies the delegate that the menu has closed. |
| 67 virtual void MenuClosed(SimpleMenuModel* source); | 67 virtual void MenuClosed(SimpleMenuModel* source); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 // The Delegate can be NULL, though if it is items can't be checked or | 70 // The Delegate can be NULL, though if it is items can't be checked or |
| 71 // disabled. | 71 // disabled. |
| 72 explicit SimpleMenuModel(Delegate* delegate); | 72 explicit SimpleMenuModel(Delegate* delegate); |
| 73 virtual ~SimpleMenuModel(); | 73 ~SimpleMenuModel() override; |
| 74 | 74 |
| 75 // Methods for adding items to the model. | 75 // Methods for adding items to the model. |
| 76 void AddItem(int command_id, const base::string16& label); | 76 void AddItem(int command_id, const base::string16& label); |
| 77 void AddItemWithStringId(int command_id, int string_id); | 77 void AddItemWithStringId(int command_id, int string_id); |
| 78 void AddCheckItem(int command_id, const base::string16& label); | 78 void AddCheckItem(int command_id, const base::string16& label); |
| 79 void AddCheckItemWithStringId(int command_id, int string_id); | 79 void AddCheckItemWithStringId(int command_id, int string_id); |
| 80 void AddRadioItem(int command_id, const base::string16& label, int group_id); | 80 void AddRadioItem(int command_id, const base::string16& label, int group_id); |
| 81 void AddRadioItemWithStringId(int command_id, int string_id, int group_id); | 81 void AddRadioItemWithStringId(int command_id, int string_id, int group_id); |
| 82 | 82 |
| 83 // Adds a separator of the specified type to the model. | 83 // Adds a separator of the specified type to the model. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 void SetMinorText(int index, const base::string16& minor_text); | 133 void SetMinorText(int index, const base::string16& minor_text); |
| 134 | 134 |
| 135 // Clears all items. Note that it does not free MenuModel of submenu. | 135 // Clears all items. Note that it does not free MenuModel of submenu. |
| 136 void Clear(); | 136 void Clear(); |
| 137 | 137 |
| 138 // Returns the index of the item that has the given |command_id|. Returns | 138 // Returns the index of the item that has the given |command_id|. Returns |
| 139 // -1 if not found. | 139 // -1 if not found. |
| 140 int GetIndexOfCommandId(int command_id); | 140 int GetIndexOfCommandId(int command_id); |
| 141 | 141 |
| 142 // Overridden from MenuModel: | 142 // Overridden from MenuModel: |
| 143 virtual bool HasIcons() const override; | 143 bool HasIcons() const override; |
| 144 virtual int GetItemCount() const override; | 144 int GetItemCount() const override; |
| 145 virtual ItemType GetTypeAt(int index) const override; | 145 ItemType GetTypeAt(int index) const override; |
| 146 virtual ui::MenuSeparatorType GetSeparatorTypeAt(int index) const override; | 146 ui::MenuSeparatorType GetSeparatorTypeAt(int index) const override; |
| 147 virtual int GetCommandIdAt(int index) const override; | 147 int GetCommandIdAt(int index) const override; |
| 148 virtual base::string16 GetLabelAt(int index) const override; | 148 base::string16 GetLabelAt(int index) const override; |
| 149 virtual base::string16 GetSublabelAt(int index) const override; | 149 base::string16 GetSublabelAt(int index) const override; |
| 150 virtual base::string16 GetMinorTextAt(int index) const override; | 150 base::string16 GetMinorTextAt(int index) const override; |
| 151 virtual bool IsItemDynamicAt(int index) const override; | 151 bool IsItemDynamicAt(int index) const override; |
| 152 virtual bool GetAcceleratorAt(int index, | 152 bool GetAcceleratorAt(int index, ui::Accelerator* accelerator) const override; |
| 153 ui::Accelerator* accelerator) const override; | 153 bool IsItemCheckedAt(int index) const override; |
| 154 virtual bool IsItemCheckedAt(int index) const override; | 154 int GetGroupIdAt(int index) const override; |
| 155 virtual int GetGroupIdAt(int index) const override; | 155 bool GetIconAt(int index, gfx::Image* icon) override; |
| 156 virtual bool GetIconAt(int index, gfx::Image* icon) override; | 156 ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const override; |
| 157 virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt( | 157 bool IsEnabledAt(int index) const override; |
| 158 int index) const override; | 158 bool IsVisibleAt(int index) const override; |
| 159 virtual bool IsEnabledAt(int index) const override; | 159 void HighlightChangedTo(int index) override; |
| 160 virtual bool IsVisibleAt(int index) const override; | 160 void ActivatedAt(int index) override; |
| 161 virtual void HighlightChangedTo(int index) override; | 161 void ActivatedAt(int index, int event_flags) override; |
| 162 virtual void ActivatedAt(int index) override; | 162 MenuModel* GetSubmenuModelAt(int index) const override; |
| 163 virtual void ActivatedAt(int index, int event_flags) override; | 163 void MenuWillShow() override; |
| 164 virtual MenuModel* GetSubmenuModelAt(int index) const override; | 164 void MenuClosed() override; |
| 165 virtual void MenuWillShow() override; | 165 void SetMenuModelDelegate( |
| 166 virtual void MenuClosed() override; | |
| 167 virtual void SetMenuModelDelegate( | |
| 168 ui::MenuModelDelegate* menu_model_delegate) override; | 166 ui::MenuModelDelegate* menu_model_delegate) override; |
| 169 virtual MenuModelDelegate* GetMenuModelDelegate() const override; | 167 MenuModelDelegate* GetMenuModelDelegate() const override; |
| 170 | 168 |
| 171 protected: | 169 protected: |
| 172 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | 170 void set_delegate(Delegate* delegate) { delegate_ = delegate; } |
| 173 Delegate* delegate() { return delegate_; } | 171 Delegate* delegate() { return delegate_; } |
| 174 | 172 |
| 175 // One or more of the menu menu items associated with the model has changed. | 173 // One or more of the menu menu items associated with the model has changed. |
| 176 // Do any handling if necessary. | 174 // Do any handling if necessary. |
| 177 virtual void MenuItemsChanged(); | 175 virtual void MenuItemsChanged(); |
| 178 | 176 |
| 179 private: | 177 private: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 199 MenuModelDelegate* menu_model_delegate_; | 197 MenuModelDelegate* menu_model_delegate_; |
| 200 | 198 |
| 201 base::WeakPtrFactory<SimpleMenuModel> method_factory_; | 199 base::WeakPtrFactory<SimpleMenuModel> method_factory_; |
| 202 | 200 |
| 203 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); | 201 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); |
| 204 }; | 202 }; |
| 205 | 203 |
| 206 } // namespace ui | 204 } // namespace ui |
| 207 | 205 |
| 208 #endif // UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ | 206 #endif // UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ |
| OLD | NEW |