2007-04-21 18:42:17 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-04-21 18:42:17 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Retrieves and displays icons in native menu items on Mac OS X.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsMenuItemIconX_h_
|
|
|
|
#define nsMenuItemIconX_h_
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
2012-10-12 09:11:22 -07:00
|
|
|
#include "imgINotificationObserver.h"
|
2007-04-21 18:42:17 -07:00
|
|
|
|
|
|
|
class nsIURI;
|
|
|
|
class nsIContent;
|
|
|
|
class imgIRequest;
|
2008-06-28 00:55:30 -07:00
|
|
|
class nsMenuObjectX;
|
2007-04-21 18:42:17 -07:00
|
|
|
|
2007-08-02 12:08:40 -07:00
|
|
|
#import <Cocoa/Cocoa.h>
|
2007-04-21 18:42:17 -07:00
|
|
|
|
2012-10-12 09:11:22 -07:00
|
|
|
class nsMenuItemIconX : public imgINotificationObserver
|
2007-04-21 18:42:17 -07:00
|
|
|
{
|
|
|
|
public:
|
2008-06-28 00:55:30 -07:00
|
|
|
nsMenuItemIconX(nsMenuObjectX* aMenuItem,
|
|
|
|
nsIContent* aContent,
|
|
|
|
NSMenuItem* aNativeMenuItem);
|
2007-04-21 18:42:17 -07:00
|
|
|
private:
|
2012-02-21 17:44:40 -08:00
|
|
|
virtual ~nsMenuItemIconX();
|
2007-04-21 18:42:17 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2012-10-12 09:11:22 -07:00
|
|
|
NS_DECL_IMGINOTIFICATIONOBSERVER
|
2007-04-21 18:42:17 -07:00
|
|
|
|
|
|
|
// SetupIcon succeeds if it was able to set up the icon, or if there should
|
|
|
|
// be no icon, in which case it clears any existing icon but still succeeds.
|
|
|
|
nsresult SetupIcon();
|
|
|
|
|
|
|
|
// GetIconURI fails if the item should not have any icon.
|
|
|
|
nsresult GetIconURI(nsIURI** aIconURI);
|
|
|
|
|
|
|
|
// LoadIcon will set a placeholder image and start a load request for the
|
|
|
|
// icon. The request may not complete until after LoadIcon returns.
|
|
|
|
nsresult LoadIcon(nsIURI* aIconURI);
|
|
|
|
|
2009-07-06 13:59:46 -07:00
|
|
|
// Unless we take precautions, we may outlive the object that created us
|
|
|
|
// (mMenuObject, which owns our native menu item (mNativeMenuItem)).
|
|
|
|
// Destroy() should be called from mMenuObject's destructor to prevent
|
|
|
|
// this from happening. See bug 499600.
|
|
|
|
void Destroy();
|
|
|
|
|
2007-04-21 18:42:17 -07:00
|
|
|
protected:
|
2012-10-12 09:11:22 -07:00
|
|
|
nsresult OnStopFrame(imgIRequest* aRequest);
|
|
|
|
|
2007-04-21 18:42:17 -07:00
|
|
|
nsCOMPtr<nsIContent> mContent;
|
|
|
|
nsCOMPtr<imgIRequest> mIconRequest;
|
2009-07-06 13:59:46 -07:00
|
|
|
nsMenuObjectX* mMenuObject; // [weak]
|
2009-12-11 14:09:11 -08:00
|
|
|
nsIntRect mImageRegionRect;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mLoadedIcon;
|
|
|
|
bool mSetIcon;
|
2009-07-06 13:59:46 -07:00
|
|
|
NSMenuItem* mNativeMenuItem; // [weak]
|
2007-04-21 18:42:17 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsMenuItemIconX_h_
|