Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "gfx/native_theme_win.h" | 5 #include "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 |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 471 right_triangle_top); | 471 right_triangle_top); |
| 472 right_triangle.lineTo(right_triangle_left, | 472 right_triangle.lineTo(right_triangle_left, |
| 473 SkIntToScalar(right_half.bottom)); | 473 SkIntToScalar(right_half.bottom)); |
| 474 right_triangle.close(); | 474 right_triangle.close(); |
| 475 canvas->drawPath(right_triangle, paint); | 475 canvas->drawPath(right_triangle, paint); |
| 476 } | 476 } |
| 477 } | 477 } |
| 478 return S_OK; | 478 return S_OK; |
| 479 } | 479 } |
| 480 | 480 |
| 481 // A ScopedRegion wrapper to set/restore clipping region during the scope. | |
| 482 class ScopedRegionClipping { | |
|
Peter Kasting
2010/05/14 18:08:11
Nit: This would be clearer as "ScopedClipRegion"
| |
| 483 public: | |
| 484 explicit ScopedRegionClipping(const HDC hdc) | |
| 485 : hdc_(hdc), clip_(NULL) { | |
| 486 RECT zero_rect = { 0 }; | |
| 487 clip_ = CreateRectRgnIndirect(&zero_rect); | |
| 488 GetClipRgn(hdc_, clip_); | |
| 489 } | |
| 490 | |
| 491 ~ScopedRegionClipping() { | |
| 492 SelectClipRgn(hdc_, clip_); | |
| 493 } | |
| 494 | |
| 495 private: | |
| 496 HDC hdc_; | |
| 497 ScopedRegion clip_; | |
| 498 DISALLOW_COPY_AND_ASSIGN(ScopedRegionClipping); | |
| 499 }; | |
| 500 | |
| 501 HRESULT NativeTheme::PaintProgressBar(HDC hdc, | |
| 502 RECT* bar_rect, | |
| 503 int value_part_id, | |
| 504 RECT* value_rect, | |
| 505 skia::PlatformCanvas* canvas) const { | |
| 506 // For an indeterminate progress bar, we draw a moving highlight that's animat ed | |
|
Peter Kasting
2010/05/14 18:08:11
Nit: Sorry, I gave you a set of comments that were
| |
| 507 // (by the caller) across the width of the bar. The highlight part is always | |
| 508 // drawn as being as wide as the bar, to scale it properly. Therefore, we nee d | |
| 509 // to clip it against the bar rect, so that as it moves, it doesn't extend pas t | |
| 510 // the ends of the bar. For a normal progress bar, we won't try to draw past | |
| 511 // the bar ends, so this clipping is useless, but harmless. | |
| 512 ScopedRegionClipping clip(hdc); | |
| 513 IntersectClipRect(hdc, bar_rect->left, bar_rect->top, | |
| 514 bar_rect->right, bar_rect->bottom); | |
| 515 | |
| 516 HANDLE handle = GetThemeHandle(PROGRESS); | |
| 517 if (handle && draw_theme_) { | |
| 518 draw_theme_(handle, hdc, PP_BAR, 0, bar_rect, NULL); | |
| 519 draw_theme_(handle, hdc, value_part_id, 0, value_rect, NULL); | |
| 520 return S_OK; | |
| 521 } | |
| 522 | |
| 523 HBRUSH bg_brush = GetSysColorBrush(COLOR_BTNFACE); | |
| 524 HBRUSH fg_brush = GetSysColorBrush(COLOR_BTNSHADOW); | |
| 525 FillRect(hdc, bar_rect, bg_brush); | |
| 526 FillRect(hdc, value_rect, fg_brush); | |
| 527 DrawEdge(hdc, bar_rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); | |
| 528 return S_OK; | |
| 529 } | |
| 530 | |
| 481 HRESULT NativeTheme::PaintTextField(HDC hdc, | 531 HRESULT NativeTheme::PaintTextField(HDC hdc, |
| 482 int part_id, | 532 int part_id, |
| 483 int state_id, | 533 int state_id, |
| 484 int classic_state, | 534 int classic_state, |
| 485 RECT* rect, | 535 RECT* rect, |
| 486 COLORREF color, | 536 COLORREF color, |
| 487 bool fill_content_area, | 537 bool fill_content_area, |
| 488 bool draw_edges) const { | 538 bool draw_edges) const { |
| 489 // TODO(ojan): http://b/1210017 Figure out how to give the ability to | 539 // TODO(ojan): http://b/1210017 Figure out how to give the ability to |
| 490 // exclude individual edges from being drawn. | 540 // exclude individual edges from being drawn. |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 700 break; | 750 break; |
| 701 case TEXTFIELD: | 751 case TEXTFIELD: |
| 702 handle = open_theme_(NULL, L"Edit"); | 752 handle = open_theme_(NULL, L"Edit"); |
| 703 break; | 753 break; |
| 704 case TRACKBAR: | 754 case TRACKBAR: |
| 705 handle = open_theme_(NULL, L"Trackbar"); | 755 handle = open_theme_(NULL, L"Trackbar"); |
| 706 break; | 756 break; |
| 707 case WINDOW: | 757 case WINDOW: |
| 708 handle = open_theme_(NULL, L"Window"); | 758 handle = open_theme_(NULL, L"Window"); |
| 709 break; | 759 break; |
| 760 case PROGRESS: | |
| 761 handle = open_theme_(NULL, L"Progress"); | |
| 762 break; | |
| 710 default: | 763 default: |
| 711 NOTREACHED(); | 764 NOTREACHED(); |
| 712 } | 765 } |
| 713 theme_handles_[theme_name] = handle; | 766 theme_handles_[theme_name] = handle; |
| 714 return handle; | 767 return handle; |
| 715 } | 768 } |
| 716 | 769 |
| 717 } // namespace gfx | 770 } // namespace gfx |
| OLD | NEW |