Chromium Code Reviews| Index: chrome_frame/infobars/internal/displaced_window.h |
| =================================================================== |
| --- chrome_frame/infobars/internal/displaced_window.h (revision 0) |
| +++ chrome_frame/infobars/internal/displaced_window.h (revision 0) |
| @@ -0,0 +1,90 @@ |
| +// 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_DISPLACED_WINDOW_H_ |
| +#define CHROME_FRAME_INFOBARS_INTERNAL_DISPLACED_WINDOW_H_ |
| + |
| +#include <atlbase.h> |
| +#include <atlapp.h> // Must be included AFTER base. |
| +#include <atlcrack.h> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/task_queue.h" |
| + |
| +// DisplacedWindowManager observes the HWND passed to Initialize and: |
| +// 1) Intercepts NCCALCSIZE events allowing the client to modify the window's |
| +// requested dimensions. |
| +// 2) Allows the client to request a recalculation of the window's dimensions |
| +// (resulting in a deferred callback as in [1]). |
| +// 3) Notifies the client when the window is destroyed. |
| +class DisplacedWindowManager : public CWindowImpl<DisplacedWindowManager> { |
| + 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; |
| + // Receives notification that the displaced window is being destroyed. |
| + // The DisplacedWindowManager instance may be deleted at any time following |
| + // this call. |
| + virtual void OnDisplacedWindowDestroyed() = 0; |
| + }; |
| + |
| + DisplacedWindowManager(); |
| + |
| + // Returns true if the provided window may be observed, 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. |
| + // In either case, takes ownership of delegate, which will be destroyed when |
| + // this instance is destroyed. |
| + bool Initialize(HWND displaced_hwnd, 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. |
| + void UpdateLayout(); |
| + |
| + BEGIN_MSG_MAP_EX(DisplacedWindowManager) |
| + MSG_WM_NCCALCSIZE(OnNcCalcSize) |
| + MSG_WM_DESTROY(OnDestroy) |
| + MESSAGE_HANDLER(TM_RUN_TASK_QUEUE, OnRunTaskQueue) |
| + END_MSG_MAP() |
| + |
| + private: |
| + enum DisplacedWindowUserMessages { |
| + TM_RUN_TASK_QUEUE = WM_USER + 600, |
|
tommi (sloooow) - chröme
2010/11/24 16:08:24
use WM_APP instead of WM_USER.
erikwright (departed)
2010/12/01 20:05:52
Now uses RegisterWindowEvent (see subclassing_wind
|
| + }; |
| + |
| + // Schedules a deferred task on the window message loop of this instance's |
|
erikwright (departed)
2010/11/24 06:24:56
To verify whether or not this really needs to be d
erikwright (departed)
2010/12/01 20:05:52
Verified that it does not need to be deferred. Yay
|
| + // managed window. The task may not occur if the window is destroyed first. |
| + void PushTask(Task* task); |
| + |
| + // Respond to a private message we send ourselves in order to trigger |
| + // deferred processing of items in the TaskQueue. |
| + LRESULT OnRunTaskQueue(UINT message, |
| + WPARAM wparam, |
| + LPARAM lparam, |
| + BOOL& handled); |
| + |
| + void DoUpdateLayout(); |
| + // The size of the displaced window is being calculated. Allow |
|
tommi (sloooow) - chröme
2010/11/24 16:08:24
add empty lines between functions
erikwright (departed)
2010/12/01 20:05:52
Done.
|
| + // InfobarWindows to reserve a part of the space for themselves, if they are |
| + // visible. |
| + LRESULT OnNcCalcSize(BOOL calc_valid_rects, LPARAM lparam); |
| + // The displaced window has been destroyed. Inform the InfobarManagerImpl, |
| + // who will orphan this instance. We will delete ourselves in |
| + // OnFinalMessage. |
| + void OnDestroy(); |
| + // This instance is now free to be deleted. |
| + void OnFinalMessage(HWND); |
|
tommi (sloooow) - chröme
2010/11/24 16:08:24
virtual?
btw, even though you declare it as priva
erikwright (departed)
2010/12/01 20:05:52
Thanks. Simply a mistake that it was in this secti
|
| + |
| + scoped_ptr<Delegate> delegate_; |
| + TaskQueue task_queue_; |
| + DISALLOW_COPY_AND_ASSIGN(DisplacedWindowManager); |
| +}; |
| + |
| +#endif // CHROME_FRAME_INFOBARS_INTERNAL_DISPLACED_WINDOW_H_ |
| Property changes on: chrome_frame\infobars\internal\displaced_window.h |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |