| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "views/widget/widget_win.h" | 5 #include "views/widget/widget_win.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/gfx/path.h" | 8 #include "app/gfx/path.h" |
| 9 #include "app/win_util.h" | 9 #include "app/win_util.h" |
| 10 #include "base/gfx/native_theme.h" | 10 #include "base/gfx/native_theme.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 219 |
| 220 void WidgetWin::SetContentsView(View* view) { | 220 void WidgetWin::SetContentsView(View* view) { |
| 221 DCHECK(view && hwnd_) << "Can't be called until after the HWND is created!"; | 221 DCHECK(view && hwnd_) << "Can't be called until after the HWND is created!"; |
| 222 // The ContentsView must be set up _after_ the window is created so that its | 222 // The ContentsView must be set up _after_ the window is created so that its |
| 223 // Widget pointer is valid. | 223 // Widget pointer is valid. |
| 224 root_view_->SetLayoutManager(new FillLayout); | 224 root_view_->SetLayoutManager(new FillLayout); |
| 225 if (root_view_->GetChildViewCount() != 0) | 225 if (root_view_->GetChildViewCount() != 0) |
| 226 root_view_->RemoveAllChildViews(true); | 226 root_view_->RemoveAllChildViews(true); |
| 227 root_view_->AddChildView(view); | 227 root_view_->AddChildView(view); |
| 228 | 228 |
| 229 // Manually size the window here to ensure the root view is laid out. | 229 // Force a layout now, since the attached hierarchy won't be ready for the |
| 230 RECT wr; | 230 // containing window's bounds. Note that we call Layout directly rather than |
| 231 GetWindowRect(&wr); | 231 // calling ChangeSize, since the RootView's bounds may not have changed, which |
| 232 ChangeSize(0, CSize(wr.right - wr.left, wr.bottom - wr.top)); | 232 // will cause the Layout not to be done otherwise. |
| 233 root_view_->Layout(); |
| 233 } | 234 } |
| 234 | 235 |
| 235 /////////////////////////////////////////////////////////////////////////////// | 236 /////////////////////////////////////////////////////////////////////////////// |
| 236 // Widget implementation: | 237 // Widget implementation: |
| 237 | 238 |
| 238 void WidgetWin::GetBounds(gfx::Rect* out, bool including_frame) const { | 239 void WidgetWin::GetBounds(gfx::Rect* out, bool including_frame) const { |
| 239 CRect crect; | 240 CRect crect; |
| 240 if (including_frame) { | 241 if (including_frame) { |
| 241 GetWindowRect(&crect); | 242 GetWindowRect(&crect); |
| 242 *out = gfx::Rect(crect); | 243 *out = gfx::Rect(crect); |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 } | 1059 } |
| 1059 if (WA_INACTIVE == activation_state) { | 1060 if (WA_INACTIVE == activation_state) { |
| 1060 focus_manager->StoreFocusedView(); | 1061 focus_manager->StoreFocusedView(); |
| 1061 } else { | 1062 } else { |
| 1062 // We must restore the focus after the message has been DefProc'ed as it | 1063 // We must restore the focus after the message has been DefProc'ed as it |
| 1063 // does set the focus to the last focused HWND. | 1064 // does set the focus to the last focused HWND. |
| 1064 focus_manager->RestoreFocusedView(); | 1065 focus_manager->RestoreFocusedView(); |
| 1065 } | 1066 } |
| 1066 } | 1067 } |
| 1067 } // namespace views | 1068 } // namespace views |
| OLD | NEW |