| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 int new_width = std::min(width() - (kCheckBoxWidth + kCheckBoxToLabel), | 77 int new_width = std::min(width() - (kCheckBoxWidth + kCheckBoxToLabel), |
| 78 s.width()); | 78 s.width()); |
| 79 out->set_width(std::max(0, new_width)); | 79 out->set_width(std::max(0, new_width)); |
| 80 out->set_height(s.height()); | 80 out->set_height(s.height()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void CheckBox::Paint(ChromeCanvas* canvas) { | 83 void CheckBox::Paint(ChromeCanvas* canvas) { |
| 84 gfx::Rect r; | 84 gfx::Rect r; |
| 85 ComputeTextRect(&r); | 85 ComputeTextRect(&r); |
| 86 // Paint the focus border if any. | 86 // Paint the focus border if any. |
| 87 if (HasFocus()) | 87 if (HasFocus()) { |
| 88 canvas->DrawFocusRect(r.x() - kFocusPaddingHorizontal, | 88 // Mirror left point for rectangle to draw focus for RTL text. |
| 89 canvas->DrawFocusRect(MirroredLeftPointForRect(r) - kFocusPaddingHorizontal, |
| 89 r.y() - kFocusPaddingVertical, | 90 r.y() - kFocusPaddingVertical, |
| 90 r.width() + kFocusPaddingHorizontal * 2, | 91 r.width() + kFocusPaddingHorizontal * 2, |
| 91 r.height() + kFocusPaddingVertical * 2); | 92 r.height() + kFocusPaddingVertical * 2); |
| 93 } |
| 92 PaintFloatingView(canvas, label_, r.x(), r.y(), r.width(), r.height()); | 94 PaintFloatingView(canvas, label_, r.x(), r.y(), r.width(), r.height()); |
| 93 } | 95 } |
| 94 | 96 |
| 95 void CheckBox::SetEnabled(bool enabled) { | 97 void CheckBox::SetEnabled(bool enabled) { |
| 96 if (enabled_ == enabled) | 98 if (enabled_ == enabled) |
| 97 return; | 99 return; |
| 98 NativeButton::SetEnabled(enabled); | 100 NativeButton::SetEnabled(enabled); |
| 99 label_->SetEnabled(enabled); | 101 label_->SetEnabled(enabled); |
| 100 } | 102 } |
| 101 | 103 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 173 |
| 172 void CheckBox::OnMouseReleased(const MouseEvent& event, | 174 void CheckBox::OnMouseReleased(const MouseEvent& event, |
| 173 bool canceled) { | 175 bool canceled) { |
| 174 HighlightButton(false); | 176 HighlightButton(false); |
| 175 if (!canceled && LabelHitTest(event)) | 177 if (!canceled && LabelHitTest(event)) |
| 176 OnCommand(BN_CLICKED, 0, GetNativeControlHWND()); | 178 OnCommand(BN_CLICKED, 0, GetNativeControlHWND()); |
| 177 } | 179 } |
| 178 | 180 |
| 179 } // namespace views | 181 } // namespace views |
| 180 | 182 |
| OLD | NEW |