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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } | 205 } |
207 } | 206 } |
208 | 207 |
209 bool NativeThemeWin::IsClassicTheme(ThemeName name) const { | 208 bool NativeThemeWin::IsClassicTheme(ThemeName name) const { |
210 if (!theme_dll_) | 209 if (!theme_dll_) |
211 return true; | 210 return true; |
212 | 211 |
213 return !GetThemeHandle(name); | 212 return !GetThemeHandle(name); |
214 } | 213 } |
215 | 214 |
216 // TODO(sky): seems like we should default to NativeThemeWin, but that currently | |
217 // breaks a couple of tests (FocusTraversalTest.NormalTraversal in | |
218 // views_unittests). | |
219 #if !defined(USE_AURA) | |
220 // static | |
221 NativeTheme* NativeTheme::instance() { | |
222 return NativeThemeWin::instance(); | |
223 } | |
224 #endif | |
225 | |
226 // static | 215 // static |
227 NativeThemeWin* NativeThemeWin::instance() { | 216 NativeThemeWin* NativeThemeWin::instance() { |
228 CR_DEFINE_STATIC_LOCAL(NativeThemeWin, s_native_theme, ()); | 217 CR_DEFINE_STATIC_LOCAL(NativeThemeWin, s_native_theme, ()); |
229 return &s_native_theme; | 218 return &s_native_theme; |
230 } | 219 } |
231 | 220 |
232 gfx::Size NativeThemeWin::GetPartSize(Part part, | 221 gfx::Size NativeThemeWin::GetPartSize(Part part, |
233 State state, | 222 State state, |
234 const ExtraParams& extra) const { | 223 const ExtraParams& extra) const { |
235 gfx::Size part_size = CommonThemeGetPartSize(part, state, extra); | 224 gfx::Size part_size = CommonThemeGetPartSize(part, state, extra); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 // todo (cpu): fix this soon. Making a call to CloseHandles() here breaks | 382 // todo (cpu): fix this soon. Making a call to CloseHandles() here breaks |
394 // certain tests and the reliability bots. | 383 // certain tests and the reliability bots. |
395 // CloseHandles(); | 384 // CloseHandles(); |
396 FreeLibrary(theme_dll_); | 385 FreeLibrary(theme_dll_); |
397 } | 386 } |
398 } | 387 } |
399 | 388 |
400 void NativeThemeWin::OnSysColorChange() { | 389 void NativeThemeWin::OnSysColorChange() { |
401 UpdateSystemColors(); | 390 UpdateSystemColors(); |
402 is_using_high_contrast_valid_ = false; | 391 is_using_high_contrast_valid_ = false; |
| 392 NotifyObservers(); |
403 } | 393 } |
404 | 394 |
405 void NativeThemeWin::UpdateSystemColors() { | 395 void NativeThemeWin::UpdateSystemColors() { |
406 for (int i = 0; i < arraysize(kSystemColors); ++i) { | 396 for (int i = 0; i < arraysize(kSystemColors); ++i) { |
407 system_colors_[kSystemColors[i]] = | 397 system_colors_[kSystemColors[i]] = |
408 color_utils::GetSysSkColor(kSystemColors[i]); | 398 color_utils::GetSysSkColor(kSystemColors[i]); |
409 } | 399 } |
410 } | 400 } |
411 | 401 |
412 void NativeThemeWin::PaintDirect(SkCanvas* canvas, | 402 void NativeThemeWin::PaintDirect(SkCanvas* canvas, |
(...skipping 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2153 handle = open_theme_(NULL, L"Spin"); | 2143 handle = open_theme_(NULL, L"Spin"); |
2154 break; | 2144 break; |
2155 default: | 2145 default: |
2156 NOTREACHED(); | 2146 NOTREACHED(); |
2157 } | 2147 } |
2158 theme_handles_[theme_name] = handle; | 2148 theme_handles_[theme_name] = handle; |
2159 return handle; | 2149 return handle; |
2160 } | 2150 } |
2161 | 2151 |
2162 } // namespace ui | 2152 } // namespace ui |
OLD | NEW |