diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-11 03:33:53 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-11 03:33:53 +0000 |
commit | 9dcdaae34846e064b2fdf173fb1796468a6db816 (patch) | |
tree | f7eae503ff1dc90af44969e05a0d298c6b02944b /views | |
parent | 78650b461b811a1abedff20e6b5d665505cd8ec4 (diff) | |
download | chromium_src-9dcdaae34846e064b2fdf173fb1796468a6db816.zip chromium_src-9dcdaae34846e064b2fdf173fb1796468a6db816.tar.gz chromium_src-9dcdaae34846e064b2fdf173fb1796468a6db816.tar.bz2 |
views: Change MessageBoxView API to string16.
BUG=68267
R=sky@chromium.org
Review URL: http://codereview.chromium.org/8221015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104843 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/message_box_view.cc | 24 | ||||
-rw-r--r-- | views/controls/message_box_view.h | 12 | ||||
-rw-r--r-- | views/examples/message_box_example.cc | 8 |
3 files changed, 23 insertions, 21 deletions
diff --git a/views/controls/message_box_view.cc b/views/controls/message_box_view.cc index a11edbd..5862460 100644 --- a/views/controls/message_box_view.cc +++ b/views/controls/message_box_view.cc @@ -21,7 +21,7 @@ #include "views/widget/widget.h" #include "views/window/client_view.h" -static const int kDefaultMessageWidth = 320; +const int kDefaultMessageWidth = 320; namespace views { @@ -29,10 +29,10 @@ namespace views { // MessageBoxView, public: MessageBoxView::MessageBoxView(int dialog_flags, - const std::wstring& message, - const std::wstring& default_prompt, + const string16& message, + const string16& default_prompt, int message_width) - : message_label_(new Label(WideToUTF16Hack(message))), + : message_label_(new Label(message)), prompt_field_(NULL), icon_(NULL), checkbox_(NULL), @@ -41,9 +41,9 @@ MessageBoxView::MessageBoxView(int dialog_flags, } MessageBoxView::MessageBoxView(int dialog_flags, - const std::wstring& message, - const std::wstring& default_prompt) - : message_label_(new Label(WideToUTF16Hack(message))), + const string16& message, + const string16& default_prompt) + : message_label_(new Label(message)), prompt_field_(NULL), icon_(NULL), checkbox_(NULL), @@ -69,11 +69,11 @@ void MessageBoxView::SetIcon(const SkBitmap& icon) { ResetLayoutManager(); } -void MessageBoxView::SetCheckBoxLabel(const std::wstring& label) { +void MessageBoxView::SetCheckBoxLabel(const string16& label) { if (!checkbox_) - checkbox_ = new Checkbox(label); + checkbox_ = new Checkbox(UTF16ToWideHack(label)); else - checkbox_->SetText(label); + checkbox_->SetText(UTF16ToWideHack(label)); ResetLayoutManager(); } @@ -127,7 +127,7 @@ bool MessageBoxView::AcceleratorPressed( // MessageBoxView, private: void MessageBoxView::Init(int dialog_flags, - const std::wstring& default_prompt) { + const string16& default_prompt) { message_label_->SetMultiLine(true); message_label_->SetAllowCharacterBreak(true); if (dialog_flags & ui::MessageBoxFlags::kAutoDetectAlignment) { @@ -152,7 +152,7 @@ void MessageBoxView::Init(int dialog_flags, if (dialog_flags & ui::MessageBoxFlags::kFlagHasPromptField) { prompt_field_ = new Textfield; - prompt_field_->SetText(WideToUTF16Hack(default_prompt)); + prompt_field_->SetText(default_prompt); } ResetLayoutManager(); diff --git a/views/controls/message_box_view.h b/views/controls/message_box_view.h index e278d38..453f29a 100644 --- a/views/controls/message_box_view.h +++ b/views/controls/message_box_view.h @@ -24,13 +24,13 @@ class Textfield; class VIEWS_EXPORT MessageBoxView : public View { public: MessageBoxView(int dialog_flags, - const std::wstring& message, - const std::wstring& default_prompt, + const string16& message, + const string16& default_prompt, int message_width); MessageBoxView(int dialog_flags, - const std::wstring& message, - const std::wstring& default_prompt); + const string16& message, + const string16& default_prompt); virtual ~MessageBoxView(); @@ -51,7 +51,7 @@ class VIEWS_EXPORT MessageBoxView : public View { // Adds a checkbox with the specified label to the message box if this is the // first call. Otherwise, it changes the label of the current checkbox. To // start, the message box has no checkbox until this function is called. - void SetCheckBoxLabel(const std::wstring& label); + void SetCheckBoxLabel(const string16& label); // Sets the state of the check-box. void SetCheckBoxSelected(bool selected); @@ -71,7 +71,7 @@ class VIEWS_EXPORT MessageBoxView : public View { private: // Sets up the layout manager and initializes the prompt field. This should // only be called once, from the constructor. - void Init(int dialog_flags, const std::wstring& default_prompt); + void Init(int dialog_flags, const string16& default_prompt); // Sets up the layout manager based on currently initialized views. Should be // called when a view is initialized or changed. diff --git a/views/examples/message_box_example.cc b/views/examples/message_box_example.cc index b46eb63..6d7d8f53 100644 --- a/views/examples/message_box_example.cc +++ b/views/examples/message_box_example.cc @@ -20,14 +20,16 @@ MessageBoxExample::~MessageBoxExample() { void MessageBoxExample::CreateExampleView(views::View* container) { message_box_view_ = new views::MessageBoxView( - 0, L"Message Box Message", L"Default Prompt"); + 0, + ASCIIToUTF16("Message Box Message"), + ASCIIToUTF16("Default Prompt")); status_ = new views::TextButton(this, L"Show Status"); toggle_ = new views::TextButton(this, L"Toggle Checkbox"); views::GridLayout* layout = new views::GridLayout(container); container->SetLayoutManager(layout); - message_box_view_->SetCheckBoxLabel(L"Check Box"); + message_box_view_->SetCheckBoxLabel(ASCIIToUTF16("Check Box")); const int message_box_column = 0; views::ColumnSet* column_set = layout->AddColumnSet(message_box_column); @@ -53,7 +55,7 @@ void MessageBoxExample::ButtonPressed(views::Button* sender, const views::Event& event) { if (sender == status_) { message_box_view_->SetCheckBoxLabel( - ASCIIToWide(BoolToOnOff(message_box_view_->IsCheckBoxSelected()))); + ASCIIToUTF16(BoolToOnOff(message_box_view_->IsCheckBoxSelected()))); PrintStatus(message_box_view_->IsCheckBoxSelected() ? "Check Box Selected" : "Check Box Not Selected"); } else if (sender == toggle_) { |