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/message_box_view.h" | 5 #include "chrome/views/message_box_view.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/controller.h" | 9 #include "chrome/browser/controller.h" |
10 #include "chrome/browser/views/standard_layout.h" | 10 #include "chrome/browser/views/standard_layout.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 112 } |
113 | 113 |
114 void MessageBoxView::ResetLayoutManager() { | 114 void MessageBoxView::ResetLayoutManager() { |
115 using ChromeViews::GridLayout; | 115 using ChromeViews::GridLayout; |
116 using ChromeViews::ColumnSet; | 116 using ChromeViews::ColumnSet; |
117 | 117 |
118 // Initialize the Grid Layout Manager used for this dialog box. | 118 // Initialize the Grid Layout Manager used for this dialog box. |
119 GridLayout* layout = CreatePanelGridLayout(this); | 119 GridLayout* layout = CreatePanelGridLayout(this); |
120 SetLayoutManager(layout); | 120 SetLayoutManager(layout); |
121 | 121 |
122 CSize icon_size; | 122 gfx::Size icon_size; |
123 if (icon_) | 123 if (icon_) |
124 icon_->GetPreferredSize(&icon_size); | 124 icon_size = icon_->GetPreferredSize(); |
125 | 125 |
126 // Add the column set for the message displayed at the top of the dialog box. | 126 // Add the column set for the message displayed at the top of the dialog box. |
127 // And an icon, if one has been set. | 127 // And an icon, if one has been set. |
128 const int message_column_view_set_id = 0; | 128 const int message_column_view_set_id = 0; |
129 ColumnSet* column_set = layout->AddColumnSet(message_column_view_set_id); | 129 ColumnSet* column_set = layout->AddColumnSet(message_column_view_set_id); |
130 if (icon_) { | 130 if (icon_) { |
131 column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0, | 131 column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0, |
132 GridLayout::FIXED, icon_size.cx, icon_size.cy); | 132 GridLayout::FIXED, icon_size.width(), |
| 133 icon_size.height()); |
133 column_set->AddPaddingColumn(0, kUnrelatedControlHorizontalSpacing); | 134 column_set->AddPaddingColumn(0, kUnrelatedControlHorizontalSpacing); |
134 } | 135 } |
135 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 136 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
136 GridLayout::FIXED, message_width_, 0); | 137 GridLayout::FIXED, message_width_, 0); |
137 | 138 |
138 // Column set for prompt textfield, if one has been set. | 139 // Column set for prompt textfield, if one has been set. |
139 const int textfield_column_view_set_id = 1; | 140 const int textfield_column_view_set_id = 1; |
140 if (prompt_field_) { | 141 if (prompt_field_) { |
141 column_set = layout->AddColumnSet(textfield_column_view_set_id); | 142 column_set = layout->AddColumnSet(textfield_column_view_set_id); |
142 if (icon_) { | 143 if (icon_) { |
143 column_set->AddPaddingColumn(0, | 144 column_set->AddPaddingColumn(0, |
144 icon_size.cx + kUnrelatedControlHorizontalSpacing); | 145 icon_size.width() + kUnrelatedControlHorizontalSpacing); |
145 } | 146 } |
146 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 147 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
147 GridLayout::USE_PREF, 0, 0); | 148 GridLayout::USE_PREF, 0, 0); |
148 } | 149 } |
149 | 150 |
150 // Column set for checkbox, if one has been set. | 151 // Column set for checkbox, if one has been set. |
151 const int checkbox_column_view_set_id = 2; | 152 const int checkbox_column_view_set_id = 2; |
152 if (check_box_) { | 153 if (check_box_) { |
153 column_set = layout->AddColumnSet(checkbox_column_view_set_id); | 154 column_set = layout->AddColumnSet(checkbox_column_view_set_id); |
154 if (icon_) { | 155 if (icon_) { |
155 column_set->AddPaddingColumn(0, | 156 column_set->AddPaddingColumn(0, |
156 icon_size.cx + kUnrelatedControlHorizontalSpacing); | 157 icon_size.width() + kUnrelatedControlHorizontalSpacing); |
157 } | 158 } |
158 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 159 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
159 GridLayout::USE_PREF, 0, 0); | 160 GridLayout::USE_PREF, 0, 0); |
160 } | 161 } |
161 | 162 |
162 layout->StartRow(0, message_column_view_set_id); | 163 layout->StartRow(0, message_column_view_set_id); |
163 if (icon_) | 164 if (icon_) |
164 layout->AddView(icon_); | 165 layout->AddView(icon_); |
165 | 166 |
166 layout->AddView(message_label_); | 167 layout->AddView(message_label_); |
167 | 168 |
168 if (prompt_field_) { | 169 if (prompt_field_) { |
169 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 170 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
170 layout->StartRow(0, textfield_column_view_set_id); | 171 layout->StartRow(0, textfield_column_view_set_id); |
171 layout->AddView(prompt_field_); | 172 layout->AddView(prompt_field_); |
172 } | 173 } |
173 | 174 |
174 if (check_box_) { | 175 if (check_box_) { |
175 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 176 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
176 layout->StartRow(0, checkbox_column_view_set_id); | 177 layout->StartRow(0, checkbox_column_view_set_id); |
177 layout->AddView(check_box_); | 178 layout->AddView(check_box_); |
178 } | 179 } |
179 | 180 |
180 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 181 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
181 } | 182 } |
182 | 183 |
OLD | NEW |