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/macros.h" | 10 #include "base/macros.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 // Methods for determining the state of specific command ids. | 33 // Methods for determining the state of specific command ids. |
34 virtual bool IsCommandIdChecked(int command_id) const = 0; | 34 virtual bool IsCommandIdChecked(int command_id) const = 0; |
35 virtual bool IsCommandIdEnabled(int command_id) const = 0; | 35 virtual bool IsCommandIdEnabled(int command_id) const = 0; |
36 virtual bool IsCommandIdVisible(int command_id) const; | 36 virtual bool IsCommandIdVisible(int command_id) const; |
37 | 37 |
38 // Gets the accelerator for the specified command id. Returns true if the | 38 // Gets the accelerator for the specified command id. Returns true if the |
39 // command id has a valid accelerator, false otherwise. | 39 // command id has a valid accelerator, false otherwise. |
40 virtual bool GetAcceleratorForCommandId( | 40 virtual bool GetAcceleratorForCommandId( |
41 int command_id, | 41 int command_id, |
42 ui::Accelerator* accelerator) = 0; | 42 ui::Accelerator* accelerator) const = 0; |
43 | 43 |
44 // Some command ids have labels, sublabels, minor text and icons that change | 44 // Some command ids have labels, sublabels, minor text and icons that change |
45 // over time. | 45 // over time. |
46 virtual bool IsItemForCommandIdDynamic(int command_id) const; | 46 virtual bool IsItemForCommandIdDynamic(int command_id) const; |
47 virtual base::string16 GetLabelForCommandId(int command_id) const; | 47 virtual base::string16 GetLabelForCommandId(int command_id) const; |
48 virtual base::string16 GetSublabelForCommandId(int command_id) const; | 48 virtual base::string16 GetSublabelForCommandId(int command_id) const; |
49 virtual base::string16 GetMinorTextForCommandId(int command_id) const; | 49 virtual base::string16 GetMinorTextForCommandId(int command_id) const; |
50 // Gets the icon for the item with the specified id, returning true if there | 50 // Gets the icon for the item with the specified id, returning true if there |
51 // is an icon, false otherwise. | 51 // is an icon, false otherwise. |
52 virtual bool GetIconForCommandId(int command_id, | 52 virtual bool GetIconForCommandId(int command_id, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 void SetSublabel(int index, const base::string16& sublabel); | 127 void SetSublabel(int index, const base::string16& sublabel); |
128 | 128 |
129 // Sets the minor text for the item at |index|. | 129 // Sets the minor text for the item at |index|. |
130 void SetMinorText(int index, const base::string16& minor_text); | 130 void SetMinorText(int index, const base::string16& minor_text); |
131 | 131 |
132 // Clears all items. Note that it does not free MenuModel of submenu. | 132 // Clears all items. Note that it does not free MenuModel of submenu. |
133 void Clear(); | 133 void Clear(); |
134 | 134 |
135 // Returns the index of the item that has the given |command_id|. Returns | 135 // Returns the index of the item that has the given |command_id|. Returns |
136 // -1 if not found. | 136 // -1 if not found. |
137 int GetIndexOfCommandId(int command_id); | 137 int GetIndexOfCommandId(int command_id) const; |
138 | 138 |
139 // Overridden from MenuModel: | 139 // Overridden from MenuModel: |
140 bool HasIcons() const override; | 140 bool HasIcons() const override; |
141 int GetItemCount() const override; | 141 int GetItemCount() const override; |
142 ItemType GetTypeAt(int index) const override; | 142 ItemType GetTypeAt(int index) const override; |
143 ui::MenuSeparatorType GetSeparatorTypeAt(int index) const override; | 143 ui::MenuSeparatorType GetSeparatorTypeAt(int index) const override; |
144 int GetCommandIdAt(int index) const override; | 144 int GetCommandIdAt(int index) const override; |
145 base::string16 GetLabelAt(int index) const override; | 145 base::string16 GetLabelAt(int index) const override; |
146 base::string16 GetSublabelAt(int index) const override; | 146 base::string16 GetSublabelAt(int index) const override; |
147 base::string16 GetMinorTextAt(int index) const override; | 147 base::string16 GetMinorTextAt(int index) const override; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 MenuModelDelegate* menu_model_delegate_; | 194 MenuModelDelegate* menu_model_delegate_; |
195 | 195 |
196 base::WeakPtrFactory<SimpleMenuModel> method_factory_; | 196 base::WeakPtrFactory<SimpleMenuModel> method_factory_; |
197 | 197 |
198 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); | 198 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); |
199 }; | 199 }; |
200 | 200 |
201 } // namespace ui | 201 } // namespace ui |
202 | 202 |
203 #endif // UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ | 203 #endif // UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ |
OLD | NEW |