OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/controls/button/checkbox.h" | 5 #include "views/controls/button/checkbox.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/base/accessibility/accessible_view_state.h" | 8 #include "ui/base/accessibility/accessible_view_state.h" |
9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
10 #include "views/controls/label.h" | 10 #include "views/controls/label.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 state->role = ui::AccessibilityTypes::ROLE_CHECKBUTTON; | 59 state->role = ui::AccessibilityTypes::ROLE_CHECKBUTTON; |
60 state->state = checked() ? ui::AccessibilityTypes::STATE_CHECKED : 0; | 60 state->state = checked() ? ui::AccessibilityTypes::STATE_CHECKED : 0; |
61 } | 61 } |
62 | 62 |
63 void Checkbox::OnPaintFocusBorder(gfx::Canvas* canvas) { | 63 void Checkbox::OnPaintFocusBorder(gfx::Canvas* canvas) { |
64 if (HasFocus() && (IsFocusable() || IsAccessibilityFocusableInRootView())) { | 64 if (HasFocus() && (IsFocusable() || IsAccessibilityFocusableInRootView())) { |
65 gfx::Rect bounds(GetTextBounds()); | 65 gfx::Rect bounds(GetTextBounds()); |
66 // Increate the bounding box by one on each side so that that focus border | 66 // Increate the bounding box by one on each side so that that focus border |
67 // does not draw on top of the letters. | 67 // does not draw on top of the letters. |
68 bounds.Inset(-1, -1, -1, -1); | 68 bounds.Inset(-1, -1, -1, -1); |
69 canvas->DrawFocusRect(bounds.x(), bounds.y(), bounds.width(), | 69 canvas->DrawFocusRect(bounds); |
70 bounds.height()); | |
71 } | 70 } |
72 } | 71 } |
73 | 72 |
74 void Checkbox::NotifyClick(const views::Event& event) { | 73 void Checkbox::NotifyClick(const views::Event& event) { |
75 SetChecked(!checked()); | 74 SetChecked(!checked()); |
76 RequestFocus(); | 75 RequestFocus(); |
77 TextButtonBase::NotifyClick(event); | 76 TextButtonBase::NotifyClick(event); |
78 } | 77 } |
79 | 78 |
80 gfx::NativeTheme::Part Checkbox::GetThemePart() const { | 79 gfx::NativeTheme::Part Checkbox::GetThemePart() const { |
(...skipping 23 matching lines...) Expand all Loading... |
104 gfx::NativeTheme::ExtraParams extra; | 103 gfx::NativeTheme::ExtraParams extra; |
105 gfx::NativeTheme::State state = GetThemeState(&extra); | 104 gfx::NativeTheme::State state = GetThemeState(&extra); |
106 gfx::Size size(gfx::NativeTheme::instance()->GetPartSize(GetThemePart(), | 105 gfx::Size size(gfx::NativeTheme::instance()->GetPartSize(GetThemePart(), |
107 state, | 106 state, |
108 extra)); | 107 extra)); |
109 bounds.Offset(size.width() + kCheckboxLabelSpacing, 0); | 108 bounds.Offset(size.width() + kCheckboxLabelSpacing, 0); |
110 return bounds; | 109 return bounds; |
111 } | 110 } |
112 | 111 |
113 } // namespace views | 112 } // namespace views |
OLD | NEW |