From 2f06ab4e65501f22de1960f1c5b124bb3518a5d7 Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Tue, 21 Sep 1999 01:03:58 +0000 Subject: [PATCH] Menu changes. --- layout/xul/base/src/nsIMenuFrame.h | 54 +++++++++++++ .../xul/base/src/nsMenuDismissalListener.cpp | 80 +++++++++++++++++++ layout/xul/base/src/nsMenuDismissalListener.h | 60 ++++++++++++++ 3 files changed, 194 insertions(+) create mode 100644 layout/xul/base/src/nsIMenuFrame.h create mode 100644 layout/xul/base/src/nsMenuDismissalListener.cpp create mode 100644 layout/xul/base/src/nsMenuDismissalListener.h diff --git a/layout/xul/base/src/nsIMenuFrame.h b/layout/xul/base/src/nsIMenuFrame.h new file mode 100644 index 000000000000..a509f1ed8ccd --- /dev/null +++ b/layout/xul/base/src/nsIMenuFrame.h @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#ifndef nsIMenuFrame_h___ +#define nsIMenuFrame_h___ + +// {6A4CDE51-6C05-11d3-BB50-00104B7B7DEB} +#define NS_IMENUFRAME_IID \ +{ 0x6a4cde51, 0x6c05, 0x11d3, { 0xbb, 0x50, 0x0, 0x10, 0x4b, 0x7b, 0x7d, 0xeb } } + +class nsIMenuParent; + +class nsIMenuFrame : public nsISupports { + +public: + static const nsIID& GetIID() { static nsIID iid = NS_IMENUFRAME_IID; return iid; } + + NS_IMETHOD ActivateMenu(PRBool aFlag) = 0; + NS_IMETHOD SelectMenu(PRBool aFlag) = 0; + NS_IMETHOD OpenMenu(PRBool aFlag) = 0; + + NS_IMETHOD MenuIsOpen(PRBool& aResult) = 0; + NS_IMETHOD MenuIsContainer(PRBool& aResult) = 0; + + NS_IMETHOD SelectFirstItem() = 0; + + NS_IMETHOD Escape(PRBool& aHandledFlag) = 0; + NS_IMETHOD Enter() = 0; + NS_IMETHOD ShortcutNavigation(PRUint32 aLetter, PRBool& aHandledFlag) = 0; + NS_IMETHOD KeyboardNavigation(PRUint32 aDirection, PRBool& aHandledFlag) = 0; + + NS_IMETHOD GetMenuParent(nsIMenuParent** aMenuParent) = 0; + + NS_IMETHOD MarkAsGenerated() = 0; +}; + +#endif + diff --git a/layout/xul/base/src/nsMenuDismissalListener.cpp b/layout/xul/base/src/nsMenuDismissalListener.cpp new file mode 100644 index 000000000000..07233e9ca9b5 --- /dev/null +++ b/layout/xul/base/src/nsMenuDismissalListener.cpp @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#include "nsMenuDismissalListener.h" +#include "nsIMenuParent.h" + +/* + * nsMenuDismissalListener implementation + */ + +NS_IMPL_ADDREF(nsMenuDismissalListener) +NS_IMPL_RELEASE(nsMenuDismissalListener) + + +//////////////////////////////////////////////////////////////////////// +nsMenuDismissalListener::nsMenuDismissalListener() +{ + NS_INIT_REFCNT(); + mMenuParent = nsnull; +} + +//////////////////////////////////////////////////////////////////////// +nsMenuDismissalListener::~nsMenuDismissalListener() +{ +} + +//////////////////////////////////////////////////////////////////////// +nsresult +nsMenuDismissalListener::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (nsnull == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + + if (aIID.Equals(nsCOMTypeInfo::GetIID())) { + *aInstancePtr = (void*)(nsIDOMEventListener*)(nsIDOMKeyListener*)this; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(nsCOMTypeInfo::GetIID())) { + *aInstancePtr = (void*)(nsIDOMMouseListener*)this; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(nsCOMTypeInfo::GetIID())) { + *aInstancePtr = (void*)(nsISupports*)(nsIDOMMouseListener*)this; + NS_ADDREF_THIS(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +//////////////////////////////////////////////////////////////////////// +nsresult +nsMenuDismissalListener::MouseDown(nsIDOMEvent* aMouseEvent) +{ + return NS_OK; +} + +void +nsMenuDismissalListener::SetCurrentMenuParent(nsIMenuParent* aMenuParent) +{ + mMenuParent = aMenuParent; +} diff --git a/layout/xul/base/src/nsMenuDismissalListener.h b/layout/xul/base/src/nsMenuDismissalListener.h new file mode 100644 index 000000000000..c9773e08afc5 --- /dev/null +++ b/layout/xul/base/src/nsMenuDismissalListener.h @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#ifndef nsMenuDismissalListener_h__ +#define nsMenuDismissalListener_h__ + +#include "nsIDOMMouseListener.h" +#include "nsIDOMEventReceiver.h" + +class nsMenuPopupFrame; +class nsIPresContext; +class nsIMenuParent; + +/** editor Implementation of the DragListener interface + */ +class nsMenuDismissalListener : public nsIDOMMouseListener +{ +public: + /** default constructor + */ + nsMenuDismissalListener(); + + /** default destructor + */ + virtual ~nsMenuDismissalListener(); + + virtual nsresult HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }; + + virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent); + virtual nsresult MouseUp(nsIDOMEvent* aMouseEvent) { return NS_OK; }; + virtual nsresult MouseClick(nsIDOMEvent* aMouseEvent) { return NS_OK; }; + virtual nsresult MouseDblClick(nsIDOMEvent* aMouseEvent) { return NS_OK; }; + virtual nsresult MouseOver(nsIDOMEvent* aMouseEvent) { return NS_OK; }; + virtual nsresult MouseOut(nsIDOMEvent* aMouseEvent) { return NS_OK; }; + + NS_DECL_ISUPPORTS + + void SetCurrentMenuParent(nsIMenuParent* aMenuParent); + +protected: + nsIMenuParent* mMenuParent; +}; + + +#endif