Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: ui/native_theme/native_theme_win.cc

Issue 2090003003: Remove NativeThemeWin::PaintIndirect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/native_theme/native_theme_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
26 #include "third_party/skia/include/core/SkShader.h" 24 #include "third_party/skia/include/core/SkShader.h"
27 #include "ui/base/material_design/material_design_controller.h" 25 #include "ui/base/material_design/material_design_controller.h"
28 #include "ui/display/win/dpi.h" 26 #include "ui/display/win/dpi.h"
29 #include "ui/gfx/color_palette.h" 27 #include "ui/gfx/color_palette.h"
30 #include "ui/gfx/color_utils.h" 28 #include "ui/gfx/color_utils.h"
31 #include "ui/gfx/gdi_util.h" 29 #include "ui/gfx/gdi_util.h"
32 #include "ui/gfx/geometry/rect.h" 30 #include "ui/gfx/geometry/rect.h"
33 #include "ui/gfx/geometry/rect_conversions.h" 31 #include "ui/gfx/geometry/rect_conversions.h"
34 #include "ui/gfx/skia_util.h" 32 #include "ui/gfx/skia_util.h"
35 #include "ui/native_theme/common_theme.h" 33 #include "ui/native_theme/common_theme.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 case kMenuPopupSeparator: 242 case kMenuPopupSeparator:
245 PaintMenuSeparator(canvas, rect); 243 PaintMenuSeparator(canvas, rect);
246 return; 244 return;
247 case kMenuPopupBackground: 245 case kMenuPopupBackground:
248 PaintMenuBackground(canvas, rect); 246 PaintMenuBackground(canvas, rect);
249 return; 247 return;
250 case kMenuItemBackground: 248 case kMenuItemBackground:
251 CommonThemePaintMenuItemBackground(this, canvas, state, rect, 249 CommonThemePaintMenuItemBackground(this, canvas, state, rect,
252 extra.menu_item); 250 extra.menu_item);
253 return; 251 return;
252 case kScrollbarCorner:
253 canvas->drawColor(SK_ColorWHITE, SkXfermode::kSrc_Mode);
254 return;
254 default: 255 default:
255 break; 256 break;
256 } 257 }
257 258
258 bool needs_paint_indirect = false; 259 skia::ScopedPlatformPaint scoped_platform_paint(canvas);
259 if (!skia::SupportsPlatformPaint(canvas)) { 260 HDC hdc = scoped_platform_paint.GetPlatformSurface();
260 // This block will only get hit with --enable-accelerated-drawing flag. 261
261 needs_paint_indirect = true; 262 switch (part) {
262 } else { 263 case kCheckbox:
263 // Scrollbar components on Windows Classic theme (on all Windows versions) 264 PaintCheckbox(hdc, part, state, rect, extra.button);
264 // have particularly problematic alpha values, so always draw them 265 return;
265 // indirectly. In addition, scrollbar thumbs and grippers for the Windows XP 266 case kInnerSpinButton:
266 // theme (available only on Windows XP) also need their alpha values 267 PaintSpinButton(hdc, part, state, rect, extra.inner_spin);
267 // fixed. 268 return;
268 switch (part) { 269 case kMenuList:
269 case kScrollbarDownArrow: 270 PaintMenuList(hdc, state, rect, extra.menu_list);
270 case kScrollbarUpArrow: 271 return;
271 case kScrollbarLeftArrow: 272 case kMenuCheck:
272 case kScrollbarRightArrow: 273 PaintMenuCheck(hdc, state, rect, extra.menu_check);
273 needs_paint_indirect = !GetThemeHandle(SCROLLBAR); 274 return;
274 break; 275 case kMenuCheckBackground:
275 case kScrollbarHorizontalThumb: 276 PaintMenuCheckBackground(hdc, state, rect);
276 case kScrollbarVerticalThumb: 277 return;
277 case kScrollbarHorizontalGripper: 278 case kMenuPopupArrow:
278 case kScrollbarVerticalGripper: 279 PaintMenuArrow(hdc, state, rect, extra.menu_arrow);
279 needs_paint_indirect = !GetThemeHandle(SCROLLBAR) || 280 return;
280 base::win::GetVersion() == base::win::VERSION_XP; 281 case kProgressBar:
281 break; 282 PaintProgressBar(hdc, rect, extra.progress_bar);
282 default: 283 return;
283 break; 284 case kPushButton:
284 } 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 case kSliderTrack:
321 case kSliderThumb:
322 case kMaxPart:
323 case kMenuPopupGutter:
324 case kMenuPopupSeparator:
325 case kMenuPopupBackground:
326 case kMenuItemBackground:
327 case kScrollbarCorner:
Peter Kasting 2016/07/06 21:04:33 Nit: Put these in enum order within this group. P
tomhudson 2016/07/07 12:51:51 Acknowledged. Changed to default:
328 NOTREACHED();
285 } 329 }
286
287 if (needs_paint_indirect)
288 PaintIndirect(canvas, part, state, rect, extra);
289 else
290 PaintDirect(canvas, part, state, rect, extra);
291 } 330 }
292 331
293 NativeThemeWin::NativeThemeWin() 332 NativeThemeWin::NativeThemeWin()
294 : draw_theme_(NULL), 333 : draw_theme_(NULL),
295 draw_theme_ex_(NULL), 334 draw_theme_ex_(NULL),
296 get_theme_color_(NULL), 335 get_theme_color_(NULL),
297 get_theme_content_rect_(NULL), 336 get_theme_content_rect_(NULL),
298 get_theme_part_size_(NULL), 337 get_theme_part_size_(NULL),
299 open_theme_(NULL), 338 open_theme_(NULL),
300 close_theme_(NULL), 339 close_theme_(NULL),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 canvas->drawLine(position_x, rect.y(), position_x, rect.bottom(), paint); 408 canvas->drawLine(position_x, rect.y(), position_x, rect.bottom(), paint);
370 } 409 }
371 410
372 void NativeThemeWin::PaintMenuBackground(SkCanvas* canvas, 411 void NativeThemeWin::PaintMenuBackground(SkCanvas* canvas,
373 const gfx::Rect& rect) const { 412 const gfx::Rect& rect) const {
374 SkPaint paint; 413 SkPaint paint;
375 paint.setColor(GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor)); 414 paint.setColor(GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor));
376 canvas->drawRect(gfx::RectToSkRect(rect), paint); 415 canvas->drawRect(gfx::RectToSkRect(rect), paint);
377 } 416 }
378 417
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
467 SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const { 418 SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const {
468 const bool md = ui::MaterialDesignController::IsModeMaterial(); 419 const bool md = ui::MaterialDesignController::IsModeMaterial();
469 if (!md) { 420 if (!md) {
470 // Link: 421 // Link:
471 const SkColor kLinkPressedColor = SkColorSetRGB(200, 0, 0); 422 const SkColor kLinkPressedColor = SkColorSetRGB(200, 0, 0);
472 423
473 switch (color_id) { 424 switch (color_id) {
474 // Link 425 // Link
475 case kColorId_LinkDisabled: 426 case kColorId_LinkDisabled:
476 return system_colors_[COLOR_WINDOWTEXT]; 427 return system_colors_[COLOR_WINDOWTEXT];
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 case NativeTheme::kColorId_CallToActionColor: 616 case NativeTheme::kColorId_CallToActionColor:
666 return kCallToActionColorInvert; 617 return kCallToActionColorInvert;
667 default: 618 default:
668 return color_utils::InvertColor(GetAuraColor(color_id, this)); 619 return color_utils::InvertColor(GetAuraColor(color_id, this));
669 } 620 }
670 } 621 }
671 622
672 return GetAuraColor(color_id, this); 623 return GetAuraColor(color_id, this);
673 } 624 }
674 625
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
745 HRESULT NativeThemeWin::GetThemePartSize(ThemeName theme_name, 626 HRESULT NativeThemeWin::GetThemePartSize(ThemeName theme_name,
746 HDC hdc, 627 HDC hdc,
747 int part_id, 628 int part_id,
748 int state_id, 629 int state_id,
749 RECT* rect, 630 RECT* rect,
750 int ts, 631 int ts,
751 SIZE* size) const { 632 SIZE* size) const {
752 HANDLE handle = GetThemeHandle(theme_name); 633 HANDLE handle = GetThemeHandle(theme_name);
753 return (handle && get_theme_part_size_) ? 634 return (handle && get_theme_part_size_) ?
754 get_theme_part_size_(handle, hdc, part_id, state_id, rect, ts, size) : 635 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
836 // "4 / 13" is same as IE10 in classic theme. 717 // "4 / 13" is same as IE10 in classic theme.
837 int padding = (inner_rect.right - inner_rect.left) * 4 / 13; 718 int padding = (inner_rect.right - inner_rect.left) * 4 / 13;
838 InflateRect(&inner_rect, -padding, -padding); 719 InflateRect(&inner_rect, -padding, -padding);
839 int color_index = state == kDisabled ? COLOR_GRAYTEXT : COLOR_WINDOWTEXT; 720 int color_index = state == kDisabled ? COLOR_GRAYTEXT : COLOR_WINDOWTEXT;
840 FillRect(hdc, &inner_rect, GetSysColorBrush(color_index)); 721 FillRect(hdc, &inner_rect, GetSysColorBrush(color_index));
841 } 722 }
842 723
843 return S_OK; 724 return S_OK;
844 } 725 }
845 726
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
873 HRESULT NativeThemeWin::PaintMenuArrow( 727 HRESULT NativeThemeWin::PaintMenuArrow(
874 HDC hdc, 728 HDC hdc,
875 State state, 729 State state,
876 const gfx::Rect& rect, 730 const gfx::Rect& rect,
877 const MenuArrowExtraParams& extra) const { 731 const MenuArrowExtraParams& extra) const {
878 int state_id = MSM_NORMAL; 732 int state_id = MSM_NORMAL;
879 if (state == kDisabled) 733 if (state == kDisabled)
880 state_id = MSM_DISABLED; 734 state_id = MSM_DISABLED;
881 735
882 HANDLE handle = GetThemeHandle(MENU); 736 HANDLE handle = GetThemeHandle(MENU);
(...skipping 26 matching lines...) Expand all
909 return result; 763 return result;
910 } 764 }
911 765
912 // For some reason, Windows uses the name DFCS_MENUARROWRIGHT to indicate a 766 // For some reason, Windows uses the name DFCS_MENUARROWRIGHT to indicate a
913 // left pointing arrow. This makes the following statement counterintuitive. 767 // left pointing arrow. This makes the following statement counterintuitive.
914 UINT pfc_state = extra.pointing_right ? DFCS_MENUARROW : DFCS_MENUARROWRIGHT; 768 UINT pfc_state = extra.pointing_right ? DFCS_MENUARROW : DFCS_MENUARROWRIGHT;
915 return PaintFrameControl(hdc, rect, DFC_MENU, pfc_state, extra.is_selected, 769 return PaintFrameControl(hdc, rect, DFC_MENU, pfc_state, extra.is_selected,
916 state); 770 state);
917 } 771 }
918 772
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
935 HRESULT NativeThemeWin::PaintMenuCheck( 773 HRESULT NativeThemeWin::PaintMenuCheck(
936 HDC hdc, 774 HDC hdc,
937 State state, 775 State state,
938 const gfx::Rect& rect, 776 const gfx::Rect& rect,
939 const MenuCheckExtraParams& extra) const { 777 const MenuCheckExtraParams& extra) const {
940 HANDLE handle = GetThemeHandle(MENU); 778 HANDLE handle = GetThemeHandle(MENU);
941 if (handle && draw_theme_) { 779 if (handle && draw_theme_) {
942 const int state_id = extra.is_radio ? 780 const int state_id = extra.is_radio ?
943 ((state == kDisabled) ? MC_BULLETDISABLED : MC_BULLETNORMAL) : 781 ((state == kDisabled) ? MC_BULLETDISABLED : MC_BULLETNORMAL) :
944 ((state == kDisabled) ? MC_CHECKMARKDISABLED : MC_CHECKMARKNORMAL); 782 ((state == kDisabled) ? MC_CHECKMARKDISABLED : MC_CHECKMARKNORMAL);
(...skipping 12 matching lines...) Expand all
957 HANDLE handle = GetThemeHandle(MENU); 795 HANDLE handle = GetThemeHandle(MENU);
958 if (!handle || !draw_theme_) 796 if (!handle || !draw_theme_)
959 return S_OK; // Nothing to do for background. 797 return S_OK; // Nothing to do for background.
960 798
961 int state_id = state == kDisabled ? MCB_DISABLED : MCB_NORMAL; 799 int state_id = state == kDisabled ? MCB_DISABLED : MCB_NORMAL;
962 RECT rect_win = rect.ToRECT(); 800 RECT rect_win = rect.ToRECT();
963 return draw_theme_(handle, hdc, MENU_POPUPCHECKBACKGROUND, state_id, 801 return draw_theme_(handle, hdc, MENU_POPUPCHECKBACKGROUND, state_id,
964 &rect_win, NULL); 802 &rect_win, NULL);
965 } 803 }
966 804
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
998 HRESULT NativeThemeWin::PaintPushButton(HDC hdc, 805 HRESULT NativeThemeWin::PaintPushButton(HDC hdc,
999 Part part, 806 Part part,
1000 State state, 807 State state,
1001 const gfx::Rect& rect, 808 const gfx::Rect& rect,
1002 const ButtonExtraParams& extra) const { 809 const ButtonExtraParams& extra) const {
1003 int state_id = extra.is_default ? PBS_DEFAULTED : PBS_NORMAL; 810 int state_id = extra.is_default ? PBS_DEFAULTED : PBS_NORMAL;
1004 switch (state) { 811 switch (state) {
1005 case kDisabled: 812 case kDisabled:
1006 state_id = PBS_DISABLED; 813 state_id = PBS_DISABLED;
1007 break; 814 break;
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 break; 1886 break;
2080 case LAST: 1887 case LAST:
2081 NOTREACHED(); 1888 NOTREACHED();
2082 break; 1889 break;
2083 } 1890 }
2084 theme_handles_[theme_name] = handle; 1891 theme_handles_[theme_name] = handle;
2085 return handle; 1892 return handle;
2086 } 1893 }
2087 1894
2088 } // namespace ui 1895 } // namespace ui
OLDNEW
« no previous file with comments | « ui/native_theme/native_theme_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698