| Index: ui/views/examples/fill_example.cc
|
| diff --git a/ui/views/examples/fill_example.cc b/ui/views/examples/fill_example.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..74295f9214da87889d96799b62bbe75bafd5dbe0
|
| --- /dev/null
|
| +++ b/ui/views/examples/fill_example.cc
|
| @@ -0,0 +1,83 @@
|
| +// Copyright (c) 2012 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 "ui/views/examples/fill_example.h"
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| +#include "build/build_config.h"
|
| +#include "ui/views/background.h"
|
| +#include "ui/views/border.h"
|
| +#include "ui/views/controls/button/label_button.h"
|
| +#include "ui/views/controls/label.h"
|
| +#include "ui/views/layout/align_layout.h"
|
| +#include "ui/views/view.h"
|
| +#include "ui/views/widget/widget.h"
|
| +
|
| +using base::ASCIIToUTF16;
|
| +
|
| +namespace views {
|
| +namespace examples {
|
| +
|
| +FillExample::FillExample() : ExampleBase("Fill") {}
|
| +
|
| +FillExample::~FillExample() {}
|
| +
|
| +void FillExample::CreateExampleView(View* container) {
|
| + container->SetLayoutManager(new AlignLayout());
|
| + new_fill_view_button_ = new LabelButton(this, ASCIIToUTF16("New View"));
|
| + new_fill_view_button_->SetFocusForPlatform();
|
| + new_fill_view_button_->set_request_focus_on_press(true);
|
| + new_fill_view_button_->SetStyle(Button::STYLE_BUTTON);
|
| + new_fill_view_button_->attributes().Add(
|
| + base::WrapUnique(new FillAttribute(views::Fill::Content)));
|
| + container->AddChildView(new_fill_view_button_);
|
| +}
|
| +
|
| +void FillExample::ButtonPressed(Button* sender, const ui::Event& event) {
|
| + Label* label = new Label(LabelText(current_fill_));
|
| + label->SetBorder(Border::CreateSolidBorder(1, SK_ColorGRAY));
|
| + label->attributes().Add(base::WrapUnique(new FillAttribute(current_fill_)));
|
| + label->SetBounds(0, 0, 20, 20);
|
| + sender->parent()->AddChildView(label);
|
| + sender->parent()->Layout();
|
| + switch (current_fill_) {
|
| + case views::Fill::Top: {
|
| + current_fill_ = views::Fill::Bottom;
|
| + break;
|
| + }
|
| + case views::Fill::Bottom: {
|
| + current_fill_ = views::Fill::Left;
|
| + break;
|
| + }
|
| + case views::Fill::Left: {
|
| + current_fill_ = views::Fill::Right;
|
| + break;
|
| + }
|
| + case views::Fill::Right: {
|
| + current_fill_ = views::Fill::Top;
|
| + break;
|
| + }
|
| + default:
|
| + current_fill_ = views::Fill::Top;
|
| + }
|
| +}
|
| +
|
| +base::string16 FillExample::LabelText(views::Fill fill) {
|
| + switch (fill) {
|
| + case views::Fill::Top:
|
| + return ASCIIToUTF16("Top Align");
|
| + case views::Fill::Bottom:
|
| + return ASCIIToUTF16("Bottom Align");
|
| + case views::Fill::Left:
|
| + return ASCIIToUTF16("Left Align");
|
| + case views::Fill::Right:
|
| + return ASCIIToUTF16("Right Align");
|
| + default:
|
| + return ASCIIToUTF16("None Or Content Align");
|
| + }
|
| +}
|
| +
|
| +} // namespace examples
|
| +} // namespace views
|
|
|