| 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 "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/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 "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 gfx::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; |
| 27 int state; | 27 int state; |
| 28 NativeTheme::State control_state; | 28 NativeTheme::State control_state; |
| 29 | 29 |
| 30 if (IsEnabled()) { | 30 if (enabled()) { |
| 31 if (render_selection) { | 31 if (render_selection) { |
| 32 control_state = NativeTheme::kHovered; | 32 control_state = NativeTheme::kHovered; |
| 33 state = MPI_HOT; | 33 state = MPI_HOT; |
| 34 default_sys_color = COLOR_HIGHLIGHTTEXT; | 34 default_sys_color = COLOR_HIGHLIGHTTEXT; |
| 35 } else { | 35 } else { |
| 36 control_state = NativeTheme::kNormal; | 36 control_state = NativeTheme::kNormal; |
| 37 state = MPI_NORMAL; | 37 state = MPI_NORMAL; |
| 38 default_sys_color = COLOR_MENUTEXT; | 38 default_sys_color = COLOR_MENUTEXT; |
| 39 } | 39 } |
| 40 } else { | 40 } else { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 gfx::Rect icon_bounds(config.item_left_margin, | 109 gfx::Rect icon_bounds(config.item_left_margin, |
| 110 top_margin + (height() - top_margin - | 110 top_margin + (height() - top_margin - |
| 111 bottom_margin - icon_.height()) / 2, | 111 bottom_margin - icon_.height()) / 2, |
| 112 icon_.width(), | 112 icon_.width(), |
| 113 icon_.height()); | 113 icon_.height()); |
| 114 icon_bounds.set_x(GetMirroredXForRect(icon_bounds)); | 114 icon_bounds.set_x(GetMirroredXForRect(icon_bounds)); |
| 115 canvas->DrawBitmapInt(icon_, icon_bounds.x(), icon_bounds.y()); | 115 canvas->DrawBitmapInt(icon_, icon_bounds.x(), icon_bounds.y()); |
| 116 } | 116 } |
| 117 | 117 |
| 118 if (HasSubmenu()) { | 118 if (HasSubmenu()) { |
| 119 int state_id = IsEnabled() ? MSM_NORMAL : MSM_DISABLED; | 119 int state_id = enabled() ? MSM_NORMAL : MSM_DISABLED; |
| 120 gfx::Rect arrow_bounds(this->width() - item_right_margin_ + | 120 gfx::Rect arrow_bounds(this->width() - item_right_margin_ + |
| 121 config.label_to_arrow_padding, 0, | 121 config.label_to_arrow_padding, 0, |
| 122 config.arrow_width, height()); | 122 config.arrow_width, height()); |
| 123 AdjustBoundsForRTLUI(&arrow_bounds); | 123 AdjustBoundsForRTLUI(&arrow_bounds); |
| 124 | 124 |
| 125 // If our sub menus open from right to left (which is the case when the | 125 // If our sub menus open from right to left (which is the case when the |
| 126 // locale is RTL) then we should make sure the menu arrow points to the | 126 // locale is RTL) then we should make sure the menu arrow points to the |
| 127 // right direction. | 127 // right direction. |
| 128 gfx::NativeTheme::ExtraParams extra; | 128 gfx::NativeTheme::ExtraParams extra; |
| 129 extra.menu_arrow.pointing_right = !base::i18n::IsRTL(); | 129 extra.menu_arrow.pointing_right = !base::i18n::IsRTL(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 NativeTheme::kMenuCheckBackground, state, bg_bounds, extra); | 162 NativeTheme::kMenuCheckBackground, state, bg_bounds, extra); |
| 163 | 163 |
| 164 // And the check. | 164 // And the check. |
| 165 gfx::Rect icon_bounds(icon_x / 2, icon_y, icon_width, icon_height); | 165 gfx::Rect icon_bounds(icon_x / 2, icon_y, icon_width, icon_height); |
| 166 AdjustBoundsForRTLUI(&icon_bounds); | 166 AdjustBoundsForRTLUI(&icon_bounds); |
| 167 NativeTheme::instance()->Paint(canvas->GetSkCanvas(), | 167 NativeTheme::instance()->Paint(canvas->GetSkCanvas(), |
| 168 NativeTheme::kMenuCheck, state, bg_bounds, extra); | 168 NativeTheme::kMenuCheck, state, bg_bounds, extra); |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace views | 171 } // namespace views |
| OLD | NEW |