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" | 7 #include "base/strings/utf_string_conversions.h" |
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 | 55 |
56 class ChildModalWindow : public WidgetDelegateView { | 56 class ChildModalWindow : public WidgetDelegateView { |
57 public: | 57 public: |
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() const OVERRIDE; |
65 | 65 |
66 // Overridden from WidgetDelegate: | 66 // Overridden from WidgetDelegate: |
67 virtual View* GetContentsView() OVERRIDE; | 67 virtual View* GetContentsView() OVERRIDE; |
68 virtual base::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() const { |
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 base::string16 ChildModalWindow::GetWindowTitle() const { | 98 base::string16 ChildModalWindow::GetWindowTitle() const { |
99 return base::ASCIIToUTF16("Examples: Child Modal Window"); | 99 return base::ASCIIToUTF16("Examples: Child Modal Window"); |
100 } | 100 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 209 |
210 void ChildModalParent::OnWidgetDestroying(Widget* widget) { | 210 void ChildModalParent::OnWidgetDestroying(Widget* widget) { |
211 if (child_) { | 211 if (child_) { |
212 DCHECK_EQ(child_, widget); | 212 DCHECK_EQ(child_, widget); |
213 child_ = NULL; | 213 child_ = NULL; |
214 } | 214 } |
215 } | 215 } |
216 | 216 |
217 } // namespace test | 217 } // namespace test |
218 } // namespace views | 218 } // namespace views |
OLD | NEW |