Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_MENU_MODEL_H_ | 5 #ifndef UI_BASE_MODELS_MENU_MODEL_H_ |
| 6 #define UI_BASE_MODELS_MENU_MODEL_H_ | 6 #define UI_BASE_MODELS_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 18 matching lines...) Expand all Loading... | |
| 29 TYPE_COMMAND, | 29 TYPE_COMMAND, |
| 30 TYPE_CHECK, | 30 TYPE_CHECK, |
| 31 TYPE_RADIO, | 31 TYPE_RADIO, |
| 32 TYPE_SEPARATOR, | 32 TYPE_SEPARATOR, |
| 33 TYPE_BUTTON_ITEM, | 33 TYPE_BUTTON_ITEM, |
| 34 TYPE_SUBMENU | 34 TYPE_SUBMENU |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 virtual ~MenuModel() {} | 37 virtual ~MenuModel() {} |
| 38 | 38 |
| 39 class Delegate { | |
|
sky
2011/02/22 18:28:28
Move this into its own file and call it MenuModelD
dill
2011/02/24 15:00:28
This should go in ui\base\models, correct?
On 201
sky
2011/02/24 15:12:50
yes.
| |
| 40 public: | |
| 41 // Invoked when an icon has been loaded from history. | |
| 42 virtual void OnIconChanged(int index) {} | |
| 43 protected: | |
| 44 virtual ~Delegate() {} | |
| 45 }; | |
| 46 | |
| 39 // Returns true if any of the items within the model have icons. Not all | 47 // Returns true if any of the items within the model have icons. Not all |
| 40 // platforms support icons in menus natively and so this is a hint for | 48 // platforms support icons in menus natively and so this is a hint for |
| 41 // triggering a custom rendering mode. | 49 // triggering a custom rendering mode. |
| 42 virtual bool HasIcons() const = 0; | 50 virtual bool HasIcons() const = 0; |
| 43 | 51 |
| 44 // Returns the index of the first item. This is 0 for most menus except the | 52 // Returns the index of the first item. This is 0 for most menus except the |
| 45 // system menu on Windows. |native_menu| is the menu to locate the start index | 53 // system menu on Windows. |native_menu| is the menu to locate the start index |
| 46 // within. It is guaranteed to be reset to a clean default state. | 54 // within. It is guaranteed to be reset to a clean default state. |
| 47 // IMPORTANT: If the model implementation returns something _other_ than 0 | 55 // IMPORTANT: If the model implementation returns something _other_ than 0 |
| 48 // here, it must offset the values for |index| it passes to the | 56 // here, it must offset the values for |index| it passes to the |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 78 | 86 |
| 79 // Returns the checked state of the item at the specified index. | 87 // Returns the checked state of the item at the specified index. |
| 80 virtual bool IsItemCheckedAt(int index) const = 0; | 88 virtual bool IsItemCheckedAt(int index) const = 0; |
| 81 | 89 |
| 82 // Returns the id of the group of radio items that the item at the specified | 90 // Returns the id of the group of radio items that the item at the specified |
| 83 // index belongs to. | 91 // index belongs to. |
| 84 virtual int GetGroupIdAt(int index) const = 0; | 92 virtual int GetGroupIdAt(int index) const = 0; |
| 85 | 93 |
| 86 // Gets the icon for the item at the specified index, returning true if there | 94 // Gets the icon for the item at the specified index, returning true if there |
| 87 // is an icon, false otherwise. | 95 // is an icon, false otherwise. |
| 88 virtual bool GetIconAt(int index, SkBitmap* icon) const = 0; | 96 virtual bool GetIconAt(int index, SkBitmap* icon) = 0; |
| 89 | 97 |
| 90 // Returns the model for a menu item with a line of buttons at |index|. | 98 // Returns the model for a menu item with a line of buttons at |index|. |
| 91 virtual ButtonMenuItemModel* GetButtonMenuItemAt(int index) const = 0; | 99 virtual ButtonMenuItemModel* GetButtonMenuItemAt(int index) const = 0; |
| 92 | 100 |
| 93 // Returns the enabled state of the item at the specified index. | 101 // Returns the enabled state of the item at the specified index. |
| 94 virtual bool IsEnabledAt(int index) const = 0; | 102 virtual bool IsEnabledAt(int index) const = 0; |
| 95 | 103 |
| 96 // Returns true if the menu item is visible. | 104 // Returns true if the menu item is visible. |
| 97 virtual bool IsVisibleAt(int index) const; | 105 virtual bool IsVisibleAt(int index) const; |
| 98 | 106 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 109 // Called when the item has been activated with a given disposition (for the | 117 // Called when the item has been activated with a given disposition (for the |
| 110 // case where the activation involves a navigation). | 118 // case where the activation involves a navigation). |
| 111 virtual void ActivatedAtWithDisposition(int index, int disposition); | 119 virtual void ActivatedAtWithDisposition(int index, int disposition); |
| 112 | 120 |
| 113 // Called when the menu is about to be shown. | 121 // Called when the menu is about to be shown. |
| 114 virtual void MenuWillShow() {} | 122 virtual void MenuWillShow() {} |
| 115 | 123 |
| 116 // Called when the menu has been closed. | 124 // Called when the menu has been closed. |
| 117 virtual void MenuClosed() {} | 125 virtual void MenuClosed() {} |
| 118 | 126 |
| 127 // Set the Delegate | |
|
sky
2011/02/22 18:28:28
End with period, and mention not-owned.
| |
| 128 virtual void SetDelegate(Delegate* delegate) = 0; | |
| 129 | |
| 119 // Retrieves the model and index that contains a specific command id. Returns | 130 // Retrieves the model and index that contains a specific command id. Returns |
| 120 // true if an item with the specified command id is found. |model| is inout, | 131 // true if an item with the specified command id is found. |model| is inout, |
| 121 // and specifies the model to start searching from. | 132 // and specifies the model to start searching from. |
| 122 static bool GetModelAndIndexForCommandId(int command_id, MenuModel** model, | 133 static bool GetModelAndIndexForCommandId(int command_id, MenuModel** model, |
| 123 int* index); | 134 int* index); |
| 124 }; | 135 }; |
| 125 | 136 |
| 126 } // namespace ui | 137 } // namespace ui |
| 127 | 138 |
| 128 #endif // UI_BASE_MODELS_MENU_MODEL_H_ | 139 #endif // UI_BASE_MODELS_MENU_MODEL_H_ |
| OLD | NEW |