diff options
Diffstat (limited to 'ui/views/examples/widget_example.cc')
-rw-r--r-- | ui/views/examples/widget_example.cc | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/ui/views/examples/widget_example.cc b/ui/views/examples/widget_example.cc index a4c221b..c91e1e8 100644 --- a/ui/views/examples/widget_example.cc +++ b/ui/views/examples/widget_example.cc @@ -6,6 +6,7 @@ #include "base/utf_string_conversions.h" #include "ui/views/controls/button/text_button.h" +#include "ui/views/controls/label.h" #include "ui/views/layout/box_layout.h" #include "ui/views/view.h" #include "ui/views/widget/widget.h" @@ -18,13 +19,34 @@ namespace { class DialogExample : public DialogDelegateView { public: + DialogExample(); + virtual ~DialogExample(); virtual string16 GetWindowTitle() const OVERRIDE; + virtual View* CreateExtraView() OVERRIDE; + virtual View* CreateFootnoteView() OVERRIDE; }; +DialogExample::DialogExample() { + set_background(Background::CreateSolidBackground(SK_ColorGRAY)); + SetLayoutManager(new BoxLayout(BoxLayout::kVertical, 10, 10, 10)); + AddChildView(new Label(ASCIIToUTF16("Dialog contents label!"))); +} + +DialogExample::~DialogExample() { +} + string16 DialogExample::GetWindowTitle() const { return ASCIIToUTF16("Dialog Widget Example"); } +View* DialogExample::CreateExtraView() { + return new NativeTextButton(NULL, ASCIIToUTF16("Extra button!")); +} + +View* DialogExample::CreateFootnoteView() { + return new Label(ASCIIToUTF16("Footnote label!")); +} + } // namespace WidgetExample::WidgetExample() : ExampleBase("Widget") { @@ -34,7 +56,7 @@ WidgetExample::~WidgetExample() { } void WidgetExample::CreateExampleView(View* container) { - container->SetLayoutManager(new BoxLayout(BoxLayout::kHorizontal, 0, 0, 2)); + container->SetLayoutManager(new BoxLayout(BoxLayout::kHorizontal, 0, 0, 10)); BuildButton(container, "Popup widget", POPUP); BuildButton(container, "Dialog widget", DIALOG); #if defined(OS_LINUX) @@ -79,11 +101,8 @@ void WidgetExample::ButtonPressed(Button* sender, const ui::Event& event) { ShowWidget(sender, Widget::InitParams(Widget::InitParams::TYPE_POPUP)); break; case DIALOG: { - Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); - params.delegate = new DialogExample(); - params.remove_standard_frame = true; - params.transparent = true; - ShowWidget(sender, params); + DialogDelegateView::CreateDialogWidget(new DialogExample(), NULL, + sender->GetWidget()->GetNativeView())->Show(); break; } case CHILD: |