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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 124 |
125 bool Checkbox::OnMousePressed(const MouseEvent& event) { | 125 bool Checkbox::OnMousePressed(const MouseEvent& event) { |
126 native_wrapper_->SetPushed(HitTestLabel(event)); | 126 native_wrapper_->SetPushed(HitTestLabel(event)); |
127 return true; | 127 return true; |
128 } | 128 } |
129 | 129 |
130 bool Checkbox::OnMouseDragged(const MouseEvent& event) { | 130 bool Checkbox::OnMouseDragged(const MouseEvent& event) { |
131 return false; | 131 return false; |
132 } | 132 } |
133 | 133 |
134 void Checkbox::OnMouseReleased(const MouseEvent& event, bool canceled) { | 134 void Checkbox::OnMouseReleased(const MouseEvent& event) { |
135 native_wrapper_->SetPushed(false); | 135 OnMouseCaptureLost(); |
136 if (!canceled && HitTestLabel(event)) { | 136 if (HitTestLabel(event)) { |
137 SetChecked(!checked()); | 137 SetChecked(!checked()); |
138 ButtonPressed(); | 138 ButtonPressed(); |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
| 142 void Checkbox::OnMouseCaptureLost() { |
| 143 native_wrapper_->SetPushed(false); |
| 144 } |
| 145 |
142 void Checkbox::OnMouseMoved(const MouseEvent& event) { | 146 void Checkbox::OnMouseMoved(const MouseEvent& event) { |
143 native_wrapper_->SetPushed(HitTestLabel(event)); | 147 native_wrapper_->SetPushed(HitTestLabel(event)); |
144 } | 148 } |
145 | 149 |
146 void Checkbox::OnMouseEntered(const MouseEvent& event) { | 150 void Checkbox::OnMouseEntered(const MouseEvent& event) { |
147 native_wrapper_->SetPushed(HitTestLabel(event)); | 151 native_wrapper_->SetPushed(HitTestLabel(event)); |
148 } | 152 } |
149 | 153 |
150 void Checkbox::OnMouseExited(const MouseEvent& event) { | 154 void Checkbox::OnMouseExited(const MouseEvent& event) { |
151 native_wrapper_->SetPushed(false); | 155 native_wrapper_->SetPushed(false); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 void Checkbox::Init(const std::wstring& label_text) { | 215 void Checkbox::Init(const std::wstring& label_text) { |
212 // Checkboxs don't need to enforce a minimum size. | 216 // Checkboxs don't need to enforce a minimum size. |
213 set_ignore_minimum_size(true); | 217 set_ignore_minimum_size(true); |
214 label_ = new Label(label_text); | 218 label_ = new Label(label_text); |
215 label_->SetHasFocusBorder(true); | 219 label_->SetHasFocusBorder(true); |
216 label_->SetHorizontalAlignment(Label::ALIGN_LEFT); | 220 label_->SetHorizontalAlignment(Label::ALIGN_LEFT); |
217 AddChildView(label_); | 221 AddChildView(label_); |
218 } | 222 } |
219 | 223 |
220 } // namespace views | 224 } // namespace views |
OLD | NEW |