2001-11-06 15:35:24 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2007-01-18 06:34:07 +00:00
|
|
|
#ifndef nsMenuItemX_h_
|
|
|
|
#define nsMenuItemX_h_
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2008-06-28 07:55:30 +00:00
|
|
|
#include "nsMenuBaseX.h"
|
2010-01-27 06:14:40 +00:00
|
|
|
#include "nsMenuGroupOwnerX.h"
|
2008-01-23 04:04:15 +00:00
|
|
|
#include "nsChangeObserver.h"
|
2007-04-22 01:42:17 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2007-01-18 06:34:07 +00:00
|
|
|
#import <Cocoa/Cocoa.h>
|
2005-12-02 21:39:26 +00:00
|
|
|
|
2008-06-28 07:55:30 +00:00
|
|
|
class nsString;
|
2007-04-22 01:42:17 +00:00
|
|
|
class nsMenuItemIconX;
|
2008-06-28 07:55:30 +00:00
|
|
|
class nsMenuX;
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2008-06-28 07:55:30 +00:00
|
|
|
enum {
|
|
|
|
knsMenuItemNoModifier = 0,
|
|
|
|
knsMenuItemShiftModifier = (1 << 0),
|
|
|
|
knsMenuItemAltModifier = (1 << 1),
|
|
|
|
knsMenuItemControlModifier = (1 << 2),
|
|
|
|
knsMenuItemCommandModifier = (1 << 3)
|
|
|
|
};
|
|
|
|
|
|
|
|
enum EMenuItemType {
|
|
|
|
eRegularMenuItemType = 0,
|
|
|
|
eCheckboxMenuItemType,
|
|
|
|
eRadioMenuItemType,
|
|
|
|
eSeparatorMenuItemType
|
|
|
|
};
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2008-06-28 07:55:30 +00:00
|
|
|
|
|
|
|
// Once instantiated, this object lives until its DOM node or its parent window is destroyed.
|
|
|
|
// Do not hold references to this, they can become invalid any time the DOM node can be destroyed.
|
|
|
|
class nsMenuItemX : public nsMenuObjectX,
|
2008-01-23 04:04:15 +00:00
|
|
|
public nsChangeObserver
|
2001-11-06 15:35:24 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsMenuItemX();
|
|
|
|
virtual ~nsMenuItemX();
|
|
|
|
|
2008-01-23 04:04:15 +00:00
|
|
|
NS_DECL_CHANGEOBSERVER
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2008-06-28 07:55:30 +00:00
|
|
|
// nsMenuObjectX
|
|
|
|
void* NativeData() {return (void*)mNativeMenuItem;}
|
|
|
|
nsMenuObjectTypeX MenuObjectType() {return eMenuItemObjectType;}
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2008-06-28 07:55:30 +00:00
|
|
|
// nsMenuItemX
|
|
|
|
nsresult Create(nsMenuX* aParent, const nsString& aLabel, EMenuItemType aItemType,
|
2010-01-27 06:14:40 +00:00
|
|
|
nsMenuGroupOwnerX* aMenuGroupOwner, nsIContent* aNode);
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult SetChecked(bool aIsChecked);
|
2008-06-28 07:55:30 +00:00
|
|
|
EMenuItemType GetMenuItemType();
|
|
|
|
void DoCommand();
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult DispatchDOMEvent(const nsString &eventName, bool* preventDefaultCalled);
|
2008-06-28 07:55:30 +00:00
|
|
|
void SetupIcon();
|
2001-11-06 15:35:24 +00:00
|
|
|
|
|
|
|
protected:
|
2007-08-31 08:08:03 +00:00
|
|
|
void UncheckRadioSiblings(nsIContent* inCheckedElement);
|
2011-02-13 12:28:00 +00:00
|
|
|
void SetKeyEquiv();
|
2001-11-06 15:35:24 +00:00
|
|
|
|
2008-06-28 07:55:30 +00:00
|
|
|
EMenuItemType mType;
|
2009-02-20 21:55:25 +00:00
|
|
|
// nsMenuItemX objects should always have a valid native menu item.
|
2008-06-28 07:55:30 +00:00
|
|
|
NSMenuItem* mNativeMenuItem; // [strong]
|
|
|
|
nsMenuX* mMenuParent; // [weak]
|
2010-01-27 06:14:40 +00:00
|
|
|
nsMenuGroupOwnerX* mMenuGroupOwner; // [weak]
|
2006-06-15 15:54:58 +00:00
|
|
|
nsCOMPtr<nsIContent> mCommandContent;
|
2009-02-20 21:55:25 +00:00
|
|
|
// The icon object should never outlive its creating nsMenuItemX object.
|
2007-04-22 01:42:17 +00:00
|
|
|
nsRefPtr<nsMenuItemIconX> mIcon;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mIsChecked;
|
2001-11-06 15:35:24 +00:00
|
|
|
};
|
|
|
|
|
2007-01-18 06:34:07 +00:00
|
|
|
#endif // nsMenuItemX_h_
|