| 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 "ui/views/controls/button/checkbox.h" | 5 #include "ui/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 "ui/views/controls/label.h" | 10 #include "ui/views/controls/label.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 return kViewClassName; | 54 return kViewClassName; |
| 55 } | 55 } |
| 56 | 56 |
| 57 void Checkbox::GetAccessibleState(ui::AccessibleViewState* state) { | 57 void Checkbox::GetAccessibleState(ui::AccessibleViewState* state) { |
| 58 TextButtonBase::GetAccessibleState(state); | 58 TextButtonBase::GetAccessibleState(state); |
| 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() && (focusable() || 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); | 69 canvas->DrawFocusRect(bounds); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 void Checkbox::NotifyClick(const views::Event& event) { | 73 void Checkbox::NotifyClick(const views::Event& event) { |
| 74 SetChecked(!checked()); | 74 SetChecked(!checked()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 103 gfx::NativeTheme::ExtraParams extra; | 103 gfx::NativeTheme::ExtraParams extra; |
| 104 gfx::NativeTheme::State state = GetThemeState(&extra); | 104 gfx::NativeTheme::State state = GetThemeState(&extra); |
| 105 gfx::Size size(gfx::NativeTheme::instance()->GetPartSize(GetThemePart(), | 105 gfx::Size size(gfx::NativeTheme::instance()->GetPartSize(GetThemePart(), |
| 106 state, | 106 state, |
| 107 extra)); | 107 extra)); |
| 108 bounds.Offset(size.width() + kCheckboxLabelSpacing, 0); | 108 bounds.Offset(size.width() + kCheckboxLabelSpacing, 0); |
| 109 return bounds; | 109 return bounds; |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace views | 112 } // namespace views |
| OLD | NEW |