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/native_theme/native_theme_win.h" | 5 #include "ui/native_theme/native_theme_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <uxtheme.h> | 9 #include <uxtheme.h> |
10 #include <vsstyle.h> | 10 #include <vsstyle.h> |
11 #include <vssym32.h> | 11 #include <vssym32.h> |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/win/scoped_gdi_object.h" | 15 #include "base/win/scoped_gdi_object.h" |
16 #include "base/win/scoped_hdc.h" | 16 #include "base/win/scoped_hdc.h" |
17 #include "base/win/scoped_select_object.h" | 17 #include "base/win/scoped_select_object.h" |
18 #include "base/win/windows_version.h" | 18 #include "base/win/windows_version.h" |
19 #include "skia/ext/bitmap_platform_device.h" | 19 #include "skia/ext/bitmap_platform_device.h" |
20 #include "skia/ext/platform_canvas.h" | 20 #include "skia/ext/platform_canvas.h" |
21 #include "skia/ext/skia_utils_win.h" | 21 #include "skia/ext/skia_utils_win.h" |
22 #include "third_party/skia/include/core/SkCanvas.h" | 22 #include "third_party/skia/include/core/SkCanvas.h" |
23 #include "third_party/skia/include/core/SkColor.h" | 23 #include "third_party/skia/include/core/SkColor.h" |
| 24 #include "third_party/skia/include/core/SkColorPriv.h" |
| 25 #include "third_party/skia/include/core/SkRefCnt.h" |
24 #include "third_party/skia/include/core/SkShader.h" | 26 #include "third_party/skia/include/core/SkShader.h" |
25 #include "ui/base/material_design/material_design_controller.h" | 27 #include "ui/base/material_design/material_design_controller.h" |
26 #include "ui/display/win/dpi.h" | 28 #include "ui/display/win/dpi.h" |
27 #include "ui/gfx/color_palette.h" | 29 #include "ui/gfx/color_palette.h" |
28 #include "ui/gfx/color_utils.h" | 30 #include "ui/gfx/color_utils.h" |
29 #include "ui/gfx/gdi_util.h" | 31 #include "ui/gfx/gdi_util.h" |
30 #include "ui/gfx/geometry/rect.h" | 32 #include "ui/gfx/geometry/rect.h" |
31 #include "ui/gfx/geometry/rect_conversions.h" | 33 #include "ui/gfx/geometry/rect_conversions.h" |
32 #include "ui/gfx/skia_util.h" | 34 #include "ui/gfx/skia_util.h" |
33 #include "ui/native_theme/common_theme.h" | 35 #include "ui/native_theme/common_theme.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 case kMenuPopupSeparator: | 244 case kMenuPopupSeparator: |
243 PaintMenuSeparator(canvas, rect); | 245 PaintMenuSeparator(canvas, rect); |
244 return; | 246 return; |
245 case kMenuPopupBackground: | 247 case kMenuPopupBackground: |
246 PaintMenuBackground(canvas, rect); | 248 PaintMenuBackground(canvas, rect); |
247 return; | 249 return; |
248 case kMenuItemBackground: | 250 case kMenuItemBackground: |
249 CommonThemePaintMenuItemBackground(this, canvas, state, rect, | 251 CommonThemePaintMenuItemBackground(this, canvas, state, rect, |
250 extra.menu_item); | 252 extra.menu_item); |
251 return; | 253 return; |
252 case kScrollbarCorner: | |
253 canvas->drawColor(SK_ColorWHITE, SkXfermode::kSrc_Mode); | |
254 return; | |
255 default: | 254 default: |
256 break; | 255 break; |
257 } | 256 } |
258 | 257 |
259 skia::ScopedPlatformPaint scoped_platform_paint(canvas); | 258 bool needs_paint_indirect = false; |
260 HDC hdc = scoped_platform_paint.GetPlatformSurface(); | 259 if (!skia::SupportsPlatformPaint(canvas)) { |
| 260 // This block will only get hit with --enable-accelerated-drawing flag. |
| 261 needs_paint_indirect = true; |
| 262 } else { |
| 263 // Scrollbar components on Windows Classic theme (on all Windows versions) |
| 264 // have particularly problematic alpha values, so always draw them |
| 265 // indirectly. In addition, scrollbar thumbs and grippers for the Windows XP |
| 266 // theme (available only on Windows XP) also need their alpha values |
| 267 // fixed. |
| 268 switch (part) { |
| 269 case kScrollbarDownArrow: |
| 270 case kScrollbarUpArrow: |
| 271 case kScrollbarLeftArrow: |
| 272 case kScrollbarRightArrow: |
| 273 needs_paint_indirect = !GetThemeHandle(SCROLLBAR); |
| 274 break; |
| 275 case kScrollbarHorizontalThumb: |
| 276 case kScrollbarVerticalThumb: |
| 277 case kScrollbarHorizontalGripper: |
| 278 case kScrollbarVerticalGripper: |
| 279 needs_paint_indirect = !GetThemeHandle(SCROLLBAR) || |
| 280 base::win::GetVersion() == base::win::VERSION_XP; |
| 281 break; |
| 282 default: |
| 283 break; |
| 284 } |
| 285 } |
261 | 286 |
262 switch (part) { | 287 if (needs_paint_indirect) |
263 case kCheckbox: | 288 PaintIndirect(canvas, part, state, rect, extra); |
264 PaintCheckbox(hdc, part, state, rect, extra.button); | 289 else |
265 return; | 290 PaintDirect(canvas, part, state, rect, extra); |
266 case kInnerSpinButton: | |
267 PaintSpinButton(hdc, part, state, rect, extra.inner_spin); | |
268 return; | |
269 case kMenuList: | |
270 PaintMenuList(hdc, state, rect, extra.menu_list); | |
271 return; | |
272 case kMenuCheck: | |
273 PaintMenuCheck(hdc, state, rect, extra.menu_check); | |
274 return; | |
275 case kMenuCheckBackground: | |
276 PaintMenuCheckBackground(hdc, state, rect); | |
277 return; | |
278 case kMenuPopupArrow: | |
279 PaintMenuArrow(hdc, state, rect, extra.menu_arrow); | |
280 return; | |
281 case kProgressBar: | |
282 PaintProgressBar(hdc, rect, extra.progress_bar); | |
283 return; | |
284 case kPushButton: | |
285 PaintPushButton(hdc, part, state, rect, extra.button); | |
286 return; | |
287 case kRadio: | |
288 PaintRadioButton(hdc, part, state, rect, extra.button); | |
289 return; | |
290 case kScrollbarDownArrow: | |
291 case kScrollbarUpArrow: | |
292 case kScrollbarLeftArrow: | |
293 case kScrollbarRightArrow: | |
294 PaintScrollbarArrow(hdc, part, state, rect, extra.scrollbar_arrow); | |
295 return; | |
296 case kScrollbarHorizontalThumb: | |
297 case kScrollbarVerticalThumb: | |
298 case kScrollbarHorizontalGripper: | |
299 case kScrollbarVerticalGripper: | |
300 PaintScrollbarThumb(hdc, part, state, rect, extra.scrollbar_thumb); | |
301 return; | |
302 case kScrollbarHorizontalTrack: | |
303 case kScrollbarVerticalTrack: | |
304 PaintScrollbarTrack(canvas, hdc, part, state, rect, | |
305 extra.scrollbar_track); | |
306 return; | |
307 case kTabPanelBackground: | |
308 PaintTabPanelBackground(hdc, rect); | |
309 return; | |
310 case kTextField: | |
311 PaintTextField(hdc, part, state, rect, extra.text_field); | |
312 return; | |
313 case kTrackbarThumb: | |
314 case kTrackbarTrack: | |
315 PaintTrackbar(canvas, hdc, part, state, rect, extra.trackbar); | |
316 return; | |
317 case kWindowResizeGripper: | |
318 PaintWindowResizeGripper(hdc, rect); | |
319 return; | |
320 default: | |
321 NOTREACHED(); | |
322 } | |
323 } | 291 } |
324 | 292 |
325 NativeThemeWin::NativeThemeWin() | 293 NativeThemeWin::NativeThemeWin() |
326 : draw_theme_(NULL), | 294 : draw_theme_(NULL), |
327 draw_theme_ex_(NULL), | 295 draw_theme_ex_(NULL), |
328 get_theme_color_(NULL), | 296 get_theme_color_(NULL), |
329 get_theme_content_rect_(NULL), | 297 get_theme_content_rect_(NULL), |
330 get_theme_part_size_(NULL), | 298 get_theme_part_size_(NULL), |
331 open_theme_(NULL), | 299 open_theme_(NULL), |
332 close_theme_(NULL), | 300 close_theme_(NULL), |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 canvas->drawLine(position_x, rect.y(), position_x, rect.bottom(), paint); | 369 canvas->drawLine(position_x, rect.y(), position_x, rect.bottom(), paint); |
402 } | 370 } |
403 | 371 |
404 void NativeThemeWin::PaintMenuBackground(SkCanvas* canvas, | 372 void NativeThemeWin::PaintMenuBackground(SkCanvas* canvas, |
405 const gfx::Rect& rect) const { | 373 const gfx::Rect& rect) const { |
406 SkPaint paint; | 374 SkPaint paint; |
407 paint.setColor(GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor)); | 375 paint.setColor(GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor)); |
408 canvas->drawRect(gfx::RectToSkRect(rect), paint); | 376 canvas->drawRect(gfx::RectToSkRect(rect), paint); |
409 } | 377 } |
410 | 378 |
| 379 void NativeThemeWin::PaintDirect(SkCanvas* canvas, |
| 380 Part part, |
| 381 State state, |
| 382 const gfx::Rect& rect, |
| 383 const ExtraParams& extra) const { |
| 384 skia::ScopedPlatformPaint scoped_platform_paint(canvas); |
| 385 HDC hdc = scoped_platform_paint.GetPlatformSurface(); |
| 386 |
| 387 switch (part) { |
| 388 case kCheckbox: |
| 389 PaintCheckbox(hdc, part, state, rect, extra.button); |
| 390 return; |
| 391 case kInnerSpinButton: |
| 392 PaintSpinButton(hdc, part, state, rect, extra.inner_spin); |
| 393 return; |
| 394 case kMenuList: |
| 395 PaintMenuList(hdc, state, rect, extra.menu_list); |
| 396 return; |
| 397 case kMenuCheck: |
| 398 PaintMenuCheck(hdc, state, rect, extra.menu_check); |
| 399 return; |
| 400 case kMenuCheckBackground: |
| 401 PaintMenuCheckBackground(hdc, state, rect); |
| 402 return; |
| 403 case kMenuPopupArrow: |
| 404 PaintMenuArrow(hdc, state, rect, extra.menu_arrow); |
| 405 return; |
| 406 case kMenuPopupBackground: |
| 407 PaintMenuBackground(hdc, rect); |
| 408 return; |
| 409 case kMenuPopupGutter: |
| 410 PaintMenuGutter(hdc, rect); |
| 411 return; |
| 412 case kMenuPopupSeparator: |
| 413 PaintMenuSeparator(hdc, rect); |
| 414 return; |
| 415 case kMenuItemBackground: |
| 416 PaintMenuItemBackground(hdc, state, rect, extra.menu_item); |
| 417 return; |
| 418 case kProgressBar: |
| 419 PaintProgressBar(hdc, rect, extra.progress_bar); |
| 420 return; |
| 421 case kPushButton: |
| 422 PaintPushButton(hdc, part, state, rect, extra.button); |
| 423 return; |
| 424 case kRadio: |
| 425 PaintRadioButton(hdc, part, state, rect, extra.button); |
| 426 return; |
| 427 case kScrollbarDownArrow: |
| 428 case kScrollbarUpArrow: |
| 429 case kScrollbarLeftArrow: |
| 430 case kScrollbarRightArrow: |
| 431 PaintScrollbarArrow(hdc, part, state, rect, extra.scrollbar_arrow); |
| 432 return; |
| 433 case kScrollbarHorizontalThumb: |
| 434 case kScrollbarVerticalThumb: |
| 435 case kScrollbarHorizontalGripper: |
| 436 case kScrollbarVerticalGripper: |
| 437 PaintScrollbarThumb(hdc, part, state, rect, extra.scrollbar_thumb); |
| 438 return; |
| 439 case kScrollbarHorizontalTrack: |
| 440 case kScrollbarVerticalTrack: |
| 441 PaintScrollbarTrack(canvas, hdc, part, state, rect, |
| 442 extra.scrollbar_track); |
| 443 return; |
| 444 case kScrollbarCorner: |
| 445 canvas->drawColor(SK_ColorWHITE, SkXfermode::kSrc_Mode); |
| 446 return; |
| 447 case kTabPanelBackground: |
| 448 PaintTabPanelBackground(hdc, rect); |
| 449 return; |
| 450 case kTextField: |
| 451 PaintTextField(hdc, part, state, rect, extra.text_field); |
| 452 return; |
| 453 case kTrackbarThumb: |
| 454 case kTrackbarTrack: |
| 455 PaintTrackbar(canvas, hdc, part, state, rect, extra.trackbar); |
| 456 return; |
| 457 case kWindowResizeGripper: |
| 458 PaintWindowResizeGripper(hdc, rect); |
| 459 return; |
| 460 case kSliderTrack: |
| 461 case kSliderThumb: |
| 462 case kMaxPart: |
| 463 NOTREACHED(); |
| 464 } |
| 465 } |
| 466 |
411 SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const { | 467 SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const { |
412 const bool md = ui::MaterialDesignController::IsModeMaterial(); | 468 const bool md = ui::MaterialDesignController::IsModeMaterial(); |
413 if (!md) { | 469 if (!md) { |
414 // Link: | 470 // Link: |
415 const SkColor kLinkPressedColor = SkColorSetRGB(200, 0, 0); | 471 const SkColor kLinkPressedColor = SkColorSetRGB(200, 0, 0); |
416 | 472 |
417 switch (color_id) { | 473 switch (color_id) { |
418 // Link | 474 // Link |
419 case kColorId_LinkDisabled: | 475 case kColorId_LinkDisabled: |
420 return system_colors_[COLOR_WINDOWTEXT]; | 476 return system_colors_[COLOR_WINDOWTEXT]; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 case NativeTheme::kColorId_CallToActionColor: | 665 case NativeTheme::kColorId_CallToActionColor: |
610 return kCallToActionColorInvert; | 666 return kCallToActionColorInvert; |
611 default: | 667 default: |
612 return color_utils::InvertColor(GetAuraColor(color_id, this)); | 668 return color_utils::InvertColor(GetAuraColor(color_id, this)); |
613 } | 669 } |
614 } | 670 } |
615 | 671 |
616 return GetAuraColor(color_id, this); | 672 return GetAuraColor(color_id, this); |
617 } | 673 } |
618 | 674 |
| 675 void NativeThemeWin::PaintIndirect(SkCanvas* canvas, |
| 676 Part part, |
| 677 State state, |
| 678 const gfx::Rect& rect, |
| 679 const ExtraParams& extra) const { |
| 680 // TODO(asvitkine): This path is pretty inefficient - for each paint operation |
| 681 // it creates a new offscreen bitmap Skia canvas. This can |
| 682 // be sped up by doing it only once per part/state and |
| 683 // keeping a cache of the resulting bitmaps. |
| 684 |
| 685 // Create an offscreen canvas that is backed by an HDC. |
| 686 sk_sp<skia::BitmapPlatformDevice> device( |
| 687 skia::BitmapPlatformDevice::Create( |
| 688 rect.width(), rect.height(), false, NULL)); |
| 689 DCHECK(device); |
| 690 SkCanvas offscreen_canvas(device.get()); |
| 691 DCHECK(skia::SupportsPlatformPaint(&offscreen_canvas)); |
| 692 |
| 693 // Some of the Windows theme drawing operations do not write correct alpha |
| 694 // values for fully-opaque pixels; instead the pixels get alpha 0. This is |
| 695 // especially a problem on Windows XP or when using the Classic theme. |
| 696 // |
| 697 // To work-around this, mark all pixels with a placeholder value, to detect |
| 698 // which pixels get touched by the paint operation. After paint, set any |
| 699 // pixels that have alpha 0 to opaque and placeholders to fully-transparent. |
| 700 const SkColor placeholder = SkColorSetARGB(1, 0, 0, 0); |
| 701 offscreen_canvas.clear(placeholder); |
| 702 |
| 703 // Offset destination rects to have origin (0,0). |
| 704 gfx::Rect adjusted_rect(rect.size()); |
| 705 ExtraParams adjusted_extra(extra); |
| 706 switch (part) { |
| 707 case kProgressBar: |
| 708 adjusted_extra.progress_bar.value_rect_x = 0; |
| 709 adjusted_extra.progress_bar.value_rect_y = 0; |
| 710 break; |
| 711 case kScrollbarHorizontalTrack: |
| 712 case kScrollbarVerticalTrack: |
| 713 adjusted_extra.scrollbar_track.track_x = 0; |
| 714 adjusted_extra.scrollbar_track.track_y = 0; |
| 715 break; |
| 716 default: |
| 717 break; |
| 718 } |
| 719 // Draw the theme controls using existing HDC-drawing code. |
| 720 PaintDirect(&offscreen_canvas, part, state, adjusted_rect, adjusted_extra); |
| 721 |
| 722 SkBitmap bitmap = skia::ReadPixels(&offscreen_canvas); |
| 723 |
| 724 // Post-process the pixels to fix up the alpha values (see big comment above). |
| 725 const SkPMColor placeholder_value = SkPreMultiplyColor(placeholder); |
| 726 const int pixel_count = rect.width() * rect.height(); |
| 727 SkPMColor* pixels = bitmap.getAddr32(0, 0); |
| 728 for (int i = 0; i < pixel_count; i++) { |
| 729 if (pixels[i] == placeholder_value) { |
| 730 // Pixel wasn't touched - make it fully transparent. |
| 731 pixels[i] = SkPackARGB32(0, 0, 0, 0); |
| 732 } else if (SkGetPackedA32(pixels[i]) == 0) { |
| 733 // Pixel was touched but has incorrect alpha of 0, make it fully opaque. |
| 734 pixels[i] = SkPackARGB32(0xFF, |
| 735 SkGetPackedR32(pixels[i]), |
| 736 SkGetPackedG32(pixels[i]), |
| 737 SkGetPackedB32(pixels[i])); |
| 738 } |
| 739 } |
| 740 |
| 741 // Draw the offscreen bitmap to the destination canvas. |
| 742 canvas->drawBitmap(bitmap, rect.x(), rect.y()); |
| 743 } |
| 744 |
619 HRESULT NativeThemeWin::GetThemePartSize(ThemeName theme_name, | 745 HRESULT NativeThemeWin::GetThemePartSize(ThemeName theme_name, |
620 HDC hdc, | 746 HDC hdc, |
621 int part_id, | 747 int part_id, |
622 int state_id, | 748 int state_id, |
623 RECT* rect, | 749 RECT* rect, |
624 int ts, | 750 int ts, |
625 SIZE* size) const { | 751 SIZE* size) const { |
626 HANDLE handle = GetThemeHandle(theme_name); | 752 HANDLE handle = GetThemeHandle(theme_name); |
627 return (handle && get_theme_part_size_) ? | 753 return (handle && get_theme_part_size_) ? |
628 get_theme_part_size_(handle, hdc, part_id, state_id, rect, ts, size) : | 754 get_theme_part_size_(handle, hdc, part_id, state_id, rect, ts, size) : |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 // "4 / 13" is same as IE10 in classic theme. | 836 // "4 / 13" is same as IE10 in classic theme. |
711 int padding = (inner_rect.right - inner_rect.left) * 4 / 13; | 837 int padding = (inner_rect.right - inner_rect.left) * 4 / 13; |
712 InflateRect(&inner_rect, -padding, -padding); | 838 InflateRect(&inner_rect, -padding, -padding); |
713 int color_index = state == kDisabled ? COLOR_GRAYTEXT : COLOR_WINDOWTEXT; | 839 int color_index = state == kDisabled ? COLOR_GRAYTEXT : COLOR_WINDOWTEXT; |
714 FillRect(hdc, &inner_rect, GetSysColorBrush(color_index)); | 840 FillRect(hdc, &inner_rect, GetSysColorBrush(color_index)); |
715 } | 841 } |
716 | 842 |
717 return S_OK; | 843 return S_OK; |
718 } | 844 } |
719 | 845 |
| 846 HRESULT NativeThemeWin::PaintMenuSeparator( |
| 847 HDC hdc, |
| 848 const gfx::Rect& rect) const { |
| 849 RECT rect_win = rect.ToRECT(); |
| 850 |
| 851 HANDLE handle = GetThemeHandle(MENU); |
| 852 if (handle && draw_theme_) { |
| 853 // Delta is needed for non-classic to move separator up slightly. |
| 854 --rect_win.top; |
| 855 --rect_win.bottom; |
| 856 return draw_theme_(handle, hdc, MENU_POPUPSEPARATOR, MPI_NORMAL, &rect_win, |
| 857 NULL); |
| 858 } |
| 859 |
| 860 DrawEdge(hdc, &rect_win, EDGE_ETCHED, BF_TOP); |
| 861 return S_OK; |
| 862 } |
| 863 |
| 864 HRESULT NativeThemeWin::PaintMenuGutter(HDC hdc, |
| 865 const gfx::Rect& rect) const { |
| 866 RECT rect_win = rect.ToRECT(); |
| 867 HANDLE handle = GetThemeHandle(MENU); |
| 868 return (handle && draw_theme_) ? |
| 869 draw_theme_(handle, hdc, MENU_POPUPGUTTER, MPI_NORMAL, &rect_win, NULL) : |
| 870 E_NOTIMPL; |
| 871 } |
| 872 |
720 HRESULT NativeThemeWin::PaintMenuArrow( | 873 HRESULT NativeThemeWin::PaintMenuArrow( |
721 HDC hdc, | 874 HDC hdc, |
722 State state, | 875 State state, |
723 const gfx::Rect& rect, | 876 const gfx::Rect& rect, |
724 const MenuArrowExtraParams& extra) const { | 877 const MenuArrowExtraParams& extra) const { |
725 int state_id = MSM_NORMAL; | 878 int state_id = MSM_NORMAL; |
726 if (state == kDisabled) | 879 if (state == kDisabled) |
727 state_id = MSM_DISABLED; | 880 state_id = MSM_DISABLED; |
728 | 881 |
729 HANDLE handle = GetThemeHandle(MENU); | 882 HANDLE handle = GetThemeHandle(MENU); |
(...skipping 26 matching lines...) Expand all Loading... |
756 return result; | 909 return result; |
757 } | 910 } |
758 | 911 |
759 // For some reason, Windows uses the name DFCS_MENUARROWRIGHT to indicate a | 912 // For some reason, Windows uses the name DFCS_MENUARROWRIGHT to indicate a |
760 // left pointing arrow. This makes the following statement counterintuitive. | 913 // left pointing arrow. This makes the following statement counterintuitive. |
761 UINT pfc_state = extra.pointing_right ? DFCS_MENUARROW : DFCS_MENUARROWRIGHT; | 914 UINT pfc_state = extra.pointing_right ? DFCS_MENUARROW : DFCS_MENUARROWRIGHT; |
762 return PaintFrameControl(hdc, rect, DFC_MENU, pfc_state, extra.is_selected, | 915 return PaintFrameControl(hdc, rect, DFC_MENU, pfc_state, extra.is_selected, |
763 state); | 916 state); |
764 } | 917 } |
765 | 918 |
| 919 HRESULT NativeThemeWin::PaintMenuBackground(HDC hdc, |
| 920 const gfx::Rect& rect) const { |
| 921 HANDLE handle = GetThemeHandle(MENU); |
| 922 RECT rect_win = rect.ToRECT(); |
| 923 if (handle && draw_theme_) { |
| 924 HRESULT result = draw_theme_(handle, hdc, MENU_POPUPBACKGROUND, 0, |
| 925 &rect_win, NULL); |
| 926 FrameRect(hdc, &rect_win, GetSysColorBrush(COLOR_3DSHADOW)); |
| 927 return result; |
| 928 } |
| 929 |
| 930 FillRect(hdc, &rect_win, GetSysColorBrush(COLOR_MENU)); |
| 931 DrawEdge(hdc, &rect_win, EDGE_RAISED, BF_RECT); |
| 932 return S_OK; |
| 933 } |
| 934 |
766 HRESULT NativeThemeWin::PaintMenuCheck( | 935 HRESULT NativeThemeWin::PaintMenuCheck( |
767 HDC hdc, | 936 HDC hdc, |
768 State state, | 937 State state, |
769 const gfx::Rect& rect, | 938 const gfx::Rect& rect, |
770 const MenuCheckExtraParams& extra) const { | 939 const MenuCheckExtraParams& extra) const { |
771 HANDLE handle = GetThemeHandle(MENU); | 940 HANDLE handle = GetThemeHandle(MENU); |
772 if (handle && draw_theme_) { | 941 if (handle && draw_theme_) { |
773 const int state_id = extra.is_radio ? | 942 const int state_id = extra.is_radio ? |
774 ((state == kDisabled) ? MC_BULLETDISABLED : MC_BULLETNORMAL) : | 943 ((state == kDisabled) ? MC_BULLETDISABLED : MC_BULLETNORMAL) : |
775 ((state == kDisabled) ? MC_CHECKMARKDISABLED : MC_CHECKMARKNORMAL); | 944 ((state == kDisabled) ? MC_CHECKMARKDISABLED : MC_CHECKMARKNORMAL); |
(...skipping 12 matching lines...) Expand all Loading... |
788 HANDLE handle = GetThemeHandle(MENU); | 957 HANDLE handle = GetThemeHandle(MENU); |
789 if (!handle || !draw_theme_) | 958 if (!handle || !draw_theme_) |
790 return S_OK; // Nothing to do for background. | 959 return S_OK; // Nothing to do for background. |
791 | 960 |
792 int state_id = state == kDisabled ? MCB_DISABLED : MCB_NORMAL; | 961 int state_id = state == kDisabled ? MCB_DISABLED : MCB_NORMAL; |
793 RECT rect_win = rect.ToRECT(); | 962 RECT rect_win = rect.ToRECT(); |
794 return draw_theme_(handle, hdc, MENU_POPUPCHECKBACKGROUND, state_id, | 963 return draw_theme_(handle, hdc, MENU_POPUPCHECKBACKGROUND, state_id, |
795 &rect_win, NULL); | 964 &rect_win, NULL); |
796 } | 965 } |
797 | 966 |
| 967 HRESULT NativeThemeWin::PaintMenuItemBackground( |
| 968 HDC hdc, |
| 969 State state, |
| 970 const gfx::Rect& rect, |
| 971 const MenuItemExtraParams& extra) const { |
| 972 HANDLE handle = GetThemeHandle(MENU); |
| 973 RECT rect_win = rect.ToRECT(); |
| 974 int state_id = MPI_NORMAL; |
| 975 switch (state) { |
| 976 case kDisabled: |
| 977 state_id = extra.is_selected ? MPI_DISABLEDHOT : MPI_DISABLED; |
| 978 break; |
| 979 case kHovered: |
| 980 state_id = MPI_HOT; |
| 981 break; |
| 982 case kNormal: |
| 983 break; |
| 984 case kPressed: |
| 985 case kNumStates: |
| 986 NOTREACHED(); |
| 987 break; |
| 988 } |
| 989 |
| 990 if (handle && draw_theme_) |
| 991 return draw_theme_(handle, hdc, MENU_POPUPITEM, state_id, &rect_win, NULL); |
| 992 |
| 993 if (extra.is_selected) |
| 994 FillRect(hdc, &rect_win, GetSysColorBrush(COLOR_HIGHLIGHT)); |
| 995 return S_OK; |
| 996 } |
| 997 |
798 HRESULT NativeThemeWin::PaintPushButton(HDC hdc, | 998 HRESULT NativeThemeWin::PaintPushButton(HDC hdc, |
799 Part part, | 999 Part part, |
800 State state, | 1000 State state, |
801 const gfx::Rect& rect, | 1001 const gfx::Rect& rect, |
802 const ButtonExtraParams& extra) const { | 1002 const ButtonExtraParams& extra) const { |
803 int state_id = extra.is_default ? PBS_DEFAULTED : PBS_NORMAL; | 1003 int state_id = extra.is_default ? PBS_DEFAULTED : PBS_NORMAL; |
804 switch (state) { | 1004 switch (state) { |
805 case kDisabled: | 1005 case kDisabled: |
806 state_id = PBS_DISABLED; | 1006 state_id = PBS_DISABLED; |
807 break; | 1007 break; |
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1879 break; | 2079 break; |
1880 case LAST: | 2080 case LAST: |
1881 NOTREACHED(); | 2081 NOTREACHED(); |
1882 break; | 2082 break; |
1883 } | 2083 } |
1884 theme_handles_[theme_name] = handle; | 2084 theme_handles_[theme_name] = handle; |
1885 return handle; | 2085 return handle; |
1886 } | 2086 } |
1887 | 2087 |
1888 } // namespace ui | 2088 } // namespace ui |
OLD | NEW |