diff options
author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-30 05:43:17 +0000 |
---|---|---|
committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-30 05:43:17 +0000 |
commit | a8da3a55ce6358c92cc976f105567f67789a2510 (patch) | |
tree | 26f58f20a9ab36ffe2cc8d563edacec5dfc7d3dd /chrome/views/hwnd_view_container.cc | |
parent | f73bdc8c33f0b395ba058083505209baeedf9f38 (diff) | |
download | chromium_src-a8da3a55ce6358c92cc976f105567f67789a2510.zip chromium_src-a8da3a55ce6358c92cc976f105567f67789a2510.tar.gz chromium_src-a8da3a55ce6358c92cc976f105567f67789a2510.tar.bz2 |
Make HWNDViewContainer set up its contents view separately from its Init method.
This is needed as a first step in further adjustments I'm going to be making to
Window, ClientView, etc.
B=1280060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views/hwnd_view_container.cc')
-rw-r--r-- | chrome/views/hwnd_view_container.cc | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/chrome/views/hwnd_view_container.cc b/chrome/views/hwnd_view_container.cc index 6aa2332..69545c9 100644 --- a/chrome/views/hwnd_view_container.cc +++ b/chrome/views/hwnd_view_container.cc @@ -169,7 +169,6 @@ HWNDViewContainer::~HWNDViewContainer() { void HWNDViewContainer::Init(HWND parent, const gfx::Rect& bounds, - View* contents_view, bool has_own_focus_manager) { toplevel_ = parent == NULL; @@ -207,20 +206,6 @@ void HWNDViewContainer::Init(HWND parent, FocusManager::InstallFocusSubclass(hwnd_, NULL); } - // The RootView is set up _after_ the window is created so that its - // ViewContainer pointer is valid. - if (contents_view) { - // The FillLayout only applies when we have been provided with a single - // contents view. If the user intends to manage the RootView themselves, - // they are responsible for providing their own LayoutManager, since - // FillLayout is only capable of laying out a single child view. - root_view_->SetLayoutManager(new FillLayout()); - root_view_->AddChildView(contents_view); - } - - // Manually size the window here to ensure the root view is laid out. - ChangeSize(0, CSize(bounds.width(), bounds.height())); - // Sets the RootView as a property, so the automation can introspect windows. SetRootViewForHWND(hwnd_, root_view_.get()); @@ -247,6 +232,21 @@ void HWNDViewContainer::Init(HWND parent, ::ImmAssociateContextEx(GetHWND(), NULL, 0); } +void HWNDViewContainer::SetContentsView(View* view) { + DCHECK(view && hwnd_) << "Can't be called until after the HWND is created!"; + // The ContentsView must be set up _after_ the window is created so that its + // ViewContainer pointer is valid. + root_view_->SetLayoutManager(new FillLayout); + if (root_view_->GetChildViewCount() != 0) + root_view_->RemoveAllChildViews(true); + root_view_->AddChildView(view); + + // Manually size the window here to ensure the root view is laid out. + RECT wr; + GetWindowRect(&wr); + ChangeSize(0, CSize(wr.right - wr.left, wr.bottom - wr.top)); +} + /////////////////////////////////////////////////////////////////////////////// // ChromeViews::ViewContainer |