From 93786d86863a0fc8e83872a78ba875fd08753ae2 Mon Sep 17 00:00:00 2001 From: "tc@google.com" Date: Wed, 22 Oct 2008 21:13:54 +0000 Subject: Changes to how we draw buttons. 1) Change RenderThemeWin.cpp so that pressed buttons have priority over focused buttons. I.e., if a button is focused and pressed, we should draw it pressed. 2) In classic mode, add the black border for focused buttons and properly add the dotted focus rect. http://crbug.com/135 Review URL: http://codereview.chromium.org/8071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3763 0039d316-1c4b-4281-b951-d872f2087c98 --- base/gfx/native_theme.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'base/gfx') diff --git a/base/gfx/native_theme.cc b/base/gfx/native_theme.cc index b8aa30c..65f1914 100644 --- a/base/gfx/native_theme.cc +++ b/base/gfx/native_theme.cc @@ -82,8 +82,9 @@ HRESULT NativeTheme::PaintButton(HDC hdc, // Draw it manually. // All pressed states have both low bits set, and no other states do. - const bool focused = ((state_id & PBS_PRESSED) == PBS_PRESSED); - if ((part_id == BP_PUSHBUTTON) && focused) { + const bool focused = ((state_id & TS_CHECKED) == TS_CHECKED); + const bool pressed = ((state_id & PBS_PRESSED) == PBS_PRESSED); + if ((BP_PUSHBUTTON == part_id) && (pressed || focused)) { // BP_PUSHBUTTON has a focus rect drawn around the outer edge, and the // button itself is shrunk by 1 pixel. HBRUSH brush = GetSysColorBrush(COLOR_3DDKSHADOW); @@ -92,13 +93,21 @@ HRESULT NativeTheme::PaintButton(HDC hdc, InflateRect(rect, -1, -1); } } - DrawFrameControl(hdc, rect, DFC_BUTTON, classic_state); - // BP_RADIOBUTTON, BP_CHECKBOX, BP_GROUPBOX and BP_USERBUTTON have their - // focus drawn over the control. - if ((part_id != BP_PUSHBUTTON) && focused) + // Draw the focus rectangle (the dotted line box) only on buttons. For radio + // and checkboxes, we let webkit draw the focus rectangle (orange glow). + if ((BP_PUSHBUTTON == part_id) && focused) { + // The focus rect is inside the button. The exact number of pixels depends + // on whether we're in classic mode or using uxtheme. + if (handle && get_theme_content_rect_) { + get_theme_content_rect_(handle, hdc, part_id, state_id, rect, rect); + } else { + InflateRect(rect, -GetSystemMetrics(SM_CXEDGE), + -GetSystemMetrics(SM_CYEDGE)); + } DrawFocusRect(hdc, rect); + } return S_OK; } -- cgit v1.1