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 "nsMenuBaseX.h"
10 #include "nsMenuGroupOwnerX.h"
11 #include "nsChangeObserver.h"
12 #include "nsAutoPtr.h"
14 #import <Cocoa/Cocoa.h>
17 class nsMenuItemIconX
;
21 knsMenuItemNoModifier
= 0,
22 knsMenuItemShiftModifier
= (1 << 0),
23 knsMenuItemAltModifier
= (1 << 1),
24 knsMenuItemControlModifier
= (1 << 2),
25 knsMenuItemCommandModifier
= (1 << 3)
29 eRegularMenuItemType
= 0,
30 eCheckboxMenuItemType
,
32 eSeparatorMenuItemType
36 // Once instantiated, this object lives until its DOM node or its parent window is destroyed.
37 // Do not hold references to this, they can become invalid any time the DOM node can be destroyed.
38 class nsMenuItemX
: public nsMenuObjectX
,
39 public nsChangeObserver
43 virtual ~nsMenuItemX();
45 NS_DECL_CHANGEOBSERVER
48 void* NativeData() {return (void*)mNativeMenuItem
;}
49 nsMenuObjectTypeX
MenuObjectType() {return eMenuItemObjectType
;}
52 nsresult
Create(nsMenuX
* aParent
, const nsString
& aLabel
, EMenuItemType aItemType
,
53 nsMenuGroupOwnerX
* aMenuGroupOwner
, nsIContent
* aNode
);
54 nsresult
SetChecked(bool aIsChecked
);
55 EMenuItemType
GetMenuItemType();
57 nsresult
DispatchDOMEvent(const nsString
&eventName
, bool* preventDefaultCalled
);
60 static uint32_t ConvertGeckoToMacKeyCode(nsAString
& aKeyCodeName
);
63 void UncheckRadioSiblings(nsIContent
* inCheckedElement
);
67 // nsMenuItemX objects should always have a valid native menu item.
68 NSMenuItem
* mNativeMenuItem
; // [strong]
69 nsMenuX
* mMenuParent
; // [weak]
70 nsMenuGroupOwnerX
* mMenuGroupOwner
; // [weak]
71 nsCOMPtr
<nsIContent
> mCommandContent
;
72 // The icon object should never outlive its creating nsMenuItemX object.
73 nsRefPtr
<nsMenuItemIconX
> mIcon
;
77 #endif // nsMenuItemX_h_