Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: views/examples/widget_example.cc

Issue 7610011: Update Sad Tab help text and link. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update SadTabControllerTest. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/examples/widget_example.h" 5 #include "views/examples/widget_example.h"
6 6
7 #include "views/controls/button/text_button.h" 7 #include "views/controls/button/text_button.h"
8 #include "views/layout/box_layout.h" 8 #include "views/layout/box_layout.h"
9 #include "views/layout/center_layout.h"
9 #include "views/layout/layout_manager.h" 10 #include "views/layout/layout_manager.h"
10 #include "views/view.h" 11 #include "views/view.h"
11 #include "views/widget/widget.h" 12 #include "views/widget/widget.h"
12 13
13 namespace {
14
15 // A layout manager that layouts a single child at
16 // the center of the host view.
17 class CenterLayout : public views::LayoutManager {
18 public:
19 CenterLayout() {}
20 virtual ~CenterLayout() {}
21
22 // Overridden from LayoutManager:
23 virtual void Layout(views::View* host) {
24 views::View* child = host->child_at(0);
25 gfx::Size size = child->GetPreferredSize();
26 child->SetBounds((host->width() - size.width()) / 2,
27 (host->height() - size.height()) / 2,
28 size.width(), size.height());
29 }
30
31 virtual gfx::Size GetPreferredSize(views::View* host) {
32 return gfx::Size();
33 }
34
35 private:
36 DISALLOW_COPY_AND_ASSIGN(CenterLayout);
37 };
38
39 } // namespace
40
41 namespace examples { 14 namespace examples {
42 15
43 WidgetExample::WidgetExample(ExamplesMain* main) 16 WidgetExample::WidgetExample(ExamplesMain* main)
44 : ExampleBase(main) { 17 : ExampleBase(main) {
45 } 18 }
46 19
47 WidgetExample::~WidgetExample() { 20 WidgetExample::~WidgetExample() {
48 } 21 }
49 22
50 std::wstring WidgetExample::GetExampleTitle() { 23 std::wstring WidgetExample::GetExampleTitle() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 new views::NativeTextButton(this, L"Native Close"); 58 new views::NativeTextButton(this, L"Native Close");
86 native_button->set_tag(CLOSE_WIDGET); 59 native_button->set_tag(CLOSE_WIDGET);
87 60
88 views::View* button_container = new views::View(); 61 views::View* button_container = new views::View();
89 button_container->SetLayoutManager( 62 button_container->SetLayoutManager(
90 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 1)); 63 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 1));
91 button_container->AddChildView(close_button); 64 button_container->AddChildView(close_button);
92 button_container->AddChildView(native_button); 65 button_container->AddChildView(native_button);
93 66
94 views::View* widget_container = new views::View(); 67 views::View* widget_container = new views::View();
95 widget_container->SetLayoutManager(new CenterLayout); 68 widget_container->SetLayoutManager(new views::CenterLayout());
96 widget_container->AddChildView(button_container); 69 widget_container->AddChildView(button_container);
97 70
98 widget->SetContentsView(widget_container); 71 widget->SetContentsView(widget_container);
99 72
100 if (!transparent) { 73 if (!transparent) {
101 widget_container->set_background( 74 widget_container->set_background(
102 views::Background::CreateStandardPanelBackground()); 75 views::Background::CreateStandardPanelBackground());
103 } 76 }
104 77
105 // Show the widget. 78 // Show the widget.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 CreateChild(sender, true); 135 CreateChild(sender, true);
163 break; 136 break;
164 #endif 137 #endif
165 case CLOSE_WIDGET: 138 case CLOSE_WIDGET:
166 sender->GetWidget()->Close(); 139 sender->GetWidget()->Close();
167 break; 140 break;
168 } 141 }
169 } 142 }
170 143
171 } // namespace examples 144 } // namespace examples
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698