widget/cocoa/nsMenuItemX.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef nsMenuItemX_h_
michael@0 7 #define nsMenuItemX_h_
michael@0 8
michael@0 9 #include "nsMenuBaseX.h"
michael@0 10 #include "nsMenuGroupOwnerX.h"
michael@0 11 #include "nsChangeObserver.h"
michael@0 12 #include "nsAutoPtr.h"
michael@0 13
michael@0 14 #import <Cocoa/Cocoa.h>
michael@0 15
michael@0 16 class nsString;
michael@0 17 class nsMenuItemIconX;
michael@0 18 class nsMenuX;
michael@0 19
michael@0 20 enum {
michael@0 21 knsMenuItemNoModifier = 0,
michael@0 22 knsMenuItemShiftModifier = (1 << 0),
michael@0 23 knsMenuItemAltModifier = (1 << 1),
michael@0 24 knsMenuItemControlModifier = (1 << 2),
michael@0 25 knsMenuItemCommandModifier = (1 << 3)
michael@0 26 };
michael@0 27
michael@0 28 enum EMenuItemType {
michael@0 29 eRegularMenuItemType = 0,
michael@0 30 eCheckboxMenuItemType,
michael@0 31 eRadioMenuItemType,
michael@0 32 eSeparatorMenuItemType
michael@0 33 };
michael@0 34
michael@0 35
michael@0 36 // Once instantiated, this object lives until its DOM node or its parent window is destroyed.
michael@0 37 // Do not hold references to this, they can become invalid any time the DOM node can be destroyed.
michael@0 38 class nsMenuItemX : public nsMenuObjectX,
michael@0 39 public nsChangeObserver
michael@0 40 {
michael@0 41 public:
michael@0 42 nsMenuItemX();
michael@0 43 virtual ~nsMenuItemX();
michael@0 44
michael@0 45 NS_DECL_CHANGEOBSERVER
michael@0 46
michael@0 47 // nsMenuObjectX
michael@0 48 void* NativeData() {return (void*)mNativeMenuItem;}
michael@0 49 nsMenuObjectTypeX MenuObjectType() {return eMenuItemObjectType;}
michael@0 50
michael@0 51 // nsMenuItemX
michael@0 52 nsresult Create(nsMenuX* aParent, const nsString& aLabel, EMenuItemType aItemType,
michael@0 53 nsMenuGroupOwnerX* aMenuGroupOwner, nsIContent* aNode);
michael@0 54 nsresult SetChecked(bool aIsChecked);
michael@0 55 EMenuItemType GetMenuItemType();
michael@0 56 void DoCommand();
michael@0 57 nsresult DispatchDOMEvent(const nsString &eventName, bool* preventDefaultCalled);
michael@0 58 void SetupIcon();
michael@0 59
michael@0 60 protected:
michael@0 61 void UncheckRadioSiblings(nsIContent* inCheckedElement);
michael@0 62 void SetKeyEquiv();
michael@0 63
michael@0 64 EMenuItemType mType;
michael@0 65 // nsMenuItemX objects should always have a valid native menu item.
michael@0 66 NSMenuItem* mNativeMenuItem; // [strong]
michael@0 67 nsMenuX* mMenuParent; // [weak]
michael@0 68 nsMenuGroupOwnerX* mMenuGroupOwner; // [weak]
michael@0 69 nsCOMPtr<nsIContent> mCommandContent;
michael@0 70 // The icon object should never outlive its creating nsMenuItemX object.
michael@0 71 nsRefPtr<nsMenuItemIconX> mIcon;
michael@0 72 bool mIsChecked;
michael@0 73 };
michael@0 74
michael@0 75 #endif // nsMenuItemX_h_

mercurial