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

Side by Side Diff: views/controls/menu/menu_item_view_win.cc

Issue 6811025: Change status button menu implementation from Menu2 to MenuItemView. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Move NetworkMenuModel declaration into .cc. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/controls/menu/menu_item_view_gtk.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/app_strings.h" 10 #include "grit/app_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 const gfx::Font& font = MenuConfig::instance().font; 21 const gfx::Font& font = GetFont();
22 return gfx::Size( 22 return gfx::Size(
23 font.GetStringWidth(title_) + label_start_ + item_right_margin_ + 23 font.GetStringWidth(title_) + label_start_ + item_right_margin_ +
24 GetChildPreferredWidth(), 24 GetChildPreferredWidth(),
25 font.GetHeight() + GetBottomMargin() + GetTopMargin()); 25 font.GetHeight() + GetBottomMargin() + GetTopMargin());
26 } 26 }
27 27
28 void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { 28 void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
29 const MenuConfig& config = MenuConfig::instance(); 29 const MenuConfig& config = MenuConfig::instance();
30 bool render_selection = 30 bool render_selection =
31 (mode == PB_NORMAL && IsSelected() && 31 (mode == PB_NORMAL && IsSelected() &&
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 76
77 // Render the foreground. 77 // Render the foreground.
78 // Menu color is specific to Vista, fallback to classic colors if can't 78 // Menu color is specific to Vista, fallback to classic colors if can't
79 // get color. 79 // get color.
80 int default_sys_color = render_selection ? COLOR_HIGHLIGHTTEXT : 80 int default_sys_color = render_selection ? COLOR_HIGHLIGHTTEXT :
81 (IsEnabled() ? COLOR_MENUTEXT : COLOR_GRAYTEXT); 81 (IsEnabled() ? COLOR_MENUTEXT : COLOR_GRAYTEXT);
82 SkColor fg_color = gfx::NativeThemeWin::instance()->GetThemeColorWithDefault( 82 SkColor fg_color = gfx::NativeThemeWin::instance()->GetThemeColorWithDefault(
83 gfx::NativeThemeWin::MENU, MENU_POPUPITEM, state, TMT_TEXTCOLOR, 83 gfx::NativeThemeWin::MENU, MENU_POPUPITEM, state, TMT_TEXTCOLOR,
84 default_sys_color); 84 default_sys_color);
85 const gfx::Font& font = MenuConfig::instance().font; 85 const gfx::Font& font = GetFont();
86 int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width(); 86 int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width();
87 int width = this->width() - item_right_margin_ - label_start_ - accel_width; 87 int width = this->width() - item_right_margin_ - label_start_ - accel_width;
88 gfx::Rect text_bounds(label_start_, top_margin, width, font.GetHeight()); 88 gfx::Rect text_bounds(label_start_, top_margin, width, font.GetHeight());
89 text_bounds.set_x(GetMirroredXForRect(text_bounds)); 89 text_bounds.set_x(GetMirroredXForRect(text_bounds));
90 if (mode == PB_FOR_DRAG) { 90 if (mode == PB_FOR_DRAG) {
91 // With different themes, it's difficult to tell what the correct 91 // With different themes, it's difficult to tell what the correct
92 // foreground and background colors are for the text to draw the correct 92 // foreground and background colors are for the text to draw the correct
93 // halo. Instead, just draw black on white, which will look good in most 93 // halo. Instead, just draw black on white, which will look good in most
94 // cases. 94 // cases.
95 canvas->AsCanvasSkia()->DrawStringWithHalo( 95 canvas->AsCanvasSkia()->DrawStringWithHalo(
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 NativeTheme::kMenuCheckBackground, state, bg_bounds, extra); 159 NativeTheme::kMenuCheckBackground, state, bg_bounds, extra);
160 160
161 // And the check. 161 // And the check.
162 gfx::Rect icon_bounds(icon_x / 2, icon_y, icon_width, icon_height); 162 gfx::Rect icon_bounds(icon_x / 2, icon_y, icon_width, icon_height);
163 AdjustBoundsForRTLUI(&icon_bounds); 163 AdjustBoundsForRTLUI(&icon_bounds);
164 NativeTheme::instance()->Paint(canvas->AsCanvasSkia(), 164 NativeTheme::instance()->Paint(canvas->AsCanvasSkia(),
165 NativeTheme::kMenuCheck, state, bg_bounds, extra); 165 NativeTheme::kMenuCheck, state, bg_bounds, extra);
166 } 166 }
167 167
168 } // namespace views 168 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/menu/menu_item_view_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698