2001-11-06 18:35:24 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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 18:35:24 +03:00
|
|
|
|
2007-01-18 09:34:07 +03:00
|
|
|
#ifndef nsMenuItemX_h_
|
|
|
|
#define nsMenuItemX_h_
|
2001-11-06 18:35:24 +03:00
|
|
|
|
2008-06-28 11:55:30 +04:00
|
|
|
#include "nsMenuBaseX.h"
|
2010-01-27 09:14:40 +03:00
|
|
|
#include "nsMenuGroupOwnerX.h"
|
2008-01-23 07:04:15 +03:00
|
|
|
#include "nsChangeObserver.h"
|
2007-04-22 05:42:17 +04:00
|
|
|
#include "nsAutoPtr.h"
|
2001-11-06 18:35:24 +03:00
|
|
|
|
2007-01-18 09:34:07 +03:00
|
|
|
#import <Cocoa/Cocoa.h>
|
2005-12-03 00:39:26 +03:00
|
|
|
|
2008-06-28 11:55:30 +04:00
|
|
|
class nsString;
|
2007-04-22 05:42:17 +04:00
|
|
|
class nsMenuItemIconX;
|
2008-06-28 11:55:30 +04:00
|
|
|
class nsMenuX;
|
2001-11-06 18:35:24 +03:00
|
|
|
|
2008-06-28 11:55:30 +04: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 18:35:24 +03:00
|
|
|
|
2008-06-28 11:55:30 +04: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 07:04:15 +03:00
|
|
|
public nsChangeObserver
|
2001-11-06 18:35:24 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsMenuItemX();
|
|
|
|
virtual ~nsMenuItemX();
|
|
|
|
|
2008-01-23 07:04:15 +03:00
|
|
|
NS_DECL_CHANGEOBSERVER
|
2001-11-06 18:35:24 +03:00
|
|
|
|
2008-06-28 11:55:30 +04:00
|
|
|
// nsMenuObjectX
|
2015-03-21 19:28:04 +03:00
|
|
|
void* NativeData() override {return (void*)mNativeMenuItem;}
|
|
|
|
nsMenuObjectTypeX MenuObjectType() override {return eMenuItemObjectType;}
|
2001-11-06 18:35:24 +03:00
|
|
|
|
2008-06-28 11:55:30 +04:00
|
|
|
// nsMenuItemX
|
|
|
|
nsresult Create(nsMenuX* aParent, const nsString& aLabel, EMenuItemType aItemType,
|
2010-01-27 09:14:40 +03:00
|
|
|
nsMenuGroupOwnerX* aMenuGroupOwner, nsIContent* aNode);
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult SetChecked(bool aIsChecked);
|
2008-06-28 11:55:30 +04:00
|
|
|
EMenuItemType GetMenuItemType();
|
|
|
|
void DoCommand();
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult DispatchDOMEvent(const nsString &eventName, bool* preventDefaultCalled);
|
2008-06-28 11:55:30 +04:00
|
|
|
void SetupIcon();
|
2001-11-06 18:35:24 +03:00
|
|
|
|
|
|
|
protected:
|
2007-08-31 12:08:03 +04:00
|
|
|
void UncheckRadioSiblings(nsIContent* inCheckedElement);
|
2011-02-13 15:28:00 +03:00
|
|
|
void SetKeyEquiv();
|
2001-11-06 18:35:24 +03:00
|
|
|
|
2008-06-28 11:55:30 +04:00
|
|
|
EMenuItemType mType;
|
2009-02-21 00:55:25 +03:00
|
|
|
// nsMenuItemX objects should always have a valid native menu item.
|
2008-06-28 11:55:30 +04:00
|
|
|
NSMenuItem* mNativeMenuItem; // [strong]
|
|
|
|
nsMenuX* mMenuParent; // [weak]
|
2010-01-27 09:14:40 +03:00
|
|
|
nsMenuGroupOwnerX* mMenuGroupOwner; // [weak]
|
2006-06-15 19:54:58 +04:00
|
|
|
nsCOMPtr<nsIContent> mCommandContent;
|
2009-02-21 00:55:25 +03:00
|
|
|
// The icon object should never outlive its creating nsMenuItemX object.
|
2007-04-22 05:42:17 +04:00
|
|
|
nsRefPtr<nsMenuItemIconX> mIcon;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsChecked;
|
2001-11-06 18:35:24 +03:00
|
|
|
};
|
|
|
|
|
2007-01-18 09:34:07 +03:00
|
|
|
#endif // nsMenuItemX_h_
|