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 <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/bitmap_platform_device.h" | 20 #include "skia/ext/bitmap_platform_device.h" |
21 #include "skia/ext/platform_canvas.h" | 21 #include "skia/ext/platform_canvas.h" |
22 #include "skia/ext/skia_utils_win.h" | 22 #include "skia/ext/skia_utils_win.h" |
23 #include "third_party/skia/include/core/SkCanvas.h" | 23 #include "third_party/skia/include/core/SkCanvas.h" |
24 #include "third_party/skia/include/core/SkColorPriv.h" | 24 #include "third_party/skia/include/core/SkColorPriv.h" |
25 #include "third_party/skia/include/core/SkShader.h" | 25 #include "third_party/skia/include/core/SkShader.h" |
26 #include "ui/gfx/color_utils.h" | 26 #include "ui/gfx/color_utils.h" |
27 #include "ui/gfx/gdi_util.h" | 27 #include "ui/gfx/gdi_util.h" |
28 #include "ui/gfx/rect.h" | 28 #include "ui/gfx/rect.h" |
29 #include "ui/gfx/rect_conversions.h" | 29 #include "ui/gfx/rect_conversions.h" |
30 #include "ui/gfx/sys_color_change_listener.h" | |
31 #include "ui/gfx/win/dpi.h" | 30 #include "ui/gfx/win/dpi.h" |
32 #include "ui/native_theme/common_theme.h" | 31 #include "ui/native_theme/common_theme.h" |
33 | 32 |
34 // This was removed from Winvers.h but is still used. | 33 // This was removed from Winvers.h but is still used. |
35 #if !defined(COLOR_MENUHIGHLIGHT) | 34 #if !defined(COLOR_MENUHIGHLIGHT) |
36 #define COLOR_MENUHIGHLIGHT 29 | 35 #define COLOR_MENUHIGHLIGHT 29 |
37 #endif | 36 #endif |
38 | 37 |
39 namespace { | 38 namespace { |
40 | 39 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 } | 204 } |
206 } | 205 } |
207 | 206 |
208 bool NativeThemeWin::IsClassicTheme(ThemeName name) const { | 207 bool NativeThemeWin::IsClassicTheme(ThemeName name) const { |
209 if (!theme_dll_) | 208 if (!theme_dll_) |
210 return true; | 209 return true; |
211 | 210 |
212 return !GetThemeHandle(name); | 211 return !GetThemeHandle(name); |
213 } | 212 } |
214 | 213 |
215 // TODO(sky): seems like we should default to NativeThemeWin, but that currently | |
216 // breaks a couple of tests (FocusTraversalTest.NormalTraversal in | |
217 // views_unittests). | |
218 #if !defined(USE_AURA) | |
219 // static | |
220 NativeTheme* NativeTheme::instance() { | |
221 return NativeThemeWin::instance(); | |
222 } | |
223 #endif | |
224 | |
225 // static | 214 // static |
226 NativeThemeWin* NativeThemeWin::instance() { | 215 NativeThemeWin* NativeThemeWin::instance() { |
227 CR_DEFINE_STATIC_LOCAL(NativeThemeWin, s_native_theme, ()); | 216 CR_DEFINE_STATIC_LOCAL(NativeThemeWin, s_native_theme, ()); |
228 return &s_native_theme; | 217 return &s_native_theme; |
229 } | 218 } |
230 | 219 |
231 gfx::Size NativeThemeWin::GetPartSize(Part part, | 220 gfx::Size NativeThemeWin::GetPartSize(Part part, |
232 State state, | 221 State state, |
233 const ExtraParams& extra) const { | 222 const ExtraParams& extra) const { |
234 gfx::Size part_size = CommonThemeGetPartSize(part, state, extra); | 223 gfx::Size part_size = CommonThemeGetPartSize(part, state, extra); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 // todo (cpu): fix this soon. Making a call to CloseHandles() here breaks | 381 // todo (cpu): fix this soon. Making a call to CloseHandles() here breaks |
393 // certain tests and the reliability bots. | 382 // certain tests and the reliability bots. |
394 // CloseHandles(); | 383 // CloseHandles(); |
395 FreeLibrary(theme_dll_); | 384 FreeLibrary(theme_dll_); |
396 } | 385 } |
397 } | 386 } |
398 | 387 |
399 void NativeThemeWin::OnSysColorChange() { | 388 void NativeThemeWin::OnSysColorChange() { |
400 UpdateSystemColors(); | 389 UpdateSystemColors(); |
401 is_using_high_contrast_valid_ = false; | 390 is_using_high_contrast_valid_ = false; |
| 391 NotifyObservers(); |
402 } | 392 } |
403 | 393 |
404 void NativeThemeWin::UpdateSystemColors() { | 394 void NativeThemeWin::UpdateSystemColors() { |
405 for (int i = 0; i < arraysize(kSystemColors); ++i) { | 395 for (int i = 0; i < arraysize(kSystemColors); ++i) { |
406 system_colors_[kSystemColors[i]] = | 396 system_colors_[kSystemColors[i]] = |
407 color_utils::GetSysSkColor(kSystemColors[i]); | 397 color_utils::GetSysSkColor(kSystemColors[i]); |
408 } | 398 } |
409 } | 399 } |
410 | 400 |
411 void NativeThemeWin::PaintDirect(SkCanvas* canvas, | 401 void NativeThemeWin::PaintDirect(SkCanvas* canvas, |
(...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2150 handle = open_theme_(NULL, L"Spin"); | 2140 handle = open_theme_(NULL, L"Spin"); |
2151 break; | 2141 break; |
2152 default: | 2142 default: |
2153 NOTREACHED(); | 2143 NOTREACHED(); |
2154 } | 2144 } |
2155 theme_handles_[theme_name] = handle; | 2145 theme_handles_[theme_name] = handle; |
2156 return handle; | 2146 return handle; |
2157 } | 2147 } |
2158 | 2148 |
2159 } // namespace ui | 2149 } // namespace ui |
OLD | NEW |