summaryrefslogtreecommitdiffstats
path: root/views/examples
diff options
context:
space:
mode:
Diffstat (limited to 'views/examples')
-rw-r--r--views/examples/examples_main.cc5
-rw-r--r--views/examples/native_window_views_example.cc91
-rw-r--r--views/examples/native_window_views_example.h32
3 files changed, 128 insertions, 0 deletions
diff --git a/views/examples/examples_main.cc b/views/examples/examples_main.cc
index be25458..7e123aa 100644
--- a/views/examples/examples_main.cc
+++ b/views/examples/examples_main.cc
@@ -22,6 +22,7 @@
#include "views/examples/native_theme_button_example.h"
#include "views/examples/native_theme_checkbox_example.h"
#include "views/examples/native_widget_views_example.h"
+#include "views/examples/native_window_views_example.h"
#include "views/examples/radio_button_example.h"
#include "views/examples/scroll_view_example.h"
#include "views/examples/single_split_view_example.h"
@@ -115,6 +116,10 @@ void ExamplesMain::Run() {
tabbed_pane->AddTab(native_widget_views_example.GetExampleTitle(),
native_widget_views_example.GetExampleView());
+ examples::NativeWindowViewsExample native_window_views_example(this);
+ tabbed_pane->AddTab(native_window_views_example.GetExampleTitle(),
+ native_window_views_example.GetExampleView());
+
examples::TextfieldExample textfield_example(this);
tabbed_pane->AddTab(textfield_example.GetExampleTitle(),
textfield_example.GetExampleView());
diff --git a/views/examples/native_window_views_example.cc b/views/examples/native_window_views_example.cc
new file mode 100644
index 0000000..b5291de
--- /dev/null
+++ b/views/examples/native_window_views_example.cc
@@ -0,0 +1,91 @@
+// 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/native_window_views_example.h"
+
+#include "ui/gfx/canvas.h"
+#include "views/examples/example_base.h"
+#include "views/controls/button/text_button.h"
+#include "views/controls/label.h"
+#include "views/layout/grid_layout.h"
+#include "views/view.h"
+#include "views/window/native_window_views.h"
+#include "views/window/window.h"
+#include "views/window/window_delegate.h"
+
+namespace examples {
+
+class WindowContentView : public views::View,
+ public views::WindowDelegate,
+ public views::ButtonListener {
+ public:
+ WindowContentView()
+ : ALLOW_THIS_IN_INITIALIZER_LIST(
+ button_(new views::TextButton(this, L"Click me!"))),
+ label_(new views::Label(L"Some label")) {
+ views::GridLayout* layout = new views::GridLayout(this);
+ views::ColumnSet* columns = layout->AddColumnSet(0);
+ columns->AddColumn(views::GridLayout::FILL,
+ views::GridLayout::FILL,
+ 1,
+ views::GridLayout::USE_PREF,
+ 0,
+ 0);
+ SetLayoutManager(layout);
+ layout->StartRow(0, 0);
+ layout->AddView(button_);
+ layout->StartRow(1, 0);
+ layout->AddView(label_);
+ }
+ virtual ~WindowContentView() {}
+
+ // Overridden from views::View:
+ virtual void OnPaint(gfx::Canvas* canvas) {
+ canvas->FillRectInt(SK_ColorWHITE, 0, 0, width(), height());
+ }
+
+ // Overridden from views::WindowDelegate:
+ virtual std::wstring GetWindowTitle() const {
+ return L"Example NativeWindowViews";
+ }
+ virtual View* GetContentsView() {
+ return this;
+ }
+
+ // Overridden from views::ButtonListener:
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event) {
+ if (sender == button_)
+ label_->SetText(L"Button Clicked!");
+ }
+
+ private:
+ views::TextButton* button_;
+ views::Label* label_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowContentView);
+};
+
+NativeWindowViewsExample::NativeWindowViewsExample(ExamplesMain* main)
+ : ExampleBase(main) {
+}
+
+NativeWindowViewsExample::~NativeWindowViewsExample() {
+}
+
+std::wstring NativeWindowViewsExample::GetExampleTitle() {
+ return L"NativeWindowViews";
+}
+
+void NativeWindowViewsExample::CreateExampleView(views::View* container) {
+ views::Window* window = new views::Window;
+ views::NativeWindowViews* nwv =
+ new views::NativeWindowViews(container, window);
+ views::Window::InitParams params(new WindowContentView);
+ params.native_window = nwv;
+ params.widget_init_params.bounds = gfx::Rect(20, 20, 600, 300);
+ window->InitWindow(params);
+ window->Show();
+}
+
+} // namespace examples
diff --git a/views/examples/native_window_views_example.h b/views/examples/native_window_views_example.h
new file mode 100644
index 0000000..361fdf8
--- /dev/null
+++ b/views/examples/native_window_views_example.h
@@ -0,0 +1,32 @@
+// 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.
+
+#ifndef VIEWS_EXAMPLES_NATIVE_WINDOW_VIEWS_EXAMPLE_H_
+#define VIEWS_EXAMPLES_NATIVE_WINDOW_VIEWS_EXAMPLE_H_
+#pragma once
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "views/examples/example_base.h"
+
+namespace examples {
+
+class NativeWindowViewsExample : public ExampleBase {
+ public:
+ explicit NativeWindowViewsExample(ExamplesMain* main);
+ virtual ~NativeWindowViewsExample();
+
+ // Overridden from ExampleBase:
+ virtual std::wstring GetExampleTitle() OVERRIDE;
+ virtual void CreateExampleView(views::View* container) OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(NativeWindowViewsExample);
+};
+
+} // namespace examples
+
+#endif // VIEWS_EXAMPLES_NATIVE_WINDOW_VIEWS_EXAMPLE_H_