| 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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "ui/views/background.h" | 8 #include "ui/views/background.h" |
| 9 #include "ui/views/controls/button/label_button.h" | 9 #include "ui/views/controls/button/label_button.h" |
| 10 #include "ui/views/controls/label.h" | 10 #include "ui/views/controls/label.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 #if defined(OS_LINUX) | 71 #if defined(OS_LINUX) |
| 72 // Windows does not support TYPE_CONTROL top-level widgets. | 72 // Windows does not support TYPE_CONTROL top-level widgets. |
| 73 BuildButton(container, "Child widget", CHILD); | 73 BuildButton(container, "Child widget", CHILD); |
| 74 #endif | 74 #endif |
| 75 } | 75 } |
| 76 | 76 |
| 77 void WidgetExample::BuildButton(View* container, | 77 void WidgetExample::BuildButton(View* container, |
| 78 const std::string& label, | 78 const std::string& label, |
| 79 int tag) { | 79 int tag) { |
| 80 LabelButton* button = new LabelButton(this, ASCIIToUTF16(label)); | 80 LabelButton* button = new LabelButton(this, ASCIIToUTF16(label)); |
| 81 button->set_focusable(true); | 81 button->SetFocusable(true); |
| 82 button->set_tag(tag); | 82 button->set_tag(tag); |
| 83 container->AddChildView(button); | 83 container->AddChildView(button); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void WidgetExample::ShowWidget(View* sender, Widget::InitParams params) { | 86 void WidgetExample::ShowWidget(View* sender, Widget::InitParams params) { |
| 87 // Setup shared Widget heirarchy and bounds parameters. | 87 // Setup shared Widget heirarchy and bounds parameters. |
| 88 params.parent = sender->GetWidget()->GetNativeView(); | 88 params.parent = sender->GetWidget()->GetNativeView(); |
| 89 params.bounds = gfx::Rect(sender->GetBoundsInScreen().CenterPoint(), | 89 params.bounds = gfx::Rect(sender->GetBoundsInScreen().CenterPoint(), |
| 90 gfx::Size(300, 200)); | 90 gfx::Size(300, 200)); |
| 91 | 91 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 118 ShowWidget(sender, Widget::InitParams(Widget::InitParams::TYPE_CONTROL)); | 118 ShowWidget(sender, Widget::InitParams(Widget::InitParams::TYPE_CONTROL)); |
| 119 break; | 119 break; |
| 120 case CLOSE_WIDGET: | 120 case CLOSE_WIDGET: |
| 121 sender->GetWidget()->Close(); | 121 sender->GetWidget()->Close(); |
| 122 break; | 122 break; |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace examples | 126 } // namespace examples |
| 127 } // namespace views | 127 } // namespace views |
| OLD | NEW |