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_MENU_MODEL_H_ | 5 #ifndef APP_MENUS_MENU_MODEL_H_ |
6 #define APP_MENUS_MENU_MODEL_H_ | 6 #define APP_MENUS_MENU_MODEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
31 // The type of item. | 31 // The type of item. |
32 enum ItemType { | 32 enum ItemType { |
33 TYPE_COMMAND, | 33 TYPE_COMMAND, |
34 TYPE_CHECK, | 34 TYPE_CHECK, |
35 TYPE_RADIO, | 35 TYPE_RADIO, |
36 TYPE_SEPARATOR, | 36 TYPE_SEPARATOR, |
37 TYPE_BUTTON_ITEM, | 37 TYPE_BUTTON_ITEM, |
38 TYPE_SUBMENU | 38 TYPE_SUBMENU |
39 }; | 39 }; |
40 | 40 |
41 class Delegate { | |
42 public: | |
43 // Invoked when an icon has been loaded from history. | |
44 virtual void OnIconChanged(int model_index) {} | |
sky
2011/01/04 21:51:15
model_index -> index. No where else does the API t
| |
45 protected: | |
46 virtual ~Delegate() {} | |
47 }; | |
48 | |
41 // Returns true if any of the items within the model have icons. Not all | 49 // Returns true if any of the items within the model have icons. Not all |
42 // platforms support icons in menus natively and so this is a hint for | 50 // platforms support icons in menus natively and so this is a hint for |
43 // triggering a custom rendering mode. | 51 // triggering a custom rendering mode. |
44 virtual bool HasIcons() const = 0; | 52 virtual bool HasIcons() const = 0; |
45 | 53 |
46 // Returns the index of the first item. This is 0 for most menus except the | 54 // Returns the index of the first item. This is 0 for most menus except the |
47 // system menu on Windows. |native_menu| is the menu to locate the start index | 55 // system menu on Windows. |native_menu| is the menu to locate the start index |
48 // within. It is guaranteed to be reset to a clean default state. | 56 // within. It is guaranteed to be reset to a clean default state. |
49 // IMPORTANT: If the model implementation returns something _other_ than 0 | 57 // IMPORTANT: If the model implementation returns something _other_ than 0 |
50 // here, it must offset the values for |index| it passes to the | 58 // here, it must offset the values for |index| it passes to the |
(...skipping 29 matching lines...) Expand all Loading... | |
80 | 88 |
81 // Returns the checked state of the item at the specified index. | 89 // Returns the checked state of the item at the specified index. |
82 virtual bool IsItemCheckedAt(int index) const = 0; | 90 virtual bool IsItemCheckedAt(int index) const = 0; |
83 | 91 |
84 // Returns the id of the group of radio items that the item at the specified | 92 // Returns the id of the group of radio items that the item at the specified |
85 // index belongs to. | 93 // index belongs to. |
86 virtual int GetGroupIdAt(int index) const = 0; | 94 virtual int GetGroupIdAt(int index) const = 0; |
87 | 95 |
88 // Gets the icon for the item at the specified index, returning true if there | 96 // Gets the icon for the item at the specified index, returning true if there |
89 // is an icon, false otherwise. | 97 // is an icon, false otherwise. |
90 virtual bool GetIconAt(int index, SkBitmap* icon) const = 0; | 98 virtual bool GetIconAt(int index, SkBitmap* icon) = 0; |
91 | 99 |
92 // Returns the model for a menu item with a line of buttons at |index|. | 100 // Returns the model for a menu item with a line of buttons at |index|. |
93 virtual ButtonMenuItemModel* GetButtonMenuItemAt(int index) const = 0; | 101 virtual ButtonMenuItemModel* GetButtonMenuItemAt(int index) const = 0; |
94 | 102 |
95 // Returns the enabled state of the item at the specified index. | 103 // Returns the enabled state of the item at the specified index. |
96 virtual bool IsEnabledAt(int index) const = 0; | 104 virtual bool IsEnabledAt(int index) const = 0; |
97 | 105 |
98 // Returns true if the menu item is visible. | 106 // Returns true if the menu item is visible. |
99 virtual bool IsVisibleAt(int index) const; | 107 virtual bool IsVisibleAt(int index) const; |
100 | 108 |
101 // Returns the model for the submenu at the specified index. | 109 // Returns the model for the submenu at the specified index. |
102 virtual MenuModel* GetSubmenuModelAt(int index) const = 0; | 110 virtual MenuModel* GetSubmenuModelAt(int index) const = 0; |
103 | 111 |
104 // Called when the highlighted menu item changes to the item at the specified | 112 // Called when the highlighted menu item changes to the item at the specified |
105 // index. | 113 // index. |
106 virtual void HighlightChangedTo(int index) = 0; | 114 virtual void HighlightChangedTo(int index) = 0; |
107 | 115 |
108 // Called when the item at the specified index has been activated. | 116 // Called when the item at the specified index has been activated. |
109 virtual void ActivatedAt(int index) = 0; | 117 virtual void ActivatedAt(int index) = 0; |
110 | 118 |
111 // Called when the item has been activated with a given disposition (for the | 119 // Called when the item has been activated with a given disposition (for the |
112 // case where the activation involves a navigation). | 120 // case where the activation involves a navigation). |
113 virtual void ActivatedAtWithDisposition(int index, int disposition); | 121 virtual void ActivatedAtWithDisposition(int index, int disposition); |
114 | 122 |
115 // Called when the menu is about to be shown. | 123 // Called when the menu is about to be shown. |
116 virtual void MenuWillShow() {} | 124 virtual void MenuWillShow() {} |
117 | 125 |
126 // Set the Delegate | |
127 virtual void SetDelegate(Delegate* delegate) = 0; | |
128 | |
118 // Retrieves the model and index that contains a specific command id. Returns | 129 // Retrieves the model and index that contains a specific command id. Returns |
119 // true if an item with the specified command id is found. |model| is inout, | 130 // true if an item with the specified command id is found. |model| is inout, |
120 // and specifies the model to start searching from. | 131 // and specifies the model to start searching from. |
121 static bool GetModelAndIndexForCommandId(int command_id, MenuModel** model, | 132 static bool GetModelAndIndexForCommandId(int command_id, MenuModel** model, |
122 int* index); | 133 int* index); |
123 }; | 134 }; |
124 | 135 |
125 } // namespace | 136 } // namespace |
126 | 137 |
127 #endif // APP_MENUS_MENU_MODEL_H_ | 138 #endif // APP_MENUS_MENU_MODEL_H_ |
OLD | NEW |