| 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" |
| 11 #include "ui/views/layout/box_layout.h" | 11 #include "ui/views/layout/box_layout.h" |
| 12 #include "ui/views/view.h" | 12 #include "ui/views/view.h" |
| 13 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
| 14 #include "ui/views/window/dialog_delegate.h" | 14 #include "ui/views/window/dialog_delegate.h" |
| 15 | 15 |
| 16 namespace views { | 16 namespace views { |
| 17 namespace examples { | 17 namespace examples { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 class DialogExample : public DialogDelegateView { | 21 class DialogExample : public DialogDelegateView { |
| 22 public: | 22 public: |
| 23 DialogExample(); | 23 DialogExample(); |
| 24 virtual ~DialogExample(); | 24 virtual ~DialogExample(); |
| 25 virtual string16 GetWindowTitle() const OVERRIDE; | 25 virtual base::string16 GetWindowTitle() const OVERRIDE; |
| 26 virtual View* CreateExtraView() OVERRIDE; | 26 virtual View* CreateExtraView() OVERRIDE; |
| 27 virtual View* CreateTitlebarExtraView() OVERRIDE; | 27 virtual View* CreateTitlebarExtraView() OVERRIDE; |
| 28 virtual View* CreateFootnoteView() OVERRIDE; | 28 virtual View* CreateFootnoteView() OVERRIDE; |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 DialogExample::DialogExample() { | 31 DialogExample::DialogExample() { |
| 32 set_background(Background::CreateSolidBackground(SK_ColorGRAY)); | 32 set_background(Background::CreateSolidBackground(SK_ColorGRAY)); |
| 33 SetLayoutManager(new BoxLayout(BoxLayout::kVertical, 10, 10, 10)); | 33 SetLayoutManager(new BoxLayout(BoxLayout::kVertical, 10, 10, 10)); |
| 34 AddChildView(new Label(ASCIIToUTF16("Dialog contents label!"))); | 34 AddChildView(new Label(ASCIIToUTF16("Dialog contents label!"))); |
| 35 } | 35 } |
| 36 | 36 |
| 37 DialogExample::~DialogExample() {} | 37 DialogExample::~DialogExample() {} |
| 38 | 38 |
| 39 string16 DialogExample::GetWindowTitle() const { | 39 base::string16 DialogExample::GetWindowTitle() const { |
| 40 return ASCIIToUTF16("Dialog Widget Example"); | 40 return ASCIIToUTF16("Dialog Widget Example"); |
| 41 } | 41 } |
| 42 | 42 |
| 43 View* DialogExample::CreateExtraView() { | 43 View* DialogExample::CreateExtraView() { |
| 44 LabelButton* button = new LabelButton(NULL, ASCIIToUTF16("Extra button!")); | 44 LabelButton* button = new LabelButton(NULL, ASCIIToUTF16("Extra button!")); |
| 45 button->SetStyle(Button::STYLE_NATIVE_TEXTBUTTON); | 45 button->SetStyle(Button::STYLE_NATIVE_TEXTBUTTON); |
| 46 return button; | 46 return button; |
| 47 } | 47 } |
| 48 | 48 |
| 49 View* DialogExample::CreateTitlebarExtraView() { | 49 View* DialogExample::CreateTitlebarExtraView() { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |