summaryrefslogtreecommitdiffstats
path: root/views/examples
diff options
context:
space:
mode:
Diffstat (limited to 'views/examples')
-rw-r--r--views/examples/box_layout.cc37
-rw-r--r--views/examples/box_layout.h40
-rw-r--r--views/examples/widget_example.h10
3 files changed, 6 insertions, 81 deletions
diff --git a/views/examples/box_layout.cc b/views/examples/box_layout.cc
deleted file mode 100644
index 957d0d6..0000000
--- a/views/examples/box_layout.cc
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2010 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/box_layout.h"
-
-namespace examples {
-
-BoxLayout::BoxLayout(Orientation orientation, int margin)
- : orientation_(orientation),
- margin_(margin) {
-}
-
-void BoxLayout::Layout(views::View* host) {
- int height = host->height();
- int width = host->width();
- int count = host->GetChildViewCount();
-
- int z = 0;
- for (int i = 0; i < count; ++i) {
- views::View* child = host->GetChildViewAt(i);
-
- if (orientation_ == kVertical) {
- child->SetBounds(0, z, width, height / count);
- z = (height + margin_) * (i + 1) / count;
- } else if (orientation_ == kHorizontal) {
- child->SetBounds(z, 0, width / count, height);
- z = (width + margin_) * (i + 1) / count;
- }
- }
-}
-
-gfx::Size BoxLayout::GetPreferredSize(views::View* host) {
- return gfx::Size();
-}
-
-} // namespace examples
diff --git a/views/examples/box_layout.h b/views/examples/box_layout.h
deleted file mode 100644
index 2e802aa..0000000
--- a/views/examples/box_layout.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2010 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.
-
-#ifndef VIEWS_EXAMPLES_BOX_LAYOUT_H_
-#define VIEWS_EXAMPLES_BOX_LAYOUT_H_
-
-#include "views/layout_manager.h"
-
-namespace examples {
-
-// A layout manager that layouts child views vertically or horizontally.
-class BoxLayout : public views::LayoutManager {
- public:
- enum Orientation {
- kHorizontal,
- kVertical,
- };
-
- BoxLayout(Orientation orientation, int margin);
-
- virtual ~BoxLayout() {}
-
- // Overridden from views::LayoutManager:
- virtual void Layout(views::View* host);
-
- virtual gfx::Size GetPreferredSize(views::View* host);
-
- private:
- const Orientation orientation_;
-
- // The pixel distance between children.
- const int margin_;
-
- DISALLOW_COPY_AND_ASSIGN(BoxLayout);
-};
-
-} // namespace examples
-
-#endif // VIEWS_EXAMPLES_BOX_LAYOUT_H_
diff --git a/views/examples/widget_example.h b/views/examples/widget_example.h
index 4fff3e2..9208a1b 100644
--- a/views/examples/widget_example.h
+++ b/views/examples/widget_example.h
@@ -6,8 +6,8 @@
#define VIEWS_EXAMPLES_WIDGET_EXAMPLE_H_
#include "views/background.h"
+#include "views/box_layout.h"
#include "views/controls/button/text_button.h"
-#include "views/examples/box_layout.h"
#include "views/examples/example_base.h"
#include "views/view.h"
#include "views/widget/root_view.h"
@@ -59,14 +59,16 @@ class WidgetExample : public ExampleBase, public views::ButtonListener {
virtual std::wstring GetExampleTitle() { return L"Widget"; }
virtual void CreateExampleView(views::View* container) {
- container->SetLayoutManager(new BoxLayout(BoxLayout::kHorizontal, 2));
+ container->SetLayoutManager(
+ new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 2));
BuildButton(container, L"Create a popup widget", POPUP);
BuildButton(container, L"Create a transparent popup widget",
TRANSPARENT_POPUP);
#if defined(OS_LINUX)
views::View* vert_container = new views::View();
container->AddChildView(vert_container);
- vert_container->SetLayoutManager(new BoxLayout(BoxLayout::kVertical, 20));
+ vert_container->SetLayoutManager(
+ new views::BoxLayout(views::BoxLayout::kVertical, 0, 20));
BuildButton(vert_container, L"Create a child widget", CHILD);
BuildButton(vert_container, L"Create a transparent child widget",
TRANSPARENT_CHILD);
@@ -100,7 +102,7 @@ class WidgetExample : public ExampleBase, public views::ButtonListener {
views::View* button_container = new views::View();
button_container->SetLayoutManager(
- new BoxLayout(BoxLayout::kHorizontal, 1));
+ new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 1));
button_container->AddChildView(close_button);
button_container->AddChildView(native_button);