| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ui/views/examples/widget_example.h" | 5 #include "ui/views/examples/widget_example.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "ui/views/background.h" | 10 #include "ui/views/background.h" |
| 11 #include "ui/views/controls/button/label_button.h" | 11 #include "ui/views/controls/button/label_button.h" |
| 12 #include "ui/views/controls/label.h" | 12 #include "ui/views/controls/label.h" |
| 13 #include "ui/views/layout/box_layout.h" | 13 #include "ui/views/layout/box_layout.h" |
| 14 #include "ui/views/style/platform_style.h" |
| 14 #include "ui/views/view.h" | 15 #include "ui/views/view.h" |
| 15 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 16 #include "ui/views/window/dialog_delegate.h" | 17 #include "ui/views/window/dialog_delegate.h" |
| 17 | 18 |
| 18 using base::ASCIIToUTF16; | 19 using base::ASCIIToUTF16; |
| 19 | 20 |
| 20 namespace views { | 21 namespace views { |
| 21 namespace examples { | 22 namespace examples { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 #if defined(OS_LINUX) | 81 #if defined(OS_LINUX) |
| 81 // Windows does not support TYPE_CONTROL top-level widgets. | 82 // Windows does not support TYPE_CONTROL top-level widgets. |
| 82 BuildButton(container, "Child widget", CHILD); | 83 BuildButton(container, "Child widget", CHILD); |
| 83 #endif | 84 #endif |
| 84 } | 85 } |
| 85 | 86 |
| 86 void WidgetExample::BuildButton(View* container, | 87 void WidgetExample::BuildButton(View* container, |
| 87 const std::string& label, | 88 const std::string& label, |
| 88 int tag) { | 89 int tag) { |
| 89 LabelButton* button = new LabelButton(this, ASCIIToUTF16(label)); | 90 LabelButton* button = new LabelButton(this, ASCIIToUTF16(label)); |
| 90 button->SetFocusable(true); | 91 PlatformStyle::ConfigureFocus(PlatformStyle::CONTROL::BUTTON, button); |
| 91 button->set_tag(tag); | 92 button->set_tag(tag); |
| 92 container->AddChildView(button); | 93 container->AddChildView(button); |
| 93 } | 94 } |
| 94 | 95 |
| 95 void WidgetExample::ShowWidget(View* sender, Widget::InitParams params) { | 96 void WidgetExample::ShowWidget(View* sender, Widget::InitParams params) { |
| 96 // Setup shared Widget heirarchy and bounds parameters. | 97 // Setup shared Widget heirarchy and bounds parameters. |
| 97 params.parent = sender->GetWidget()->GetNativeView(); | 98 params.parent = sender->GetWidget()->GetNativeView(); |
| 98 params.bounds = gfx::Rect(sender->GetBoundsInScreen().CenterPoint(), | 99 params.bounds = gfx::Rect(sender->GetBoundsInScreen().CenterPoint(), |
| 99 gfx::Size(300, 200)); | 100 gfx::Size(300, 200)); |
| 100 | 101 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 ShowWidget(sender, Widget::InitParams(Widget::InitParams::TYPE_CONTROL)); | 133 ShowWidget(sender, Widget::InitParams(Widget::InitParams::TYPE_CONTROL)); |
| 133 break; | 134 break; |
| 134 case CLOSE_WIDGET: | 135 case CLOSE_WIDGET: |
| 135 sender->GetWidget()->Close(); | 136 sender->GetWidget()->Close(); |
| 136 break; | 137 break; |
| 137 } | 138 } |
| 138 } | 139 } |
| 139 | 140 |
| 140 } // namespace examples | 141 } // namespace examples |
| 141 } // namespace views | 142 } // namespace views |
| OLD | NEW |