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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 314 |
309 case kSliderTrack: | 315 case kSliderTrack: |
310 case kSliderThumb: | 316 case kSliderThumb: |
311 default: | 317 default: |
312 // While transitioning NativeThemeWin to the single Paint() entry point, | 318 // While transitioning NativeThemeWin to the single Paint() entry point, |
313 // unsupported parts will DCHECK here. | 319 // unsupported parts will DCHECK here. |
314 DCHECK(false); | 320 DCHECK(false); |
315 } | 321 } |
316 } | 322 } |
317 | 323 |
| 324 SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const { |
| 325 switch (color_id) { |
| 326 case kColorId_DialogBackground: |
| 327 // TODO(benrg): Should this use the new Windows theme functions? The old |
| 328 // code in DialogClientView::OnPaint used GetSysColor(COLOR_3DFACE). |
| 329 return WinColorToSkColor(GetSysColor(COLOR_3DFACE)); |
| 330 default: |
| 331 NOTREACHED() << "Invalid color_id: " << color_id; |
| 332 break; |
| 333 } |
| 334 return kInvalidColorIdColor; |
| 335 } |
| 336 |
318 HRESULT NativeThemeWin::PaintScrollbarArrow( | 337 HRESULT NativeThemeWin::PaintScrollbarArrow( |
319 HDC hdc, | 338 HDC hdc, |
320 Part part, | 339 Part part, |
321 State state, | 340 State state, |
322 const gfx::Rect& rect, | 341 const gfx::Rect& rect, |
323 const ScrollbarArrowExtraParams& extra) const { | 342 const ScrollbarArrowExtraParams& extra) const { |
324 static int state_id_matrix[4][kMaxState] = { | 343 static int state_id_matrix[4][kMaxState] = { |
325 ABS_DOWNDISABLED, ABS_DOWNHOT, ABS_DOWNNORMAL, ABS_DOWNPRESSED, | 344 ABS_DOWNDISABLED, ABS_DOWNHOT, ABS_DOWNNORMAL, ABS_DOWNPRESSED, |
326 ABS_LEFTDISABLED, ABS_LEFTHOT, ABS_LEFTNORMAL, ABS_LEFTPRESSED, | 345 ABS_LEFTDISABLED, ABS_LEFTHOT, ABS_LEFTNORMAL, ABS_LEFTPRESSED, |
327 ABS_RIGHTDISABLED, ABS_RIGHTHOT, ABS_RIGHTNORMAL, ABS_RIGHTPRESSED, | 346 ABS_RIGHTDISABLED, ABS_RIGHTHOT, ABS_RIGHTNORMAL, ABS_RIGHTPRESSED, |
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1676 } | 1695 } |
1677 break; | 1696 break; |
1678 default: | 1697 default: |
1679 NOTREACHED() << "Invalid part: " << part; | 1698 NOTREACHED() << "Invalid part: " << part; |
1680 break; | 1699 break; |
1681 } | 1700 } |
1682 return state_id; | 1701 return state_id; |
1683 } | 1702 } |
1684 | 1703 |
1685 } // namespace gfx | 1704 } // namespace gfx |
OLD | NEW |