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, sublabels 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 associates with the specified command id. | 54 // Performs the action associates with the specified command id. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 void InsertRadioItemWithStringIdAt( | 107 void InsertRadioItemWithStringIdAt( |
107 int index, int command_id, int string_id, int group_id); | 108 int index, int command_id, int string_id, int group_id); |
108 void InsertSubMenuAt( | 109 void InsertSubMenuAt( |
109 int index, int command_id, const string16& label, MenuModel* model); | 110 int index, int command_id, const string16& label, MenuModel* model); |
110 void InsertSubMenuWithStringIdAt( | 111 void InsertSubMenuWithStringIdAt( |
111 int index, int command_id, int string_id, MenuModel* model); | 112 int index, int command_id, int string_id, MenuModel* model); |
112 | 113 |
113 // Sets the icon for the item at |index|. | 114 // Sets the icon for the item at |index|. |
114 void SetIcon(int index, const gfx::Image& icon); | 115 void SetIcon(int index, const gfx::Image& icon); |
115 | 116 |
| 117 // Sets the sublabel for the item at |index|. |
| 118 void SetSublabel(int index, const string16& sublabel); |
| 119 |
116 // Clears all items. Note that it does not free MenuModel of submenu. | 120 // Clears all items. Note that it does not free MenuModel of submenu. |
117 void Clear(); | 121 void Clear(); |
118 | 122 |
119 // Returns the index of the item that has the given |command_id|. Returns | 123 // Returns the index of the item that has the given |command_id|. Returns |
120 // -1 if not found. | 124 // -1 if not found. |
121 int GetIndexOfCommandId(int command_id); | 125 int GetIndexOfCommandId(int command_id); |
122 | 126 |
123 // Overridden from MenuModel: | 127 // Overridden from MenuModel: |
124 virtual bool HasIcons() const OVERRIDE; | 128 virtual bool HasIcons() const OVERRIDE; |
125 virtual int GetItemCount() const OVERRIDE; | 129 virtual int GetItemCount() const OVERRIDE; |
126 virtual ItemType GetTypeAt(int index) const OVERRIDE; | 130 virtual ItemType GetTypeAt(int index) const OVERRIDE; |
127 virtual ui::MenuSeparatorType GetSeparatorTypeAt(int index) const OVERRIDE; | 131 virtual ui::MenuSeparatorType GetSeparatorTypeAt(int index) const OVERRIDE; |
128 virtual int GetCommandIdAt(int index) const OVERRIDE; | 132 virtual int GetCommandIdAt(int index) const OVERRIDE; |
129 virtual string16 GetLabelAt(int index) const OVERRIDE; | 133 virtual string16 GetLabelAt(int index) const OVERRIDE; |
| 134 virtual string16 GetSublabelAt(int index) const OVERRIDE; |
130 virtual bool IsItemDynamicAt(int index) const OVERRIDE; | 135 virtual bool IsItemDynamicAt(int index) const OVERRIDE; |
131 virtual bool GetAcceleratorAt(int index, | 136 virtual bool GetAcceleratorAt(int index, |
132 ui::Accelerator* accelerator) const OVERRIDE; | 137 ui::Accelerator* accelerator) const OVERRIDE; |
133 virtual bool IsItemCheckedAt(int index) const OVERRIDE; | 138 virtual bool IsItemCheckedAt(int index) const OVERRIDE; |
134 virtual int GetGroupIdAt(int index) const OVERRIDE; | 139 virtual int GetGroupIdAt(int index) const OVERRIDE; |
135 virtual bool GetIconAt(int index, gfx::Image* icon) OVERRIDE; | 140 virtual bool GetIconAt(int index, gfx::Image* icon) OVERRIDE; |
136 virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt( | 141 virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt( |
137 int index) const OVERRIDE; | 142 int index) const OVERRIDE; |
138 virtual bool IsEnabledAt(int index) const OVERRIDE; | 143 virtual bool IsEnabledAt(int index) const OVERRIDE; |
139 virtual bool IsVisibleAt(int index) const OVERRIDE; | 144 virtual bool IsVisibleAt(int index) const OVERRIDE; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 MenuModelDelegate* menu_model_delegate_; | 179 MenuModelDelegate* menu_model_delegate_; |
175 | 180 |
176 base::WeakPtrFactory<SimpleMenuModel> method_factory_; | 181 base::WeakPtrFactory<SimpleMenuModel> method_factory_; |
177 | 182 |
178 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); | 183 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); |
179 }; | 184 }; |
180 | 185 |
181 } // namespace ui | 186 } // namespace ui |
182 | 187 |
183 #endif // UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ | 188 #endif // UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ |
OLD | NEW |