| OLD | NEW |
| 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/layout_manager.h" | 9 #include "views/layout/layout_manager.h" |
| 10 #include "views/view.h" | 10 #include "views/view.h" |
| 11 #include "views/widget/widget.h" | 11 #include "views/widget/widget.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 // A layout manager that layouts a single child at | 15 // A layout manager that layouts a single child at |
| 16 // the center of the host view. | 16 // the center of the host view. |
| 17 class CenterLayout : public views::LayoutManager { | 17 class CenterLayout : public views::LayoutManager { |
| 18 public: | 18 public: |
| 19 CenterLayout() {} | 19 CenterLayout() {} |
| 20 virtual ~CenterLayout() {} | 20 virtual ~CenterLayout() {} |
| 21 | 21 |
| 22 // Overridden from LayoutManager: | 22 // Overridden from LayoutManager: |
| 23 virtual void Layout(views::View* host) { | 23 virtual void Layout(views::View* host) { |
| 24 views::View* child = host->GetChildViewAt(0); | 24 views::View* child = host->child_at(0); |
| 25 gfx::Size size = child->GetPreferredSize(); | 25 gfx::Size size = child->GetPreferredSize(); |
| 26 child->SetBounds((host->width() - size.width()) / 2, | 26 child->SetBounds((host->width() - size.width()) / 2, |
| 27 (host->height() - size.height()) / 2, | 27 (host->height() - size.height()) / 2, |
| 28 size.width(), size.height()); | 28 size.width(), size.height()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 virtual gfx::Size GetPreferredSize(views::View* host) { | 31 virtual gfx::Size GetPreferredSize(views::View* host) { |
| 32 return gfx::Size(); | 32 return gfx::Size(); |
| 33 } | 33 } |
| 34 | 34 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 CreateChild(sender, true); | 162 CreateChild(sender, true); |
| 163 break; | 163 break; |
| 164 #endif | 164 #endif |
| 165 case CLOSE_WIDGET: | 165 case CLOSE_WIDGET: |
| 166 sender->GetWidget()->Close(); | 166 sender->GetWidget()->Close(); |
| 167 break; | 167 break; |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace examples | 171 } // namespace examples |
| OLD | NEW |