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

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

Issue 10387121: Revert 136996 - ui: Move NativeTheme files into ui/base/native_theme/ directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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"
12 #include "ui/gfx/canvas.h" 11 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/native_theme_win.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 gfx::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 = MenuConfig::instance();
22 bool render_selection = 22 bool render_selection =
23 (mode == PB_NORMAL && IsSelected() && 23 (mode == PB_NORMAL && IsSelected() &&
24 parent_menu_item_->GetSubmenu()->GetShowSelection(this) && 24 parent_menu_item_->GetSubmenu()->GetShowSelection(this) &&
25 !has_children()); 25 !has_children());
26 int default_sys_color; 26 int default_sys_color;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 if ((type_ == RADIO || type_ == CHECKBOX) && 73 if ((type_ == RADIO || type_ == CHECKBOX) &&
74 GetDelegate()->IsItemChecked(GetCommand())) { 74 GetDelegate()->IsItemChecked(GetCommand())) {
75 PaintCheck(canvas, control_state, render_selection ? SELECTED : UNSELECTED, 75 PaintCheck(canvas, control_state, render_selection ? SELECTED : UNSELECTED,
76 config); 76 config);
77 } 77 }
78 78
79 // Render the foreground. 79 // Render the foreground.
80 // Menu color is specific to Vista, fallback to classic colors if can't 80 // Menu color is specific to Vista, fallback to classic colors if can't
81 // get color. 81 // get color.
82 SkColor fg_color = ui::NativeThemeWin::instance()->GetThemeColorWithDefault( 82 SkColor fg_color = gfx::NativeThemeWin::instance()->GetThemeColorWithDefault(
83 ui::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 = GetFont(); 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
(...skipping 23 matching lines...) Expand all
117 if (HasSubmenu()) { 117 if (HasSubmenu()) {
118 int state_id = enabled() ? MSM_NORMAL : MSM_DISABLED; 118 int state_id = enabled() ? MSM_NORMAL : MSM_DISABLED;
119 gfx::Rect arrow_bounds(this->width() - item_right_margin_ + 119 gfx::Rect arrow_bounds(this->width() - item_right_margin_ +
120 config.label_to_arrow_padding, 0, 120 config.label_to_arrow_padding, 0,
121 config.arrow_width, height()); 121 config.arrow_width, height());
122 AdjustBoundsForRTLUI(&arrow_bounds); 122 AdjustBoundsForRTLUI(&arrow_bounds);
123 123
124 // If our sub menus open from right to left (which is the case when the 124 // If our sub menus open from right to left (which is the case when the
125 // locale is RTL) then we should make sure the menu arrow points to the 125 // locale is RTL) then we should make sure the menu arrow points to the
126 // right direction. 126 // right direction.
127 ui::NativeTheme::ExtraParams extra; 127 gfx::NativeTheme::ExtraParams extra;
128 extra.menu_arrow.pointing_right = !base::i18n::IsRTL(); 128 extra.menu_arrow.pointing_right = !base::i18n::IsRTL();
129 extra.menu_arrow.is_selected = render_selection; 129 extra.menu_arrow.is_selected = render_selection;
130 ui::NativeTheme::instance()->Paint(canvas->sk_canvas(), 130 gfx::NativeTheme::instance()->Paint(canvas->sk_canvas(),
131 ui::NativeTheme::kMenuPopupArrow, control_state, arrow_bounds, extra); 131 gfx::NativeTheme::kMenuPopupArrow, control_state, arrow_bounds, extra);
132 } 132 }
133 } 133 }
134 134
135 void MenuItemView::PaintCheck(gfx::Canvas* canvas, 135 void MenuItemView::PaintCheck(gfx::Canvas* canvas,
136 NativeTheme::State state, 136 NativeTheme::State state,
137 SelectionState selection_state, 137 SelectionState selection_state,
138 const MenuConfig& config) { 138 const MenuConfig& config) {
139 int icon_width; 139 int icon_width;
140 int icon_height; 140 int icon_height;
141 if (type_ == RADIO) { 141 if (type_ == RADIO) {
(...skipping 19 matching lines...) Expand all
161 NativeTheme::kMenuCheckBackground, state, bg_bounds, extra); 161 NativeTheme::kMenuCheckBackground, state, bg_bounds, extra);
162 162
163 // And the check. 163 // And the check.
164 gfx::Rect icon_bounds(icon_x / 2, icon_y, icon_width, icon_height); 164 gfx::Rect icon_bounds(icon_x / 2, icon_y, icon_width, icon_height);
165 AdjustBoundsForRTLUI(&icon_bounds); 165 AdjustBoundsForRTLUI(&icon_bounds);
166 NativeTheme::instance()->Paint(canvas->sk_canvas(), 166 NativeTheme::instance()->Paint(canvas->sk_canvas(),
167 NativeTheme::kMenuCheck, state, bg_bounds, extra); 167 NativeTheme::kMenuCheck, state, bg_bounds, extra);
168 } 168 }
169 169
170 } // namespace views 170 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_item_view_views.cc ('k') | ui/views/controls/menu/menu_scroll_view_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698