Index: views/controls/menu/menu_item_view.h |
diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h |
index cc0a91f9890adefde878343ec38328f1ec6f594b..ddbed74d3f15438ba3eb9d6a7af3ab38b3dbef03 100644 |
--- a/views/controls/menu/menu_item_view.h |
+++ b/views/controls/menu/menu_item_view.h |
@@ -40,6 +40,50 @@ class SubmenuView; |
struct MenuConfig; |
+// MenuItemInterface ----------------------------------------------------------- |
+ |
+// Interface class for the menu items. |
+class MenuItemInterface { |
+ public: |
rhashimoto
2011/07/29 17:17:13
virtual destructor?
Nikita (slow)
2011/08/05 23:40:26
Obsolete, using ui::MenuModel now.
|
+ // Append a sub-menu to this menu. |
+ // The returned pointer is owned by this menu. |
+ virtual MenuItemInterface* AppendSubMenu(int item_id, |
+ const std::wstring& label) = 0; |
rhashimoto
2011/07/29 17:17:13
nit: wrapped indentation needs to be adjusted in t
Nikita (slow)
2011/08/05 23:40:26
Obsolete, using ui::MenuModel now.
|
+ |
+ // Append a sub-menu with an icon to this menu. |
+ // The returned pointer is owned by this menu. |
+ virtual MenuItemInterface* AppendSubMenuWithIcon(int item_id, |
+ const std::wstring& label, |
+ const SkBitmap& icon) = 0; |
+ |
+ // This is a convenience for standard text label menu items where the label |
+ // is provided with this call. |
+ virtual MenuItemInterface* AppendMenuItemWithLabel(int item_id, |
+ const std::wstring& label) = 0; |
+ |
+ |
+ // Appends a menu item with an icon. This is for the menu item which |
+ // needs an icon. Calling this function forces the Menu class to draw |
+ // the menu, instead of relying on Windows. |
+ virtual MenuItemInterface* AppendMenuItemWithIcon(int item_id, |
+ const std::wstring& label, |
+ const SkBitmap& icon) = 0; |
+ |
+ // Adds a separator to this menu |
+ virtual void AppendSeparator() = 0; |
+ |
+ // Clears the sub-menu. |
+ virtual void ClearSubmenu() = 0; |
+ |
+ // Called when update is done. |
+ virtual void ChildrenChanged() = 0; |
+ |
+ // Hides and cancels the menu. This does nothing if the menu is not open. |
+ virtual void Cancel() = 0; |
+ |
+ virtual void set_margins(int top_margin, int bottom_margin) = 0; |
+}; |
+ |
// MenuItemView -------------------------------------------------------------- |
// MenuItemView represents a single menu item with a label and optional icon. |
@@ -66,7 +110,7 @@ struct MenuConfig; |
// and does NOT block the caller. Instead the delegate is notified when the |
// menu closes via the DropMenuClosed method. |
-class VIEWS_API MenuItemView : public View { |
+class VIEWS_API MenuItemView : public MenuItemInterface, public View { |
public: |
friend class MenuController; |
@@ -145,7 +189,7 @@ class VIEWS_API MenuItemView : public View { |
AnchorPosition anchor); |
// Hides and cancels the menu. This does nothing if the menu is not open. |
- void Cancel(); |
+ virtual void Cancel(); |
rhashimoto
2011/07/29 17:17:13
group overridden methods, add OVERRIDE
Nikita (slow)
2011/08/05 23:40:26
Obsolete, using ui::MenuModel now.
|
// Add an item to the menu at a specified index. ChildrenChanged() should |
// called after adding menu items if the menu may be active. |
@@ -176,14 +220,14 @@ class VIEWS_API MenuItemView : public View { |
// Append a submenu to this menu. |
// The returned pointer is owned by this menu. |
- MenuItemView* AppendSubMenu(int item_id, |
+ virtual MenuItemInterface* AppendSubMenu(int item_id, |
const std::wstring& label) { |
return AppendMenuItemImpl(item_id, label, SkBitmap(), SUBMENU); |
} |
// Append a submenu with an icon to this menu. |
// The returned pointer is owned by this menu. |
- MenuItemView* AppendSubMenuWithIcon(int item_id, |
+ virtual MenuItemInterface* AppendSubMenuWithIcon(int item_id, |
const std::wstring& label, |
const SkBitmap& icon) { |
return AppendMenuItemImpl(item_id, label, icon, SUBMENU); |
@@ -191,7 +235,7 @@ class VIEWS_API MenuItemView : public View { |
// This is a convenience for standard text label menu items where the label |
// is provided with this call. |
- MenuItemView* AppendMenuItemWithLabel(int item_id, |
+ virtual MenuItemInterface* AppendMenuItemWithLabel(int item_id, |
const std::wstring& label) { |
return AppendMenuItem(item_id, label, NORMAL); |
} |
@@ -203,14 +247,14 @@ class VIEWS_API MenuItemView : public View { |
} |
// Adds a separator to this menu |
- void AppendSeparator() { |
+ virtual void AppendSeparator() { |
AppendMenuItemImpl(0, std::wstring(), SkBitmap(), SEPARATOR); |
} |
// Appends a menu item with an icon. This is for the menu item which |
// needs an icon. Calling this function forces the Menu class to draw |
// the menu, instead of relying on Windows. |
- MenuItemView* AppendMenuItemWithIcon(int item_id, |
+ virtual MenuItemInterface* AppendMenuItemWithIcon(int item_id, |
const std::wstring& label, |
const SkBitmap& icon) { |
return AppendMenuItemImpl(item_id, label, icon, NORMAL); |
@@ -236,6 +280,8 @@ class VIEWS_API MenuItemView : public View { |
// Returns true if this menu item has a submenu. |
virtual bool HasSubmenu() const; |
+ virtual void ClearSubmenu(); |
+ |
// Returns the view containing child menu items. |
virtual SubmenuView* GetSubmenu() const; |
@@ -307,7 +353,7 @@ class VIEWS_API MenuItemView : public View { |
// Invoke if you remove/add children to the menu while it's showing. This |
// recalculates the bounds. |
- void ChildrenChanged(); |
+ virtual void ChildrenChanged(); |
// Sizes any child views. |
virtual void Layout(); |
@@ -322,7 +368,7 @@ class VIEWS_API MenuItemView : public View { |
// Set top and bottom margins in pixels. If no margin is set or a |
// negative margin is specified then MenuConfig values are used. |
- void set_margins(int top_margin, int bottom_margin) { |
+ virtual void set_margins(int top_margin, int bottom_margin) { |
top_margin_ = top_margin; |
bottom_margin_ = bottom_margin; |
} |