| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VIEWS_EXAMPLES_WIDGET_EXAMPLE_H_ | 5 #ifndef VIEWS_EXAMPLES_WIDGET_EXAMPLE_H_ |
| 6 #define VIEWS_EXAMPLES_WIDGET_EXAMPLE_H_ | 6 #define VIEWS_EXAMPLES_WIDGET_EXAMPLE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "views/background.h" | 9 #include "views/background.h" |
| 10 #include "views/box_layout.h" | 10 #include "views/box_layout.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 class WidgetExample : public ExampleBase, public views::ButtonListener { | 54 class WidgetExample : public ExampleBase, public views::ButtonListener { |
| 55 public: | 55 public: |
| 56 explicit WidgetExample(ExamplesMain* main) : ExampleBase(main) {} | 56 explicit WidgetExample(ExamplesMain* main) : ExampleBase(main) {} |
| 57 | 57 |
| 58 virtual ~WidgetExample() {} | 58 virtual ~WidgetExample() {} |
| 59 | 59 |
| 60 virtual std::wstring GetExampleTitle() { return L"Widget"; } | 60 virtual std::wstring GetExampleTitle() { return L"Widget"; } |
| 61 | 61 |
| 62 virtual void CreateExampleView(views::View* container) { | 62 virtual void CreateExampleView(views::View* container) { |
| 63 container->SetLayoutManager( | 63 container->SetLayoutManager( |
| 64 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 2)); | 64 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 2)); |
| 65 BuildButton(container, L"Create a popup widget", POPUP); | 65 BuildButton(container, L"Create a popup widget", POPUP); |
| 66 BuildButton(container, L"Create a transparent popup widget", | 66 BuildButton(container, L"Create a transparent popup widget", |
| 67 TRANSPARENT_POPUP); | 67 TRANSPARENT_POPUP); |
| 68 #if defined(OS_LINUX) | 68 #if defined(OS_LINUX) |
| 69 views::View* vert_container = new views::View(); | 69 views::View* vert_container = new views::View(); |
| 70 container->AddChildView(vert_container); | 70 container->AddChildView(vert_container); |
| 71 vert_container->SetLayoutManager( | 71 vert_container->SetLayoutManager( |
| 72 new views::BoxLayout(views::BoxLayout::kVertical, 0, 20)); | 72 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 20)); |
| 73 BuildButton(vert_container, L"Create a child widget", CHILD); | 73 BuildButton(vert_container, L"Create a child widget", CHILD); |
| 74 BuildButton(vert_container, L"Create a transparent child widget", | 74 BuildButton(vert_container, L"Create a transparent child widget", |
| 75 TRANSPARENT_CHILD); | 75 TRANSPARENT_CHILD); |
| 76 #endif | 76 #endif |
| 77 } | 77 } |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 enum Command { | 80 enum Command { |
| 81 POPUP, | 81 POPUP, |
| 82 CHILD, | 82 CHILD, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 96 // Add view/native buttons to close the popup widget. | 96 // Add view/native buttons to close the popup widget. |
| 97 views::TextButton* close_button = new views::TextButton(this, L"Close"); | 97 views::TextButton* close_button = new views::TextButton(this, L"Close"); |
| 98 close_button->set_tag(CLOSE_WIDGET); | 98 close_button->set_tag(CLOSE_WIDGET); |
| 99 // TODO(oshima): support transparent native view. | 99 // TODO(oshima): support transparent native view. |
| 100 views::NativeButton* native_button | 100 views::NativeButton* native_button |
| 101 = new views::NativeButton(this, L"Native Close"); | 101 = new views::NativeButton(this, L"Native Close"); |
| 102 native_button->set_tag(CLOSE_WIDGET); | 102 native_button->set_tag(CLOSE_WIDGET); |
| 103 | 103 |
| 104 views::View* button_container = new views::View(); | 104 views::View* button_container = new views::View(); |
| 105 button_container->SetLayoutManager( | 105 button_container->SetLayoutManager( |
| 106 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 1)); | 106 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 1)); |
| 107 button_container->AddChildView(close_button); | 107 button_container->AddChildView(close_button); |
| 108 button_container->AddChildView(native_button); | 108 button_container->AddChildView(native_button); |
| 109 | 109 |
| 110 views::View* widget_container = new views::View(); | 110 views::View* widget_container = new views::View(); |
| 111 widget_container->SetLayoutManager(new CenterLayout); | 111 widget_container->SetLayoutManager(new CenterLayout); |
| 112 widget_container->AddChildView(button_container); | 112 widget_container->AddChildView(button_container); |
| 113 | 113 |
| 114 widget->SetContentsView(widget_container); | 114 widget->SetContentsView(widget_container); |
| 115 | 115 |
| 116 if (transparency != Widget::Transparent) { | 116 if (transparency != Widget::Transparent) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 break; | 184 break; |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 DISALLOW_COPY_AND_ASSIGN(WidgetExample); | 188 DISALLOW_COPY_AND_ASSIGN(WidgetExample); |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 } // namespace examples | 191 } // namespace examples |
| 192 | 192 |
| 193 #endif // VIEWS_EXAMPLES_WIDGET_EXAMPLE_H_ | 193 #endif // VIEWS_EXAMPLES_WIDGET_EXAMPLE_H_ |
| OLD | NEW |