| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 return true; | 155 return true; |
| 156 } | 156 } |
| 157 | 157 |
| 158 /////////////////////////////////////////////////////////////////////////////// | 158 /////////////////////////////////////////////////////////////////////////////// |
| 159 // MessageBoxView, private: | 159 // MessageBoxView, private: |
| 160 | 160 |
| 161 void MessageBoxView::Init(const InitParams& params) { | 161 void MessageBoxView::Init(const InitParams& params) { |
| 162 if (params.options & DETECT_DIRECTIONALITY) { | 162 if (params.options & DETECT_DIRECTIONALITY) { |
| 163 std::vector<string16> texts; | 163 std::vector<string16> texts; |
| 164 SplitStringIntoParagraphs(params.message, &texts); | 164 SplitStringIntoParagraphs(params.message, &texts); |
| 165 // If the text originates from a web page, its alignment is based on its | |
| 166 // first character with strong directionality. | |
| 167 base::i18n::TextDirection message_direction = | |
| 168 base::i18n::GetFirstStrongCharacterDirection(params.message); | |
| 169 Label::Alignment alignment = | |
| 170 (message_direction == base::i18n::RIGHT_TO_LEFT) ? | |
| 171 Label::ALIGN_RIGHT : Label::ALIGN_LEFT; | |
| 172 for (size_t i = 0; i < texts.size(); ++i) { | 165 for (size_t i = 0; i < texts.size(); ++i) { |
| 173 Label* message_label = new Label(texts[i]); | 166 Label* message_label = new Label(texts[i]); |
| 174 // Don't set multi-line to true if the text is empty, else the label will | 167 // Don't set multi-line to true if the text is empty, else the label will |
| 175 // have a height of 0. | 168 // have a height of 0. |
| 176 message_label->SetMultiLine(!texts[i].empty()); | 169 message_label->SetMultiLine(!texts[i].empty()); |
| 177 message_label->SetAllowCharacterBreak(true); | 170 message_label->SetAllowCharacterBreak(true); |
| 178 message_label->set_directionality_mode(Label::AUTO_DETECT_DIRECTIONALITY); | 171 // TODO(msw): Remove Options::DETECT_DIRECTIONALITY and split all text int
o paragraphs??? |
| 179 message_label->SetHorizontalAlignment(alignment); | 172 // message_label->set_directionality_mode(Label::AUTO_DETECT_DI
RECTIONALITY); |
| 173 // TODO(msw): Set leading... Test RTL with this value (that should mean "l
eading"...). |
| 174 message_label->SetHorizontalAlignment(Label::ALIGN_LEFT); |
| 180 message_labels_.push_back(message_label); | 175 message_labels_.push_back(message_label); |
| 181 } | 176 } |
| 182 } else { | 177 } else { |
| 183 Label* message_label = new Label(params.message); | 178 Label* message_label = new Label(params.message); |
| 184 message_label->SetMultiLine(true); | 179 message_label->SetMultiLine(true); |
| 185 message_label->SetAllowCharacterBreak(true); | 180 message_label->SetAllowCharacterBreak(true); |
| 181 // TODO(msw): Set leading... |
| 186 message_label->SetHorizontalAlignment(Label::ALIGN_LEFT); | 182 message_label->SetHorizontalAlignment(Label::ALIGN_LEFT); |
| 187 message_labels_.push_back(message_label); | 183 message_labels_.push_back(message_label); |
| 188 } | 184 } |
| 189 | 185 |
| 190 if (params.options & HAS_PROMPT_FIELD) { | 186 if (params.options & HAS_PROMPT_FIELD) { |
| 191 prompt_field_ = new Textfield; | 187 prompt_field_ = new Textfield; |
| 192 prompt_field_->SetText(params.default_prompt); | 188 prompt_field_->SetText(params.default_prompt); |
| 193 } | 189 } |
| 194 | 190 |
| 195 ResetLayoutManager(); | 191 ResetLayoutManager(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 if (checkbox_) { | 257 if (checkbox_) { |
| 262 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 258 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
| 263 layout->StartRow(0, checkbox_column_view_set_id); | 259 layout->StartRow(0, checkbox_column_view_set_id); |
| 264 layout->AddView(checkbox_); | 260 layout->AddView(checkbox_); |
| 265 } | 261 } |
| 266 | 262 |
| 267 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 263 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
| 268 } | 264 } |
| 269 | 265 |
| 270 } // namespace views | 266 } // namespace views |
| OLD | NEW |