Chromium Code Reviews| 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" |
| 11 #include "ui/base/accessibility/accessible_view_state.h" | 11 #include "ui/base/accessibility/accessible_view_state.h" |
| 12 #include "ui/base/clipboard/clipboard.h" | 12 #include "ui/base/clipboard/clipboard.h" |
| 13 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 13 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 14 #include "ui/views/controls/button/checkbox.h" | 14 #include "ui/views/controls/button/checkbox.h" |
| 15 #include "ui/views/controls/image_view.h" | 15 #include "ui/views/controls/image_view.h" |
| 16 #include "ui/views/controls/label.h" | 16 #include "ui/views/controls/label.h" |
| 17 #include "ui/views/controls/textfield/textfield.h" | 17 #include "ui/views/controls/textfield/textfield.h" |
| 18 #include "ui/views/layout/grid_layout.h" | 18 #include "ui/views/layout/grid_layout.h" |
| 19 #include "ui/views/layout/layout_constants.h" | 19 #include "ui/views/layout/layout_constants.h" |
| 20 #include "ui/views/views_delegate.h" | 20 #include "ui/views/views_delegate.h" |
| 21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
| 22 #include "ui/views/window/client_view.h" | 22 #include "ui/views/window/client_view.h" |
| 23 | 23 |
| 24 namespace { | |
| 25 | |
| 24 const int kDefaultMessageWidth = 320; | 26 const int kDefaultMessageWidth = 320; |
| 25 | 27 |
| 26 namespace { | |
| 27 | |
| 28 // Paragraph separators are defined in | 28 // Paragraph separators are defined in |
| 29 // http://www.unicode.org/Public/6.0.0/ucd/extracted/DerivedBidiClass.txt | 29 // http://www.unicode.org/Public/6.0.0/ucd/extracted/DerivedBidiClass.txt |
| 30 // | 30 // |
| 31 // # Bidi_Class=Paragraph_Separator | 31 // # Bidi_Class=Paragraph_Separator |
| 32 // | 32 // |
| 33 // 000A ; B # Cc <control-000A> | 33 // 000A ; B # Cc <control-000A> |
| 34 // 000D ; B # Cc <control-000D> | 34 // 000D ; B # Cc <control-000D> |
| 35 // 001C..001E ; B # Cc [3] <control-001C>..<control-001E> | 35 // 001C..001E ; B # Cc [3] <control-001C>..<control-001E> |
| 36 // 0085 ; B # Cc <control-0085> | 36 // 0085 ; B # Cc <control-0085> |
| 37 // 2029 ; B # Zp PARAGRAPH SEPARATOR | 37 // 2029 ; B # Zp PARAGRAPH SEPARATOR |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 r->push_back(last); | 89 r->push_back(last); |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace | 92 } // namespace |
| 93 | 93 |
| 94 namespace views { | 94 namespace views { |
| 95 | 95 |
| 96 /////////////////////////////////////////////////////////////////////////////// | 96 /////////////////////////////////////////////////////////////////////////////// |
| 97 // MessageBoxView, public: | 97 // MessageBoxView, public: |
| 98 | 98 |
| 99 MessageBoxView::MessageBoxView(int options, | 99 MessageBoxView::InitParams::InitParams(const string16& message) |
| 100 const string16& message, | 100 : options(NO_OPTIONS), |
| 101 const string16& default_prompt, | 101 message(message), |
| 102 int message_width) | 102 message_width(kDefaultMessageWidth) { |
| 103 } | |
| 104 | |
| 105 MessageBoxView::MessageBoxView(const InitParams& params) | |
| 103 : prompt_field_(NULL), | 106 : prompt_field_(NULL), |
| 104 icon_(NULL), | 107 icon_(NULL), |
| 105 checkbox_(NULL), | 108 checkbox_(NULL), |
| 106 message_width_(message_width) { | 109 message_width_(params.message_width) { |
| 107 Init(options, message, default_prompt); | 110 Init(params.options, params.message, params.default_prompt); |
|
sky
2012/05/11 17:31:10
Pass InitParams to Init.
tfarina
2012/05/11 17:41:42
Done.
| |
| 108 } | |
| 109 | |
| 110 MessageBoxView::MessageBoxView(int options, | |
| 111 const string16& message, | |
| 112 const string16& default_prompt) | |
| 113 : prompt_field_(NULL), | |
| 114 icon_(NULL), | |
| 115 checkbox_(NULL), | |
| 116 message_width_(kDefaultMessageWidth) { | |
| 117 Init(options, message, default_prompt); | |
| 118 } | 111 } |
| 119 | 112 |
| 120 MessageBoxView::~MessageBoxView() {} | 113 MessageBoxView::~MessageBoxView() {} |
| 121 | 114 |
| 122 string16 MessageBoxView::GetInputText() { | 115 string16 MessageBoxView::GetInputText() { |
| 123 return prompt_field_ ? prompt_field_->text() : string16(); | 116 return prompt_field_ ? prompt_field_->text() : string16(); |
| 124 } | 117 } |
| 125 | 118 |
| 126 bool MessageBoxView::IsCheckBoxSelected() { | 119 bool MessageBoxView::IsCheckBoxSelected() { |
| 127 return checkbox_ ? checkbox_->checked() : false; | 120 return checkbox_ ? checkbox_->checked() : false; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 if (checkbox_) { | 290 if (checkbox_) { |
| 298 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 291 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
| 299 layout->StartRow(0, checkbox_column_view_set_id); | 292 layout->StartRow(0, checkbox_column_view_set_id); |
| 300 layout->AddView(checkbox_); | 293 layout->AddView(checkbox_); |
| 301 } | 294 } |
| 302 | 295 |
| 303 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 296 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
| 304 } | 297 } |
| 305 | 298 |
| 306 } // namespace views | 299 } // namespace views |
| OLD | NEW |