OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128); | |
31 | |
32 SkColor WinColorToSkColor(COLORREF color) { | |
33 return SkColorSetRGB(GetRValue(color), GetGValue(color), GetBValue(color)); | |
34 } | |
35 | |
30 void SetCheckerboardShader(SkPaint* paint, const RECT& align_rect) { | 36 void SetCheckerboardShader(SkPaint* paint, const RECT& align_rect) { |
31 // Create a 2x2 checkerboard pattern using the 3D face and highlight colors. | 37 // Create a 2x2 checkerboard pattern using the 3D face and highlight colors. |
32 SkColor face = skia::COLORREFToSkColor(GetSysColor(COLOR_3DFACE)); | 38 SkColor face = skia::COLORREFToSkColor(GetSysColor(COLOR_3DFACE)); |
33 SkColor highlight = skia::COLORREFToSkColor(GetSysColor(COLOR_3DHILIGHT)); | 39 SkColor highlight = skia::COLORREFToSkColor(GetSysColor(COLOR_3DHILIGHT)); |
34 SkColor buffer[] = { face, highlight, highlight, face }; | 40 SkColor buffer[] = { face, highlight, highlight, face }; |
35 // Confusing bit: we first create a temporary bitmap with our desired pattern, | 41 // Confusing bit: we first create a temporary bitmap with our desired pattern, |
36 // then copy it to another bitmap. The temporary bitmap doesn't take | 42 // then copy it to another bitmap. The temporary bitmap doesn't take |
37 // ownership of the pixel data, and so will point to garbage when this | 43 // ownership of the pixel data, and so will point to garbage when this |
38 // function returns. The copy will copy the pixel data into a place owned by | 44 // function returns. The copy will copy the pixel data into a place owned by |
39 // the bitmap, which is in turn owned by the shader, etc., so it will live | 45 // the bitmap, which is in turn owned by the shader, etc., so it will live |
(...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1675 break; | 1681 break; |
1676 } | 1682 } |
1677 break; | 1683 break; |
1678 default: | 1684 default: |
1679 NOTREACHED() << "Invalid part: " << part; | 1685 NOTREACHED() << "Invalid part: " << part; |
1680 break; | 1686 break; |
1681 } | 1687 } |
1682 return state_id; | 1688 return state_id; |
1683 } | 1689 } |
1684 | 1690 |
1691 SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const { | |
1692 switch (color_id) { | |
1693 case kColorId_DialogBackground: | |
1694 // TODO(benrg): Should this use the new Windows theme functions? The old | |
1695 // code in DialogClientView::OnPaint used GetSysColor(COLOR_3DFACE). | |
1696 return WinColorToSkColor(GetSysColor(COLOR_3DFACE)); | |
1697 default: | |
1698 NOTREACHED() << "Invalid color_id: " << color_id; | |
1699 break; | |
1700 } | |
1701 return kInvalidColorIdColor; | |
1702 } | |
1703 | |
benrg
2011/11/22 21:43:49
Until other methods are rearranged, there's no cor
| |
1685 } // namespace gfx | 1704 } // namespace gfx |
OLD | NEW |