OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/controls/message_box_view.h" | 5 #include "ui/views/controls/message_box_view.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // MessageBoxView, private: | 161 // MessageBoxView, private: |
162 | 162 |
163 void MessageBoxView::Init(const InitParams& params) { | 163 void MessageBoxView::Init(const InitParams& params) { |
164 if (params.options & DETECT_DIRECTIONALITY) { | 164 if (params.options & DETECT_DIRECTIONALITY) { |
165 std::vector<string16> texts; | 165 std::vector<string16> texts; |
166 SplitStringIntoParagraphs(params.message, &texts); | 166 SplitStringIntoParagraphs(params.message, &texts); |
167 // If the text originates from a web page, its alignment is based on its | 167 // If the text originates from a web page, its alignment is based on its |
168 // first character with strong directionality. | 168 // first character with strong directionality. |
169 base::i18n::TextDirection message_direction = | 169 base::i18n::TextDirection message_direction = |
170 base::i18n::GetFirstStrongCharacterDirection(params.message); | 170 base::i18n::GetFirstStrongCharacterDirection(params.message); |
171 Label::Alignment alignment = | 171 gfx::HorizontalAlignment alignment = |
172 (message_direction == base::i18n::RIGHT_TO_LEFT) ? | 172 (message_direction == base::i18n::RIGHT_TO_LEFT) ? |
173 Label::ALIGN_RIGHT : Label::ALIGN_LEFT; | 173 gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT; |
174 for (size_t i = 0; i < texts.size(); ++i) { | 174 for (size_t i = 0; i < texts.size(); ++i) { |
175 Label* message_label = new Label(texts[i]); | 175 Label* message_label = new Label(texts[i]); |
176 // Don't set multi-line to true if the text is empty, else the label will | 176 // Don't set multi-line to true if the text is empty, else the label will |
177 // have a height of 0. | 177 // have a height of 0. |
178 message_label->SetMultiLine(!texts[i].empty()); | 178 message_label->SetMultiLine(!texts[i].empty()); |
179 message_label->SetAllowCharacterBreak(true); | 179 message_label->SetAllowCharacterBreak(true); |
180 message_label->set_directionality_mode(Label::AUTO_DETECT_DIRECTIONALITY); | 180 message_label->set_directionality_mode(Label::AUTO_DETECT_DIRECTIONALITY); |
181 message_label->SetHorizontalAlignment(alignment); | 181 message_label->SetHorizontalAlignment(alignment); |
182 message_labels_.push_back(message_label); | 182 message_labels_.push_back(message_label); |
183 } | 183 } |
184 } else { | 184 } else { |
185 Label* message_label = new Label(params.message); | 185 Label* message_label = new Label(params.message); |
186 message_label->SetMultiLine(true); | 186 message_label->SetMultiLine(true); |
187 message_label->SetAllowCharacterBreak(true); | 187 message_label->SetAllowCharacterBreak(true); |
188 message_label->SetHorizontalAlignment(Label::ALIGN_LEFT); | 188 message_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
189 message_labels_.push_back(message_label); | 189 message_labels_.push_back(message_label); |
190 } | 190 } |
191 | 191 |
192 if (params.options & HAS_PROMPT_FIELD) { | 192 if (params.options & HAS_PROMPT_FIELD) { |
193 prompt_field_ = new Textfield; | 193 prompt_field_ = new Textfield; |
194 prompt_field_->SetText(params.default_prompt); | 194 prompt_field_->SetText(params.default_prompt); |
195 } | 195 } |
196 | 196 |
197 top_inset_ = params.top_inset; | 197 top_inset_ = params.top_inset; |
198 bottom_inset_ = params.bottom_inset; | 198 bottom_inset_ = params.bottom_inset; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 if (checkbox_) { | 270 if (checkbox_) { |
271 layout->AddPaddingRow(0, inter_row_vertical_spacing_); | 271 layout->AddPaddingRow(0, inter_row_vertical_spacing_); |
272 layout->StartRow(0, checkbox_column_view_set_id); | 272 layout->StartRow(0, checkbox_column_view_set_id); |
273 layout->AddView(checkbox_); | 273 layout->AddView(checkbox_); |
274 } | 274 } |
275 | 275 |
276 layout->AddPaddingRow(0, inter_row_vertical_spacing_); | 276 layout->AddPaddingRow(0, inter_row_vertical_spacing_); |
277 } | 277 } |
278 | 278 |
279 } // namespace views | 279 } // namespace views |
OLD | NEW |