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/radio_button.h" | 5 #include "chrome/views/radio_button.h" |
6 | 6 |
7 #include "chrome/views/label.h" | 7 #include "chrome/views/label.h" |
8 #include "chrome/views/hwnd_view.h" | 8 #include "chrome/views/hwnd_view.h" |
9 #include "chrome/views/root_view.h" | 9 #include "chrome/views/root_view.h" |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // static | 53 // static |
54 int RadioButton::GetTextIndent() { | 54 int RadioButton::GetTextIndent() { |
55 return kRadioWidth + kRadioToLabel + kFocusPaddingHorizontal; | 55 return kRadioWidth + kRadioToLabel + kFocusPaddingHorizontal; |
56 } | 56 } |
57 | 57 |
58 | 58 |
59 std::string RadioButton::GetClassName() const { | 59 std::string RadioButton::GetClassName() const { |
60 return kViewClassName; | 60 return kViewClassName; |
61 } | 61 } |
62 | 62 |
63 void RadioButton::GetPreferredSize(CSize *out) { | 63 gfx::Size RadioButton::GetPreferredSize() { |
64 label_->GetPreferredSize(out); | 64 gfx::Size prefsize = label_->GetPreferredSize(); |
65 out->cy = std::max(static_cast<int>(out->cy + kFocusPaddingVertical * 2), | 65 prefsize.set_height(std::max(prefsize.height() + kFocusPaddingVertical * 2, |
66 kRadioHeight) ; | 66 kRadioHeight)); |
67 out->cx += kRadioToLabel + kRadioWidth + kFocusPaddingHorizontal * 2; | 67 prefsize.Enlarge(kRadioToLabel + kRadioWidth + kFocusPaddingHorizontal * 2, |
| 68 0); |
| 69 return prefsize; |
68 } | 70 } |
69 | 71 |
70 void RadioButton::Layout() { | 72 void RadioButton::Layout() { |
71 int label_x = GetTextIndent(); | 73 int label_x = GetTextIndent(); |
72 label_->SetBounds(label_x, 0, width() - label_x, height()); | 74 label_->SetBounds(label_x, 0, width() - label_x, height()); |
73 if (hwnd_view_) { | 75 if (hwnd_view_) { |
74 int first_line_height = label_->GetFont().height(); | 76 int first_line_height = label_->GetFont().height(); |
75 hwnd_view_->SetBounds(0, ((first_line_height - kRadioHeight) / 2) + 1, | 77 hwnd_view_->SetBounds(0, ((first_line_height - kRadioHeight) / 2) + 1, |
76 kRadioWidth, kRadioHeight); | 78 kRadioWidth, kRadioHeight); |
77 hwnd_view_->UpdateHWNDBounds(); | 79 hwnd_view_->UpdateHWNDBounds(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 iter != views.end(); ++iter) { | 115 iter != views.end(); ++iter) { |
114 RadioButton* radio_button = static_cast<RadioButton*>(*iter); | 116 RadioButton* radio_button = static_cast<RadioButton*>(*iter); |
115 if (radio_button->IsSelected()) | 117 if (radio_button->IsSelected()) |
116 return radio_button; | 118 return radio_button; |
117 } | 119 } |
118 return NULL; | 120 return NULL; |
119 } | 121 } |
120 | 122 |
121 } | 123 } |
122 | 124 |
OLD | NEW |