michael@0: /* vim: se cin sw=2 ts=2 et : */ michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef __mozilla_widget_TaskbarPreview_h__ michael@0: #define __mozilla_widget_TaskbarPreview_h__ michael@0: michael@0: #include michael@0: #include michael@0: #undef LogSeverity // SetupAPI.h #defines this as DWORD michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include "WindowHook.h" michael@0: michael@0: namespace mozilla { michael@0: namespace widget { michael@0: michael@0: class TaskbarPreview : public nsITaskbarPreview michael@0: { michael@0: public: michael@0: TaskbarPreview(ITaskbarList4 *aTaskbar, nsITaskbarPreviewController *aController, HWND aHWND, nsIDocShell *aShell); michael@0: virtual ~TaskbarPreview(); michael@0: michael@0: NS_DECL_NSITASKBARPREVIEW michael@0: michael@0: protected: michael@0: // Called to update ITaskbarList4 dependent properties michael@0: virtual nsresult UpdateTaskbarProperties(); michael@0: michael@0: // Invoked when the preview is made visible michael@0: virtual nsresult Enable(); michael@0: // Invoked when the preview is made invisible michael@0: virtual nsresult Disable(); michael@0: michael@0: // Detaches this preview from the nsWindow instance it's tied to michael@0: virtual void DetachFromNSWindow(); michael@0: michael@0: // Determines if the window is available and a destroy has not yet started michael@0: bool IsWindowAvailable() const; michael@0: michael@0: // Marks this preview as being active michael@0: virtual nsresult ShowActive(bool active) = 0; michael@0: // Gets a reference to the window used to handle the preview messages michael@0: virtual HWND& PreviewWindow() = 0; michael@0: michael@0: // Window procedure for the PreviewWindow (hooked for window previews) michael@0: virtual LRESULT WndProc(UINT nMsg, WPARAM wParam, LPARAM lParam); michael@0: michael@0: // Returns whether or not the taskbar icon has been created for mWnd The michael@0: // ITaskbarList4 API requires that we wait until the icon has been created michael@0: // before we can call its methods. michael@0: bool CanMakeTaskbarCalls(); michael@0: michael@0: // Gets the WindowHook for the nsWindow michael@0: WindowHook &GetWindowHook(); michael@0: michael@0: // Enables/disables custom drawing for the given window michael@0: static void EnableCustomDrawing(HWND aHWND, bool aEnable); michael@0: michael@0: // MSCOM Taskbar interface michael@0: nsRefPtr mTaskbar; michael@0: // Controller for this preview michael@0: nsCOMPtr mController; michael@0: // The HWND to the nsWindow that this object previews michael@0: HWND mWnd; michael@0: // Whether or not this preview is visible michael@0: bool mVisible; michael@0: michael@0: private: michael@0: // Called when the tooltip should be updated michael@0: nsresult UpdateTooltip(); michael@0: michael@0: // Requests the controller to draw into a canvas of the given width and michael@0: // height. The resulting bitmap is sent to the DWM to display. michael@0: void DrawBitmap(uint32_t width, uint32_t height, bool isPreview); michael@0: michael@0: // WindowHook procedure for hooking mWnd michael@0: static bool MainWindowHook(void *aContext, michael@0: HWND hWnd, UINT nMsg, michael@0: WPARAM wParam, LPARAM lParam, michael@0: LRESULT *aResult); michael@0: michael@0: // Docshell corresponding to the the nsWindow contains michael@0: nsWeakPtr mDocShell; michael@0: nsString mTooltip; michael@0: michael@0: // The preview currently marked as active in the taskbar. nullptr if no michael@0: // preview is active (some other window is). michael@0: static TaskbarPreview *sActivePreview; michael@0: }; michael@0: michael@0: } // namespace widget michael@0: } // namespace mozilla michael@0: michael@0: #endif /* __mozilla_widget_TaskbarPreview_h__ */ michael@0: