diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-01 11:40:04 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-01 11:40:04 +0000 |
commit | 1a5c97540834be79830865a401368c75f3138381 (patch) | |
tree | 433545cba236b0c628ae8d0002ccf98bce5411ce /views/examples/message_box_example.cc | |
parent | 7d121994978c05073f4d63bf44311465fcdb2251 (diff) | |
download | chromium_src-1a5c97540834be79830865a401368c75f3138381.zip chromium_src-1a5c97540834be79830865a401368c75f3138381.tar.gz chromium_src-1a5c97540834be79830865a401368c75f3138381.tar.bz2 |
views: Move the implementation of more examples from header to source file.
BUG=None
TEST=run out/Debug/views_examples, everything should works as before.
Review URL: http://codereview.chromium.org/6347030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73276 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/examples/message_box_example.cc')
-rw-r--r-- | views/examples/message_box_example.cc | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/views/examples/message_box_example.cc b/views/examples/message_box_example.cc new file mode 100644 index 0000000..0fa3777 --- /dev/null +++ b/views/examples/message_box_example.cc @@ -0,0 +1,67 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "views/examples/message_box_example.h" + +#include "views/layout/grid_layout.h" +#include "views/view.h" + +namespace examples { + +MessageBoxExample::MessageBoxExample(ExamplesMain* main) + : ExampleBase(main) { +} + +MessageBoxExample::~MessageBoxExample() { +} + +std::wstring MessageBoxExample::GetExampleTitle() { + return L"Message Box View"; +} + +void MessageBoxExample::CreateExampleView(views::View* container) { + message_box_view_ = new MessageBoxView( + 0, L"Message Box Message", L"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"); + + const int message_box_column = 0; + views::ColumnSet* column_set = layout->AddColumnSet(message_box_column); + column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, + views::GridLayout::USE_PREF, 0, 0); + layout->StartRow(1 /* expand */, message_box_column); + layout->AddView(message_box_view_); + + const int button_column = 1; + column_set = layout->AddColumnSet(button_column); + column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, + 0.5f, views::GridLayout::USE_PREF, 0, 0); + column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, + 0.5f, views::GridLayout::USE_PREF, 0, 0); + + layout->StartRow(0 /* no expand */, button_column); + + layout->AddView(status_); + layout->AddView(toggle_); +} + +void MessageBoxExample::ButtonPressed(views::Button* sender, + const views::Event& event) { + if (sender == status_) { + message_box_view_->SetCheckBoxLabel( + IntToOnOff(message_box_view_->IsCheckBoxSelected())); + PrintStatus(message_box_view_->IsCheckBoxSelected() ? + L"Check Box Selected" : L"Check Box Not Selected"); + } else if (sender == toggle_) { + message_box_view_->SetCheckBoxSelected( + !message_box_view_->IsCheckBoxSelected()); + } +} + +} // namespace examples |