bug 818009 - canActivate: only click-to-play-type plugins are valid r=jaws
[gecko.git] / widget / cocoa / nsMenuItemX.h
blobd1f8b6fd5a3ce05e28bd213ec642618fd6c24462
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/. */
6 #ifndef nsMenuItemX_h_
7 #define nsMenuItemX_h_
9 #include "nsMenuBaseX.h"
10 #include "nsMenuGroupOwnerX.h"
11 #include "nsChangeObserver.h"
12 #include "nsAutoPtr.h"
14 #import <Cocoa/Cocoa.h>
16 class nsString;
17 class nsMenuItemIconX;
18 class nsMenuX;
20 enum {
21 knsMenuItemNoModifier = 0,
22 knsMenuItemShiftModifier = (1 << 0),
23 knsMenuItemAltModifier = (1 << 1),
24 knsMenuItemControlModifier = (1 << 2),
25 knsMenuItemCommandModifier = (1 << 3)
28 enum EMenuItemType {
29 eRegularMenuItemType = 0,
30 eCheckboxMenuItemType,
31 eRadioMenuItemType,
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
41 public:
42 nsMenuItemX();
43 virtual ~nsMenuItemX();
45 NS_DECL_CHANGEOBSERVER
47 // nsMenuObjectX
48 void* NativeData() {return (void*)mNativeMenuItem;}
49 nsMenuObjectTypeX MenuObjectType() {return eMenuItemObjectType;}
51 // nsMenuItemX
52 nsresult Create(nsMenuX* aParent, const nsString& aLabel, EMenuItemType aItemType,
53 nsMenuGroupOwnerX* aMenuGroupOwner, nsIContent* aNode);
54 nsresult SetChecked(bool aIsChecked);
55 EMenuItemType GetMenuItemType();
56 void DoCommand();
57 nsresult DispatchDOMEvent(const nsString &eventName, bool* preventDefaultCalled);
58 void SetupIcon();
60 static uint32_t ConvertGeckoToMacKeyCode(nsAString& aKeyCodeName);
62 protected:
63 void UncheckRadioSiblings(nsIContent* inCheckedElement);
64 void SetKeyEquiv();
66 EMenuItemType mType;
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;
74 bool mIsChecked;
77 #endif // nsMenuItemX_h_