| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/views/chrome_menu.h" | 5 #include "chrome/views/chrome_menu.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <uxtheme.h> | 8 #include <uxtheme.h> |
| 9 #include <Vssym32.h> | 9 #include <Vssym32.h> |
| 10 | 10 |
| (...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 int state = render_selection ? MPI_HOT : | 1421 int state = render_selection ? MPI_HOT : |
| 1422 (IsEnabled() ? MPI_NORMAL : MPI_DISABLED); | 1422 (IsEnabled() ? MPI_NORMAL : MPI_DISABLED); |
| 1423 HDC dc = canvas->beginPlatformPaint(); | 1423 HDC dc = canvas->beginPlatformPaint(); |
| 1424 | 1424 |
| 1425 // The gutter is rendered before the background. | 1425 // The gutter is rendered before the background. |
| 1426 if (render_gutter && !for_drag) { | 1426 if (render_gutter && !for_drag) { |
| 1427 RECT gutter_bounds = { label_start - kGutterToLabel - gutter_width, 0, 0, | 1427 RECT gutter_bounds = { label_start - kGutterToLabel - gutter_width, 0, 0, |
| 1428 height() }; | 1428 height() }; |
| 1429 gutter_bounds.right = gutter_bounds.left + gutter_width; | 1429 gutter_bounds.right = gutter_bounds.left + gutter_width; |
| 1430 AdjustBoundsForRTLUI(&gutter_bounds); | 1430 AdjustBoundsForRTLUI(&gutter_bounds); |
| 1431 NativeTheme::instance()->PaintMenuGutter(dc, MENU_POPUPGUTTER, MPI_NORMAL, &
gutter_bounds); | 1431 NativeTheme::instance()->PaintMenuGutter(dc, MENU_POPUPGUTTER, MPI_NORMAL, |
| 1432 &gutter_bounds); |
| 1432 } | 1433 } |
| 1433 | 1434 |
| 1434 // Render the background. | 1435 // Render the background. |
| 1435 if (!for_drag) { | 1436 if (!for_drag) { |
| 1436 RECT item_bounds = { 0, 0, width(), height() }; | 1437 RECT item_bounds = { 0, 0, width(), height() }; |
| 1437 AdjustBoundsForRTLUI(&item_bounds); | 1438 AdjustBoundsForRTLUI(&item_bounds); |
| 1438 NativeTheme::instance()->PaintMenuItemBackground( | 1439 NativeTheme::instance()->PaintMenuItemBackground( |
| 1439 NativeTheme::MENU, dc, MENU_POPUPITEM, state, render_selection, | 1440 NativeTheme::MENU, dc, MENU_POPUPITEM, state, render_selection, |
| 1440 &item_bounds); | 1441 &item_bounds); |
| 1441 } | 1442 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1467 NativeTheme::MENU, dc, MENU_POPUPCHECK, check_state, &check_bounds, | 1468 NativeTheme::MENU, dc, MENU_POPUPCHECK, check_state, &check_bounds, |
| 1468 render_selection); | 1469 render_selection); |
| 1469 } | 1470 } |
| 1470 | 1471 |
| 1471 // Render the foreground. | 1472 // Render the foreground. |
| 1472 // Menu color is specific to Vista, fallback to classic colors if can't | 1473 // Menu color is specific to Vista, fallback to classic colors if can't |
| 1473 // get color. | 1474 // get color. |
| 1474 int default_sys_color = render_selection ? COLOR_HIGHLIGHTTEXT : | 1475 int default_sys_color = render_selection ? COLOR_HIGHLIGHTTEXT : |
| 1475 (IsEnabled() ? COLOR_MENUTEXT : COLOR_GRAYTEXT); | 1476 (IsEnabled() ? COLOR_MENUTEXT : COLOR_GRAYTEXT); |
| 1476 SkColor fg_color = NativeTheme::instance()->GetThemeColorWithDefault( | 1477 SkColor fg_color = NativeTheme::instance()->GetThemeColorWithDefault( |
| 1477 NativeTheme::MENU, MENU_POPUPITEM, state, TMT_TEXTCOLOR, default_sys_color
); | 1478 NativeTheme::MENU, MENU_POPUPITEM, state, TMT_TEXTCOLOR, |
| 1479 default_sys_color); |
| 1478 int width = this->width() - item_right_margin - label_start; | 1480 int width = this->width() - item_right_margin - label_start; |
| 1479 ChromeFont& font = GetRootMenuItem()->font_; | 1481 ChromeFont& font = GetRootMenuItem()->font_; |
| 1480 gfx::Rect text_bounds(label_start, top_margin, width, font.height()); | 1482 gfx::Rect text_bounds(label_start, top_margin, width, font.height()); |
| 1481 text_bounds.set_x(MirroredLeftPointForRect(text_bounds)); | 1483 text_bounds.set_x(MirroredLeftPointForRect(text_bounds)); |
| 1482 if (for_drag) { | 1484 if (for_drag) { |
| 1483 // With different themes, it's difficult to tell what the correct foreground | 1485 // With different themes, it's difficult to tell what the correct foreground |
| 1484 // and background colors are for the text to draw the correct halo. Instead, | 1486 // and background colors are for the text to draw the correct halo. Instead, |
| 1485 // just draw black on white, which will look good in most cases. | 1487 // just draw black on white, which will look good in most cases. |
| 1486 canvas->DrawStringWithHalo(GetTitle(), font, 0x00000000, 0xFFFFFFFF, | 1488 canvas->DrawStringWithHalo(GetTitle(), font, 0x00000000, 0xFFFFFFFF, |
| 1487 text_bounds.x(), text_bounds.y(), | 1489 text_bounds.x(), text_bounds.y(), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1499 top_margin + (height() - top_margin - | 1501 top_margin + (height() - top_margin - |
| 1500 bottom_margin - icon_.height()) / 2, | 1502 bottom_margin - icon_.height()) / 2, |
| 1501 icon_.width(), | 1503 icon_.width(), |
| 1502 icon_.height()); | 1504 icon_.height()); |
| 1503 icon_bounds.set_x(MirroredLeftPointForRect(icon_bounds)); | 1505 icon_bounds.set_x(MirroredLeftPointForRect(icon_bounds)); |
| 1504 canvas->DrawBitmapInt(icon_, icon_bounds.x(), icon_bounds.y()); | 1506 canvas->DrawBitmapInt(icon_, icon_bounds.x(), icon_bounds.y()); |
| 1505 } | 1507 } |
| 1506 | 1508 |
| 1507 if (HasSubmenu()) { | 1509 if (HasSubmenu()) { |
| 1508 int state_id = IsEnabled() ? MSM_NORMAL : MSM_DISABLED; | 1510 int state_id = IsEnabled() ? MSM_NORMAL : MSM_DISABLED; |
| 1509 RECT arrow_bounds = { this->width() - item_right_margin + kLabelToArrowPaddi
ng, | 1511 RECT arrow_bounds = { |
| 1510 0, 0, height() }; | 1512 this->width() - item_right_margin + kLabelToArrowPadding, |
| 1513 0, |
| 1514 0, |
| 1515 height() |
| 1516 }; |
| 1511 arrow_bounds.right = arrow_bounds.left + arrow_width; | 1517 arrow_bounds.right = arrow_bounds.left + arrow_width; |
| 1512 AdjustBoundsForRTLUI(&arrow_bounds); | 1518 AdjustBoundsForRTLUI(&arrow_bounds); |
| 1513 | 1519 |
| 1514 // If our sub menus open from right to left (which is the case when the | 1520 // If our sub menus open from right to left (which is the case when the |
| 1515 // locale is RTL) then we should make sure the menu arrow points to the | 1521 // locale is RTL) then we should make sure the menu arrow points to the |
| 1516 // right direction. | 1522 // right direction. |
| 1517 NativeTheme::MenuArrowDirection arrow_direction; | 1523 NativeTheme::MenuArrowDirection arrow_direction; |
| 1518 if (UILayoutIsRightToLeft()) | 1524 if (UILayoutIsRightToLeft()) |
| 1519 arrow_direction = NativeTheme::LEFT_POINTING_ARROW; | 1525 arrow_direction = NativeTheme::LEFT_POINTING_ARROW; |
| 1520 else | 1526 else |
| (...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2806 if (!scroll_task_.get()) | 2812 if (!scroll_task_.get()) |
| 2807 scroll_task_.reset(new MenuScrollTask()); | 2813 scroll_task_.reset(new MenuScrollTask()); |
| 2808 scroll_task_->Update(part); | 2814 scroll_task_->Update(part); |
| 2809 } | 2815 } |
| 2810 | 2816 |
| 2811 void MenuController::StopScrolling() { | 2817 void MenuController::StopScrolling() { |
| 2812 scroll_task_.reset(NULL); | 2818 scroll_task_.reset(NULL); |
| 2813 } | 2819 } |
| 2814 | 2820 |
| 2815 } // namespace views | 2821 } // namespace views |
| OLD | NEW |