| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/views/checkbox.h" | 5 #include "chrome/views/checkbox.h" |
| 6 | 6 |
| 7 #include "chrome/common/gfx/chrome_canvas.h" | 7 #include "chrome/common/gfx/chrome_canvas.h" |
| 8 #include "chrome/views/checkbox.h" | 8 #include "chrome/views/checkbox.h" |
| 9 #include "chrome/views/hwnd_view.h" | 9 #include "chrome/views/hwnd_view.h" |
| 10 #include "chrome/views/label.h" | 10 #include "chrome/views/label.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 134 } |
| 135 | 135 |
| 136 void CheckBox::HighlightButton(bool f) { | 136 void CheckBox::HighlightButton(bool f) { |
| 137 ::SendMessage(GetNativeControlHWND(), | 137 ::SendMessage(GetNativeControlHWND(), |
| 138 static_cast<UINT>(BM_SETSTATE), | 138 static_cast<UINT>(BM_SETSTATE), |
| 139 static_cast<WPARAM>(f), | 139 static_cast<WPARAM>(f), |
| 140 0); | 140 0); |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool CheckBox::LabelHitTest(const MouseEvent& event) { | 143 bool CheckBox::LabelHitTest(const MouseEvent& event) { |
| 144 CPoint p(event.x(), event.y()); | |
| 145 gfx::Rect r; | 144 gfx::Rect r; |
| 146 ComputeTextRect(&r); | 145 ComputeTextRect(&r); |
| 147 return r.Contains(event.x(), event.y()); | 146 return r.Contains(event.x(), event.y()); |
| 148 } | 147 } |
| 149 | 148 |
| 150 void CheckBox::OnMouseEntered(const MouseEvent& event) { | 149 void CheckBox::OnMouseEntered(const MouseEvent& event) { |
| 151 HighlightButton(LabelHitTest(event)); | 150 HighlightButton(LabelHitTest(event)); |
| 152 } | 151 } |
| 153 | 152 |
| 154 void CheckBox::OnMouseMoved(const MouseEvent& event) { | 153 void CheckBox::OnMouseMoved(const MouseEvent& event) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 171 | 170 |
| 172 void CheckBox::OnMouseReleased(const MouseEvent& event, | 171 void CheckBox::OnMouseReleased(const MouseEvent& event, |
| 173 bool canceled) { | 172 bool canceled) { |
| 174 HighlightButton(false); | 173 HighlightButton(false); |
| 175 if (!canceled && LabelHitTest(event)) | 174 if (!canceled && LabelHitTest(event)) |
| 176 OnCommand(BN_CLICKED, 0, GetNativeControlHWND()); | 175 OnCommand(BN_CLICKED, 0, GetNativeControlHWND()); |
| 177 } | 176 } |
| 178 | 177 |
| 179 } // namespace views | 178 } // namespace views |
| 180 | 179 |
| OLD | NEW |