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

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

Issue 11026076: Added MenuConfig setter to MenuItemView, updated rest of the code to use set MenuConfig if it avail… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/controls/menu/menu_item_view.h" 5 #include "ui/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/base/native_theme/native_theme_win.h" 11 #include "ui/base/native_theme/native_theme_win.h"
12 #include "ui/gfx/canvas.h" 12 #include "ui/gfx/canvas.h"
13 #include "ui/views/controls/menu/menu_config.h" 13 #include "ui/views/controls/menu/menu_config.h"
14 #include "ui/views/controls/menu/submenu_view.h" 14 #include "ui/views/controls/menu/submenu_view.h"
15 15
16 using ui::NativeTheme; 16 using ui::NativeTheme;
17 17
18 namespace views { 18 namespace views {
19 19
20 void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { 20 void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
21 const MenuConfig& config = MenuConfig::instance(); 21 const MenuConfig& config = GetMenuConfig();
22 22
23 bool render_selection = 23 bool render_selection =
24 (mode == PB_NORMAL && IsSelected() && 24 (mode == PB_NORMAL && IsSelected() &&
25 parent_menu_item_->GetSubmenu()->GetShowSelection(this) && 25 parent_menu_item_->GetSubmenu()->GetShowSelection(this) &&
26 (NonIconChildViewsCount() == 0)); 26 (NonIconChildViewsCount() == 0));
27 int default_sys_color; 27 int default_sys_color;
28 int state; 28 int state;
29 NativeTheme::State control_state; 29 NativeTheme::State control_state;
30 30
31 if (enabled()) { 31 if (enabled()) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 int icon_height; 133 int icon_height;
134 if (type_ == RADIO) { 134 if (type_ == RADIO) {
135 icon_width = config.radio_width; 135 icon_width = config.radio_width;
136 icon_height = config.radio_height; 136 icon_height = config.radio_height;
137 } else { 137 } else {
138 icon_width = config.check_width; 138 icon_width = config.check_width;
139 icon_height = config.check_height; 139 icon_height = config.check_height;
140 } 140 }
141 141
142 int top_margin = GetTopMargin(); 142 int top_margin = GetTopMargin();
143 int icon_x = MenuConfig::instance().item_left_margin; 143 int icon_x = GetMenuConfig().item_left_margin;
144 int icon_y = top_margin + 144 int icon_y = top_margin +
145 (height() - top_margin - GetBottomMargin() - icon_height) / 2; 145 (height() - top_margin - GetBottomMargin() - icon_height) / 2;
146 NativeTheme::ExtraParams extra; 146 NativeTheme::ExtraParams extra;
147 extra.menu_check.is_radio = type_ == RADIO; 147 extra.menu_check.is_radio = type_ == RADIO;
148 extra.menu_check.is_selected = selection_state == SELECTED; 148 extra.menu_check.is_selected = selection_state == SELECTED;
149 149
150 // Draw the background. 150 // Draw the background.
151 gfx::Rect bg_bounds(0, 0, icon_x + icon_width, height()); 151 gfx::Rect bg_bounds(0, 0, icon_x + icon_width, height());
152 AdjustBoundsForRTLUI(&bg_bounds); 152 AdjustBoundsForRTLUI(&bg_bounds);
153 NativeTheme::instance()->Paint(canvas->sk_canvas(), 153 NativeTheme::instance()->Paint(canvas->sk_canvas(),
154 NativeTheme::kMenuCheckBackground, state, bg_bounds, extra); 154 NativeTheme::kMenuCheckBackground, state, bg_bounds, extra);
155 155
156 // And the check. 156 // And the check.
157 gfx::Rect icon_bounds(icon_x / 2, icon_y, icon_width, icon_height); 157 gfx::Rect icon_bounds(icon_x / 2, icon_y, icon_width, icon_height);
158 AdjustBoundsForRTLUI(&icon_bounds); 158 AdjustBoundsForRTLUI(&icon_bounds);
159 NativeTheme::instance()->Paint(canvas->sk_canvas(), 159 NativeTheme::instance()->Paint(canvas->sk_canvas(),
160 NativeTheme::kMenuCheck, state, bg_bounds, extra); 160 NativeTheme::kMenuCheck, state, bg_bounds, extra);
161 } 161 }
162 162
163 } // namespace views 163 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698