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 <stddef.h> | 8 #include <stddef.h> |
9 #include <uxtheme.h> | 9 #include <uxtheme.h> |
10 #include <vsstyle.h> | 10 #include <vsstyle.h> |
(...skipping 12 matching lines...) Expand all Loading... |
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/SkColor.h" | 24 #include "third_party/skia/include/core/SkColor.h" |
25 #include "third_party/skia/include/core/SkColorPriv.h" | 25 #include "third_party/skia/include/core/SkColorPriv.h" |
26 #include "third_party/skia/include/core/SkShader.h" | 26 #include "third_party/skia/include/core/SkShader.h" |
27 #include "ui/base/material_design/material_design_controller.h" | 27 #include "ui/base/material_design/material_design_controller.h" |
28 #include "ui/gfx/color_palette.h" | 28 #include "ui/gfx/color_palette.h" |
29 #include "ui/gfx/color_utils.h" | 29 #include "ui/gfx/color_utils.h" |
30 #include "ui/gfx/gdi_util.h" | 30 #include "ui/gfx/gdi_util.h" |
31 #include "ui/gfx/geometry/rect.h" | 31 #include "ui/gfx/geometry/rect.h" |
32 #include "ui/gfx/geometry/rect_conversions.h" | 32 #include "ui/gfx/geometry/rect_conversions.h" |
| 33 #include "ui/gfx/skia_util.h" |
33 #include "ui/gfx/win/dpi.h" | 34 #include "ui/gfx/win/dpi.h" |
34 #include "ui/native_theme/common_theme.h" | 35 #include "ui/native_theme/common_theme.h" |
35 | 36 |
36 // This was removed from Winvers.h but is still used. | 37 // This was removed from Winvers.h but is still used. |
37 #if !defined(COLOR_MENUHIGHLIGHT) | 38 #if !defined(COLOR_MENUHIGHLIGHT) |
38 #define COLOR_MENUHIGHLIGHT 29 | 39 #define COLOR_MENUHIGHLIGHT 29 |
39 #endif | 40 #endif |
40 | 41 |
41 namespace { | 42 namespace { |
42 | 43 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 const gfx::Rect& rect, | 239 const gfx::Rect& rect, |
239 const ExtraParams& extra) const { | 240 const ExtraParams& extra) const { |
240 if (rect.IsEmpty()) | 241 if (rect.IsEmpty()) |
241 return; | 242 return; |
242 | 243 |
243 switch (part) { | 244 switch (part) { |
244 case kComboboxArrow: | 245 case kComboboxArrow: |
245 CommonThemePaintComboboxArrow(canvas, rect); | 246 CommonThemePaintComboboxArrow(canvas, rect); |
246 return; | 247 return; |
247 case kMenuPopupGutter: | 248 case kMenuPopupGutter: |
248 CommonThemePaintMenuGutter(canvas, rect); | 249 PaintMenuGutter(canvas, rect); |
249 return; | 250 return; |
250 case kMenuPopupSeparator: | 251 case kMenuPopupSeparator: |
251 CommonThemePaintMenuSeparator(canvas, rect); | 252 PaintMenuSeparator(canvas, rect); |
252 return; | 253 return; |
253 case kMenuPopupBackground: | 254 case kMenuPopupBackground: |
254 CommonThemePaintMenuBackground(canvas, rect); | 255 PaintMenuBackground(canvas, rect); |
255 return; | 256 return; |
256 case kMenuItemBackground: | 257 case kMenuItemBackground: |
257 CommonThemePaintMenuItemBackground(canvas, state, rect, extra.menu_item); | 258 CommonThemePaintMenuItemBackground(this, canvas, state, rect, |
| 259 extra.menu_item); |
258 return; | 260 return; |
259 default: | 261 default: |
260 break; | 262 break; |
261 } | 263 } |
262 | 264 |
263 bool needs_paint_indirect = false; | 265 bool needs_paint_indirect = false; |
264 if (!skia::SupportsPlatformPaint(canvas)) { | 266 if (!skia::SupportsPlatformPaint(canvas)) { |
265 // This block will only get hit with --enable-accelerated-drawing flag. | 267 // This block will only get hit with --enable-accelerated-drawing flag. |
266 needs_paint_indirect = true; | 268 needs_paint_indirect = true; |
267 } else { | 269 } else { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 UpdateSystemColors(); | 353 UpdateSystemColors(); |
352 is_using_high_contrast_valid_ = false; | 354 is_using_high_contrast_valid_ = false; |
353 NotifyObservers(); | 355 NotifyObservers(); |
354 } | 356 } |
355 | 357 |
356 void NativeThemeWin::UpdateSystemColors() { | 358 void NativeThemeWin::UpdateSystemColors() { |
357 for (int kSystemColor : kSystemColors) | 359 for (int kSystemColor : kSystemColors) |
358 system_colors_[kSystemColor] = color_utils::GetSysSkColor(kSystemColor); | 360 system_colors_[kSystemColor] = color_utils::GetSysSkColor(kSystemColor); |
359 } | 361 } |
360 | 362 |
| 363 void NativeThemeWin::PaintMenuSeparator(SkCanvas* canvas, |
| 364 const gfx::Rect& rect) const { |
| 365 SkPaint paint; |
| 366 paint.setColor(GetSystemColor(NativeTheme::kColorId_MenuSeparatorColor)); |
| 367 int position_y = rect.y() + rect.height() / 2; |
| 368 canvas->drawLine(rect.x(), position_y, rect.right(), position_y, paint); |
| 369 } |
| 370 |
| 371 void NativeThemeWin::PaintMenuGutter(SkCanvas* canvas, |
| 372 const gfx::Rect& rect) const { |
| 373 SkPaint paint; |
| 374 paint.setColor(GetSystemColor(NativeTheme::kColorId_MenuSeparatorColor)); |
| 375 int position_x = rect.x() + rect.width() / 2; |
| 376 canvas->drawLine(position_x, rect.y(), position_x, rect.bottom(), paint); |
| 377 } |
| 378 |
| 379 void NativeThemeWin::PaintMenuBackground(SkCanvas* canvas, |
| 380 const gfx::Rect& rect) const { |
| 381 SkPaint paint; |
| 382 paint.setColor(GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor)); |
| 383 canvas->drawRect(gfx::RectToSkRect(rect), paint); |
| 384 } |
| 385 |
361 void NativeThemeWin::PaintDirect(SkCanvas* canvas, | 386 void NativeThemeWin::PaintDirect(SkCanvas* canvas, |
362 Part part, | 387 Part part, |
363 State state, | 388 State state, |
364 const gfx::Rect& rect, | 389 const gfx::Rect& rect, |
365 const ExtraParams& extra) const { | 390 const ExtraParams& extra) const { |
366 skia::ScopedPlatformPaint scoped_platform_paint(canvas); | 391 skia::ScopedPlatformPaint scoped_platform_paint(canvas); |
367 HDC hdc = scoped_platform_paint.GetPlatformSurface(); | 392 HDC hdc = scoped_platform_paint.GetPlatformSurface(); |
368 | 393 |
369 switch (part) { | 394 switch (part) { |
370 case kCheckbox: | 395 case kCheckbox: |
(...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2063 break; | 2088 break; |
2064 case LAST: | 2089 case LAST: |
2065 NOTREACHED(); | 2090 NOTREACHED(); |
2066 break; | 2091 break; |
2067 } | 2092 } |
2068 theme_handles_[theme_name] = handle; | 2093 theme_handles_[theme_name] = handle; |
2069 return handle; | 2094 return handle; |
2070 } | 2095 } |
2071 | 2096 |
2072 } // namespace ui | 2097 } // namespace ui |
OLD | NEW |