| 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/utf_string_conversions.h" // ASCIIToUTF16 | 7 #include "base/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 27 matching lines...) Expand all Loading... |
| 38 const int kChildTextfieldLeft = 20; | 38 const int kChildTextfieldLeft = 20; |
| 39 const int kChildTextfieldTop = 50; | 39 const int kChildTextfieldTop = 50; |
| 40 const int kChildTextfieldWidth = 290; | 40 const int kChildTextfieldWidth = 290; |
| 41 const int kChildTextfieldHeight = 35; | 41 const int kChildTextfieldHeight = 35; |
| 42 | 42 |
| 43 const SkColor kModalParentColor = SK_ColorWHITE; | 43 const SkColor kModalParentColor = SK_ColorWHITE; |
| 44 const SkColor kChildColor = SK_ColorWHITE; | 44 const SkColor kChildColor = SK_ColorWHITE; |
| 45 | 45 |
| 46 } // namespace | 46 } // namespace |
| 47 | 47 |
| 48 void CreateChildModalParent() { | 48 void CreateChildModalParent(gfx::NativeView context) { |
| 49 Widget::CreateWindowWithBounds( | 49 Widget::CreateWindowWithContextAndBounds( |
| 50 new ChildModalParent, | 50 new ChildModalParent(context), |
| 51 context, |
| 51 gfx::Rect(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight))->Show(); | 52 gfx::Rect(kWindowLeft, kWindowTop, kWindowWidth, kWindowHeight))->Show(); |
| 52 } | 53 } |
| 53 | 54 |
| 54 | 55 |
| 55 class ChildModalWindow : public WidgetDelegateView { | 56 class ChildModalWindow : public WidgetDelegateView { |
| 56 public: | 57 public: |
| 57 ChildModalWindow(); | 58 ChildModalWindow(); |
| 58 virtual ~ChildModalWindow(); | 59 virtual ~ChildModalWindow(); |
| 59 | 60 |
| 60 private: | 61 private: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 100 } |
| 100 | 101 |
| 101 bool ChildModalWindow::CanResize() const { | 102 bool ChildModalWindow::CanResize() const { |
| 102 return false; | 103 return false; |
| 103 } | 104 } |
| 104 | 105 |
| 105 ui::ModalType ChildModalWindow::GetModalType() const { | 106 ui::ModalType ChildModalWindow::GetModalType() const { |
| 106 return ui::MODAL_TYPE_CHILD; | 107 return ui::MODAL_TYPE_CHILD; |
| 107 } | 108 } |
| 108 | 109 |
| 109 ChildModalParent::ChildModalParent() | 110 ChildModalParent::ChildModalParent(gfx::NativeView context) |
| 110 : ALLOW_THIS_IN_INITIALIZER_LIST(button_(new NativeTextButton( | 111 : ALLOW_THIS_IN_INITIALIZER_LIST(button_(new NativeTextButton( |
| 111 this, ASCIIToUTF16("Show/Hide Child Modal Window")))), | 112 this, ASCIIToUTF16("Show/Hide Child Modal Window")))), |
| 112 textfield_(new Textfield), | 113 textfield_(new Textfield), |
| 113 host_(new NativeViewHost), | 114 host_(new NativeViewHost), |
| 114 modal_parent_(NULL), | 115 modal_parent_(NULL), |
| 115 child_(NULL) { | 116 child_(NULL) { |
| 116 Widget* widget = new Widget; | 117 Widget* widget = new Widget; |
| 117 widget->Init(Widget::InitParams(Widget::InitParams::TYPE_CONTROL)); | 118 Widget::InitParams params(Widget::InitParams::TYPE_CONTROL); |
| 119 params.context = context; |
| 120 widget->Init(params); |
| 118 widget->GetRootView()->set_background( | 121 widget->GetRootView()->set_background( |
| 119 Background::CreateSolidBackground(kModalParentColor)); | 122 Background::CreateSolidBackground(kModalParentColor)); |
| 120 modal_parent_ = widget->GetNativeView(); | 123 modal_parent_ = widget->GetNativeView(); |
| 121 widget->GetNativeView()->SetName("ModalParent"); | 124 widget->GetNativeView()->SetName("ModalParent"); |
| 122 AddChildView(button_); | 125 AddChildView(button_); |
| 123 AddChildView(textfield_); | 126 AddChildView(textfield_); |
| 124 AddChildView(host_); | 127 AddChildView(host_); |
| 125 } | 128 } |
| 126 | 129 |
| 127 ChildModalParent::~ChildModalParent() { | 130 ChildModalParent::~ChildModalParent() { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 207 |
| 205 void ChildModalParent::OnWidgetClosing(Widget* widget) { | 208 void ChildModalParent::OnWidgetClosing(Widget* widget) { |
| 206 if (child_) { | 209 if (child_) { |
| 207 DCHECK_EQ(child_, widget); | 210 DCHECK_EQ(child_, widget); |
| 208 child_ = NULL; | 211 child_ = NULL; |
| 209 } | 212 } |
| 210 } | 213 } |
| 211 | 214 |
| 212 } // namespace test | 215 } // namespace test |
| 213 } // namespace views | 216 } // namespace views |
| OLD | NEW |