2007-04-22 01:42:17 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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-22 01:42:17 +00: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 12:43:01 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2012-10-12 16:11:22 +00:00
|
|
|
#include "imgINotificationObserver.h"
|
2007-04-22 01:42:17 +00:00
|
|
|
|
|
|
|
class nsIURI;
|
|
|
|
class nsIContent;
|
2012-10-12 12:43:01 +00:00
|
|
|
class imgRequestProxy;
|
2008-06-28 07:55:30 +00:00
|
|
|
class nsMenuObjectX;
|
2007-04-22 01:42:17 +00:00
|
|
|
|
2007-08-02 19:08:40 +00:00
|
|
|
#import <Cocoa/Cocoa.h>
|
2007-04-22 01:42:17 +00:00
|
|
|
|
2012-10-12 16:11:22 +00:00
|
|
|
class nsMenuItemIconX : public imgINotificationObserver
|
2007-04-22 01:42:17 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-06-28 07:55:30 +00:00
|
|
|
nsMenuItemIconX(nsMenuObjectX* aMenuItem,
|
|
|
|
nsIContent* aContent,
|
|
|
|
NSMenuItem* aNativeMenuItem);
|
2007-04-22 01:42:17 +00:00
|
|
|
private:
|
2012-02-22 01:44:40 +00:00
|
|
|
virtual ~nsMenuItemIconX();
|
2007-04-22 01:42:17 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2012-10-12 16:11:22 +00:00
|
|
|
NS_DECL_IMGINOTIFICATIONOBSERVER
|
2007-04-22 01:42:17 +00: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 20:59:46 +00: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-22 01:42:17 +00:00
|
|
|
protected:
|
2012-10-12 16:11:22 +00:00
|
|
|
nsresult OnStopFrame(imgIRequest* aRequest);
|
|
|
|
|
2012-10-12 12:43:01 +00:00
|
|
|
nsCOMPtr<nsIContent> mContent;
|
|
|
|
nsRefPtr<imgRequestProxy> mIconRequest;
|
|
|
|
nsMenuObjectX* mMenuObject; // [weak]
|
|
|
|
nsIntRect mImageRegionRect;
|
|
|
|
bool mLoadedIcon;
|
|
|
|
bool mSetIcon;
|
|
|
|
NSMenuItem* mNativeMenuItem; // [weak]
|
2007-04-22 01:42:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsMenuItemIconX_h_
|