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 20 matching lines...) Expand all Loading... |
31 virtual bool IsCommandIdChecked(int command_id) const = 0; | 31 virtual bool IsCommandIdChecked(int command_id) const = 0; |
32 virtual bool IsCommandIdEnabled(int command_id) const = 0; | 32 virtual bool IsCommandIdEnabled(int command_id) const = 0; |
33 virtual bool IsCommandIdVisible(int command_id) const; | 33 virtual bool IsCommandIdVisible(int command_id) const; |
34 | 34 |
35 // Gets the accelerator for the specified command id. Returns true if the | 35 // Gets the accelerator for the specified command id. Returns true if the |
36 // command id has a valid accelerator, false otherwise. | 36 // command id has a valid accelerator, false otherwise. |
37 virtual bool GetAcceleratorForCommandId( | 37 virtual bool GetAcceleratorForCommandId( |
38 int command_id, | 38 int command_id, |
39 ui::Accelerator* accelerator) = 0; | 39 ui::Accelerator* accelerator) = 0; |
40 | 40 |
41 // Some command ids have labels and icons that change over time. | 41 // Some command ids have labels, sub-labels and icons that change over time. |
42 virtual bool IsItemForCommandIdDynamic(int command_id) const; | 42 virtual bool IsItemForCommandIdDynamic(int command_id) const; |
43 virtual string16 GetLabelForCommandId(int command_id) const; | 43 virtual string16 GetLabelForCommandId(int command_id) const; |
| 44 virtual string16 GetSubLabelForCommandId(int command_id) const; |
44 // Gets the icon for the item with the specified id, returning true if there | 45 // Gets the icon for the item with the specified id, returning true if there |
45 // is an icon, false otherwise. | 46 // is an icon, false otherwise. |
46 virtual bool GetIconForCommandId(int command_id, | 47 virtual bool GetIconForCommandId(int command_id, |
47 gfx::Image* icon) const; | 48 gfx::Image* icon) const; |
48 | 49 |
49 // Notifies the delegate that the item with the specified command id was | 50 // Notifies the delegate that the item with the specified command id was |
50 // visually highlighted within the menu. | 51 // visually highlighted within the menu. |
51 virtual void CommandIdHighlighted(int command_id); | 52 virtual void CommandIdHighlighted(int command_id); |
52 | 53 |
53 // Performs the action associated with the specified command id. | 54 // Performs the action associated with the specified command id. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 void InsertRadioItemWithStringIdAt( | 108 void InsertRadioItemWithStringIdAt( |
108 int index, int command_id, int string_id, int group_id); | 109 int index, int command_id, int string_id, int group_id); |
109 void InsertSubMenuAt( | 110 void InsertSubMenuAt( |
110 int index, int command_id, const string16& label, MenuModel* model); | 111 int index, int command_id, const string16& label, MenuModel* model); |
111 void InsertSubMenuWithStringIdAt( | 112 void InsertSubMenuWithStringIdAt( |
112 int index, int command_id, int string_id, MenuModel* model); | 113 int index, int command_id, int string_id, MenuModel* model); |
113 | 114 |
114 // Sets the icon for the item at |index|. | 115 // Sets the icon for the item at |index|. |
115 void SetIcon(int index, const gfx::Image& icon); | 116 void SetIcon(int index, const gfx::Image& icon); |
116 | 117 |
| 118 // Sets the sub-label for the item at |index|. |
| 119 void SetSubLabel(int index, const string16& sublabel); |
| 120 |
117 // Clears all items. Note that it does not free MenuModel of submenu. | 121 // Clears all items. Note that it does not free MenuModel of submenu. |
118 void Clear(); | 122 void Clear(); |
119 | 123 |
120 // Returns the index of the item that has the given |command_id|. Returns | 124 // Returns the index of the item that has the given |command_id|. Returns |
121 // -1 if not found. | 125 // -1 if not found. |
122 int GetIndexOfCommandId(int command_id); | 126 int GetIndexOfCommandId(int command_id); |
123 | 127 |
124 // Overridden from MenuModel: | 128 // Overridden from MenuModel: |
125 virtual bool HasIcons() const OVERRIDE; | 129 virtual bool HasIcons() const OVERRIDE; |
126 virtual int GetItemCount() const OVERRIDE; | 130 virtual int GetItemCount() const OVERRIDE; |
127 virtual ItemType GetTypeAt(int index) const OVERRIDE; | 131 virtual ItemType GetTypeAt(int index) const OVERRIDE; |
128 virtual ui::MenuSeparatorType GetSeparatorTypeAt(int index) const OVERRIDE; | 132 virtual ui::MenuSeparatorType GetSeparatorTypeAt(int index) const OVERRIDE; |
129 virtual int GetCommandIdAt(int index) const OVERRIDE; | 133 virtual int GetCommandIdAt(int index) const OVERRIDE; |
130 virtual string16 GetLabelAt(int index) const OVERRIDE; | 134 virtual string16 GetLabelAt(int index) const OVERRIDE; |
| 135 virtual string16 GetSubLabelAt(int index) const OVERRIDE; |
131 virtual bool IsItemDynamicAt(int index) const OVERRIDE; | 136 virtual bool IsItemDynamicAt(int index) const OVERRIDE; |
132 virtual bool GetAcceleratorAt(int index, | 137 virtual bool GetAcceleratorAt(int index, |
133 ui::Accelerator* accelerator) const OVERRIDE; | 138 ui::Accelerator* accelerator) const OVERRIDE; |
134 virtual bool IsItemCheckedAt(int index) const OVERRIDE; | 139 virtual bool IsItemCheckedAt(int index) const OVERRIDE; |
135 virtual int GetGroupIdAt(int index) const OVERRIDE; | 140 virtual int GetGroupIdAt(int index) const OVERRIDE; |
136 virtual bool GetIconAt(int index, gfx::Image* icon) OVERRIDE; | 141 virtual bool GetIconAt(int index, gfx::Image* icon) OVERRIDE; |
137 virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt( | 142 virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt( |
138 int index) const OVERRIDE; | 143 int index) const OVERRIDE; |
139 virtual bool IsEnabledAt(int index) const OVERRIDE; | 144 virtual bool IsEnabledAt(int index) const OVERRIDE; |
140 virtual bool IsVisibleAt(int index) const OVERRIDE; | 145 virtual bool IsVisibleAt(int index) const OVERRIDE; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 MenuModelDelegate* menu_model_delegate_; | 180 MenuModelDelegate* menu_model_delegate_; |
176 | 181 |
177 base::WeakPtrFactory<SimpleMenuModel> method_factory_; | 182 base::WeakPtrFactory<SimpleMenuModel> method_factory_; |
178 | 183 |
179 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); | 184 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); |
180 }; | 185 }; |
181 | 186 |
182 } // namespace ui | 187 } // namespace ui |
183 | 188 |
184 #endif // UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ | 189 #endif // UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ |
OLD | NEW |