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

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

Issue 12524011: Fix GetPartSize to account for customized themes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 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 | « no previous file | no next file » | 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) 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>
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 226 }
227 227
228 gfx::Size NativeThemeWin::GetPartSize(Part part, 228 gfx::Size NativeThemeWin::GetPartSize(Part part,
229 State state, 229 State state,
230 const ExtraParams& extra) const { 230 const ExtraParams& extra) const {
231 if (IsNewMenuStyleEnabled()) { 231 if (IsNewMenuStyleEnabled()) {
232 gfx::Size size = CommonThemeGetPartSize(part, state, extra); 232 gfx::Size size = CommonThemeGetPartSize(part, state, extra);
233 if (!size.IsEmpty()) 233 if (!size.IsEmpty())
234 return size; 234 return size;
235 } 235 }
236
237 // The GetThemePartSize call below returns the default size without
238 // accounting for user customization (crbug/218291).
236 SIZE size; 239 SIZE size;
240 switch (part) {
241 case kScrollbarDownArrow:
242 case kScrollbarLeftArrow:
243 case kScrollbarRightArrow:
244 case kScrollbarUpArrow:
245 case kScrollbarHorizontalThumb:
246 case kScrollbarVerticalThumb:
247 case kScrollbarHorizontalTrack:
248 case kScrollbarVerticalTrack:
249 size.cx = size.cy = ui::win::GetSystemMetricsInDIP(SM_CXVSCROLL);
250 return gfx::Size(size.cx, size.cy);
251 }
252
237 int part_id = GetWindowsPart(part, state, extra); 253 int part_id = GetWindowsPart(part, state, extra);
238 int state_id = GetWindowsState(part, state, extra); 254 int state_id = GetWindowsState(part, state, extra);
239 255
240 HDC hdc = GetDC(NULL); 256 HDC hdc = GetDC(NULL);
241 HRESULT hr = GetThemePartSize(GetThemeName(part), hdc, part_id, state_id, 257 HRESULT hr = GetThemePartSize(GetThemeName(part), hdc, part_id, state_id,
242 NULL, TS_TRUE, &size); 258 NULL, TS_TRUE, &size);
243 ReleaseDC(NULL, hdc); 259 ReleaseDC(NULL, hdc);
244 260
245 if (FAILED(hr)) { 261 if (FAILED(hr)) {
246 // TODO(rogerta): For now, we need to support radio buttons and checkboxes 262 // TODO(rogerta): For now, we need to support radio buttons and checkboxes
247 // when theming is not enabled. Support for other parts can be added 263 // when theming is not enabled. Support for other parts can be added
248 // if/when needed. 264 // if/when needed.
249 switch (part) { 265 switch (part) {
250 case kCheckbox: 266 case kCheckbox:
251 case kRadio: 267 case kRadio:
252 // TODO(rogerta): I was not able to find any API to get the default 268 // TODO(rogerta): I was not able to find any API to get the default
253 // size of these controls, so determined these values empirically. 269 // size of these controls, so determined these values empirically.
254 size.cx = 13; 270 size.cx = 13;
255 size.cy = 13; 271 size.cy = 13;
256 break; 272 break;
257 case kScrollbarDownArrow:
258 case kScrollbarLeftArrow:
259 case kScrollbarRightArrow:
260 case kScrollbarUpArrow:
261 case kScrollbarHorizontalThumb:
262 case kScrollbarVerticalThumb:
263 case kScrollbarHorizontalTrack:
264 case kScrollbarVerticalTrack:
265 size.cx = size.cy = GetSystemMetrics(SM_CXVSCROLL) /
266 ui::win::GetDeviceScaleFactor();
267 break;
268 default: 273 default:
269 size.cx = 0; 274 size.cx = 0;
270 size.cy = 0; 275 size.cy = 0;
271 break; 276 break;
272 } 277 }
273 } 278 }
274 279
275 return gfx::Size(size.cx, size.cy); 280 return gfx::Size(size.cx, size.cy);
276 } 281 }
277 282
(...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 handle = open_theme_(NULL, L"Spin"); 2076 handle = open_theme_(NULL, L"Spin");
2072 break; 2077 break;
2073 default: 2078 default:
2074 NOTREACHED(); 2079 NOTREACHED();
2075 } 2080 }
2076 theme_handles_[theme_name] = handle; 2081 theme_handles_[theme_name] = handle;
2077 return handle; 2082 return handle;
2078 } 2083 }
2079 2084
2080 } // namespace ui 2085 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698