OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/test/child_modal_window.h" | 5 #include "ash/test/child_modal_window.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 | 57 |
58 class ChildModalWindow : public views::WidgetDelegateView { | 58 class ChildModalWindow : public views::WidgetDelegateView { |
59 public: | 59 public: |
60 ChildModalWindow(); | 60 ChildModalWindow(); |
61 ~ChildModalWindow() override; | 61 ~ChildModalWindow() override; |
62 | 62 |
63 private: | 63 private: |
64 // Overridden from View: | 64 // Overridden from View: |
65 void OnPaint(gfx::Canvas* canvas) override; | 65 void OnPaint(gfx::Canvas* canvas) override; |
66 gfx::Size GetPreferredSize() const override; | 66 gfx::Size CalculatePreferredSize() const override; |
67 | 67 |
68 // Overridden from WidgetDelegate: | 68 // Overridden from WidgetDelegate: |
69 base::string16 GetWindowTitle() const override; | 69 base::string16 GetWindowTitle() const override; |
70 bool CanResize() const override; | 70 bool CanResize() const override; |
71 ui::ModalType GetModalType() const override; | 71 ui::ModalType GetModalType() const override; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(ChildModalWindow); | 73 DISALLOW_COPY_AND_ASSIGN(ChildModalWindow); |
74 }; | 74 }; |
75 | 75 |
76 ChildModalWindow::ChildModalWindow() { | 76 ChildModalWindow::ChildModalWindow() { |
77 views::Textfield* textfield = new views::Textfield; | 77 views::Textfield* textfield = new views::Textfield; |
78 AddChildView(textfield); | 78 AddChildView(textfield); |
79 textfield->SetBounds(kChildTextfieldLeft, kChildTextfieldTop, | 79 textfield->SetBounds(kChildTextfieldLeft, kChildTextfieldTop, |
80 kChildTextfieldWidth, kChildTextfieldHeight); | 80 kChildTextfieldWidth, kChildTextfieldHeight); |
81 } | 81 } |
82 | 82 |
83 ChildModalWindow::~ChildModalWindow() {} | 83 ChildModalWindow::~ChildModalWindow() {} |
84 | 84 |
85 void ChildModalWindow::OnPaint(gfx::Canvas* canvas) { | 85 void ChildModalWindow::OnPaint(gfx::Canvas* canvas) { |
86 canvas->FillRect(GetLocalBounds(), kChildColor); | 86 canvas->FillRect(GetLocalBounds(), kChildColor); |
87 } | 87 } |
88 | 88 |
89 gfx::Size ChildModalWindow::GetPreferredSize() const { | 89 gfx::Size ChildModalWindow::CalculatePreferredSize() const { |
90 return gfx::Size(kChildWindowWidth, kChildWindowHeight); | 90 return gfx::Size(kChildWindowWidth, kChildWindowHeight); |
91 } | 91 } |
92 | 92 |
93 base::string16 ChildModalWindow::GetWindowTitle() const { | 93 base::string16 ChildModalWindow::GetWindowTitle() const { |
94 return base::ASCIIToUTF16("Examples: Child Modal Window"); | 94 return base::ASCIIToUTF16("Examples: Child Modal Window"); |
95 } | 95 } |
96 | 96 |
97 bool ChildModalWindow::CanResize() const { | 97 bool ChildModalWindow::CanResize() const { |
98 return false; | 98 return false; |
99 } | 99 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 198 |
199 void ChildModalParent::OnWidgetDestroying(Widget* widget) { | 199 void ChildModalParent::OnWidgetDestroying(Widget* widget) { |
200 if (child_) { | 200 if (child_) { |
201 DCHECK_EQ(child_, widget); | 201 DCHECK_EQ(child_, widget); |
202 child_ = NULL; | 202 child_ = NULL; |
203 } | 203 } |
204 } | 204 } |
205 | 205 |
206 } // namespace test | 206 } // namespace test |
207 } // namespace ash | 207 } // namespace ash |
OLD | NEW |