| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "views/controls/menu/menu_item_view.h" | 5 #include "views/controls/menu/menu_item_view.h" |
| 6 | 6 |
| 7 #include <uxtheme.h> | 7 #include <uxtheme.h> |
| 8 #include <Vssym32.h> | 8 #include <Vssym32.h> |
| 9 | 9 |
| 10 #include "grit/ui_strings.h" | 10 #include "grit/ui_strings.h" |
| 11 #include "ui/gfx/canvas_skia.h" | 11 #include "ui/gfx/canvas_skia.h" |
| 12 #include "ui/gfx/native_theme_win.h" | 12 #include "ui/gfx/native_theme_win.h" |
| 13 #include "views/controls/menu/menu_config.h" | 13 #include "views/controls/menu/menu_config.h" |
| 14 #include "views/controls/menu/submenu_view.h" | 14 #include "views/controls/menu/submenu_view.h" |
| 15 | 15 |
| 16 using gfx::NativeTheme; | 16 using gfx::NativeTheme; |
| 17 | 17 |
| 18 namespace views { | 18 namespace views { |
| 19 | 19 |
| 20 gfx::Size MenuItemView::CalculatePreferredSize() { | 20 gfx::Size MenuItemView::CalculatePreferredSize() { |
| 21 gfx::Size child_size = GetChildPreferredSize(); |
| 21 const gfx::Font& font = GetFont(); | 22 const gfx::Font& font = GetFont(); |
| 22 return gfx::Size( | 23 return gfx::Size( |
| 23 font.GetStringWidth(title_) + label_start_ + item_right_margin_ + | 24 font.GetStringWidth(title_) + label_start_ + item_right_margin_ + |
| 24 GetChildPreferredWidth(), | 25 child_size.width(), |
| 25 font.GetHeight() + GetBottomMargin() + GetTopMargin()); | 26 std::max(child_size.height(), font.GetHeight()) + GetBottomMargin() + |
| 27 GetTopMargin()); |
| 26 } | 28 } |
| 27 | 29 |
| 28 void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { | 30 void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { |
| 29 const MenuConfig& config = MenuConfig::instance(); | 31 const MenuConfig& config = MenuConfig::instance(); |
| 30 bool render_selection = | 32 bool render_selection = |
| 31 (mode == PB_NORMAL && IsSelected() && | 33 (mode == PB_NORMAL && IsSelected() && |
| 32 parent_menu_item_->GetSubmenu()->GetShowSelection(this) && | 34 parent_menu_item_->GetSubmenu()->GetShowSelection(this) && |
| 33 !has_children()); | 35 !has_children()); |
| 34 int default_sys_color; | 36 int default_sys_color; |
| 35 int state; | 37 int state; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 NativeTheme::kMenuCheckBackground, state, bg_bounds, extra); | 172 NativeTheme::kMenuCheckBackground, state, bg_bounds, extra); |
| 171 | 173 |
| 172 // And the check. | 174 // And the check. |
| 173 gfx::Rect icon_bounds(icon_x / 2, icon_y, icon_width, icon_height); | 175 gfx::Rect icon_bounds(icon_x / 2, icon_y, icon_width, icon_height); |
| 174 AdjustBoundsForRTLUI(&icon_bounds); | 176 AdjustBoundsForRTLUI(&icon_bounds); |
| 175 NativeTheme::instance()->Paint(canvas->AsCanvasSkia(), | 177 NativeTheme::instance()->Paint(canvas->AsCanvasSkia(), |
| 176 NativeTheme::kMenuCheck, state, bg_bounds, extra); | 178 NativeTheme::kMenuCheck, state, bg_bounds, extra); |
| 177 } | 179 } |
| 178 | 180 |
| 179 } // namespace views | 181 } // namespace views |
| OLD | NEW |