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/test/child_modal_window.h" | 5 #include "ui/views/test/child_modal_window.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" // ASCIIToUTF16 | 7 #include "base/strings/utf_string_conversions.h" // ASCIIToUTF16 |
8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
10 #include "ui/views/background.h" | 10 #include "ui/views/background.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 ChildModalWindow(); | 58 ChildModalWindow(); |
59 virtual ~ChildModalWindow(); | 59 virtual ~ChildModalWindow(); |
60 | 60 |
61 private: | 61 private: |
62 // Overridden from View: | 62 // Overridden from View: |
63 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 63 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
64 virtual gfx::Size GetPreferredSize() OVERRIDE; | 64 virtual gfx::Size GetPreferredSize() OVERRIDE; |
65 | 65 |
66 // Overridden from WidgetDelegate: | 66 // Overridden from WidgetDelegate: |
67 virtual View* GetContentsView() OVERRIDE; | 67 virtual View* GetContentsView() OVERRIDE; |
68 virtual string16 GetWindowTitle() const OVERRIDE; | 68 virtual base::string16 GetWindowTitle() const OVERRIDE; |
69 virtual bool CanResize() const OVERRIDE; | 69 virtual bool CanResize() const OVERRIDE; |
70 virtual ui::ModalType GetModalType() const OVERRIDE; | 70 virtual ui::ModalType GetModalType() const OVERRIDE; |
71 | 71 |
72 DISALLOW_COPY_AND_ASSIGN(ChildModalWindow); | 72 DISALLOW_COPY_AND_ASSIGN(ChildModalWindow); |
73 }; | 73 }; |
74 | 74 |
75 ChildModalWindow::ChildModalWindow() { | 75 ChildModalWindow::ChildModalWindow() { |
76 Textfield* textfield = new Textfield; | 76 Textfield* textfield = new Textfield; |
77 AddChildView(textfield); | 77 AddChildView(textfield); |
78 textfield->SetBounds( | 78 textfield->SetBounds( |
79 kChildTextfieldLeft, kChildTextfieldTop, | 79 kChildTextfieldLeft, kChildTextfieldTop, |
80 kChildTextfieldWidth, kChildTextfieldHeight); | 80 kChildTextfieldWidth, kChildTextfieldHeight); |
81 } | 81 } |
82 | 82 |
83 ChildModalWindow::~ChildModalWindow() { | 83 ChildModalWindow::~ChildModalWindow() { |
84 } | 84 } |
85 | 85 |
86 void ChildModalWindow::OnPaint(gfx::Canvas* canvas) { | 86 void ChildModalWindow::OnPaint(gfx::Canvas* canvas) { |
87 canvas->FillRect(GetLocalBounds(), kChildColor); | 87 canvas->FillRect(GetLocalBounds(), kChildColor); |
88 } | 88 } |
89 | 89 |
90 gfx::Size ChildModalWindow::GetPreferredSize() { | 90 gfx::Size ChildModalWindow::GetPreferredSize() { |
91 return gfx::Size(kChildWindowWidth, kChildWindowHeight); | 91 return gfx::Size(kChildWindowWidth, kChildWindowHeight); |
92 } | 92 } |
93 | 93 |
94 View* ChildModalWindow::GetContentsView() { | 94 View* ChildModalWindow::GetContentsView() { |
95 return this; | 95 return this; |
96 } | 96 } |
97 | 97 |
98 string16 ChildModalWindow::GetWindowTitle() const { | 98 base::string16 ChildModalWindow::GetWindowTitle() const { |
99 return ASCIIToUTF16("Examples: Child Modal Window"); | 99 return ASCIIToUTF16("Examples: Child Modal Window"); |
100 } | 100 } |
101 | 101 |
102 bool ChildModalWindow::CanResize() const { | 102 bool ChildModalWindow::CanResize() const { |
103 return false; | 103 return false; |
104 } | 104 } |
105 | 105 |
106 ui::ModalType ChildModalWindow::GetModalType() const { | 106 ui::ModalType ChildModalWindow::GetModalType() const { |
107 return ui::MODAL_TYPE_CHILD; | 107 return ui::MODAL_TYPE_CHILD; |
108 } | 108 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 corewm::SetModalParent(child->GetNativeView(), GetModalParent()); | 152 corewm::SetModalParent(child->GetNativeView(), GetModalParent()); |
153 child->AddObserver(this); | 153 child->AddObserver(this); |
154 child->GetNativeView()->SetName("ChildModalWindow"); | 154 child->GetNativeView()->SetName("ChildModalWindow"); |
155 return child; | 155 return child; |
156 } | 156 } |
157 | 157 |
158 View* ChildModalParent::GetContentsView() { | 158 View* ChildModalParent::GetContentsView() { |
159 return this; | 159 return this; |
160 } | 160 } |
161 | 161 |
162 string16 ChildModalParent::GetWindowTitle() const { | 162 base::string16 ChildModalParent::GetWindowTitle() const { |
163 return ASCIIToUTF16("Examples: Child Modal Parent"); | 163 return ASCIIToUTF16("Examples: Child Modal Parent"); |
164 } | 164 } |
165 | 165 |
166 bool ChildModalParent::CanResize() const { | 166 bool ChildModalParent::CanResize() const { |
167 return false; | 167 return false; |
168 } | 168 } |
169 | 169 |
170 void ChildModalParent::DeleteDelegate() { | 170 void ChildModalParent::DeleteDelegate() { |
171 if (child_) { | 171 if (child_) { |
172 child_->RemoveObserver(this); | 172 child_->RemoveObserver(this); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 void ChildModalParent::OnWidgetDestroying(Widget* widget) { | 209 void ChildModalParent::OnWidgetDestroying(Widget* widget) { |
210 if (child_) { | 210 if (child_) { |
211 DCHECK_EQ(child_, widget); | 211 DCHECK_EQ(child_, widget); |
212 child_ = NULL; | 212 child_ = NULL; |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 } // namespace test | 216 } // namespace test |
217 } // namespace views | 217 } // namespace views |
OLD | NEW |