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