Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: views/controls/menu/menu_item_view.h

Issue 6931039: Add MenuItemView API to add and remove items at a particular index. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed another spurious OVERRIDE. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 980f2d6af353fe11dbf13d0429321731e51b1bf5..45fb60b03803ec3a11d6d4aa8cd40063f66ae3dd 100644
--- a/views/controls/menu/menu_item_view.h
+++ b/views/controls/menu/menu_item_view.h
@@ -7,6 +7,7 @@
#pragma once
#include <string>
+#include <vector>
#if defined(OS_WIN)
#include <windows.h>
@@ -127,7 +128,19 @@ class MenuItemView : public View {
// Hides and cancels the menu. This does nothing if the menu is not open.
void Cancel();
- // Adds an item to this menu.
+ // Add an item to the menu at a specified index.
+ MenuItemView* AddMenuItemAt(int index,
+ int item_id,
+ const std::wstring& label,
+ const SkBitmap& icon,
+ Type type);
+
+ // Remove an item from the menu at a specified index. Either
+ // ChildrenChanged() or DeleteRemovedItems() should be called after
sky 2011/05/06 16:17:00 DeleteRemovedItems isn't public, so folks have to
+ // removing menu items.
+ void RemoveMenuItemAt(int index);
+
+ // Appends an item to this menu.
// item_id The id of the item, used to identify it in delegate callbacks
// or (if delegate is NULL) to identify the command associated
// with this item with the controller specified in the ctor. Note
@@ -361,6 +374,9 @@ class MenuItemView : public View {
// Calculates the preferred size.
gfx::Size CalculatePreferredSize();
+ // Delete orphaned items removed from the menu.
+ void DeleteRemovedItems();
+
// The delegate. This is only valid for the root menu item. You shouldn't
// use this directly, instead use GetDelegate() which walks the tree as
// as necessary.
@@ -423,6 +439,9 @@ class MenuItemView : public View {
// GetPreferredSize.
gfx::Size pref_size_;
+ // Removed items to be deleted in ChildrenChanged().
+ std::vector<View*> removed_items_;
+
DISALLOW_COPY_AND_ASSIGN(MenuItemView);
};

Powered by Google App Engine
This is Rietveld 408576698