OLD | NEW |
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 "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 | 815 |
816 native_theme->Paint(canvas->sk_canvas(), | 816 native_theme->Paint(canvas->sk_canvas(), |
817 ui::NativeTheme::kMenuItemBackground, | 817 ui::NativeTheme::kMenuItemBackground, |
818 ui::NativeTheme::kHovered, | 818 ui::NativeTheme::kHovered, |
819 item_bounds, | 819 item_bounds, |
820 ui::NativeTheme::ExtraParams()); | 820 ui::NativeTheme::ExtraParams()); |
821 } | 821 } |
822 | 822 |
823 // Render the check. | 823 // Render the check. |
824 if (type_ == CHECKBOX && delegate->IsItemChecked(GetCommand())) { | 824 if (type_ == CHECKBOX && delegate->IsItemChecked(GetCommand())) { |
825 const gfx::ImageSkia* check = GetMenuCheckImage(); | 825 gfx::ImageSkia check = GetMenuCheckImage(IsSelected()); |
826 // Don't use config.check_width here as it's padded | 826 // Don't use config.check_width here as it's padded |
827 // to force more padding (AURA). | 827 // to force more padding (AURA). |
828 gfx::Rect check_bounds(icon_x, icon_y, check->width(), icon_height); | 828 gfx::Rect check_bounds(icon_x, icon_y, check.width(), icon_height); |
829 AdjustBoundsForRTLUI(&check_bounds); | 829 AdjustBoundsForRTLUI(&check_bounds); |
830 canvas->DrawImageInt(*check, check_bounds.x(), check_bounds.y()); | 830 canvas->DrawImageInt(check, check_bounds.x(), check_bounds.y()); |
831 } else if (type_ == RADIO) { | 831 } else if (type_ == RADIO) { |
832 const gfx::ImageSkia* image = | 832 gfx::ImageSkia image = |
833 GetRadioButtonImage(delegate->IsItemChecked(GetCommand())); | 833 GetRadioButtonImage(delegate->IsItemChecked(GetCommand())); |
834 gfx::Rect radio_bounds(icon_x, | 834 gfx::Rect radio_bounds(icon_x, |
835 top_margin + | 835 top_margin + |
836 (height() - top_margin - bottom_margin - | 836 (height() - top_margin - bottom_margin - |
837 image->height()) / 2, | 837 image.height()) / 2, |
838 image->width(), | 838 image.width(), |
839 image->height()); | 839 image.height()); |
840 AdjustBoundsForRTLUI(&radio_bounds); | 840 AdjustBoundsForRTLUI(&radio_bounds); |
841 canvas->DrawImageInt(*image, radio_bounds.x(), radio_bounds.y()); | 841 canvas->DrawImageInt(image, radio_bounds.x(), radio_bounds.y()); |
842 } | 842 } |
843 | 843 |
844 // Render the foreground. | 844 // Render the foreground. |
845 ui::NativeTheme::ColorId color_id = | 845 ui::NativeTheme::ColorId color_id = |
846 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor; | 846 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor; |
847 if (enabled()) { | 847 if (enabled()) { |
848 color_id = render_selection ? | 848 color_id = render_selection ? |
849 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor: | 849 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor: |
850 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor; | 850 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor; |
851 } | 851 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 PaintMinorText(canvas, render_selection); | 890 PaintMinorText(canvas, render_selection); |
891 | 891 |
892 // Render the submenu indicator (arrow). | 892 // Render the submenu indicator (arrow). |
893 if (HasSubmenu()) { | 893 if (HasSubmenu()) { |
894 gfx::Rect arrow_bounds(this->width() - config.arrow_width - | 894 gfx::Rect arrow_bounds(this->width() - config.arrow_width - |
895 config.arrow_to_edge_padding, | 895 config.arrow_to_edge_padding, |
896 top_margin + (available_height - | 896 top_margin + (available_height - |
897 config.arrow_width) / 2, | 897 config.arrow_width) / 2, |
898 config.arrow_width, height()); | 898 config.arrow_width, height()); |
899 AdjustBoundsForRTLUI(&arrow_bounds); | 899 AdjustBoundsForRTLUI(&arrow_bounds); |
900 canvas->DrawImageInt(*GetSubmenuArrowImage(), | 900 canvas->DrawImageInt(GetSubmenuArrowImage(IsSelected()), |
901 arrow_bounds.x(), arrow_bounds.y()); | 901 arrow_bounds.x(), arrow_bounds.y()); |
902 } | 902 } |
903 } | 903 } |
904 | 904 |
905 void MenuItemView::PaintMinorText(gfx::Canvas* canvas, | 905 void MenuItemView::PaintMinorText(gfx::Canvas* canvas, |
906 bool render_selection) { | 906 bool render_selection) { |
907 string16 minor_text = GetMinorText(); | 907 string16 minor_text = GetMinorText(); |
908 if (minor_text.empty()) | 908 if (minor_text.empty()) |
909 return; | 909 return; |
910 | 910 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 } else { | 1110 } else { |
1111 const Type& type = menu_item->GetType(); | 1111 const Type& type = menu_item->GetType(); |
1112 if (type == CHECKBOX || type == RADIO) | 1112 if (type == CHECKBOX || type == RADIO) |
1113 return true; | 1113 return true; |
1114 } | 1114 } |
1115 } | 1115 } |
1116 return false; | 1116 return false; |
1117 } | 1117 } |
1118 | 1118 |
1119 } // namespace views | 1119 } // namespace views |
OLD | NEW |