Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: gfx/native_theme_win.cc

Issue 1596018: Added support for HTML5 progress element. (Closed)
Patch Set: just sync the change of webkit side. Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gfx/native_theme_win.h ('k') | webkit/glue/webthemeengine_impl_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 namespace gfx { 52 namespace gfx {
53 53
54 /* static */ 54 /* static */
55 const NativeTheme* NativeTheme::instance() { 55 const NativeTheme* NativeTheme::instance() {
56 // The global NativeTheme instance. 56 // The global NativeTheme instance.
57 static const NativeTheme s_native_theme; 57 static const NativeTheme s_native_theme;
58 return &s_native_theme; 58 return &s_native_theme;
59 } 59 }
60 60
61 NativeTheme::NativeTheme() 61 NativeTheme::NativeTheme()
62 : theme_dll_(LoadLibrary(L"uxtheme.dll")), 62 : theme_dll_(LoadLibrary(L"uxtheme.dll")),
63 clip_(NULL),
63 draw_theme_(NULL), 64 draw_theme_(NULL),
64 draw_theme_ex_(NULL), 65 draw_theme_ex_(NULL),
65 get_theme_color_(NULL), 66 get_theme_color_(NULL),
66 get_theme_content_rect_(NULL), 67 get_theme_content_rect_(NULL),
67 get_theme_part_size_(NULL), 68 get_theme_part_size_(NULL),
68 open_theme_(NULL), 69 open_theme_(NULL),
69 close_theme_(NULL), 70 close_theme_(NULL),
70 set_theme_properties_(NULL), 71 set_theme_properties_(NULL),
71 is_theme_active_(NULL), 72 is_theme_active_(NULL),
72 get_theme_int_(NULL) { 73 get_theme_int_(NULL) {
(...skipping 21 matching lines...) Expand all
94 } 95 }
95 memset(theme_handles_, 0, sizeof(theme_handles_)); 96 memset(theme_handles_, 0, sizeof(theme_handles_));
96 } 97 }
97 98
98 NativeTheme::~NativeTheme() { 99 NativeTheme::~NativeTheme() {
99 if (theme_dll_) { 100 if (theme_dll_) {
100 // todo (cpu): fix this soon. 101 // todo (cpu): fix this soon.
101 // CloseHandles(); 102 // CloseHandles();
102 FreeLibrary(theme_dll_); 103 FreeLibrary(theme_dll_);
103 } 104 }
105
106 if (clip_)
107 DeleteObject(clip_);
104 } 108 }
105 109
106 HRESULT NativeTheme::PaintButton(HDC hdc, 110 HRESULT NativeTheme::PaintButton(HDC hdc,
107 int part_id, 111 int part_id,
108 int state_id, 112 int state_id,
109 int classic_state, 113 int classic_state,
110 RECT* rect) const { 114 RECT* rect) const {
111 HANDLE handle = GetThemeHandle(BUTTON); 115 HANDLE handle = GetThemeHandle(BUTTON);
112 if (handle && draw_theme_) 116 if (handle && draw_theme_)
113 return draw_theme_(handle, hdc, part_id, state_id, rect, NULL); 117 return draw_theme_(handle, hdc, part_id, state_id, rect, NULL);
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 right_triangle_top); 475 right_triangle_top);
472 right_triangle.lineTo(right_triangle_left, 476 right_triangle.lineTo(right_triangle_left,
473 SkIntToScalar(right_half.bottom)); 477 SkIntToScalar(right_half.bottom));
474 right_triangle.close(); 478 right_triangle.close();
475 canvas->drawPath(right_triangle, paint); 479 canvas->drawPath(right_triangle, paint);
476 } 480 }
477 } 481 }
478 return S_OK; 482 return S_OK;
479 } 483 }
480 484
485 HRESULT NativeTheme::PaintProgressBar(HDC hdc,
486 RECT* bar_rect,
487 int value_part_id,
488 RECT* value_rect,
489 skia::PlatformCanvas* canvas) const {
490
491 // We need to clip painting because the value theme
492 // for indeterminate overflows bar rectangle.
493 HRGN clip = GetClipHandle();
494 GetClipRgn(hdc, clip);
495 IntersectClipRect(hdc, bar_rect->left, bar_rect->top,
496 bar_rect->right, bar_rect->bottom);
497
498 HANDLE handle = GetThemeHandle(PROGRESS);
499 if (handle && draw_theme_) {
500 draw_theme_(handle, hdc, PP_BAR, 0, bar_rect, NULL);
501 draw_theme_(handle, hdc, value_part_id, 0, value_rect, NULL);
502
503 SelectClipRgn(hdc, clip);
504 return S_OK;
505 }
506
507 HBRUSH bg_brush = GetSysColorBrush(COLOR_BTNFACE);
508 HBRUSH fg_brush = GetSysColorBrush(COLOR_BTNSHADOW);
509 FillRect(hdc, bar_rect, bg_brush);
510 FillRect(hdc, value_rect, fg_brush);
511 DrawEdge(hdc, bar_rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
512
513 SelectClipRgn(hdc, clip);
514 return S_OK;
515 }
516
481 HRESULT NativeTheme::PaintTextField(HDC hdc, 517 HRESULT NativeTheme::PaintTextField(HDC hdc,
482 int part_id, 518 int part_id,
483 int state_id, 519 int state_id,
484 int classic_state, 520 int classic_state,
485 RECT* rect, 521 RECT* rect,
486 COLORREF color, 522 COLORREF color,
487 bool fill_content_area, 523 bool fill_content_area,
488 bool draw_edges) const { 524 bool draw_edges) const {
489 // TODO(ojan): http://b/1210017 Figure out how to give the ability to 525 // TODO(ojan): http://b/1210017 Figure out how to give the ability to
490 // exclude individual edges from being drawn. 526 // exclude individual edges from being drawn.
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 if (!close_theme_) 688 if (!close_theme_)
653 return; 689 return;
654 690
655 for (int i = 0; i < LAST; ++i) { 691 for (int i = 0; i < LAST; ++i) {
656 if (theme_handles_[i]) 692 if (theme_handles_[i])
657 close_theme_(theme_handles_[i]); 693 close_theme_(theme_handles_[i]);
658 theme_handles_[i] = NULL; 694 theme_handles_[i] = NULL;
659 } 695 }
660 } 696 }
661 697
698 HRGN NativeTheme::GetClipHandle() const {
699 if (!clip_) {
700 RECT dummy_rect;
701 dummy_rect.left = dummy_rect.right = 0;
702 dummy_rect.top = dummy_rect.bottom = 0;
703 clip_ = CreateRectRgnIndirect(&dummy_rect);
704 }
705
706 return clip_;
707 }
708
662 HANDLE NativeTheme::GetThemeHandle(ThemeName theme_name) const 709 HANDLE NativeTheme::GetThemeHandle(ThemeName theme_name) const
663 { 710 {
664 if (!open_theme_ || theme_name < 0 || theme_name >= LAST) 711 if (!open_theme_ || theme_name < 0 || theme_name >= LAST)
665 return 0; 712 return 0;
666 713
667 if (theme_handles_[theme_name]) 714 if (theme_handles_[theme_name])
668 return theme_handles_[theme_name]; 715 return theme_handles_[theme_name];
669 716
670 // Not found, try to load it. 717 // Not found, try to load it.
671 HANDLE handle = 0; 718 HANDLE handle = 0;
(...skipping 21 matching lines...) Expand all
693 break; 740 break;
694 case TEXTFIELD: 741 case TEXTFIELD:
695 handle = open_theme_(NULL, L"Edit"); 742 handle = open_theme_(NULL, L"Edit");
696 break; 743 break;
697 case TRACKBAR: 744 case TRACKBAR:
698 handle = open_theme_(NULL, L"Trackbar"); 745 handle = open_theme_(NULL, L"Trackbar");
699 break; 746 break;
700 case WINDOW: 747 case WINDOW:
701 handle = open_theme_(NULL, L"Window"); 748 handle = open_theme_(NULL, L"Window");
702 break; 749 break;
750 case PROGRESS:
751 handle = open_theme_(NULL, L"Progress");
752 break;
703 default: 753 default:
704 NOTREACHED(); 754 NOTREACHED();
705 } 755 }
706 theme_handles_[theme_name] = handle; 756 theme_handles_[theme_name] = handle;
707 return handle; 757 return handle;
708 } 758 }
709 759
710 } // namespace gfx 760 } // namespace gfx
OLDNEW
« no previous file with comments | « gfx/native_theme_win.h ('k') | webkit/glue/webthemeengine_impl_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698