| 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/app_strings.h" | 10 #include "grit/app_strings.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 NativeTheme::kNormal; | 42 NativeTheme::kNormal; |
| 43 } | 43 } |
| 44 | 44 |
| 45 // The gutter is rendered before the background. | 45 // The gutter is rendered before the background. |
| 46 if (config.render_gutter && mode == PB_NORMAL) { | 46 if (config.render_gutter && mode == PB_NORMAL) { |
| 47 gfx::Rect gutter_bounds(label_start_ - config.gutter_to_label - | 47 gfx::Rect gutter_bounds(label_start_ - config.gutter_to_label - |
| 48 config.gutter_width, 0, config.gutter_width, | 48 config.gutter_width, 0, config.gutter_width, |
| 49 height()); | 49 height()); |
| 50 AdjustBoundsForRTLUI(&gutter_bounds); | 50 AdjustBoundsForRTLUI(&gutter_bounds); |
| 51 NativeTheme::ExtraParams extra; | 51 NativeTheme::ExtraParams extra; |
| 52 NativeTheme::instance()->Paint(canvas->AsCanvasSkia(), | 52 NativeTheme::instance()->Paint(canvas->AsCanvasSkia()->skia_canvas(), |
| 53 NativeTheme::kMenuPopupGutter, | 53 NativeTheme::kMenuPopupGutter, |
| 54 NativeTheme::kNormal, | 54 NativeTheme::kNormal, |
| 55 gutter_bounds, | 55 gutter_bounds, |
| 56 extra); | 56 extra); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Render the background. | 59 // Render the background. |
| 60 if (mode == PB_NORMAL) { | 60 if (mode == PB_NORMAL) { |
| 61 gfx::Rect item_bounds(0, 0, width(), height()); | 61 gfx::Rect item_bounds(0, 0, width(), height()); |
| 62 NativeTheme::ExtraParams extra; | 62 NativeTheme::ExtraParams extra; |
| 63 extra.menu_item.is_selected = render_selection; | 63 extra.menu_item.is_selected = render_selection; |
| 64 AdjustBoundsForRTLUI(&item_bounds); | 64 AdjustBoundsForRTLUI(&item_bounds); |
| 65 NativeTheme::instance()->Paint(canvas->AsCanvasSkia(), | 65 NativeTheme::instance()->Paint(canvas->AsCanvasSkia()->skia_canvas(), |
| 66 NativeTheme::kMenuItemBackground, control_state, item_bounds, extra); | 66 NativeTheme::kMenuItemBackground, control_state, item_bounds, extra); |
| 67 } | 67 } |
| 68 | 68 |
| 69 int top_margin = GetTopMargin(); | 69 int top_margin = GetTopMargin(); |
| 70 int bottom_margin = GetBottomMargin(); | 70 int bottom_margin = GetBottomMargin(); |
| 71 | 71 |
| 72 if ((type_ == RADIO || type_ == CHECKBOX) && | 72 if ((type_ == RADIO || type_ == CHECKBOX) && |
| 73 GetDelegate()->IsItemChecked(GetCommand())) { | 73 GetDelegate()->IsItemChecked(GetCommand())) { |
| 74 PaintCheck(canvas, control_state, config); | 74 PaintCheck(canvas, control_state, config); |
| 75 } | 75 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(); |
| 130 gfx::NativeTheme::instance()->Paint(canvas->AsCanvasSkia(), | 130 gfx::NativeTheme::instance()->Paint(canvas->AsCanvasSkia()->skia_canvas(), |
| 131 gfx::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 const MenuConfig& config) { | 137 const MenuConfig& config) { |
| 138 int icon_width; | 138 int icon_width; |
| 139 int icon_height; | 139 int icon_height; |
| 140 if (type_ == RADIO) { | 140 if (type_ == RADIO) { |
| 141 icon_width = config.radio_width; | 141 icon_width = config.radio_width; |
| 142 icon_height = config.radio_height; | 142 icon_height = config.radio_height; |
| 143 } else { | 143 } else { |
| 144 icon_width = config.check_width; | 144 icon_width = config.check_width; |
| 145 icon_height = config.check_height; | 145 icon_height = config.check_height; |
| 146 } | 146 } |
| 147 | 147 |
| 148 int top_margin = GetTopMargin(); | 148 int top_margin = GetTopMargin(); |
| 149 int icon_x = MenuConfig::instance().item_left_margin; | 149 int icon_x = MenuConfig::instance().item_left_margin; |
| 150 int icon_y = top_margin + | 150 int icon_y = top_margin + |
| 151 (height() - top_margin - GetBottomMargin() - icon_height) / 2; | 151 (height() - top_margin - GetBottomMargin() - icon_height) / 2; |
| 152 NativeTheme::ExtraParams extra; | 152 NativeTheme::ExtraParams extra; |
| 153 extra.menu_check.is_radio = type_ == RADIO; | 153 extra.menu_check.is_radio = type_ == RADIO; |
| 154 | 154 |
| 155 // Draw the background. | 155 // Draw the background. |
| 156 gfx::Rect bg_bounds(0, 0, icon_x + icon_width, height()); | 156 gfx::Rect bg_bounds(0, 0, icon_x + icon_width, height()); |
| 157 AdjustBoundsForRTLUI(&bg_bounds); | 157 AdjustBoundsForRTLUI(&bg_bounds); |
| 158 NativeTheme::instance()->Paint(canvas->AsCanvasSkia(), | 158 NativeTheme::instance()->Paint(canvas->AsCanvasSkia()->skia_canvas(), |
| 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()->skia_canvas(), |
| 165 NativeTheme::kMenuCheck, state, bg_bounds, extra); | 165 NativeTheme::kMenuCheck, state, bg_bounds, extra); |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace views | 168 } // namespace views |
| OLD | NEW |