| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/controls/message_box_view.h" | 5 #include "views/controls/message_box_view.h" |
| 6 | 6 |
| 7 #include "app/message_box_flags.h" | |
| 8 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 9 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 10 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 11 #include "ui/base/clipboard/clipboard.h" | 10 #include "ui/base/clipboard/clipboard.h" |
| 12 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 11 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 12 #include "ui/base/message_box_flags.h" |
| 13 #include "views/controls/button/checkbox.h" | 13 #include "views/controls/button/checkbox.h" |
| 14 #include "views/standard_layout.h" | 14 #include "views/standard_layout.h" |
| 15 #include "views/views_delegate.h" | 15 #include "views/views_delegate.h" |
| 16 #include "views/window/client_view.h" | 16 #include "views/window/client_view.h" |
| 17 | 17 |
| 18 static const int kDefaultMessageWidth = 320; | 18 static const int kDefaultMessageWidth = 320; |
| 19 | 19 |
| 20 /////////////////////////////////////////////////////////////////////////////// | 20 /////////////////////////////////////////////////////////////////////////////// |
| 21 // MessageBoxView, public: | 21 // MessageBoxView, public: |
| 22 | 22 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 return true; | 111 return true; |
| 112 } | 112 } |
| 113 | 113 |
| 114 /////////////////////////////////////////////////////////////////////////////// | 114 /////////////////////////////////////////////////////////////////////////////// |
| 115 // MessageBoxView, private: | 115 // MessageBoxView, private: |
| 116 | 116 |
| 117 void MessageBoxView::Init(int dialog_flags, | 117 void MessageBoxView::Init(int dialog_flags, |
| 118 const std::wstring& default_prompt) { | 118 const std::wstring& default_prompt) { |
| 119 message_label_->SetMultiLine(true); | 119 message_label_->SetMultiLine(true); |
| 120 message_label_->SetAllowCharacterBreak(true); | 120 message_label_->SetAllowCharacterBreak(true); |
| 121 if (dialog_flags & MessageBoxFlags::kAutoDetectAlignment) { | 121 if (dialog_flags & ui::MessageBoxFlags::kAutoDetectAlignment) { |
| 122 // Determine the alignment and directionality based on the first character | 122 // Determine the alignment and directionality based on the first character |
| 123 // with strong directionality. | 123 // with strong directionality. |
| 124 base::i18n::TextDirection direction = | 124 base::i18n::TextDirection direction = |
| 125 base::i18n::GetFirstStrongCharacterDirection(message_label_->GetText()); | 125 base::i18n::GetFirstStrongCharacterDirection(message_label_->GetText()); |
| 126 views::Label::Alignment alignment; | 126 views::Label::Alignment alignment; |
| 127 if (direction == base::i18n::RIGHT_TO_LEFT) | 127 if (direction == base::i18n::RIGHT_TO_LEFT) |
| 128 alignment = views::Label::ALIGN_RIGHT; | 128 alignment = views::Label::ALIGN_RIGHT; |
| 129 else | 129 else |
| 130 alignment = views::Label::ALIGN_LEFT; | 130 alignment = views::Label::ALIGN_LEFT; |
| 131 // In addition, we should set the RTL alignment mode as | 131 // In addition, we should set the RTL alignment mode as |
| 132 // AUTO_DETECT_ALIGNMENT so that the alignment will not be flipped around | 132 // AUTO_DETECT_ALIGNMENT so that the alignment will not be flipped around |
| 133 // in RTL locales. | 133 // in RTL locales. |
| 134 message_label_->set_rtl_alignment_mode(views::Label::AUTO_DETECT_ALIGNMENT); | 134 message_label_->set_rtl_alignment_mode(views::Label::AUTO_DETECT_ALIGNMENT); |
| 135 message_label_->SetHorizontalAlignment(alignment); | 135 message_label_->SetHorizontalAlignment(alignment); |
| 136 } else { | 136 } else { |
| 137 message_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 137 message_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 138 } | 138 } |
| 139 | 139 |
| 140 if (dialog_flags & MessageBoxFlags::kFlagHasPromptField) { | 140 if (dialog_flags & ui::MessageBoxFlags::kFlagHasPromptField) { |
| 141 prompt_field_ = new views::Textfield; | 141 prompt_field_ = new views::Textfield; |
| 142 prompt_field_->SetText(WideToUTF16Hack(default_prompt)); | 142 prompt_field_->SetText(WideToUTF16Hack(default_prompt)); |
| 143 } | 143 } |
| 144 | 144 |
| 145 ResetLayoutManager(); | 145 ResetLayoutManager(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void MessageBoxView::ResetLayoutManager() { | 148 void MessageBoxView::ResetLayoutManager() { |
| 149 using views::GridLayout; | 149 using views::GridLayout; |
| 150 using views::ColumnSet; | 150 using views::ColumnSet; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 } | 207 } |
| 208 | 208 |
| 209 if (checkbox_) { | 209 if (checkbox_) { |
| 210 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 210 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
| 211 layout->StartRow(0, checkbox_column_view_set_id); | 211 layout->StartRow(0, checkbox_column_view_set_id); |
| 212 layout->AddView(checkbox_); | 212 layout->AddView(checkbox_); |
| 213 } | 213 } |
| 214 | 214 |
| 215 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 215 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
| 216 } | 216 } |
| OLD | NEW |