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 "views/controls/message_box_view.h" | 5 #include "views/controls/message_box_view.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/message_box_flags.h" | 8 #include "app/message_box_flags.h" |
9 #include "base/clipboard.h" | 9 #include "base/clipboard.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 prompt_field_(NULL), | 40 prompt_field_(NULL), |
41 icon_(NULL), | 41 icon_(NULL), |
42 checkbox_(NULL), | 42 checkbox_(NULL), |
43 message_width_(kDefaultMessageWidth), | 43 message_width_(kDefaultMessageWidth), |
44 ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)) { | 44 ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)) { |
45 Init(dialog_flags, default_prompt); | 45 Init(dialog_flags, default_prompt); |
46 } | 46 } |
47 | 47 |
48 std::wstring MessageBoxView::GetInputText() { | 48 std::wstring MessageBoxView::GetInputText() { |
49 if (prompt_field_) | 49 if (prompt_field_) |
50 return prompt_field_->text(); | 50 return UTF16ToWideHack(prompt_field_->text()); |
51 return EmptyWString(); | 51 return EmptyWString(); |
52 } | 52 } |
53 | 53 |
54 bool MessageBoxView::IsCheckBoxSelected() { | 54 bool MessageBoxView::IsCheckBoxSelected() { |
55 return checkbox_ ? checkbox_->checked() : false; | 55 return checkbox_ ? checkbox_->checked() : false; |
56 } | 56 } |
57 | 57 |
58 void MessageBoxView::SetIcon(const SkBitmap& icon) { | 58 void MessageBoxView::SetIcon(const SkBitmap& icon) { |
59 if (!icon_) | 59 if (!icon_) |
60 icon_ = new views::ImageView(); | 60 icon_ = new views::ImageView(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 return false; | 99 return false; |
100 | 100 |
101 if (!views::ViewsDelegate::views_delegate) | 101 if (!views::ViewsDelegate::views_delegate) |
102 return false; | 102 return false; |
103 | 103 |
104 Clipboard* clipboard = views::ViewsDelegate::views_delegate->GetClipboard(); | 104 Clipboard* clipboard = views::ViewsDelegate::views_delegate->GetClipboard(); |
105 if (!clipboard) | 105 if (!clipboard) |
106 return false; | 106 return false; |
107 | 107 |
108 ScopedClipboardWriter scw(clipboard); | 108 ScopedClipboardWriter scw(clipboard); |
109 scw.WriteText(message_label_->GetText()); | 109 scw.WriteText(WideToUTF16Hack(message_label_->GetText())); |
110 return true; | 110 return true; |
111 } | 111 } |
112 | 112 |
113 /////////////////////////////////////////////////////////////////////////////// | 113 /////////////////////////////////////////////////////////////////////////////// |
114 // MessageBoxView, private: | 114 // MessageBoxView, private: |
115 | 115 |
116 void MessageBoxView::Init(int dialog_flags, | 116 void MessageBoxView::Init(int dialog_flags, |
117 const std::wstring& default_prompt) { | 117 const std::wstring& default_prompt) { |
118 message_label_->SetMultiLine(true); | 118 message_label_->SetMultiLine(true); |
119 message_label_->SetAllowCharacterBreak(true); | 119 message_label_->SetAllowCharacterBreak(true); |
(...skipping 11 matching lines...) Expand all Loading... |
131 // AUTO_DETECT_ALIGNMENT so that the alignment will not be flipped around | 131 // AUTO_DETECT_ALIGNMENT so that the alignment will not be flipped around |
132 // in RTL locales. | 132 // in RTL locales. |
133 message_label_->SetRTLAlignmentMode(views::Label::AUTO_DETECT_ALIGNMENT); | 133 message_label_->SetRTLAlignmentMode(views::Label::AUTO_DETECT_ALIGNMENT); |
134 message_label_->SetHorizontalAlignment(alignment); | 134 message_label_->SetHorizontalAlignment(alignment); |
135 } else { | 135 } else { |
136 message_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 136 message_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
137 } | 137 } |
138 | 138 |
139 if (dialog_flags & MessageBoxFlags::kFlagHasPromptField) { | 139 if (dialog_flags & MessageBoxFlags::kFlagHasPromptField) { |
140 prompt_field_ = new views::Textfield; | 140 prompt_field_ = new views::Textfield; |
141 prompt_field_->SetText(default_prompt); | 141 prompt_field_->SetText(WideToUTF16Hack(default_prompt)); |
142 } | 142 } |
143 | 143 |
144 ResetLayoutManager(); | 144 ResetLayoutManager(); |
145 } | 145 } |
146 | 146 |
147 void MessageBoxView::ResetLayoutManager() { | 147 void MessageBoxView::ResetLayoutManager() { |
148 using views::GridLayout; | 148 using views::GridLayout; |
149 using views::ColumnSet; | 149 using views::ColumnSet; |
150 | 150 |
151 // Initialize the Grid Layout Manager used for this dialog box. | 151 // Initialize the Grid Layout Manager used for this dialog box. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } | 206 } |
207 | 207 |
208 if (checkbox_) { | 208 if (checkbox_) { |
209 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 209 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
210 layout->StartRow(0, checkbox_column_view_set_id); | 210 layout->StartRow(0, checkbox_column_view_set_id); |
211 layout->AddView(checkbox_); | 211 layout->AddView(checkbox_); |
212 } | 212 } |
213 | 213 |
214 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 214 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
215 } | 215 } |
OLD | NEW |