summaryrefslogtreecommitdiffstats
path: root/chrome/views/menu.h
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-11 17:46:45 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-11 17:46:45 +0000
commitd4f2e68c7e85383674adcfb105741c664c0b4128 (patch)
tree1e9e9053897f2522d68d36710210bf05c0a4cdba /chrome/views/menu.h
parent00d8cf0a2a9435c64e2421d761cec2ff32baefc5 (diff)
downloadchromium_src-d4f2e68c7e85383674adcfb105741c664c0b4128.zip
chromium_src-d4f2e68c7e85383674adcfb105741c664c0b4128.tar.gz
chromium_src-d4f2e68c7e85383674adcfb105741c664c0b4128.tar.bz2
Allow the ChromeViews' Menu to wrap the Windows system menu and insert items into it.
Basically adds an alternate ctor for Menu that takes an existing HMENU, and then provides variants of most of the APIs that allow insertion of an item at a specified index. I will use this in the new frames to add the task manager and app frame menu items. B=1293995 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@661 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views/menu.h')
-rw-r--r--chrome/views/menu.h58
1 files changed, 35 insertions, 23 deletions
diff --git a/chrome/views/menu.h b/chrome/views/menu.h
index 8b9a5ff..3894a5b 100644
--- a/chrome/views/menu.h
+++ b/chrome/views/menu.h
@@ -233,6 +233,11 @@ class Menu {
// to. Not actually used for anything but must not be
// NULL.
Menu(Delegate* delegate, AnchorPoint anchor, HWND owner);
+ // Alternatively, a Menu object can be constructed wrapping an existing
+ // HMENU. This can be used to use the convenience methods to insert
+ // menu items and manage label string ownership. However this kind of
+ // Menu object cannot use the delegate.
+ explicit Menu(HMENU hmenu);
virtual ~Menu();
// Adds an item to this menu.
@@ -245,17 +250,17 @@ class Menu {
// type The type of item.
void AppendMenuItem(int item_id,
const std::wstring& label,
- MenuItemType type) {
- if (type == SEPARATOR)
- AppendSeparator();
- else
- AppendMenuItemInternal(item_id, label, SkBitmap(), NULL, type);
- }
+ MenuItemType type);
+ void AddMenuItem(int index,
+ int item_id,
+ const std::wstring& label,
+ MenuItemType type);
// Append a submenu to this menu.
// The returned pointer is owned by this menu.
Menu* AppendSubMenu(int item_id,
const std::wstring& label);
+ Menu* AddSubMenu(int index, int item_id, const std::wstring& label);
// Append a submenu with an icon to this menu
// The returned pointer is owned by this menu.
@@ -264,33 +269,39 @@ class Menu {
Menu* AppendSubMenuWithIcon(int item_id,
const std::wstring& label,
const SkBitmap& icon);
+ Menu* AddSubMenuWithIcon(int index,
+ int item_id,
+ const std::wstring& label,
+ const SkBitmap& icon);
// This is a convenience for standard text label menu items where the label
// is provided with this call.
- void AppendMenuItemWithLabel(int item_id,
- const std::wstring& label) {
- AppendMenuItem(item_id, label, Menu::NORMAL);
- }
+ void AppendMenuItemWithLabel(int item_id, const std::wstring& label);
+ void AddMenuItemWithLabel(int index, int item_id, const std::wstring& label);
// This is a convenience for text label menu items where the label is
// provided by the delegate.
- void AppendDelegateMenuItem(int item_id) {
- AppendMenuItem(item_id, std::wstring(), Menu::NORMAL);
- }
+ void AppendDelegateMenuItem(int item_id);
+ void AddDelegateMenuItem(int index, int item_id);
// Adds a separator to this menu
void AppendSeparator();
+ void AddSeparator(int index);
// 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.
void AppendMenuItemWithIcon(int item_id,
const std::wstring& label,
- const SkBitmap& icon) {
- if (!owner_draw_)
- owner_draw_ = true;
- AppendMenuItemInternal(item_id, label, icon, NULL, Menu::NORMAL);
- }
+ const SkBitmap& icon);
+ void AddMenuItemWithIcon(int index,
+ int item_id,
+ const std::wstring& label,
+ const SkBitmap& icon);
+
+ // Enables or disables the item with the specified id.
+ void EnableMenuItemByID(int item_id, bool enabled);
+ void EnableMenuItemAt(int index, bool enabled);
// Sets an icon for an item with a given item_id. Calling this function
// also forces the Menu class to draw the menu, instead of relying on Windows.
@@ -312,11 +323,12 @@ class Menu {
private:
explicit Menu(Menu* parent);
- void AppendMenuItemInternal(int item_id,
- const std::wstring& label,
- const SkBitmap& icon,
- HMENU submenu,
- MenuItemType type);
+ void AddMenuItemInternal(int index,
+ int item_id,
+ const std::wstring& label,
+ const SkBitmap& icon,
+ HMENU submenu,
+ MenuItemType type);
// Sets menu information before displaying, including sub-menus.
void SetMenuInfo();