Index: views/controls/menu/menu_item_view.cc |
diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc |
index 3ff7f2b7e2eed01ff1a6d2d855b76e302b47aa88..d8a5f594df9808c83b96ee0fc037d62e366cc14f 100644 |
--- a/views/controls/menu/menu_item_view.cc |
+++ b/views/controls/menu/menu_item_view.cc |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2011 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. |
@@ -456,7 +456,7 @@ void MenuItemView::Layout() { |
int MenuItemView::GetAcceleratorTextWidth() { |
string16 text = GetAcceleratorText(); |
- return text.empty() ? 0 : MenuConfig::instance().font.GetStringWidth(text); |
+ return text.empty() ? 0 : GetFont()->GetStringWidth(text); |
} |
MenuItemView::MenuItemView(MenuItemView* parent, |
@@ -584,6 +584,19 @@ int MenuItemView::GetDrawStringFlags() { |
return flags; |
} |
+const gfx::Font* MenuItemView::GetFont() { |
+ // Check for item-specific font. |
+ const MenuDelegate* delegate = GetDelegate(); |
+ if (delegate) |
+ { |
oshima
2011/04/14 17:27:31
move { to previous line
rhashimoto
2011/04/14 18:27:04
Done.
|
+ const gfx::Font* font = delegate->GetLabelFont(GetCommand()); |
+ if (font) |
+ return font; |
+ } |
+ |
+ return &MenuConfig::instance().font; |
+} |
+ |
void MenuItemView::AddEmptyMenus() { |
DCHECK(HasSubmenu()); |
if (!submenu_->has_children()) { |
@@ -623,7 +636,7 @@ void MenuItemView::PaintAccelerator(gfx::Canvas* canvas) { |
if (accel_text.empty()) |
return; |
- const gfx::Font& font = MenuConfig::instance().font; |
+ const gfx::Font* font = GetFont(); |
int available_height = height() - GetTopMargin() - GetBottomMargin(); |
int max_accel_width = |
parent_menu_item_->GetSubmenu()->max_accelerator_width(); |
@@ -638,7 +651,7 @@ void MenuItemView::PaintAccelerator(gfx::Canvas* canvas) { |
else |
flags |= gfx::Canvas::TEXT_ALIGN_RIGHT; |
canvas->DrawStringInt( |
- accel_text, font, TextButton::kDisabledColor, |
+ accel_text, *font, TextButton::kDisabledColor, |
accel_bounds.x(), accel_bounds.y(), accel_bounds.width(), |
accel_bounds.height(), flags); |
} |