Chromium Code Reviews| Index: chrome_frame/infobars/internal/host_window.h |
| =================================================================== |
| --- chrome_frame/infobars/internal/host_window.h (revision 0) |
| +++ chrome_frame/infobars/internal/host_window.h (revision 0) |
| @@ -0,0 +1,92 @@ |
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_FRAME_INFOBARS_INTERNAL_HOST_WINDOW_H_ |
| +#define CHROME_FRAME_INFOBARS_INTERNAL_HOST_WINDOW_H_ |
| + |
| +#include <atlbase.h> |
| +#include <atlapp.h> // Must be included AFTER base. |
|
tommi (sloooow) - chröme
2010/11/24 16:08:24
what functionality from atlapp.h do you need?
look
erikwright (departed)
2010/12/01 20:05:52
CWindowImpl in atlwin.h, which was transiently inc
|
| +#include <atlcrack.h> |
|
tommi (sloooow) - chröme
2010/11/24 16:08:24
... and I think atlwin depends on atlcrack... or r
erikwright (departed)
2010/12/01 20:05:52
Yep. Sadly, I need both for CWindowImpl.
|
| + |
| +#include "base/basictypes.h" |
| +#include "base/scoped_ptr.h" |
| + |
| +class DisplacedWindowManager; |
| + |
| +// HostWindowManager observes the HWND passed to Initialize and: |
| +// 1) Monitors the lifecycle of a specific child window (as identified by |
| +// FindDisplacedWindow). |
| +// 2) Intercepts NCCALCSIZE events on the child window, allowing the client to |
| +// modify the child window's requested dimensions. |
| +// 3) Allows the client to request a recalculation of the child window's |
| +// dimensions (resulting in a deferred callback as in [2]). |
| +class HostWindowManager |
| + : public CWindowImpl<HostWindowManager> { |
| + public: |
| + class Delegate { |
| + public: |
| + virtual ~Delegate() {} |
| + // Receives the natural dimensions of the displaced window. Upon return, |
| + // rect should contain the adjusted dimensions (i.e., possibly reduced to |
| + // accomodate an infobar). |
| + virtual void AdjustDisplacedWindowDimensions(RECT* rect) = 0; |
| + }; |
| + |
| + static Delegate* GetDelegateForHostHwnd(HWND host_window); |
| + |
| + HostWindowManager(); |
| + ~HostWindowManager(); |
| + |
| + // Returns true if observation of the host window starts successfully, in |
| + // which case this instance will take responsibility for its own destruction |
| + // when the window is destroyed. If this method returns false, the caller |
| + // should delete the instance immediately. |
| + // |
| + // Takes ownership of delegate in either case, deleting it when this instance |
| + // is deleted. |
| + bool Initialize(HWND host_window, Delegate* delegate); |
| + |
| + // Triggers a deferred re-evaluation of the dimensions of the displaced |
| + // window. Delegate::AdjustDisplacedWindowDimensions will be called with the |
| + // natural dimensions of the displaced window. Returns true if successful (in |
| + // which case the callback is guaranteed). |
| + bool UpdateLayout(); |
| + |
| + BEGIN_MSG_MAP_EX(HostWindowManager) |
| + MESSAGE_HANDLER(WM_GET_DELEGATE, OnGetDelegate) |
| + END_MSG_MAP() |
| + |
| + protected: |
| + virtual void OnFinalMessage(HWND /*hWnd*/); |
|
tommi (sloooow) - chröme
2010/11/24 16:08:24
remove /* */
erikwright (departed)
2010/12/01 20:05:52
Thanks. It's quite confusing that we comment them
|
| + |
| + private: |
| + class DisplacedWindowDelegate; |
| + |
| + friend class DisplacedWindowDelegate; |
| + |
| + enum { |
| + WM_GET_DELEGATE = WM_APP + 1982 |
|
tommi (sloooow) - chröme
2010/11/24 16:08:24
hah, that's the first time an enum made me age con
erikwright (departed)
2010/12/01 20:05:52
Done ;)
|
| + }; |
| + |
| + LRESULT OnGetDelegate(UINT message, |
| + WPARAM wparam, |
| + LPARAM lparam, |
| + BOOL& handled); |
| + // Finds the window to be displaced and instantiate a DisplacedWindowManager |
|
tommi (sloooow) - chröme
2010/11/24 16:08:24
add empty line
erikwright (departed)
2010/12/01 20:05:52
Done.
|
| + // for it if one does not already exist. Returns true if there is a valid |
| + // DisplacedWindowManager instance at the end of the call. |
| + bool FindDisplacedWindow(HWND old_window); |
| + |
| + // Called by DisplacedWindowDelegate |
| + void AdjustDisplacedWindowDimensions(RECT* rect); |
| + void OnDisplacedWindowDestroyed(); |
| + |
| + scoped_ptr<Delegate> delegate_; |
| + // Subclasses and observes changes to the displaced window. |
| + DisplacedWindowManager* displaced_window_manager_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(HostWindowManager); |
| +}; |
| + |
| +#endif // CHROME_FRAME_INFOBARS_INTERNAL_HOST_WINDOW_H_ |
| Property changes on: chrome_frame\infobars\internal\host_window.h |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |