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/controls/message_box_view.h" | 5 #include "chrome/views/controls/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/views/standard_layout.h" | 9 #include "chrome/browser/views/standard_layout.h" |
10 #include "chrome/common/l10n_util.h" | 10 #include "chrome/common/l10n_util.h" |
| 11 #include "chrome/common/message_box_flags.h" |
11 #include "chrome/views/controls/button/checkbox.h" | 12 #include "chrome/views/controls/button/checkbox.h" |
12 #include "chrome/views/window/client_view.h" | 13 #include "chrome/views/window/client_view.h" |
13 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
14 | 15 |
15 static const int kDefaultMessageWidth = 320; | 16 static const int kDefaultMessageWidth = 320; |
16 | 17 |
17 /////////////////////////////////////////////////////////////////////////////// | 18 /////////////////////////////////////////////////////////////////////////////// |
18 // MessageBoxView, public: | 19 // MessageBoxView, public: |
19 | 20 |
20 MessageBoxView::MessageBoxView(int dialog_flags, | 21 MessageBoxView::MessageBoxView(int dialog_flags, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 prompt_field_->SelectAll(); | 86 prompt_field_->SelectAll(); |
86 } | 87 } |
87 } | 88 } |
88 | 89 |
89 /////////////////////////////////////////////////////////////////////////////// | 90 /////////////////////////////////////////////////////////////////////////////// |
90 // MessageBoxView, private: | 91 // MessageBoxView, private: |
91 | 92 |
92 void MessageBoxView::Init(int dialog_flags, | 93 void MessageBoxView::Init(int dialog_flags, |
93 const std::wstring& default_prompt) { | 94 const std::wstring& default_prompt) { |
94 message_label_->SetMultiLine(true); | 95 message_label_->SetMultiLine(true); |
95 if (dialog_flags & kAutoDetectAlignment) { | 96 if (dialog_flags & MessageBox::kAutoDetectAlignment) { |
96 // Determine the alignment and directionality based on the first character | 97 // Determine the alignment and directionality based on the first character |
97 // with strong directionality. | 98 // with strong directionality. |
98 l10n_util::TextDirection direction = | 99 l10n_util::TextDirection direction = |
99 l10n_util::GetFirstStrongCharacterDirection(message_label_->GetText()); | 100 l10n_util::GetFirstStrongCharacterDirection(message_label_->GetText()); |
100 views::Label::Alignment alignment; | 101 views::Label::Alignment alignment; |
101 if (direction == l10n_util::RIGHT_TO_LEFT) | 102 if (direction == l10n_util::RIGHT_TO_LEFT) |
102 alignment = views::Label::ALIGN_RIGHT; | 103 alignment = views::Label::ALIGN_RIGHT; |
103 else | 104 else |
104 alignment = views::Label::ALIGN_LEFT; | 105 alignment = views::Label::ALIGN_LEFT; |
105 // In addition, we should set the RTL alignment mode as | 106 // In addition, we should set the RTL alignment mode as |
106 // AUTO_DETECT_ALIGNMENT so that the alignment will not be flipped around | 107 // AUTO_DETECT_ALIGNMENT so that the alignment will not be flipped around |
107 // in RTL locales. | 108 // in RTL locales. |
108 message_label_->SetRTLAlignmentMode(views::Label::AUTO_DETECT_ALIGNMENT); | 109 message_label_->SetRTLAlignmentMode(views::Label::AUTO_DETECT_ALIGNMENT); |
109 message_label_->SetHorizontalAlignment(alignment); | 110 message_label_->SetHorizontalAlignment(alignment); |
110 } else { | 111 } else { |
111 message_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 112 message_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
112 } | 113 } |
113 | 114 |
114 if (dialog_flags & kFlagHasPromptField) { | 115 if (dialog_flags & MessageBox::kFlagHasPromptField) { |
115 prompt_field_ = new views::TextField; | 116 prompt_field_ = new views::TextField; |
116 prompt_field_->SetText(default_prompt); | 117 prompt_field_->SetText(default_prompt); |
117 } | 118 } |
118 | 119 |
119 ResetLayoutManager(); | 120 ResetLayoutManager(); |
120 } | 121 } |
121 | 122 |
122 void MessageBoxView::ResetLayoutManager() { | 123 void MessageBoxView::ResetLayoutManager() { |
123 using views::GridLayout; | 124 using views::GridLayout; |
124 using views::ColumnSet; | 125 using views::ColumnSet; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 182 } |
182 | 183 |
183 if (checkbox_) { | 184 if (checkbox_) { |
184 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 185 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
185 layout->StartRow(0, checkbox_column_view_set_id); | 186 layout->StartRow(0, checkbox_column_view_set_id); |
186 layout->AddView(checkbox_); | 187 layout->AddView(checkbox_); |
187 } | 188 } |
188 | 189 |
189 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 190 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
190 } | 191 } |
OLD | NEW |