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/widget/widget.h" | 5 #include "ui/views/widget/widget.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "ui/base/hit_test.h" | 10 #include "ui/base/hit_test.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 params.delegate = delegate; | 214 params.delegate = delegate; |
215 #if defined(OS_WIN) || defined(USE_AURA) | 215 #if defined(OS_WIN) || defined(USE_AURA) |
216 params.parent = parent; | 216 params.parent = parent; |
217 #endif | 217 #endif |
218 params.bounds = bounds; | 218 params.bounds = bounds; |
219 widget->Init(params); | 219 widget->Init(params); |
220 return widget; | 220 return widget; |
221 } | 221 } |
222 | 222 |
223 // static | 223 // static |
224 Widget* Widget::CreateFramelessWindowWithParentAndBounds( | |
225 WidgetDelegate* delegate, | |
226 gfx::NativeWindow parent, | |
227 const gfx::Rect& bounds) { | |
Ben Goodger (Google)
2012/01/30 21:16:16
Rather than do this in Widget, can you just move t
jennyz
2012/01/30 23:13:28
Done.
| |
228 Widget* widget = new Widget; | |
229 Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | |
230 params.delegate = delegate; | |
231 // Will this function be called if !defined(USE_AURA)? | |
232 #if defined(OS_WIN) || defined(USE_AURA) | |
233 params.parent = parent; | |
234 #endif | |
235 params.bounds = bounds; | |
236 widget->Init(params); | |
237 widget->SetContentsView(delegate->GetContentsView()); | |
238 widget->SetInitialBoundsForFramelessWindow(bounds); | |
jennyz
2012/01/27 23:17:48
I was thinking for moving SetContentsView(delegate
| |
239 return widget; | |
240 } | |
241 | |
242 // static | |
224 void Widget::SetPureViews(bool pure) { | 243 void Widget::SetPureViews(bool pure) { |
225 use_pure_views = pure; | 244 use_pure_views = pure; |
226 } | 245 } |
227 | 246 |
228 // static | 247 // static |
229 bool Widget::IsPureViews() { | 248 bool Widget::IsPureViews() { |
230 #if defined(USE_AURA) | 249 #if defined(USE_AURA) |
231 return true; | 250 return true; |
232 #else | 251 #else |
233 return use_pure_views; | 252 return use_pure_views; |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1197 // No initial bounds supplied, so size the window to its content and | 1216 // No initial bounds supplied, so size the window to its content and |
1198 // center over its parent. | 1217 // center over its parent. |
1199 native_widget_->CenterWindow(non_client_view_->GetPreferredSize()); | 1218 native_widget_->CenterWindow(non_client_view_->GetPreferredSize()); |
1200 } else { | 1219 } else { |
1201 // Use the supplied initial bounds. | 1220 // Use the supplied initial bounds. |
1202 SetBoundsConstrained(bounds); | 1221 SetBoundsConstrained(bounds); |
1203 } | 1222 } |
1204 } | 1223 } |
1205 } | 1224 } |
1206 | 1225 |
1226 void Widget::SetInitialBoundsForFramelessWindow(const gfx::Rect& bounds) { | |
1227 View* contents_view = GetContentsView(); | |
1228 DCHECK(contents_view != NULL); | |
1229 if (bounds.IsEmpty()) { | |
1230 // No initial bounds supplied, so size the window to its content and | |
1231 // center over its parent. | |
1232 native_widget_->CenterWindow(contents_view->GetPreferredSize()); | |
1233 } else { | |
1234 // Use the supplied initial bounds. | |
1235 SetBoundsConstrained(bounds); | |
1236 } | |
1237 } | |
1238 | |
1207 bool Widget::GetSavedWindowPlacement(gfx::Rect* bounds, | 1239 bool Widget::GetSavedWindowPlacement(gfx::Rect* bounds, |
1208 ui::WindowShowState* show_state) { | 1240 ui::WindowShowState* show_state) { |
1209 // First we obtain the window's saved show-style and store it. We need to do | 1241 // First we obtain the window's saved show-style and store it. We need to do |
1210 // this here, rather than in Show() because by the time Show() is called, | 1242 // this here, rather than in Show() because by the time Show() is called, |
1211 // the window's size will have been reset (below) and the saved maximized | 1243 // the window's size will have been reset (below) and the saved maximized |
1212 // state will have been lost. Sadly there's no way to tell on Windows when | 1244 // state will have been lost. Sadly there's no way to tell on Windows when |
1213 // a window is restored from maximized state, so we can't more accurately | 1245 // a window is restored from maximized state, so we can't more accurately |
1214 // track maximized state independently of sizing information. | 1246 // track maximized state independently of sizing information. |
1215 | 1247 |
1216 // Restore the window's placement from the controller. | 1248 // Restore the window's placement from the controller. |
(...skipping 28 matching lines...) Expand all Loading... | |
1245 | 1277 |
1246 //////////////////////////////////////////////////////////////////////////////// | 1278 //////////////////////////////////////////////////////////////////////////////// |
1247 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1279 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1248 | 1280 |
1249 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1281 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1250 return this; | 1282 return this; |
1251 } | 1283 } |
1252 | 1284 |
1253 } // namespace internal | 1285 } // namespace internal |
1254 } // namespace views | 1286 } // namespace views |
OLD | NEW |