Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: ui/views/test/child_modal_window.cc

Issue 303543004: MacViews: views_examples_with_content_exe working! Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add files Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/examples/examples_window.cc ('k') | ui/views/test/desktop_test_views_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 textfield_(new Textfield), 114 textfield_(new Textfield),
115 host_(new NativeViewHost), 115 host_(new NativeViewHost),
116 modal_parent_(NULL), 116 modal_parent_(NULL),
117 child_(NULL) { 117 child_(NULL) {
118 Widget* widget = new Widget; 118 Widget* widget = new Widget;
119 Widget::InitParams params(Widget::InitParams::TYPE_CONTROL); 119 Widget::InitParams params(Widget::InitParams::TYPE_CONTROL);
120 params.context = context; 120 params.context = context;
121 widget->Init(params); 121 widget->Init(params);
122 widget->GetRootView()->set_background( 122 widget->GetRootView()->set_background(
123 Background::CreateSolidBackground(kModalParentColor)); 123 Background::CreateSolidBackground(kModalParentColor));
124 modal_parent_ = widget->GetNativeView(); 124 modal_parent_ = widget->GetNativeWindow();
125 #if defined(USE_AURA)
125 widget->GetNativeView()->SetName("ModalParent"); 126 widget->GetNativeView()->SetName("ModalParent");
127 #endif
126 AddChildView(button_); 128 AddChildView(button_);
127 AddChildView(textfield_); 129 AddChildView(textfield_);
128 AddChildView(host_); 130 AddChildView(host_);
129 } 131 }
130 132
131 ChildModalParent::~ChildModalParent() { 133 ChildModalParent::~ChildModalParent() {
132 } 134 }
133 135
134 void ChildModalParent::ShowChild() { 136 void ChildModalParent::ShowChild() {
135 if (!child_) 137 if (!child_)
136 child_ = CreateChild(); 138 child_ = CreateChild();
137 child_->Show(); 139 child_->Show();
138 } 140 }
139 141
140 gfx::NativeWindow ChildModalParent::GetModalParent() const { 142 gfx::NativeWindow ChildModalParent::GetModalParent() const {
141 return modal_parent_; 143 return modal_parent_;
142 } 144 }
143 145
144 gfx::NativeWindow ChildModalParent::GetChild() const { 146 gfx::NativeWindow ChildModalParent::GetChild() const {
145 if (child_) 147 if (child_)
146 return child_->GetNativeView(); 148 return child_->GetNativeWindow();
147 return NULL; 149 return NULL;
148 } 150 }
149 151
150 Widget* ChildModalParent::CreateChild() { 152 Widget* ChildModalParent::CreateChild() {
151 Widget* child = Widget::CreateWindowWithParent( 153 Widget* child = Widget::CreateWindowWithParent(
152 new ChildModalWindow, GetWidget()->GetNativeView()); 154 new ChildModalWindow, GetWidget()->GetNativeView());
155 #if defined(USE_AURA)
153 wm::SetModalParent(child->GetNativeView(), GetModalParent()); 156 wm::SetModalParent(child->GetNativeView(), GetModalParent());
157 child->GetNativeView()->SetName("ChildModalWindow");
158 #endif
154 child->AddObserver(this); 159 child->AddObserver(this);
155 child->GetNativeView()->SetName("ChildModalWindow");
156 return child; 160 return child;
157 } 161 }
158 162
159 View* ChildModalParent::GetContentsView() { 163 View* ChildModalParent::GetContentsView() {
160 return this; 164 return this;
161 } 165 }
162 166
163 base::string16 ChildModalParent::GetWindowTitle() const { 167 base::string16 ChildModalParent::GetWindowTitle() const {
164 return base::ASCIIToUTF16("Examples: Child Modal Parent"); 168 return base::ASCIIToUTF16("Examples: Child Modal Parent");
165 } 169 }
(...skipping 17 matching lines...) Expand all
183 button_->SetBounds(x(), running_y, width(), kButtonHeight); 187 button_->SetBounds(x(), running_y, width(), kButtonHeight);
184 running_y += kButtonHeight; 188 running_y += kButtonHeight;
185 textfield_->SetBounds(x(), running_y, width(), kTextfieldHeight); 189 textfield_->SetBounds(x(), running_y, width(), kTextfieldHeight);
186 running_y += kTextfieldHeight; 190 running_y += kTextfieldHeight;
187 host_->SetBounds(x(), running_y, width(), height() - running_y); 191 host_->SetBounds(x(), running_y, width(), height() - running_y);
188 } 192 }
189 193
190 void ChildModalParent::ViewHierarchyChanged( 194 void ChildModalParent::ViewHierarchyChanged(
191 const ViewHierarchyChangedDetails& details) { 195 const ViewHierarchyChangedDetails& details) {
192 if (details.is_add && details.child == this) { 196 if (details.is_add && details.child == this) {
197 #if defined(USE_AURA)
193 host_->Attach(modal_parent_); 198 host_->Attach(modal_parent_);
194 GetWidget()->GetNativeView()->SetName("Parent"); 199 GetWidget()->GetNativeView()->SetName("Parent");
200 #endif
195 } 201 }
196 } 202 }
197 203
198 void ChildModalParent::ButtonPressed(Button* sender, 204 void ChildModalParent::ButtonPressed(Button* sender,
199 const ui::Event& event) { 205 const ui::Event& event) {
200 if (sender == button_) { 206 if (sender == button_) {
201 if (!child_) 207 if (!child_)
202 child_ = CreateChild(); 208 child_ = CreateChild();
203 if (child_->IsVisible()) 209 if (child_->IsVisible())
204 child_->Hide(); 210 child_->Hide();
205 else 211 else
206 child_->Show(); 212 child_->Show();
207 } 213 }
208 } 214 }
209 215
210 void ChildModalParent::OnWidgetDestroying(Widget* widget) { 216 void ChildModalParent::OnWidgetDestroying(Widget* widget) {
211 if (child_) { 217 if (child_) {
212 DCHECK_EQ(child_, widget); 218 DCHECK_EQ(child_, widget);
213 child_ = NULL; 219 child_ = NULL;
214 } 220 }
215 } 221 }
216 222
217 } // namespace test 223 } // namespace test
218 } // namespace views 224 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/examples/examples_window.cc ('k') | ui/views/test/desktop_test_views_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698