Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_FRAME_INFOBARS_INTERNAL_DISPLACED_WINDOW_H_ | |
| 6 #define CHROME_FRAME_INFOBARS_INTERNAL_DISPLACED_WINDOW_H_ | |
| 7 | |
| 8 #include <atlbase.h> | |
| 9 #include <atlapp.h> // Must be included AFTER base. | |
| 10 #include <atlcrack.h> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/task_queue.h" | |
| 14 | |
| 15 // DisplacedWindowManager observes the HWND passed to Initialize and: | |
| 16 // 1) Intercepts NCCALCSIZE events allowing the client to modify the window's | |
| 17 // requested dimensions. | |
| 18 // 2) Allows the client to request a recalculation of the window's dimensions | |
| 19 // (resulting in a deferred callback as in [1]). | |
| 20 // 3) Notifies the client when the window is destroyed. | |
| 21 class DisplacedWindowManager : public CWindowImpl<DisplacedWindowManager> { | |
| 22 public: | |
| 23 class Delegate { | |
| 24 public: | |
| 25 virtual ~Delegate() {} | |
| 26 // Receives the natural dimensions of the displaced window. Upon return, | |
| 27 // rect should contain the adjusted dimensions (i.e., possibly reduced to | |
| 28 // accomodate an infobar). | |
| 29 virtual void AdjustDisplacedWindowDimensions(RECT* rect) = 0; | |
| 30 // Receives notification that the displaced window is being destroyed. | |
| 31 // The DisplacedWindowManager instance may be deleted at any time following | |
| 32 // this call. | |
| 33 virtual void OnDisplacedWindowDestroyed() = 0; | |
| 34 }; | |
| 35 | |
| 36 DisplacedWindowManager(); | |
| 37 | |
| 38 // Returns true if the provided window may be observed, in which case this | |
| 39 // instance will take responsibility for its own destruction when the window | |
| 40 // is destroyed. If this method returns false, the caller should delete the | |
| 41 // instance immediately. | |
| 42 // In either case, takes ownership of delegate, which will be destroyed when | |
| 43 // this instance is destroyed. | |
| 44 bool Initialize(HWND displaced_hwnd, Delegate* delegate); | |
| 45 | |
| 46 // Triggers a deferred re-evaluation of the dimensions of the displaced | |
| 47 // window. Delegate::AdjustDisplacedWindowDimensions will be called with the | |
| 48 // natural dimensions of the displaced window. | |
| 49 void UpdateLayout(); | |
| 50 | |
| 51 BEGIN_MSG_MAP_EX(DisplacedWindowManager) | |
| 52 MSG_WM_NCCALCSIZE(OnNcCalcSize) | |
| 53 MSG_WM_DESTROY(OnDestroy) | |
| 54 MESSAGE_HANDLER(TM_RUN_TASK_QUEUE, OnRunTaskQueue) | |
| 55 END_MSG_MAP() | |
| 56 | |
| 57 private: | |
| 58 enum DisplacedWindowUserMessages { | |
| 59 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
| |
| 60 }; | |
| 61 | |
| 62 // 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
| |
| 63 // managed window. The task may not occur if the window is destroyed first. | |
| 64 void PushTask(Task* task); | |
| 65 | |
| 66 // Respond to a private message we send ourselves in order to trigger | |
| 67 // deferred processing of items in the TaskQueue. | |
| 68 LRESULT OnRunTaskQueue(UINT message, | |
| 69 WPARAM wparam, | |
| 70 LPARAM lparam, | |
| 71 BOOL& handled); | |
| 72 | |
| 73 void DoUpdateLayout(); | |
| 74 // 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.
| |
| 75 // InfobarWindows to reserve a part of the space for themselves, if they are | |
| 76 // visible. | |
| 77 LRESULT OnNcCalcSize(BOOL calc_valid_rects, LPARAM lparam); | |
| 78 // The displaced window has been destroyed. Inform the InfobarManagerImpl, | |
| 79 // who will orphan this instance. We will delete ourselves in | |
| 80 // OnFinalMessage. | |
| 81 void OnDestroy(); | |
| 82 // This instance is now free to be deleted. | |
| 83 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
| |
| 84 | |
| 85 scoped_ptr<Delegate> delegate_; | |
| 86 TaskQueue task_queue_; | |
| 87 DISALLOW_COPY_AND_ASSIGN(DisplacedWindowManager); | |
| 88 }; | |
| 89 | |
| 90 #endif // CHROME_FRAME_INFOBARS_INTERNAL_DISPLACED_WINDOW_H_ | |
| OLD | NEW |