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/. */
9 #include "mozilla/RefPtr.h"
10 #include "nsMenuBaseX.h"
11 #include "nsMenuGroupOwnerX.h"
12 #include "nsChangeObserver.h"
13 #include "nsStringFwd.h"
15 #import <Cocoa/Cocoa.h>
17 class nsMenuItemIconX
;
24 } // namespace mozilla
27 knsMenuItemNoModifier
= 0,
28 knsMenuItemShiftModifier
= (1 << 0),
29 knsMenuItemAltModifier
= (1 << 1),
30 knsMenuItemControlModifier
= (1 << 2),
31 knsMenuItemCommandModifier
= (1 << 3)
35 eRegularMenuItemType
= 0,
36 eCheckboxMenuItemType
,
38 eSeparatorMenuItemType
41 // Once instantiated, this object lives until its DOM node or its parent window
42 // is destroyed. Do not hold references to this, they can become invalid any
43 // time the DOM node can be destroyed.
44 class nsMenuItemX
: public nsMenuObjectX
, public nsChangeObserver
{
47 virtual ~nsMenuItemX();
49 NS_DECL_CHANGEOBSERVER
52 void* NativeData() override
{ return (void*)mNativeMenuItem
; }
53 nsMenuObjectTypeX
MenuObjectType() override
{ return eMenuItemObjectType
; }
56 nsresult
Create(nsMenuX
* aParent
, const nsString
& aLabel
,
57 EMenuItemType aItemType
, nsMenuGroupOwnerX
* aMenuGroupOwner
,
59 nsresult
SetChecked(bool aIsChecked
);
60 EMenuItemType
GetMenuItemType();
62 nsresult
DispatchDOMEvent(const nsString
& eventName
,
63 bool* preventDefaultCalled
);
67 void UncheckRadioSiblings(nsIContent
* inCheckedElement
);
72 // nsMenuItemX objects should always have a valid native menu item.
73 NSMenuItem
* mNativeMenuItem
; // [strong]
74 nsMenuX
* mMenuParent
; // [weak]
75 nsMenuGroupOwnerX
* mMenuGroupOwner
; // [weak]
76 RefPtr
<mozilla::dom::Element
> mCommandElement
;
77 // The icon object should never outlive its creating nsMenuItemX object.
78 RefPtr
<nsMenuItemIconX
> mIcon
;
82 #endif // nsMenuItemX_h_