Bumping manifests a=b2g-bump
[gecko.git] / widget / cocoa / nsMenuItemX.h
blob228957994f95e5adf3bdf1e6646b1203328b7eb8
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() MOZ_OVERRIDE {return (void*)mNativeMenuItem;}
49 nsMenuObjectTypeX MenuObjectType() MOZ_OVERRIDE {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 protected:
61 void UncheckRadioSiblings(nsIContent* inCheckedElement);
62 void SetKeyEquiv();
64 EMenuItemType mType;
65 // nsMenuItemX objects should always have a valid native menu item.
66 NSMenuItem* mNativeMenuItem; // [strong]
67 nsMenuX* mMenuParent; // [weak]
68 nsMenuGroupOwnerX* mMenuGroupOwner; // [weak]
69 nsCOMPtr<nsIContent> mCommandContent;
70 // The icon object should never outlive its creating nsMenuItemX object.
71 nsRefPtr<nsMenuItemIconX> mIcon;
72 bool mIsChecked;
75 #endif // nsMenuItemX_h_