OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 APP_MENUS_SIMPLE_MENU_MODEL_H_ | 5 #ifndef APP_MENUS_SIMPLE_MENU_MODEL_H_ |
6 #define APP_MENUS_SIMPLE_MENU_MODEL_H_ | 6 #define APP_MENUS_SIMPLE_MENU_MODEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 virtual bool IsCommandIdChecked(int command_id) const = 0; | 27 virtual bool IsCommandIdChecked(int command_id) const = 0; |
28 virtual bool IsCommandIdEnabled(int command_id) const = 0; | 28 virtual bool IsCommandIdEnabled(int command_id) const = 0; |
29 virtual bool IsCommandIdVisible(int command_id) const; | 29 virtual bool IsCommandIdVisible(int command_id) const; |
30 | 30 |
31 // Gets the accelerator for the specified command id. Returns true if the | 31 // Gets the accelerator for the specified command id. Returns true if the |
32 // command id has a valid accelerator, false otherwise. | 32 // command id has a valid accelerator, false otherwise. |
33 virtual bool GetAcceleratorForCommandId( | 33 virtual bool GetAcceleratorForCommandId( |
34 int command_id, | 34 int command_id, |
35 menus::Accelerator* accelerator) = 0; | 35 menus::Accelerator* accelerator) = 0; |
36 | 36 |
37 // Some command ids have labels that change over time. | 37 // Some command ids have labels and icons that change over time. |
38 virtual bool IsLabelForCommandIdDynamic(int command_id) const; | 38 virtual bool IsItemForCommandIdDynamic(int command_id) const; |
39 virtual string16 GetLabelForCommandId(int command_id) const; | 39 virtual string16 GetLabelForCommandId(int command_id) const; |
| 40 // Gets the icon for the item with the specified id, returning true if there |
| 41 // is an icon, false otherwise. |
| 42 virtual bool GetIconForCommandId(int command_id, SkBitmap* icon) const; |
40 | 43 |
41 // Notifies the delegate that the item with the specified command id was | 44 // Notifies the delegate that the item with the specified command id was |
42 // visually highlighted within the menu. | 45 // visually highlighted within the menu. |
43 virtual void CommandIdHighlighted(int command_id); | 46 virtual void CommandIdHighlighted(int command_id); |
44 | 47 |
45 // Performs the action associated with the specified command id. | 48 // Performs the action associated with the specified command id. |
46 virtual void ExecuteCommand(int command_id) = 0; | 49 virtual void ExecuteCommand(int command_id) = 0; |
47 | 50 |
48 protected: | 51 protected: |
49 virtual ~Delegate() {} | 52 virtual ~Delegate() {} |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // Returns the index of the item that has the given |command_id|. Returns | 96 // Returns the index of the item that has the given |command_id|. Returns |
94 // -1 if not found. | 97 // -1 if not found. |
95 int GetIndexOfCommandId(int command_id); | 98 int GetIndexOfCommandId(int command_id); |
96 | 99 |
97 // Overridden from MenuModel: | 100 // Overridden from MenuModel: |
98 virtual bool HasIcons() const; | 101 virtual bool HasIcons() const; |
99 virtual int GetItemCount() const; | 102 virtual int GetItemCount() const; |
100 virtual ItemType GetTypeAt(int index) const; | 103 virtual ItemType GetTypeAt(int index) const; |
101 virtual int GetCommandIdAt(int index) const; | 104 virtual int GetCommandIdAt(int index) const; |
102 virtual string16 GetLabelAt(int index) const; | 105 virtual string16 GetLabelAt(int index) const; |
103 virtual bool IsLabelDynamicAt(int index) const; | 106 virtual bool IsItemDynamicAt(int index) const; |
104 virtual bool GetAcceleratorAt(int index, | 107 virtual bool GetAcceleratorAt(int index, |
105 menus::Accelerator* accelerator) const; | 108 menus::Accelerator* accelerator) const; |
106 virtual bool IsItemCheckedAt(int index) const; | 109 virtual bool IsItemCheckedAt(int index) const; |
107 virtual int GetGroupIdAt(int index) const; | 110 virtual int GetGroupIdAt(int index) const; |
108 virtual bool GetIconAt(int index, SkBitmap* icon) const; | 111 virtual bool GetIconAt(int index, SkBitmap* icon) const; |
109 virtual menus::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const; | 112 virtual menus::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const; |
110 virtual bool IsEnabledAt(int index) const; | 113 virtual bool IsEnabledAt(int index) const; |
111 virtual bool IsVisibleAt(int index) const; | 114 virtual bool IsVisibleAt(int index) const; |
112 virtual void HighlightChangedTo(int index); | 115 virtual void HighlightChangedTo(int index); |
113 virtual void ActivatedAt(int index); | 116 virtual void ActivatedAt(int index); |
(...skipping 19 matching lines...) Expand all Loading... |
133 void ValidateItem(const Item& item); | 136 void ValidateItem(const Item& item); |
134 | 137 |
135 Delegate* delegate_; | 138 Delegate* delegate_; |
136 | 139 |
137 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); | 140 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); |
138 }; | 141 }; |
139 | 142 |
140 } // namespace menus | 143 } // namespace menus |
141 | 144 |
142 #endif // APP_MENUS_SIMPLE_MENU_MODEL_H_ | 145 #endif // APP_MENUS_SIMPLE_MENU_MODEL_H_ |
OLD | NEW |