| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // get color. | 81 // get color. |
| 82 int default_sys_color = render_selection ? COLOR_HIGHLIGHTTEXT : | 82 int default_sys_color = render_selection ? COLOR_HIGHLIGHTTEXT : |
| 83 (IsEnabled() ? COLOR_MENUTEXT : COLOR_GRAYTEXT); | 83 (IsEnabled() ? COLOR_MENUTEXT : COLOR_GRAYTEXT); |
| 84 SkColor fg_color = NativeTheme::instance()->GetThemeColorWithDefault( | 84 SkColor fg_color = NativeTheme::instance()->GetThemeColorWithDefault( |
| 85 NativeTheme::MENU, MENU_POPUPITEM, state, TMT_TEXTCOLOR, | 85 NativeTheme::MENU, MENU_POPUPITEM, state, TMT_TEXTCOLOR, |
| 86 default_sys_color); | 86 default_sys_color); |
| 87 const gfx::Font& font = MenuConfig::instance().font; | 87 const gfx::Font& font = MenuConfig::instance().font; |
| 88 int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width(); | 88 int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width(); |
| 89 int width = this->width() - item_right_margin_ - label_start_ - accel_width; | 89 int width = this->width() - item_right_margin_ - label_start_ - accel_width; |
| 90 gfx::Rect text_bounds(label_start_, top_margin, width, font.GetHeight()); | 90 gfx::Rect text_bounds(label_start_, top_margin, width, font.GetHeight()); |
| 91 text_bounds.set_x(MirroredLeftPointForRect(text_bounds)); | 91 text_bounds.set_x(GetMirroredXForRect(text_bounds)); |
| 92 if (for_drag) { | 92 if (for_drag) { |
| 93 // With different themes, it's difficult to tell what the correct | 93 // With different themes, it's difficult to tell what the correct |
| 94 // foreground and background colors are for the text to draw the correct | 94 // foreground and background colors are for the text to draw the correct |
| 95 // halo. Instead, just draw black on white, which will look good in most | 95 // halo. Instead, just draw black on white, which will look good in most |
| 96 // cases. | 96 // cases. |
| 97 canvas->AsCanvasSkia()->DrawStringWithHalo( | 97 canvas->AsCanvasSkia()->DrawStringWithHalo( |
| 98 GetTitle(), font, 0x00000000, 0xFFFFFFFF, text_bounds.x(), | 98 GetTitle(), font, 0x00000000, 0xFFFFFFFF, text_bounds.x(), |
| 99 text_bounds.y(), text_bounds.width(), text_bounds.height(), | 99 text_bounds.y(), text_bounds.width(), text_bounds.height(), |
| 100 GetRootMenuItem()->GetDrawStringFlags()); | 100 GetRootMenuItem()->GetDrawStringFlags()); |
| 101 } else { | 101 } else { |
| 102 canvas->DrawStringInt(GetTitle(), font, fg_color, | 102 canvas->DrawStringInt(GetTitle(), font, fg_color, |
| 103 text_bounds.x(), text_bounds.y(), text_bounds.width(), | 103 text_bounds.x(), text_bounds.y(), text_bounds.width(), |
| 104 text_bounds.height(), | 104 text_bounds.height(), |
| 105 GetRootMenuItem()->GetDrawStringFlags()); | 105 GetRootMenuItem()->GetDrawStringFlags()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 PaintAccelerator(canvas); | 108 PaintAccelerator(canvas); |
| 109 | 109 |
| 110 if (icon_.width() > 0) { | 110 if (icon_.width() > 0) { |
| 111 gfx::Rect icon_bounds(config.item_left_margin, | 111 gfx::Rect icon_bounds(config.item_left_margin, |
| 112 top_margin + (height() - top_margin - | 112 top_margin + (height() - top_margin - |
| 113 bottom_margin - icon_.height()) / 2, | 113 bottom_margin - icon_.height()) / 2, |
| 114 icon_.width(), | 114 icon_.width(), |
| 115 icon_.height()); | 115 icon_.height()); |
| 116 icon_bounds.set_x(MirroredLeftPointForRect(icon_bounds)); | 116 icon_bounds.set_x(GetMirroredXForRect(icon_bounds)); |
| 117 canvas->DrawBitmapInt(icon_, icon_bounds.x(), icon_bounds.y()); | 117 canvas->DrawBitmapInt(icon_, icon_bounds.x(), icon_bounds.y()); |
| 118 } | 118 } |
| 119 | 119 |
| 120 if (HasSubmenu()) { | 120 if (HasSubmenu()) { |
| 121 int state_id = IsEnabled() ? MSM_NORMAL : MSM_DISABLED; | 121 int state_id = IsEnabled() ? MSM_NORMAL : MSM_DISABLED; |
| 122 gfx::Rect arrow_bounds(this->width() - item_right_margin_ + | 122 gfx::Rect arrow_bounds(this->width() - item_right_margin_ + |
| 123 config.label_to_arrow_padding, 0, | 123 config.label_to_arrow_padding, 0, |
| 124 config.arrow_width, height()); | 124 config.arrow_width, height()); |
| 125 AdjustBoundsForRTLUI(&arrow_bounds); | 125 AdjustBoundsForRTLUI(&arrow_bounds); |
| 126 | 126 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // And the check. | 162 // And the check. |
| 163 gfx::Rect icon_bounds(icon_x / 2, icon_y, icon_width, icon_height); | 163 gfx::Rect icon_bounds(icon_x / 2, icon_y, icon_width, icon_height); |
| 164 AdjustBoundsForRTLUI(&icon_bounds); | 164 AdjustBoundsForRTLUI(&icon_bounds); |
| 165 RECT icon_rect = icon_bounds.ToRECT(); | 165 RECT icon_rect = icon_bounds.ToRECT(); |
| 166 NativeTheme::instance()->PaintMenuCheck( | 166 NativeTheme::instance()->PaintMenuCheck( |
| 167 NativeTheme::MENU, dc, MENU_POPUPCHECK, state_id, &icon_rect, | 167 NativeTheme::MENU, dc, MENU_POPUPCHECK, state_id, &icon_rect, |
| 168 control_state); | 168 control_state); |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace views | 171 } // namespace views |
| OLD | NEW |