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