michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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: /* michael@0: * Retrieves and displays icons in native menu items on Mac OS X. michael@0: */ michael@0: michael@0: #ifndef nsMenuItemIconX_h_ michael@0: #define nsMenuItemIconX_h_ michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "imgINotificationObserver.h" michael@0: michael@0: class nsIURI; michael@0: class nsIContent; michael@0: class imgRequestProxy; michael@0: class nsMenuObjectX; michael@0: michael@0: #import michael@0: michael@0: class nsMenuItemIconX : public imgINotificationObserver michael@0: { michael@0: public: michael@0: nsMenuItemIconX(nsMenuObjectX* aMenuItem, michael@0: nsIContent* aContent, michael@0: NSMenuItem* aNativeMenuItem); michael@0: private: michael@0: virtual ~nsMenuItemIconX(); michael@0: michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_IMGINOTIFICATIONOBSERVER michael@0: michael@0: // SetupIcon succeeds if it was able to set up the icon, or if there should michael@0: // be no icon, in which case it clears any existing icon but still succeeds. michael@0: nsresult SetupIcon(); michael@0: michael@0: // GetIconURI fails if the item should not have any icon. michael@0: nsresult GetIconURI(nsIURI** aIconURI); michael@0: michael@0: // LoadIcon will set a placeholder image and start a load request for the michael@0: // icon. The request may not complete until after LoadIcon returns. michael@0: nsresult LoadIcon(nsIURI* aIconURI); michael@0: michael@0: // Unless we take precautions, we may outlive the object that created us michael@0: // (mMenuObject, which owns our native menu item (mNativeMenuItem)). michael@0: // Destroy() should be called from mMenuObject's destructor to prevent michael@0: // this from happening. See bug 499600. michael@0: void Destroy(); michael@0: michael@0: protected: michael@0: nsresult OnStopFrame(imgIRequest* aRequest); michael@0: michael@0: nsCOMPtr mContent; michael@0: nsRefPtr mIconRequest; michael@0: nsMenuObjectX* mMenuObject; // [weak] michael@0: nsIntRect mImageRegionRect; michael@0: bool mLoadedIcon; michael@0: bool mSetIcon; michael@0: NSMenuItem* mNativeMenuItem; // [weak] michael@0: }; michael@0: michael@0: #endif // nsMenuItemIconX_h_