summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-17 00:58:20 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-17 00:58:20 +0000
commit70a3eb47feb92a984347f68e80c4a8a50e599e74 (patch)
tree829487aa5859a6a96e01aaeafb4b6550ccef9332 /views
parent3fb19f5c0515f39de06928cd68f561e85b006967 (diff)
downloadchromium_src-70a3eb47feb92a984347f68e80c4a8a50e599e74.zip
chromium_src-70a3eb47feb92a984347f68e80c4a8a50e599e74.tar.gz
chromium_src-70a3eb47feb92a984347f68e80c4a8a50e599e74.tar.bz2
Support tooltips in MenuItemView. Use that tooltip support in the
Browser Action Container overflow menu. BUG=35345 TEST=None Review URL: http://codereview.chromium.org/611009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39174 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/menu/menu_item_view.cc13
-rw-r--r--views/controls/menu/menu_item_view.h11
2 files changed, 22 insertions, 2 deletions
diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc
index 698502b..20ee28e 100644
--- a/views/controls/menu/menu_item_view.cc
+++ b/views/controls/menu/menu_item_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -73,6 +73,11 @@ MenuItemView::~MenuItemView() {
delete submenu_;
}
+bool MenuItemView::GetTooltipText(int x, int y, std::wstring* tooltip) {
+ *tooltip = tooltip_;
+ return !tooltip_.empty();
+}
+
void MenuItemView::RunMenuAt(gfx::NativeWindow parent,
MenuButton* button,
const gfx::Rect& bounds,
@@ -164,6 +169,12 @@ void MenuItemView::SetSelected(bool selected) {
SchedulePaint();
}
+void MenuItemView::SetTooltip(const std::wstring& tooltip, int item_id) {
+ MenuItemView* item = GetMenuItemByID(item_id);
+ DCHECK(item);
+ item->tooltip_ = tooltip;
+}
+
void MenuItemView::SetIcon(const SkBitmap& icon, int item_id) {
MenuItemView* item = GetMenuItemByID(item_id);
DCHECK(item);
diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h
index 936ff1e..6caa09a 100644
--- a/views/controls/menu/menu_item_view.h
+++ b/views/controls/menu/menu_item_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -71,6 +71,9 @@ class MenuItemView : public View {
virtual ~MenuItemView();
+ // Overridden from View:
+ virtual bool GetTooltipText(int x, int y, std::wstring* tooltip);
+
// Returns the preferred height of menu items. This is only valid when the
// menu is about to be shown.
static int pref_menu_height() { return pref_menu_height_; }
@@ -178,6 +181,9 @@ class MenuItemView : public View {
// Returns true if the item is selected.
bool IsSelected() const { return selected_; }
+ // Sets the |tooltip| for a menu item view with |item_id| identifier.
+ void SetTooltip(const std::wstring& tooltip, int item_id);
+
// Sets the icon for the descendant identified by item_id.
void SetIcon(const SkBitmap& icon, int item_id);
@@ -321,6 +327,9 @@ class MenuItemView : public View {
bool has_icons_;
+ // The tooltip to show on hover for this menu item.
+ std::wstring tooltip_;
+
// X-coordinate of where the label starts.
static int label_start_;