From 07cb5b84da542587d4743848cddb80d1ce82e541 Mon Sep 17 00:00:00 2001 From: "saari%netscape.com" Date: Tue, 13 Apr 1999 00:12:59 +0000 Subject: [PATCH] Menu changes getting ready for dynamic menus --- widget/src/windows/nsMenu.cpp | 25 +++++++++++++++++++++++++ widget/src/windows/nsMenu.h | 6 +++--- widget/src/windows/nsMenuBar.cpp | 17 +++++++++++++++++ widget/src/windows/nsMenuBar.h | 10 ++++++++++ widget/src/windows/nsMenuItem.cpp | 17 +++++++++++++++++ widget/src/windows/nsMenuItem.h | 2 ++ 6 files changed, 74 insertions(+), 3 deletions(-) diff --git a/widget/src/windows/nsMenu.cpp b/widget/src/windows/nsMenu.cpp index f24ef8aee956..cdb86e0b63bc 100644 --- a/widget/src/windows/nsMenu.cpp +++ b/widget/src/windows/nsMenu.cpp @@ -480,6 +480,7 @@ nsEventStatus nsMenu::MenuSelected(const nsMenuEvent & aMenuEvent) printf("Menu Selected %s\n", menuLabel); delete[] menuLabel; if (nsnull != mListener) { + NS_ASSERTION(false, "get debugger"); mListener->MenuSelected(aMenuEvent); } return nsEventStatus_eIgnore; @@ -497,3 +498,27 @@ nsEventStatus nsMenu::MenuDeselected(const nsMenuEvent & aMenuEvent) return nsEventStatus_eIgnore; } +//------------------------------------------------------------------------- +nsEventStatus nsMenu::MenuConstruct(const nsMenuEvent & aMenuEvent) +{ + char* menuLabel = GetACPString(mLabel); + printf("Menu Selected %s\n", menuLabel); + delete[] menuLabel; + if (nsnull != mListener) { + NS_ASSERTION(false, "get debugger"); + mListener->MenuSelected(aMenuEvent); + } + return nsEventStatus_eIgnore; +} + +//------------------------------------------------------------------------- +nsEventStatus nsMenu::MenuDestruct(const nsMenuEvent & aMenuEvent) +{ + char* menuLabel = GetACPString(mLabel); + printf("Menu Deselected %s\n", menuLabel); + delete[] menuLabel; + if (nsnull != mListener) { + mListener->MenuDeselected(aMenuEvent); + } + return nsEventStatus_eIgnore; +} \ No newline at end of file diff --git a/widget/src/windows/nsMenu.h b/widget/src/windows/nsMenu.h index 671e59ec114c..77dd8a695b08 100644 --- a/widget/src/windows/nsMenu.h +++ b/widget/src/windows/nsMenu.h @@ -44,11 +44,11 @@ public: //nsIMenuListener interface nsEventStatus MenuSelected(const nsMenuEvent & aMenuEvent); nsEventStatus MenuDeselected(const nsMenuEvent & aMenuEvent); - - NS_IMETHOD Create(nsISupports * aParent, const nsString &aLabel); - + nsEventStatus MenuConstruct(const nsMenuEvent & aMenuEvent); + nsEventStatus MenuDestruct(const nsMenuEvent & aMenuEvent); // nsIMenu Methods + NS_IMETHOD Create(nsISupports * aParent, const nsString &aLabel); NS_IMETHOD GetParent(nsISupports *&aParent); NS_IMETHOD GetLabel(nsString &aText); NS_IMETHOD SetLabel(const nsString &aText); diff --git a/widget/src/windows/nsMenuBar.cpp b/widget/src/windows/nsMenuBar.cpp index 87f552a4acc6..ddb9cab26aae 100644 --- a/widget/src/windows/nsMenuBar.cpp +++ b/widget/src/windows/nsMenuBar.cpp @@ -79,6 +79,16 @@ nsEventStatus nsMenuBar::MenuDeselected(const nsMenuEvent & aMenuEvent) return nsEventStatus_eIgnore; } +nsEventStatus nsMenuBar::MenuConstruct(const nsMenuEvent & aMenuEvent) +{ + return nsEventStatus_eIgnore; +} + +nsEventStatus nsMenuBar::MenuDestruct(const nsMenuEvent & aMenuEvent) +{ + return nsEventStatus_eIgnore; +} + //------------------------------------------------------------------------- // // nsMenuBar constructor @@ -240,3 +250,10 @@ NS_METHOD nsMenuBar::Paint() mParent->Invalidate(PR_TRUE); return NS_OK; } + +NS_METHOD nsMenuBar::ConstructMenuBar(nsIDOMElement * menubarElement) +{ + // Build the menubar + //mDOMElement = menubarElement; + return NS_OK; +} diff --git a/widget/src/windows/nsMenuBar.h b/widget/src/windows/nsMenuBar.h index 0e979b7c29c2..e519d4993f2e 100644 --- a/widget/src/windows/nsMenuBar.h +++ b/widget/src/windows/nsMenuBar.h @@ -23,6 +23,10 @@ #include "nsWindow.h" #include "nsSwitchToUIThread.h" +#include "nsCOMPtr.h" +#include "nsIDOMElement.h" +#include "nsIWebShell.h" + #include "nsIMenuBar.h" #include "nsIMenuListener.h" #include "nsVoidArray.h" @@ -43,6 +47,8 @@ public: // nsIMenuListener interface nsEventStatus MenuSelected(const nsMenuEvent & aMenuEvent); nsEventStatus MenuDeselected(const nsMenuEvent & aMenuEvent); + nsEventStatus MenuConstruct(const nsMenuEvent & aMenuEvent); + nsEventStatus MenuDestruct(const nsMenuEvent & aMenuEvent); NS_DECL_ISUPPORTS @@ -62,6 +68,8 @@ public: NS_IMETHOD Paint(); NS_IMETHOD SetNativeData(void* aData); + NS_IMETHOD ConstructMenuBar(nsIDOMElement * menubarElement); + protected: PRUint32 mNumMenus; HMENU mMenu; @@ -71,6 +79,8 @@ protected: nsVoidArray * mItems; + nsCOMPtr mWebShell; + nsCOMPtr mDOMElement; }; #endif // nsMenuBar_h__ diff --git a/widget/src/windows/nsMenuItem.cpp b/widget/src/windows/nsMenuItem.cpp index 57a340c1b453..ba797ad026b7 100644 --- a/widget/src/windows/nsMenuItem.cpp +++ b/widget/src/windows/nsMenuItem.cpp @@ -314,3 +314,20 @@ nsEventStatus nsMenuItem::MenuDeselected(const nsMenuEvent & aMenuEvent) return nsEventStatus_eIgnore; } +//------------------------------------------------------------------------- +nsEventStatus nsMenuItem::MenuConstruct(const nsMenuEvent & aMenuEvent) +{ + if (mListener) { + mListener->MenuSelected(aMenuEvent); + } + return nsEventStatus_eIgnore; +} + +//------------------------------------------------------------------------- +nsEventStatus nsMenuItem::MenuDestruct(const nsMenuEvent & aMenuEvent) +{ + if (mListener) { + mListener->MenuDeselected(aMenuEvent); + } + return nsEventStatus_eIgnore; +} diff --git a/widget/src/windows/nsMenuItem.h b/widget/src/windows/nsMenuItem.h index 3391e1738532..18c2ed73ecd0 100644 --- a/widget/src/windows/nsMenuItem.h +++ b/widget/src/windows/nsMenuItem.h @@ -67,6 +67,8 @@ public: // nsIMenuListener interface nsEventStatus MenuSelected(const nsMenuEvent & aMenuEvent); nsEventStatus MenuDeselected(const nsMenuEvent & aMenuEvent); + nsEventStatus MenuConstruct(const nsMenuEvent & aMenuEvent); + nsEventStatus MenuDestruct(const nsMenuEvent & aMenuEvent); // Need for Native Impl void SetCmdId(PRInt32 aId);