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 "imgINotificationObserver.h"
21 #import <Cocoa/Cocoa.h>
23 class nsMenuItemIconX
: public imgINotificationObserver
26 nsMenuItemIconX(nsMenuObjectX
* aMenuItem
,
28 NSMenuItem
* aNativeMenuItem
);
30 virtual ~nsMenuItemIconX();
34 NS_DECL_IMGINOTIFICATIONOBSERVER
36 // SetupIcon succeeds if it was able to set up the icon, or if there should
37 // be no icon, in which case it clears any existing icon but still succeeds.
40 // GetIconURI fails if the item should not have any icon.
41 nsresult
GetIconURI(nsIURI
** aIconURI
);
43 // LoadIcon will set a placeholder image and start a load request for the
44 // icon. The request may not complete until after LoadIcon returns.
45 nsresult
LoadIcon(nsIURI
* aIconURI
);
47 // Unless we take precautions, we may outlive the object that created us
48 // (mMenuObject, which owns our native menu item (mNativeMenuItem)).
49 // Destroy() should be called from mMenuObject's destructor to prevent
50 // this from happening. See bug 499600.
54 nsresult
OnStopFrame(imgIRequest
* aRequest
);
56 nsCOMPtr
<nsIContent
> mContent
;
57 nsCOMPtr
<imgIRequest
> mIconRequest
;
58 nsMenuObjectX
* mMenuObject
; // [weak]
59 nsIntRect mImageRegionRect
;
62 NSMenuItem
* mNativeMenuItem
; // [weak]
65 #endif // nsMenuItemIconX_h_