From 9df3fac01ffa3722b1df76e6d178d57407aeb982 Mon Sep 17 00:00:00 2001 From: "zuperdee%penguinpowered.com" Date: Mon, 5 Jul 1999 07:57:04 +0000 Subject: [PATCH] Lots of Motif menu code fixes. With these changes, hopefully it will no longer grab the mouse and refuse to release it, though the pulldown menus still don't quite work yet. git-svn-id: svn://10.0.0.236/trunk@38350 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/motif/nsMenu.cpp | 132 +++++++++++-- mozilla/widget/src/motif/nsMenu.h | 17 ++ mozilla/widget/src/motif/nsMenuItem.cpp | 251 +++++++++++------------- mozilla/widget/src/motif/nsMenuItem.h | 69 ++++--- 4 files changed, 283 insertions(+), 186 deletions(-) diff --git a/mozilla/widget/src/motif/nsMenu.cpp b/mozilla/widget/src/motif/nsMenu.cpp index dedb126cf45..b15b635a05f 100644 --- a/mozilla/widget/src/motif/nsMenu.cpp +++ b/mozilla/widget/src/motif/nsMenu.cpp @@ -81,6 +81,13 @@ nsMenu::nsMenu() : nsIMenu() mMenu = nsnull; mMenuParent = nsnull; mMenuBarParent = nsnull; + mListener = nsnull; + mConstructCalled = PR_FALSE; + + mDOMNode = nsnull; + mWebShell = nsnull; + mDOMElement = nsnull; + mAccessKey = "_"; } //------------------------------------------------------------------------- @@ -90,14 +97,16 @@ nsMenu::nsMenu() : nsIMenu() //------------------------------------------------------------------------- nsMenu::~nsMenu() { - NS_IF_RELEASE(mMenuBarParent); - NS_IF_RELEASE(mMenuParent); + NS_IF_RELEASE(mListener); + // Free our menu items + RemoveAll(); +// gtk_widget_destroy(mMenu); +// mMenu = nsnull; } //------------------------------------------------------------------------- Widget nsMenu::GetNativeParent() { - void * voidData; if (nsnull != mMenuParent) { mMenuParent->GetNativeData(&voidData); @@ -107,7 +116,6 @@ Widget nsMenu::GetNativeParent() return NULL; } return (Widget)voidData; - } //------------------------------------------------------------------------- @@ -199,11 +207,36 @@ NS_METHOD nsMenu::SetAccessKey(const nsString &aText) } //------------------------------------------------------------------------- -NS_METHOD nsMenu::AddItem(nsISupports* aItem) +NS_METHOD nsMenu::AddItem(nsISupports * aItem) { + printf("nsMenu::AddItem called\n"); + if(aItem) + { + nsIMenuItem * menuitem = nsnull; + aItem->QueryInterface(nsIMenuItem::GetIID(), + (void**)&menuitem); + if(menuitem) + { + AddMenuItem(menuitem); // nsMenu now owns this + NS_RELEASE(menuitem); + } + else + { + nsIMenu * menu = nsnull; + aItem->QueryInterface(nsIMenu::GetIID(), + (void**)&menu); + if(menu) + { + AddMenu(menu); // nsMenu now owns this + NS_RELEASE(menu); + } + } + } + return NS_OK; } +// local method used by nsMenu::AddItem //------------------------------------------------------------------------- NS_METHOD nsMenu::AddMenuItem(nsIMenuItem * aMenuItem) { @@ -221,6 +254,7 @@ NS_METHOD nsMenu::AddMenu(nsIMenu * aMenu) //------------------------------------------------------------------------- NS_METHOD nsMenu::AddSeparator() { + printf("nsMenu::AddSeparator() called\n"); XtVaCreateManagedWidget("__sep", xmSeparatorGadgetClass, mMenu, NULL); return NS_OK; } @@ -263,34 +297,47 @@ NS_METHOD nsMenu::GetNativeData(void ** aData) NS_METHOD nsMenu::AddMenuListener(nsIMenuListener * aMenuListener) { - //XXX:Implement this. + mListener = aMenuListener; + NS_ADDREF(mListener); return NS_OK; } NS_METHOD nsMenu::RemoveMenuListener(nsIMenuListener * aMenuListener) { - //XXX:Implement this. + if (aMenuListener == mListener) { + NS_IF_RELEASE(mListener); + } return NS_OK; } NS_METHOD nsMenu::SetDOMNode(nsIDOMNode * aMenuNode) { - //XXX:Implement this. + mDOMNode = aMenuNode; return NS_OK; } NS_METHOD nsMenu::SetDOMElement(nsIDOMElement * aMenuElement) { - //XXX:Implement this. + mDOMElement = aMenuElement; return NS_OK; } NS_METHOD nsMenu::SetWebShell(nsIWebShell * aWebShell) { - //XXX:Implement this. + mWebShell = aWebShell; return NS_OK; } +void nsMenu::LoadMenuItem(nsIMenu * pParentMenu, + nsIDOMElement * menuitemElement, + nsIDOMNode * menuitemNode, + unsigned short menuitemIndex, + nsIWebShell * aWebShell) +{ + //XXX:Implement this. + return; +} + nsEventStatus nsMenu::MenuItemSelected(const nsMenuEvent & aMenuEvent) { return nsEventStatus_eIgnore; @@ -303,18 +350,75 @@ nsEventStatus nsMenu::MenuSelected(const nsMenuEvent & aMenuEvent) nsEventStatus nsMenu::MenuDeselected(const nsMenuEvent & aMenuEvent) { - //XXX:Implement this. + if (nsnull != mListener) { + mListener->MenuDeselected(aMenuEvent); + } return nsEventStatus_eIgnore; } -nsEventStatus nsMenu::MenuConstruct(const struct nsMenuEvent & aMenuEvent, nsIWidget * aParentWindow, void * menubarNode, void * aWebShell) +nsEventStatus nsMenu::MenuConstruct(const nsMenuEvent & aMenuEvent, + nsIWidget * aParentWindow, + void * menuNode, + void * aWebShell) { - //XXX:Implement this. + printf("nsMenu::MenuConstruct called\n"); + if(menuNode){ + SetDOMNode((nsIDOMNode*)menuNode); + } + + if(!aWebShell){ + aWebShell = mWebShell; + } + + // First open the menu. + nsCOMPtr domElement = do_QueryInterface(mDOMNode); + if (domElement) + domElement->SetAttribute("open", "true"); + + // Begin menuitem inner loop + nsCOMPtr menuitemNode; + ((nsIDOMNode*)mDOMNode)->GetFirstChild(getter_AddRefs(menuitemNode)); + + unsigned short menuIndex = 0; + + while (menuitemNode) { + nsCOMPtr menuitemElement(do_QueryInterface(menuitemNode)); + if (menuitemElement) { + nsString menuitemNodeType; + nsString menuitemName; + menuitemElement->GetNodeName(menuitemNodeType); + if (menuitemNodeType.Equals("menuitem")) { + // LoadMenuItem + LoadMenuItem(this, + menuitemElement, + menuitemNode, + menuIndex, + (nsIWebShell*)aWebShell); + } else if (menuitemNodeType.Equals("separator")) { + AddSeparator(); + } else if (menuitemNodeType.Equals("menu")) { + // Load a submenu + LoadSubMenu(this, menuitemElement, menuitemNode); + } + } + + ++menuIndex; + + nsCOMPtr oldmenuitemNode(menuitemNode); + oldmenuitemNode->GetNextSibling(getter_AddRefs(menuitemNode)); + } // end menu item innner loop return nsEventStatus_eIgnore; } nsEventStatus nsMenu::MenuDestruct(const nsMenuEvent & aMenuEvent) { - //XXX:Implement this. + printf("nsMenu::MenuDestruct called\n"); + // Close the node. + nsCOMPtr domElement = do_QueryInterface(mDOMNode); + if (domElement) + domElement->RemoveAttribute("open"); + + mConstructCalled = PR_FALSE; + RemoveAll(); return nsEventStatus_eIgnore; } diff --git a/mozilla/widget/src/motif/nsMenu.h b/mozilla/widget/src/motif/nsMenu.h index 1fe8aa9f99d..5efdf8c3024 100644 --- a/mozilla/widget/src/motif/nsMenu.h +++ b/mozilla/widget/src/motif/nsMenu.h @@ -22,10 +22,14 @@ #include "nsIMenu.h" #include "nsIMenuListener.h" #include "nsVoidArray.h" + #include "Xm/Xm.h" #include "nsXtManageWidget.h" +class nsIDOMElement; +class nsIDOMNode; class nsIMenuBar; +class nsIWebShell; /** * Native Motif Menu wrapper @@ -75,15 +79,28 @@ public: NS_IMETHOD SetWebShell(nsIWebShell * aWebShell); protected: + void LoadMenuItem( + nsIMenu * pParentMenu, + nsIDOMElement * menuitemElement, + nsIDOMNode * menuitemNode, + unsigned short menuitemIndex, + nsIWebShell * aWebShell); + Widget GetNativeParent(); nsString mLabel; + nsString mAccessKey; PRUint32 mNumMenuItems; Widget mMenu; nsIMenu *mMenuParent; nsIMenuBar *mMenuBarParent; + nsIMenuListener * mListener; + PRBool mConstructCalled; + nsIDOMNode * mDOMNode; + nsIWebShell * mWebShell; + nsIDOMElement * mDOMElement; }; #endif // nsMenu_h__ diff --git a/mozilla/widget/src/motif/nsMenuItem.cpp b/mozilla/widget/src/motif/nsMenuItem.cpp index 2e0b6612695..5290aef1f6f 100644 --- a/mozilla/widget/src/motif/nsMenuItem.cpp +++ b/mozilla/widget/src/motif/nsMenuItem.cpp @@ -16,23 +16,32 @@ * Reserved. */ +#include + #include "nsMenuItem.h" #include "nsIMenu.h" #include "nsIMenuBar.h" #include "nsIWidget.h" -#include "nsStringUtil.h" #include "nsXtEventHandler.h" #include "nsIPopUpMenu.h" -#include -static NS_DEFINE_IID(kIMenuIID, NS_IMENU_IID); -static NS_DEFINE_IID(kIMenuBarIID, NS_IMENUBAR_IID); +#include "nsCOMPtr.h" +#include "nsIContent.h" +#include "nsIContentViewerContainer.h" +#include "nsIContentViewer.h" +#include "nsIDOMElement.h" +#include "nsIDocumentViewer.h" +#include "nsIPresContext.h" +#include "nsIWebShell.h" +#include "nsICharsetConverterManager.h" +#include "nsIPlatformCharset.h" +#include "nsIServiceManager.h" + +#include "nsStringUtil.h" + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kIPopUpMenuIID, NS_IPOPUPMENU_IID); -static NS_DEFINE_IID(kIMenuItemIID, NS_IMENUITEM_IID); -//NS_IMPL_ISUPPORTS(nsMenuItem, kIMenuItemIID) nsresult nsMenuItem::QueryInterface(REFNSIID aIID, void** aInstancePtr) { @@ -40,24 +49,24 @@ nsresult nsMenuItem::QueryInterface(REFNSIID aIID, void** aInstancePtr) return NS_ERROR_NULL_POINTER; } - *aInstancePtr = NULL; - - if (aIID.Equals(kIMenuItemIID)) { - *aInstancePtr = (void*)(nsIMenuItem*)this; - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*)(nsISupports*)(nsIMenuItem*)this; - NS_ADDREF_THIS(); - return NS_OK; + *aInstancePtr = NULL; + + if (aIID.Equals(nsIMenuItem::GetIID())) { + *aInstancePtr = (void*)(nsIMenuItem*)this; + NS_ADDREF_THIS(); + return NS_OK; } - if (aIID.Equals(kIMenuListenerIID)) { - *aInstancePtr = (void*)(nsIMenuListener*)this; - NS_ADDREF_THIS(); - return NS_OK; - } - return NS_NOINTERFACE; + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*)(nsISupports*)(nsIMenuItem*)this; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(nsIMenuListener::GetIID())) { + *aInstancePtr = (void*)(nsIMenuListener*)this; + NS_ADDREF_THIS(); + return NS_OK; + } + return NS_NOINTERFACE; } NS_IMPL_ADDREF(nsMenuItem) @@ -72,10 +81,15 @@ NS_IMPL_RELEASE(nsMenuItem) nsMenuItem::nsMenuItem() : nsIMenuItem() { NS_INIT_REFCNT(); - mMenu = nsnull; + mMenuItem = nsnull; mMenuParent = nsnull; mPopUpParent = nsnull; mTarget = nsnull; + mXULCommandListener = nsnull; + mIsSeparator = PR_FALSE; + mWebShell = nsnull; + mDOMElement = nsnull; + mIsSubMenu = PR_FALSE; } //------------------------------------------------------------------------- @@ -90,31 +104,6 @@ nsMenuItem::~nsMenuItem() NS_IF_RELEASE(mTarget); } -//------------------------------------------------------------------------- -void nsMenuItem::Create(nsIWidget *aMBParent, - Widget aParent, - const nsString &aLabel, - PRUint32 aCommand) -{ - mTarget = aMBParent; - mCommand = aCommand; - mLabel = aLabel; - - if (NULL == aParent || nsnull == aMBParent) { - return; - } - - mTarget = aMBParent; - char * nameStr = mLabel.ToNewCString(); - Widget parentMenuHandle = GetNativeParent(); - mMenu = XtVaCreateManagedWidget(nameStr, xmCascadeButtonGadgetClass, - parentMenuHandle, - NULL); - XtAddCallback(mMenu, XmNactivateCallback, nsXtWidget_Menu_Callback, - (nsIMenuItem *)this); - delete[] nameStr; -} - //------------------------------------------------------------------------- Widget nsMenuItem::GetNativeParent() { @@ -142,7 +131,7 @@ nsIWidget * nsMenuItem::GetMenuBarParent(nsISupports * aParent) // Bump the ref count on the parent, since it gets released unconditionally.. NS_ADDREF(parent); while (1) { - if (NS_OK == parent->QueryInterface(kIMenuIID,(void**)&menu)) { + if (NS_OK == parent->QueryInterface(nsIMenu::GetIID(),(void**)&menu)) { NS_RELEASE(parent); if (NS_OK != menu->GetParent(parent)) { NS_RELEASE(menu); @@ -150,7 +139,7 @@ nsIWidget * nsMenuItem::GetMenuBarParent(nsISupports * aParent) } NS_RELEASE(menu); - } else if (NS_OK == parent->QueryInterface(kIPopUpMenuIID,(void**)&popup)) { + } else if (NS_OK == parent->QueryInterface(nsIPopUpMenu::GetIID(),(void**)&popup)) { if (NS_OK != popup->GetParent(widget)) { widget = nsnull; } @@ -158,7 +147,7 @@ nsIWidget * nsMenuItem::GetMenuBarParent(nsISupports * aParent) NS_RELEASE(popup); return widget; - } else if (NS_OK == parent->QueryInterface(kIMenuBarIID,(void**)&menuBar)) { + } else if (NS_OK == parent->QueryInterface(nsIMenuBar::GetIID(),(void**)&menuBar)) { if (NS_OK != menuBar->GetParent(widget)) { widget = nsnull; } @@ -173,51 +162,6 @@ nsIWidget * nsMenuItem::GetMenuBarParent(nsISupports * aParent) return nsnull; } -//------------------------------------------------------------------------- -NS_METHOD nsMenuItem::Create(nsIMenu *aParent, - const nsString &aLabel, - PRUint32 aCommand) - -{ - if (nsnull == aParent) { - return NS_ERROR_FAILURE; - } - - mMenuParent = aParent; - NS_ADDREF(mMenuParent); - - nsIWidget * widget = nsnull; // MenuBar's Parent - nsISupports * sups; - if (NS_OK == aParent->QueryInterface(kISupportsIID,(void**)&sups)) { - widget = GetMenuBarParent(sups); - NS_RELEASE(sups); - } - - Create(widget, GetNativeParent(), aLabel, aCommand); - //aParent->AddItem(this); - - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuItem::Create(nsIPopUpMenu *aParent, - const nsString &aLabel, - PRUint32 aCommand) -{ - mPopUpParent = aParent; - NS_ADDREF(mPopUpParent); - - nsIWidget * widget = nsnull; - if (NS_OK != aParent->GetParent(widget)) { - widget = nsnull; - } - - Create(widget, GetNativeParent(), aLabel, aCommand); - aParent->AddItem(this); - - return NS_OK; -} - //------------------------------------------------------------------------- NS_METHOD nsMenuItem::GetLabel(nsString &aText) { @@ -260,7 +204,7 @@ NS_METHOD nsMenuItem::GetTarget(nsIWidget *& aTarget) //------------------------------------------------------------------------- NS_METHOD nsMenuItem::GetNativeData(void *& aData) { - aData = (void *)mMenu; +// aData = (void *)mMenu; return NS_OK; } @@ -269,126 +213,161 @@ NS_METHOD nsMenuItem::GetNativeData(void *& aData) //------------------------------------------------------------------------- nsEventStatus nsMenuItem::MenuItemSelected(const nsMenuEvent & aMenuEvent) { -// FIXME: This needs to be implemented. --ZuperDee + if(!mIsSeparator) { + DoCommand(); + } return nsEventStatus_eIgnore; } nsEventStatus nsMenuItem::MenuSelected(const nsMenuEvent & aMenuEvent) { -// FIXME: This was here before, and not created by me... But still looks -// like it needs to be implemented. --ZuperDee + if(mXULCommandListener) + return mXULCommandListener->MenuSelected(aMenuEvent); + return nsEventStatus_eIgnore; } nsEventStatus nsMenuItem::MenuDeselected(const nsMenuEvent & aMenuEvent) { -// FIXME: This needs to be implemented. --ZuperDee return nsEventStatus_eIgnore; } -nsEventStatus nsMenuItem::MenuConstruct( - const nsMenuEvent & aMenuEvent, - nsIWidget * aParentWindow, - void * menubarNode, - void * aWebShell) +nsEventStatus nsMenuItem::MenuConstruct(const nsMenuEvent &aMenuEvent, + nsIWidget *aParentWindow, + void *menuNode, + void *aWebShell) { -// FIXME: This needs to be implemented. --ZuperDee return nsEventStatus_eIgnore; } nsEventStatus nsMenuItem::MenuDestruct(const nsMenuEvent & aMenuEvent) { -//FIXME: This needs to be implemented. --ZuperDee return nsEventStatus_eIgnore; } //---------------------------------------------------- -NS_METHOD nsMenuItem::Create(nsISupports * aParent, - const nsString & aLabel, - PRBool isSeparator) +NS_METHOD nsMenuItem::Create(nsISupports *aParent, + const nsString &aLabel, + PRBool aIsSeparator) { -//FIXME: This needs to be implemented. --ZuperDee - return nsEventStatus_eIgnore; + printf("nsMenuItem::Create called\n"); + if (nsnull == aParent) { + return NS_ERROR_FAILURE; + } + + if(aParent) { + nsIMenu * menu; + aParent->QueryInterface(nsIMenu::GetIID(), (void**) &menu); + mMenuParent = menu; + NS_RELEASE(menu); + } + + nsIWidget * widget = nsnull; // MenuBar's Parent + nsISupports * sups; + if (NS_OK == aParent->QueryInterface(kISupportsIID,(void**)&sups)) { + widget = GetMenuBarParent(sups); + // GetMenuBarParent will call release for us + // NS_RELEASE(sups); + mTarget = widget; + } + + mIsSeparator = aIsSeparator; + mLabel = aLabel; + + // create the native menu item + + if(mIsSeparator) { + mMenuItem = nsnull; + } else { + char * nameStr = mLabel.ToNewCString(); + Widget parentMenuHandle = GetNativeParent(); + mMenuItem = XtVaCreateManagedWidget(nameStr, xmCascadeButtonGadgetClass, + parentMenuHandle, + NULL); + XtAddCallback(mMenuItem, XmNactivateCallback, nsXtWidget_Menu_Callback, + (nsIMenuItem *)this); + delete[] nameStr; + } + return NS_OK; } NS_METHOD nsMenuItem::SetEnabled(PRBool aIsEnabled) { -//FIXME: This needs to be implemented. --ZuperDee + //XXX:Implement this. return nsEventStatus_eIgnore; } NS_METHOD nsMenuItem::GetEnabled(PRBool *aIsEnabled) { -//FIXME: This needs to be implemented. --ZuperDee + //XXX:Implement this. return nsEventStatus_eIgnore; } NS_METHOD nsMenuItem::SetChecked(PRBool aIsEnabled) { -//FIXME: This needs to be implemented. --ZuperDee - return nsEventStatus_eIgnore; + return NS_OK; } NS_METHOD nsMenuItem::GetChecked(PRBool *aIsEnabled) { -//FIXME: This needs to be implemented. --ZuperDee - return nsEventStatus_eIgnore; + return NS_OK; } NS_METHOD nsMenuItem::AddMenuListener(nsIMenuListener * aMenuListener) { -//FIXME: This needs to be implemented. --ZuperDee - return nsEventStatus_eIgnore; + NS_IF_RELEASE(mXULCommandListener); + NS_IF_ADDREF(aMenuListener); + mXULCommandListener = aMenuListener; + return NS_OK; } NS_METHOD nsMenuItem::RemoveMenuListener(nsIMenuListener * aMenuListener) { -//FIXME: This needs to be implemented. --ZuperDee - return nsEventStatus_eIgnore; + return NS_OK; } NS_METHOD nsMenuItem::IsSeparator(PRBool & aIsSep) { -//FIXME: This needs to be implemented. --ZuperDee - return nsEventStatus_eIgnore; + aIsSep = mIsSeparator; + return NS_OK; } -NS_METHOD nsMenuItem::SetCommand(const nsString & aStrCmd) +NS_METHOD nsMenuItem::SetCommand(const nsString &aStrCmd) { -//FIXME: This needs to be implemented. --ZuperDee return nsEventStatus_eIgnore; } NS_METHOD nsMenuItem::DoCommand() { -//FIXME: This needs to be implemented. --ZuperDee + //XXX:Implement this. return nsEventStatus_eIgnore; } NS_METHOD nsMenuItem::SetDOMElement(nsIDOMElement * aDOMElement) { -//FIXME: This needs to be implemented. --ZuperDee - return nsEventStatus_eIgnore; + mDOMElement = aDOMElement; + return NS_OK; } NS_METHOD nsMenuItem::GetDOMElement(nsIDOMElement ** aDOMElement) { -//FIXME: This needs to be implemented. --ZuperDee - return nsEventStatus_eIgnore; + return NS_OK; } NS_METHOD nsMenuItem::SetWebShell(nsIWebShell * aWebShell) { -//FIXME: This needs to be implemented. --ZuperDee - return nsEventStatus_eIgnore; + mWebShell = aWebShell; + return NS_OK; } NS_METHOD nsMenuItem::SetModifiers(PRUint8 aModifiers) { + mModifiers = aModifiers; return NS_OK; } NS_METHOD nsMenuItem::GetModifiers(PRUint8 * aModifiers) { + *aModifiers = mModifiers; return NS_OK; } diff --git a/mozilla/widget/src/motif/nsMenuItem.h b/mozilla/widget/src/motif/nsMenuItem.h index a70a8b90fc1..cf565a27ff0 100644 --- a/mozilla/widget/src/motif/nsMenuItem.h +++ b/mozilla/widget/src/motif/nsMenuItem.h @@ -25,8 +25,10 @@ #include "nsString.h" #include "nsIMenuListener.h" +class nsIDOMElement; class nsIMenu; class nsIPopUpMenu; +class nsIWebShell; class nsIWidget; /** @@ -43,68 +45,63 @@ public: // nsISupports NS_DECL_ISUPPORTS - NS_IMETHOD Create(nsIMenu *aParent, - const nsString &aLabel, - PRUint32 aCommand); - - NS_IMETHOD Create(nsIPopUpMenu *aParent, - const nsString &aLabel, - PRUint32 aCommand) ; - - // nsIMenuBar Methods - NS_IMETHOD GetLabel(nsString &aText); - NS_IMETHOD SetLabel(nsString &aText); - NS_IMETHOD SetShortcutChar(const nsString &aText); - NS_IMETHOD GetShortcutChar(nsString &aText); - - NS_IMETHOD GetCommand(PRUint32 & aCommand); - NS_IMETHOD GetTarget(nsIWidget *& aTarget); - NS_IMETHOD GetNativeData(void*& aData); - - // nsIMenuListener interface - nsEventStatus MenuItemSelected(const nsMenuEvent & aMenuEvent); - nsEventStatus MenuSelected(const nsMenuEvent & aMenuEvent); - nsEventStatus MenuDeselected(const nsMenuEvent & aMenuEvent); - nsEventStatus MenuConstruct( - const nsMenuEvent & aMenuEvent, - nsIWidget * aParentWindow, - void * menubarNode, - void * aWebShell); - nsEventStatus MenuDestruct(const nsMenuEvent & aMenuEvent); - - // nsIMenuItem interface (put here by ZuperDee) + // nsIMenuItem Methods NS_IMETHOD Create(nsISupports * aParent, const nsString & aLabel, PRBool isSeparator); + NS_IMETHOD GetLabel(nsString &aText); + NS_IMETHOD SetLabel(nsString &aText); NS_IMETHOD SetEnabled(PRBool aIsEnabled); NS_IMETHOD GetEnabled(PRBool *aIsEnabled); NS_IMETHOD SetChecked(PRBool aIsEnabled); NS_IMETHOD GetChecked(PRBool *aIsEnabled); + NS_IMETHOD GetCommand(PRUint32 & aCommand); + NS_IMETHOD GetTarget(nsIWidget *& aTarget); + NS_IMETHOD GetNativeData(void*& aData); NS_IMETHOD AddMenuListener(nsIMenuListener * aMenuListener); NS_IMETHOD RemoveMenuListener(nsIMenuListener * aMenuListener); NS_IMETHOD IsSeparator(PRBool & aIsSep); + NS_IMETHOD SetCommand(const nsString & aStrCmd); NS_IMETHOD DoCommand(); NS_IMETHOD SetDOMElement(nsIDOMElement * aDOMElement); NS_IMETHOD GetDOMElement(nsIDOMElement ** aDOMElement); NS_IMETHOD SetWebShell(nsIWebShell * aWebShell); + + NS_IMETHOD SetShortcutChar(const nsString &aText); + NS_IMETHOD GetShortcutChar(nsString &aText); NS_IMETHOD SetModifiers(PRUint8 aModifiers); NS_IMETHOD GetModifiers(PRUint8 * aModifiers); -protected: - void Create(nsIWidget * aMBParent, Widget aParent, - const nsString &aLabel, PRUint32 aCommand); - nsIWidget * GetMenuBarParent(nsISupports * aParentSupports); - Widget GetNativeParent(); + // nsIMenuListener interface + nsEventStatus MenuItemSelected(const nsMenuEvent & aMenuEvent); + nsEventStatus MenuSelected(const nsMenuEvent & aMenuEvent); + nsEventStatus MenuDeselected(const nsMenuEvent & aMenuEvent); + nsEventStatus MenuConstruct(const nsMenuEvent & aMenuEvent, + nsIWidget * aParentWindow, + void * menubarNode, + void * aWebShell); + nsEventStatus MenuDestruct(const nsMenuEvent & aMenuEvent); +protected: + nsIWidget *GetMenuBarParent(nsISupports * aParentSupports); + Widget GetNativeParent(); + + nsIMenuListener *mXULCommandListener; nsString mLabel; + nsString mKeyEquivalent; + PRUint8 mModifiers; PRUint32 mCommand; nsIMenu *mMenuParent; nsIPopUpMenu *mPopUpParent; nsIWidget *mTarget; - Widget mMenu; // native cascade widget + Widget mMenuItem; // native cascade widget + PRBool mIsSeparator; + PRBool mIsSubMenu; + nsIWebShell * mWebShell; + nsIDOMElement * mDOMElement; }; #endif // nsMenuItem_h__