From e92b2b2d4c22be12570e1becfdc328384b16eb05 Mon Sep 17 00:00:00 2001 From: "saari%netscape.com" Date: Tue, 11 May 1999 18:15:48 +0000 Subject: [PATCH] nsIMenuItem changes for context menus --- widget/public/nsWidgetsCID.h | 12 ++++++++++++ widget/src/mac/nsMenuItem.cpp | 2 +- widget/src/mac/nsMenuItem.h | 17 ++++++++--------- widget/src/windows/nsMenuItem.cpp | 19 ++++++++----------- widget/src/windows/nsMenuItem.h | 9 +++++---- widget/src/windows/nsWindow.cpp | 2 -- 6 files changed, 34 insertions(+), 27 deletions(-) diff --git a/widget/public/nsWidgetsCID.h b/widget/public/nsWidgetsCID.h index 8d9d8b7b6389..9e3ae0c4a631 100644 --- a/widget/public/nsWidgetsCID.h +++ b/widget/public/nsWidgetsCID.h @@ -114,6 +114,10 @@ { 0xf3131891, 0x3dc7, 0x11d2, \ { 0x8d, 0xb8, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } } +//----------------------------------------------------------- +// Menus +//----------------------------------------------------------- + // {BC658C81-4BEB-11d2-8DBB-00609703C14E} #define NS_MENUBAR_CID \ { 0xbc658c81, 0x4beb, 0x11d2, \ @@ -129,6 +133,14 @@ { 0x7f045771, 0x4beb, 0x11d2, \ { 0x8d, 0xbb, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } } +// {1677DAE1-04E2-11d3-B35C-00A0CC3C1CDE} +#define NS_CONTEXTMENU_CID \ +{ 0x1677dae1, 0x4e2, 0x11d3, \ + { 0xb3, 0x5c, 0x0, 0xa0, 0xcc, 0x3c, 0x1c, 0xde } }; + + + + // deb24690-35f8-11d2-9248-00805f8a7ab6 #define NS_TOOLBAR_CID \ { 0xdeb24690, 0x35f8, 0x11d2, \ diff --git a/widget/src/mac/nsMenuItem.cpp b/widget/src/mac/nsMenuItem.cpp index f7efcde98737..19b02337a0ac 100644 --- a/widget/src/mac/nsMenuItem.cpp +++ b/widget/src/mac/nsMenuItem.cpp @@ -184,7 +184,7 @@ nsIWidget * nsMenuItem::GetMenuBarParent(nsISupports * aParent) } //------------------------------------------------------------------------- -NS_METHOD nsMenuItem::Create(nsIMenu *aParent, +NS_METHOD nsMenuItem::Create(nsISupports *aParent, const nsString &aLabel, PRBool aIsSeparator) diff --git a/widget/src/mac/nsMenuItem.h b/widget/src/mac/nsMenuItem.h index 665b0721c2e2..36b3415dca91 100644 --- a/widget/src/mac/nsMenuItem.h +++ b/widget/src/mac/nsMenuItem.h @@ -42,17 +42,10 @@ public: // nsISupports NS_DECL_ISUPPORTS - NS_IMETHOD Create(nsIMenu *aParent, + // nsIMenuItem Methods + NS_IMETHOD Create(nsISupports *aParent, const nsString &aLabel, PRBool aIsSeparator); - - NS_IMETHOD Create(nsIPopUpMenu *aParent, - const nsString &aLabel, - PRUint32 aCommand) ; - NS_IMETHOD Create(nsIMenu * aParent); - NS_IMETHOD Create(nsIPopUpMenu * aParent); - - // nsIMenuBar Methods NS_IMETHOD GetLabel(nsString &aText); NS_IMETHOD SetLabel(nsString &aText); NS_IMETHOD SetEnabled(PRBool aIsEnabled); @@ -84,6 +77,12 @@ public: nsEventStatus MenuDestruct(const nsMenuEvent & aMenuEvent); protected: + NS_IMETHOD Create(nsIPopUpMenu *aParent, + const nsString &aLabel, + PRUint32 aCommand) ; + NS_IMETHOD Create(nsIMenu * aParent); + NS_IMETHOD Create(nsIPopUpMenu * aParent); + //void Create(nsIWidget * aMBParent, Widget aParent, //const nsString &aLabel, PRUint32 aCommand); nsIWidget * GetMenuBarParent(nsISupports * aParentSupports); diff --git a/widget/src/windows/nsMenuItem.cpp b/widget/src/windows/nsMenuItem.cpp index af983a31307b..43474da71cb2 100644 --- a/widget/src/windows/nsMenuItem.cpp +++ b/widget/src/windows/nsMenuItem.cpp @@ -147,20 +147,17 @@ nsIWidget * nsMenuItem::GetMenuBarParent(nsISupports * aParent) //------------------------------------------------------------------------- NS_METHOD nsMenuItem::Create( - nsIMenu * aParent, + nsISupports * aParent, const nsString &aLabel, PRBool aIsSeparator) { - //mCommand = aCommand; - mLabel = aLabel; - mMenu = aParent; - //NS_ADDREF(mMenu); - - nsISupports * sups; - if (NS_OK == aParent->QueryInterface(kISupportsIID,(void**)&sups)) { - //mTarget = GetMenuBarParent(sups); - - NS_RELEASE(sups); + mLabel = aLabel; + mIsSeparator = aIsSeparator; + + nsIMenu * menu = nsnull; + if (NS_OK == aParent->QueryInterface(kIMenuIID,(void**)&menu)) { + mMenu = menu; + NS_RELEASE(menu); } else { mTarget = nsnull; } diff --git a/widget/src/windows/nsMenuItem.h b/widget/src/windows/nsMenuItem.h index bb54cffb7c62..e94d4841c9ed 100644 --- a/widget/src/windows/nsMenuItem.h +++ b/widget/src/windows/nsMenuItem.h @@ -47,10 +47,7 @@ public: // nsISupports NS_DECL_ISUPPORTS - NS_IMETHOD Create(nsIMenu * aParent, const nsString &aLabel, PRBool aIsSeparator); - NS_IMETHOD Create(nsIPopUpMenu * aParent, const nsString &aLabel, PRUint32 aCommand); - NS_IMETHOD Create(nsIMenu * aParent); - NS_IMETHOD Create(nsIPopUpMenu * aParent); + NS_IMETHOD Create(nsISupports * aParent, const nsString &aLabel, PRBool aIsSeparator); // nsIMenuBar Methods NS_IMETHOD SetDOMElement(nsIDOMElement * aDOMElement); @@ -88,6 +85,10 @@ public: PRInt32 GetCmdId(); protected: + NS_IMETHOD Create(nsIPopUpMenu * aParent, const nsString &aLabel, PRUint32 aCommand); + NS_IMETHOD Create(nsIMenu * aParent); + NS_IMETHOD Create(nsIPopUpMenu * aParent); + nsIWidget * GetMenuBarParent(nsISupports * aParent); nsString mLabel; diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 2812a666da23..17204d4e9da4 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -1441,7 +1441,6 @@ static void AdjustMenus(nsIMenu * aCurrentMenu, nsIMenu * aNewMenu, nsMenuEvent nsIMenuListener * listener; if (NS_OK == aCurrentMenu->QueryInterface(kIMenuListenerIID, (void **)&listener)) { //listener->MenuDeselected(aEvent); - //listener->MenuDestruct(aEvent); NS_RELEASE(listener); } } @@ -1450,7 +1449,6 @@ static void AdjustMenus(nsIMenu * aCurrentMenu, nsIMenu * aNewMenu, nsMenuEvent if (NS_OK == aNewMenu->QueryInterface(kIMenuListenerIID, (void **)&listener)) { NS_ASSERTION(false, "get debugger"); //listener->MenuSelected(aEvent); - //listener->MenuConstruct(aEvent, this, null); NS_RELEASE(listener); } }