1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 * Retrieves and displays icons in native menu items on Mac OS X.
10 #ifndef nsMenuItemIconX_h_
11 #define nsMenuItemIconX_h_
14 #include "nsAutoPtr.h"
15 #include "imgINotificationObserver.h"
19 class imgRequestProxy
;
22 #import <Cocoa/Cocoa.h>
24 class nsMenuItemIconX
: public imgINotificationObserver
27 nsMenuItemIconX(nsMenuObjectX
* aMenuItem
,
29 NSMenuItem
* aNativeMenuItem
);
31 virtual ~nsMenuItemIconX();
35 NS_DECL_IMGINOTIFICATIONOBSERVER
37 // SetupIcon succeeds if it was able to set up the icon, or if there should
38 // be no icon, in which case it clears any existing icon but still succeeds.
41 // GetIconURI fails if the item should not have any icon.
42 nsresult
GetIconURI(nsIURI
** aIconURI
);
44 // LoadIcon will set a placeholder image and start a load request for the
45 // icon. The request may not complete until after LoadIcon returns.
46 nsresult
LoadIcon(nsIURI
* aIconURI
);
48 // Unless we take precautions, we may outlive the object that created us
49 // (mMenuObject, which owns our native menu item (mNativeMenuItem)).
50 // Destroy() should be called from mMenuObject's destructor to prevent
51 // this from happening. See bug 499600.
55 nsresult
OnStopFrame(imgIRequest
* aRequest
);
57 nsCOMPtr
<nsIContent
> mContent
;
58 nsRefPtr
<imgRequestProxy
> mIconRequest
;
59 nsMenuObjectX
* mMenuObject
; // [weak]
60 nsIntRect mImageRegionRect
;
63 NSMenuItem
* mNativeMenuItem
; // [weak]
66 #endif // nsMenuItemIconX_h_