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

Side by Side Diff: ui/base/native_theme/native_theme_win.cc

Issue 10310136: ui: Move NativeTheme files into ui/base/native_theme/ directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
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/gfx/native_theme_win.h" 5 #include "ui/base/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"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 114
115 RECT InsetRect(const RECT* rect, int size) { 115 RECT InsetRect(const RECT* rect, int size) {
116 gfx::Rect result(*rect); 116 gfx::Rect result(*rect);
117 result.Inset(size, size); 117 result.Inset(size, size);
118 return result.ToRECT(); 118 return result.ToRECT();
119 } 119 }
120 120
121 } // namespace 121 } // namespace
122 122
123 namespace gfx { 123 namespace ui {
124 124
125 bool NativeThemeWin::IsThemingActive() const { 125 bool NativeThemeWin::IsThemingActive() const {
126 if (is_theme_active_) 126 if (is_theme_active_)
127 return !!is_theme_active_(); 127 return !!is_theme_active_();
128 return false; 128 return false;
129 } 129 }
130 130
131 HRESULT NativeThemeWin::GetThemeColor(ThemeName theme, 131 HRESULT NativeThemeWin::GetThemeColor(ThemeName theme,
132 int part_id, 132 int part_id,
133 int state_id, 133 int state_id,
(...skipping 15 matching lines...) Expand all
149 int part_id, 149 int part_id,
150 int state_id, 150 int state_id,
151 int prop_id, 151 int prop_id,
152 int default_sys_color) const { 152 int default_sys_color) const {
153 SkColor color; 153 SkColor color;
154 if (GetThemeColor(theme, part_id, state_id, prop_id, &color) != S_OK) 154 if (GetThemeColor(theme, part_id, state_id, prop_id, &color) != S_OK)
155 color = skia::COLORREFToSkColor(GetSysColor(default_sys_color)); 155 color = skia::COLORREFToSkColor(GetSysColor(default_sys_color));
156 return color; 156 return color;
157 } 157 }
158 158
159 Size NativeThemeWin::GetThemeBorderSize(ThemeName theme) const { 159 gfx::Size NativeThemeWin::GetThemeBorderSize(ThemeName theme) const {
160 // For simplicity use the wildcard state==0, part==0, since it works 160 // For simplicity use the wildcard state==0, part==0, since it works
161 // for the cases we currently depend on. 161 // for the cases we currently depend on.
162 int border; 162 int border;
163 if (GetThemeInt(theme, 0, 0, TMT_BORDERSIZE, &border) == S_OK) 163 if (GetThemeInt(theme, 0, 0, TMT_BORDERSIZE, &border) == S_OK)
164 return Size(border, border); 164 return gfx::Size(border, border);
165 else 165 else
166 return Size(GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE)); 166 return gfx::Size(GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
167 } 167 }
168 168
169 void NativeThemeWin::DisableTheming() const { 169 void NativeThemeWin::DisableTheming() const {
170 if (!set_theme_properties_) 170 if (!set_theme_properties_)
171 return; 171 return;
172 set_theme_properties_(0); 172 set_theme_properties_(0);
173 } 173 }
174 174
175 void NativeThemeWin::CloseHandles() const { 175 void NativeThemeWin::CloseHandles() const {
176 if (!close_theme_) 176 if (!close_theme_)
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 size.cx = 13; 272 size.cx = 13;
273 size.cy = 13; 273 size.cy = 13;
274 break; 274 break;
275 default: 275 default:
276 size.cx = 0; 276 size.cx = 0;
277 size.cy = 0; 277 size.cy = 0;
278 break; 278 break;
279 } 279 }
280 } 280 }
281 281
282 return Size(size.cx, size.cy); 282 return gfx::Size(size.cx, size.cy);
283 } 283 }
284 284
285 void NativeThemeWin::Paint(SkCanvas* canvas, 285 void NativeThemeWin::Paint(SkCanvas* canvas,
286 Part part, 286 Part part,
287 State state, 287 State state,
288 const gfx::Rect& rect, 288 const gfx::Rect& rect,
289 const ExtraParams& extra) const { 289 const ExtraParams& extra) const {
290 if (!skia::SupportsPlatformPaint(canvas)) { 290 if (!skia::SupportsPlatformPaint(canvas)) {
291 // This block will only get hit with --enable-accelerated-drawing flag. 291 // This block will only get hit with --enable-accelerated-drawing flag.
292 PaintToNonPlatformCanvas(canvas, part, state, rect, extra); 292 PaintToNonPlatformCanvas(canvas, part, state, rect, extra);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 RECT rect_win = rect.ToRECT(); 641 RECT rect_win = rect.ToRECT();
642 if (handle && draw_theme_) { 642 if (handle && draw_theme_) {
643 if (extra.pointing_right) { 643 if (extra.pointing_right) {
644 return draw_theme_(handle, hdc, MENU_POPUPSUBMENU, state_id, &rect_win, 644 return draw_theme_(handle, hdc, MENU_POPUPSUBMENU, state_id, &rect_win,
645 NULL); 645 NULL);
646 } else { 646 } else {
647 // There is no way to tell the uxtheme API to draw a left pointing arrow; 647 // There is no way to tell the uxtheme API to draw a left pointing arrow;
648 // it doesn't have a flag equivalent to DFCS_MENUARROWRIGHT. But they 648 // it doesn't have a flag equivalent to DFCS_MENUARROWRIGHT. But they
649 // are needed for RTL locales on Vista. So use a memory DC and mirror 649 // are needed for RTL locales on Vista. So use a memory DC and mirror
650 // the region with GDI's StretchBlt. 650 // the region with GDI's StretchBlt.
651 Rect r(rect); 651 gfx::Rect r(rect);
652 base::win::ScopedCreateDC mem_dc(CreateCompatibleDC(hdc)); 652 base::win::ScopedCreateDC mem_dc(CreateCompatibleDC(hdc));
653 base::win::ScopedBitmap mem_bitmap(CreateCompatibleBitmap(hdc, r.width(), 653 base::win::ScopedBitmap mem_bitmap(CreateCompatibleBitmap(hdc, r.width(),
654 r.height())); 654 r.height()));
655 base::win::ScopedSelectObject select_bitmap(mem_dc, mem_bitmap); 655 base::win::ScopedSelectObject select_bitmap(mem_dc, mem_bitmap);
656 // Copy and horizontally mirror the background from hdc into mem_dc. Use 656 // Copy and horizontally mirror the background from hdc into mem_dc. Use
657 // a negative-width source rect, starting at the rightmost pixel. 657 // a negative-width source rect, starting at the rightmost pixel.
658 StretchBlt(mem_dc, 0, 0, r.width(), r.height(), 658 StretchBlt(mem_dc, 0, 0, r.width(), r.height(),
659 hdc, r.right()-1, r.y(), -r.width(), r.height(), SRCCOPY); 659 hdc, r.right()-1, r.y(), -r.width(), r.height(), SRCCOPY);
660 // Draw the arrow. 660 // Draw the arrow.
661 RECT theme_rect = {0, 0, r.width(), r.height()}; 661 RECT theme_rect = {0, 0, r.width(), r.height()};
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 Part part, 977 Part part,
978 State state, 978 State state,
979 const gfx::Rect& rect, 979 const gfx::Rect& rect,
980 const ScrollbarThumbExtraParams& extra) const { 980 const ScrollbarThumbExtraParams& extra) const {
981 HANDLE handle = GetThemeHandle(SCROLLBAR); 981 HANDLE handle = GetThemeHandle(SCROLLBAR);
982 RECT rect_win = rect.ToRECT(); 982 RECT rect_win = rect.ToRECT();
983 int part_id; 983 int part_id;
984 int state_id; 984 int state_id;
985 985
986 switch (part) { 986 switch (part) {
987 case gfx::NativeTheme::kScrollbarHorizontalThumb: 987 case NativeTheme::kScrollbarHorizontalThumb:
988 part_id = SBP_THUMBBTNHORZ; 988 part_id = SBP_THUMBBTNHORZ;
989 break; 989 break;
990 case gfx::NativeTheme::kScrollbarVerticalThumb: 990 case NativeTheme::kScrollbarVerticalThumb:
991 part_id = SBP_THUMBBTNVERT; 991 part_id = SBP_THUMBBTNVERT;
992 break; 992 break;
993 case gfx::NativeTheme::kScrollbarHorizontalGripper: 993 case NativeTheme::kScrollbarHorizontalGripper:
994 part_id = SBP_GRIPPERHORZ; 994 part_id = SBP_GRIPPERHORZ;
995 break; 995 break;
996 case gfx::NativeTheme::kScrollbarVerticalGripper: 996 case NativeTheme::kScrollbarVerticalGripper:
997 part_id = SBP_GRIPPERVERT; 997 part_id = SBP_GRIPPERVERT;
998 break; 998 break;
999 default: 999 default:
1000 NOTREACHED() << "Invalid part: " << part; 1000 NOTREACHED() << "Invalid part: " << part;
1001 break; 1001 break;
1002 } 1002 }
1003 1003
1004 switch (state) { 1004 switch (state) {
1005 case kDisabled: 1005 case kDisabled:
1006 state_id = SCRBS_DISABLED; 1006 state_id = SCRBS_DISABLED;
(...skipping 28 matching lines...) Expand all
1035 Part part, 1035 Part part,
1036 State state, 1036 State state,
1037 const gfx::Rect& rect, 1037 const gfx::Rect& rect,
1038 const ScrollbarTrackExtraParams& extra) const { 1038 const ScrollbarTrackExtraParams& extra) const {
1039 HANDLE handle = GetThemeHandle(SCROLLBAR); 1039 HANDLE handle = GetThemeHandle(SCROLLBAR);
1040 RECT rect_win = rect.ToRECT(); 1040 RECT rect_win = rect.ToRECT();
1041 int part_id; 1041 int part_id;
1042 int state_id; 1042 int state_id;
1043 1043
1044 switch (part) { 1044 switch (part) {
1045 case gfx::NativeTheme::kScrollbarHorizontalTrack: 1045 case NativeTheme::kScrollbarHorizontalTrack:
1046 part_id = extra.is_upper ? SBP_UPPERTRACKHORZ : SBP_LOWERTRACKHORZ; 1046 part_id = extra.is_upper ? SBP_UPPERTRACKHORZ : SBP_LOWERTRACKHORZ;
1047 break; 1047 break;
1048 case gfx::NativeTheme::kScrollbarVerticalTrack: 1048 case NativeTheme::kScrollbarVerticalTrack:
1049 part_id = extra.is_upper ? SBP_UPPERTRACKVERT : SBP_LOWERTRACKVERT; 1049 part_id = extra.is_upper ? SBP_UPPERTRACKVERT : SBP_LOWERTRACKVERT;
1050 break; 1050 break;
1051 default: 1051 default:
1052 NOTREACHED() << "Invalid part: " << part; 1052 NOTREACHED() << "Invalid part: " << part;
1053 break; 1053 break;
1054 } 1054 }
1055 1055
1056 switch (state) { 1056 switch (state) {
1057 case kDisabled: 1057 case kDisabled:
1058 state_id = SCRBS_DISABLED; 1058 state_id = SCRBS_DISABLED;
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 RECT local_rect = { 0, 0, width, height }; 1689 RECT local_rect = { 0, 0, width, height };
1690 DrawFrameControl(bitmap_dc, &local_rect, type, state); 1690 DrawFrameControl(bitmap_dc, &local_rect, type, state);
1691 1691
1692 // We're going to use BitBlt with a b&w mask. This results in using the dest 1692 // We're going to use BitBlt with a b&w mask. This results in using the dest
1693 // dc's text color for the black bits in the mask, and the dest dc's 1693 // dc's text color for the black bits in the mask, and the dest dc's
1694 // background color for the white bits in the mask. DrawFrameControl draws the 1694 // background color for the white bits in the mask. DrawFrameControl draws the
1695 // check in black, and the background in white. 1695 // check in black, and the background in white.
1696 int bg_color_key; 1696 int bg_color_key;
1697 int text_color_key; 1697 int text_color_key;
1698 switch (control_state) { 1698 switch (control_state) {
1699 case gfx::NativeTheme::kHovered: 1699 case NativeTheme::kHovered:
1700 bg_color_key = COLOR_HIGHLIGHT; 1700 bg_color_key = COLOR_HIGHLIGHT;
1701 text_color_key = COLOR_HIGHLIGHTTEXT; 1701 text_color_key = COLOR_HIGHLIGHTTEXT;
1702 break; 1702 break;
1703 case gfx::NativeTheme::kNormal: 1703 case NativeTheme::kNormal:
1704 bg_color_key = COLOR_MENU; 1704 bg_color_key = COLOR_MENU;
1705 text_color_key = COLOR_MENUTEXT; 1705 text_color_key = COLOR_MENUTEXT;
1706 break; 1706 break;
1707 case gfx::NativeTheme::kDisabled: 1707 case NativeTheme::kDisabled:
1708 bg_color_key = is_selected ? COLOR_HIGHLIGHT : COLOR_MENU; 1708 bg_color_key = is_selected ? COLOR_HIGHLIGHT : COLOR_MENU;
1709 text_color_key = COLOR_GRAYTEXT; 1709 text_color_key = COLOR_GRAYTEXT;
1710 break; 1710 break;
1711 default: 1711 default:
1712 NOTREACHED(); 1712 NOTREACHED();
1713 bg_color_key = COLOR_MENU; 1713 bg_color_key = COLOR_MENU;
1714 text_color_key = COLOR_MENUTEXT; 1714 text_color_key = COLOR_MENUTEXT;
1715 break; 1715 break;
1716 } 1716 }
1717 COLORREF old_bg_color = SetBkColor(hdc, GetSysColor(bg_color_key)); 1717 COLORREF old_bg_color = SetBkColor(hdc, GetSysColor(bg_color_key));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 case SPIN: 1769 case SPIN:
1770 handle = open_theme_(NULL, L"Spin"); 1770 handle = open_theme_(NULL, L"Spin");
1771 break; 1771 break;
1772 default: 1772 default:
1773 NOTREACHED(); 1773 NOTREACHED();
1774 } 1774 }
1775 theme_handles_[theme_name] = handle; 1775 theme_handles_[theme_name] = handle;
1776 return handle; 1776 return handle;
1777 } 1777 }
1778 1778
1779 } // namespace gfx 1779 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/native_theme/native_theme_win.h ('k') | ui/base/native_theme/native_theme_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698