| OLD | NEW |
| 1 // Copyright (c) 2011 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/gfx/native_theme_win.h" | 5 #include "ui/gfx/native_theme_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <uxtheme.h> | 8 #include <uxtheme.h> |
| 9 #include <vsstyle.h> | 9 #include <vsstyle.h> |
| 10 #include <vssym32.h> | 10 #include <vssym32.h> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/scoped_handle.h" | 14 #include "base/memory/scoped_handle.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/win/scoped_gdi_object.h" | 16 #include "base/win/scoped_gdi_object.h" |
| 17 #include "base/win/scoped_hdc.h" | 17 #include "base/win/scoped_hdc.h" |
| 18 #include "base/win/scoped_select_object.h" | 18 #include "base/win/scoped_select_object.h" |
| 19 #include "base/win/windows_version.h" | 19 #include "base/win/windows_version.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/SkColorPriv.h" | 23 #include "third_party/skia/include/core/SkColorPriv.h" |
| 24 #include "third_party/skia/include/core/SkShader.h" | 24 #include "third_party/skia/include/core/SkShader.h" |
| 25 #include "ui/gfx/gdi_util.h" | 25 #include "ui/gfx/gdi_util.h" |
| 26 #include "ui/gfx/rect.h" | 26 #include "ui/gfx/rect.h" |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 // Theme colors returned by GetSystemColor(). |
| 30 const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128); | 31 const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128); |
| 32 // Dialogs: |
| 33 const SkColor kDialogBackgroundColor = SkColorSetRGB(200, 200, 200); |
| 34 // FocusableBorder (should be unused on Win): |
| 35 const SkColor kFocusedBorderColor= SkColorSetRGB(0x4D, 0x90, 0xFE); |
| 36 const SkColor kUnfocusedBorderColor = SkColorSetRGB(0xD9, 0xD9, 0xD9); |
| 37 // TextButton: |
| 38 const SkColor kTextButtonBackgroundColor = SkColorSetRGB(0xde, 0xde, 0xde); |
| 39 const SkColor kTextButtonEnabledColor = SkColorSetRGB(6, 45, 117); |
| 40 const SkColor kTextButtonDisabledColor = SkColorSetRGB(161, 161, 146); |
| 41 const SkColor kTextButtonHighlightColor = SkColorSetARGB(200, 255, 255, 255); |
| 42 const SkColor kTextButtonHoverColor = kTextButtonEnabledColor; |
| 43 // MenuItem: |
| 44 const SkColor kEnabledMenuItemForegroundColor = kTextButtonEnabledColor; |
| 45 const SkColor kDisabledMenuItemForegroundColor = kTextButtonDisabledColor; |
| 46 const SkColor kFocusedMenuItemBackgroundColor = SkColorSetRGB(246, 249, 253); |
| 31 | 47 |
| 32 SkColor WinColorToSkColor(COLORREF color) { | 48 SkColor WinColorToSkColor(COLORREF color) { |
| 33 return SkColorSetRGB(GetRValue(color), GetGValue(color), GetBValue(color)); | 49 return SkColorSetRGB(GetRValue(color), GetGValue(color), GetBValue(color)); |
| 34 } | 50 } |
| 35 | 51 |
| 36 void SetCheckerboardShader(SkPaint* paint, const RECT& align_rect) { | 52 void SetCheckerboardShader(SkPaint* paint, const RECT& align_rect) { |
| 37 // Create a 2x2 checkerboard pattern using the 3D face and highlight colors. | 53 // Create a 2x2 checkerboard pattern using the 3D face and highlight colors. |
| 38 SkColor face = skia::COLORREFToSkColor(GetSysColor(COLOR_3DFACE)); | 54 SkColor face = skia::COLORREFToSkColor(GetSysColor(COLOR_3DFACE)); |
| 39 SkColor highlight = skia::COLORREFToSkColor(GetSysColor(COLOR_3DHILIGHT)); | 55 SkColor highlight = skia::COLORREFToSkColor(GetSysColor(COLOR_3DHILIGHT)); |
| 40 SkColor buffer[] = { face, highlight, highlight, face }; | 56 SkColor buffer[] = { face, highlight, highlight, face }; |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 case kSliderThumb: | 357 case kSliderThumb: |
| 342 default: | 358 default: |
| 343 // While transitioning NativeThemeWin to the single Paint() entry point, | 359 // While transitioning NativeThemeWin to the single Paint() entry point, |
| 344 // unsupported parts will DCHECK here. | 360 // unsupported parts will DCHECK here. |
| 345 DCHECK(false); | 361 DCHECK(false); |
| 346 } | 362 } |
| 347 } | 363 } |
| 348 | 364 |
| 349 SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const { | 365 SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const { |
| 350 switch (color_id) { | 366 switch (color_id) { |
| 367 |
| 368 // Dialogs |
| 351 case kColorId_DialogBackground: | 369 case kColorId_DialogBackground: |
| 352 // TODO(benrg): Should this use the new Windows theme functions? The old | 370 // TODO(benrg): Should this use the new Windows theme functions? The old |
| 353 // code in DialogClientView::OnPaint used GetSysColor(COLOR_3DFACE). | 371 // code in DialogClientView::OnPaint used GetSysColor(COLOR_3DFACE). |
| 354 return WinColorToSkColor(GetSysColor(COLOR_3DFACE)); | 372 return WinColorToSkColor(GetSysColor(COLOR_3DFACE)); |
| 373 |
| 374 // TextButton |
| 375 case kColorId_TextButtonBackgroundColor: |
| 376 return kTextButtonBackgroundColor; |
| 377 case kColorId_TextButtonEnabledColor: |
| 378 return kTextButtonEnabledColor; |
| 379 case kColorId_TextButtonDisabledColor: |
| 380 return kTextButtonDisabledColor; |
| 381 case kColorId_TextButtonHighlightColor: |
| 382 return kTextButtonHighlightColor; |
| 383 case kColorId_TextButtonHoverColor: |
| 384 return kTextButtonHoverColor; |
| 385 |
| 386 // MenuItem |
| 387 case kColorId_EnabledMenuItemForegroundColor: |
| 388 return kEnabledMenuItemForegroundColor; |
| 389 case kColorId_DisabledMenuItemForegroundColor: |
| 390 return kDisabledMenuItemForegroundColor; |
| 391 case kColorId_FocusedMenuItemBackgroundColor: |
| 392 return kFocusedMenuItemBackgroundColor; |
| 393 |
| 355 default: | 394 default: |
| 356 NOTREACHED() << "Invalid color_id: " << color_id; | 395 NOTREACHED() << "Invalid color_id: " << color_id; |
| 357 break; | 396 break; |
| 358 } | 397 } |
| 359 return kInvalidColorIdColor; | 398 return kInvalidColorIdColor; |
| 360 } | 399 } |
| 361 | 400 |
| 362 void NativeThemeWin::PaintToNonPlatformCanvas(SkCanvas* canvas, | 401 void NativeThemeWin::PaintToNonPlatformCanvas(SkCanvas* canvas, |
| 363 Part part, | 402 Part part, |
| 364 State state, | 403 State state, |
| (...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1694 handle = open_theme_(NULL, L"Spin"); | 1733 handle = open_theme_(NULL, L"Spin"); |
| 1695 break; | 1734 break; |
| 1696 default: | 1735 default: |
| 1697 NOTREACHED(); | 1736 NOTREACHED(); |
| 1698 } | 1737 } |
| 1699 theme_handles_[theme_name] = handle; | 1738 theme_handles_[theme_name] = handle; |
| 1700 return handle; | 1739 return handle; |
| 1701 } | 1740 } |
| 1702 | 1741 |
| 1703 } // namespace gfx | 1742 } // namespace gfx |
| OLD | NEW |