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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 virtual bool HasIcons() const; | 101 virtual bool HasIcons() const; |
102 virtual int GetItemCount() const; | 102 virtual int GetItemCount() const; |
103 virtual ItemType GetTypeAt(int index) const; | 103 virtual ItemType GetTypeAt(int index) const; |
104 virtual int GetCommandIdAt(int index) const; | 104 virtual int GetCommandIdAt(int index) const; |
105 virtual string16 GetLabelAt(int index) const; | 105 virtual string16 GetLabelAt(int index) const; |
106 virtual bool IsItemDynamicAt(int index) const; | 106 virtual bool IsItemDynamicAt(int index) const; |
107 virtual bool GetAcceleratorAt(int index, | 107 virtual bool GetAcceleratorAt(int index, |
108 menus::Accelerator* accelerator) const; | 108 menus::Accelerator* accelerator) const; |
109 virtual bool IsItemCheckedAt(int index) const; | 109 virtual bool IsItemCheckedAt(int index) const; |
110 virtual int GetGroupIdAt(int index) const; | 110 virtual int GetGroupIdAt(int index) const; |
111 virtual bool GetIconAt(int index, SkBitmap* icon) const; | 111 virtual bool GetIconAt(int index, SkBitmap* icon); |
112 virtual menus::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const; | 112 virtual menus::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const; |
113 virtual bool IsEnabledAt(int index) const; | 113 virtual bool IsEnabledAt(int index) const; |
114 virtual bool IsVisibleAt(int index) const; | 114 virtual bool IsVisibleAt(int index) const; |
115 virtual void HighlightChangedTo(int index); | 115 virtual void HighlightChangedTo(int index); |
116 virtual void ActivatedAt(int index); | 116 virtual void ActivatedAt(int index); |
117 virtual MenuModel* GetSubmenuModelAt(int index) const; | 117 virtual MenuModel* GetSubmenuModelAt(int index) const; |
| 118 virtual void SetDelegate(menus::MenuModel::Delegate* delegate); |
118 | 119 |
119 protected: | 120 protected: |
120 // Some variants of this model (SystemMenuModel) relies on items to be | 121 // Some variants of this model (SystemMenuModel) relies on items to be |
121 // inserted backwards. This is counter-intuitive for the API, so rather than | 122 // inserted backwards. This is counter-intuitive for the API, so rather than |
122 // forcing customers to insert things backwards, we return the indices | 123 // forcing customers to insert things backwards, we return the indices |
123 // backwards instead. That's what this method is for. By default, it just | 124 // backwards instead. That's what this method is for. By default, it just |
124 // returns what it's passed. | 125 // returns what it's passed. |
125 virtual int FlipIndex(int index) const; | 126 virtual int FlipIndex(int index) const; |
126 | 127 |
127 Delegate* delegate() { return delegate_; } | 128 Delegate* delegate() { return delegate_; } |
128 | 129 |
129 private: | 130 private: |
130 struct Item; | 131 struct Item; |
131 std::vector<Item> items_; | 132 std::vector<Item> items_; |
132 | 133 |
133 // Functions for inserting items into |items_|. | 134 // Functions for inserting items into |items_|. |
134 void AppendItem(const Item& item); | 135 void AppendItem(const Item& item); |
135 void InsertItemAtIndex(const Item& item, int index); | 136 void InsertItemAtIndex(const Item& item, int index); |
136 void ValidateItem(const Item& item); | 137 void ValidateItem(const Item& item); |
137 | 138 |
138 Delegate* delegate_; | 139 Delegate* delegate_; |
139 | 140 |
140 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); | 141 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); |
141 }; | 142 }; |
142 | 143 |
143 } // namespace menus | 144 } // namespace menus |
144 | 145 |
145 #endif // APP_MENUS_SIMPLE_MENU_MODEL_H_ | 146 #endif // APP_MENUS_SIMPLE_MENU_MODEL_H_ |
OLD | NEW |