diff --git a/widget/src/motif/nsMenu.cpp b/widget/src/motif/nsMenu.cpp new file mode 100644 index 000000000000..ab1067fa3804 --- /dev/null +++ b/widget/src/motif/nsMenu.cpp @@ -0,0 +1,228 @@ +/* -*- 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 "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsMenu.h" +#include "nsIMenu.h" +#include "nsIMenuBar.h" + +#include "nsString.h" +#include "nsStringUtil.h" + +#include +#include + +static NS_DEFINE_IID(kMenuIID, NS_IMENU_IID); +NS_IMPL_ISUPPORTS(nsMenu, kMenuIID) + +//------------------------------------------------------------------------- +// +// nsMenu constructor +// +//------------------------------------------------------------------------- +nsMenu::nsMenu() : nsIMenu() +{ + NS_INIT_REFCNT(); + mNumMenuItems = 0; + mMenu = nsnull; + mMenuParent = nsnull; + mMenuBarParent = nsnull; +} + +//------------------------------------------------------------------------- +// +// nsMenu destructor +// +//------------------------------------------------------------------------- +nsMenu::~nsMenu() +{ + NS_IF_RELEASE(mMenuBarParent); + NS_IF_RELEASE(mMenuParent); +} + +//------------------------------------------------------------------------- +// +// Create the proper widget +// +//------------------------------------------------------------------------- +void nsMenu::Create(Widget aParent, const nsString &aLabel) +{ + if (NULL == aParent) { + return; + } + mLabel = aLabel; + + char * labelStr = mLabel.ToNewCString(); + + char wName[512]; + + sprintf(wName, "__pulldown_%s", labelStr); + mMenu = XmCreatePulldownMenu(aParent, wName, NULL, 0); + + Widget casBtn; + XmString str; + + str = XmStringCreateLocalized(labelStr); + casBtn = XtVaCreateManagedWidget(labelStr, + xmCascadeButtonGadgetClass, aParent, + XmNsubMenuId, mMenu, + XmNlabelString, str, + NULL); + XmStringFree(str); + + + delete[] labelStr; +} + +//------------------------------------------------------------------------- +Widget nsMenu::GetNativeParent() +{ + + void * voidData; + if (nsnull != mMenuParent) { + mMenuParent->GetNativeData(voidData); + } else if (nsnull != mMenuBarParent) { + mMenuBarParent->GetNativeData(voidData); + } else { + return NULL; + } + return (Widget)voidData; + +} + + +//------------------------------------------------------------------------- +// +// Create the proper widget +// +//------------------------------------------------------------------------- +NS_METHOD nsMenu::Create(nsIMenuBar *aParent, const nsString &aLabel) +{ + mMenuBarParent = aParent; + NS_ADDREF(mMenuBarParent); + + Create(GetNativeParent(), aLabel); + + + aParent->AddMenu(this); + + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenu::Create(nsIMenu *aParent, const nsString &aLabel) +{ + mMenuParent = aParent; + NS_ADDREF(mMenuParent); + + Create(GetNativeParent(), aLabel); + aParent->AddMenu(this); + + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenu::GetLabel(nsString &aText) +{ + aText = mLabel; + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenu::AddItem(const nsString &aText) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenu::AddItem(nsIMenuItem * aMenuItem) +{ + // XXX add aMenuItem to internal data structor list + + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenu::AddMenu(nsIMenu * aMenu) +{ + + // XXX add aMenu to internal data structor list + + return NS_OK; + +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenu::AddSeparator() +{ + + Widget widget = XtVaCreateManagedWidget("__sep", xmSeparatorGadgetClass, + mMenu, + NULL); + + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenu::GetItemCount(PRUint32 &aCount) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenu::GetItemAt(const PRUint32 aCount, nsIMenuItem *& aMenuItem) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenu::InsertItemAt(const PRUint32 aCount, nsIMenuItem *& aMenuItem) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenu::InsertItemAt(const PRUint32 aCount, const nsString & aMenuItemName) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenu::InsertSeparator(const PRUint32 aCount) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenu::RemoveItem(const PRUint32 aCount) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenu::RemoveAll() +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenu::GetNativeData(void *& aData) +{ + aData = (void *)mMenu; + return NS_OK; +} + diff --git a/widget/src/motif/nsMenu.h b/widget/src/motif/nsMenu.h new file mode 100644 index 000000000000..14c41524606a --- /dev/null +++ b/widget/src/motif/nsMenu.h @@ -0,0 +1,72 @@ +/* -*- 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 "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsMenu_h__ +#define nsMenu_h__ + +#include "nsIMenu.h" +#include "Xm/Xm.h" +#include "nsXtManageWidget.h" + +class nsIMenuBar; + +/** + * Native Motif Menu wrapper + */ + +class nsMenu : public nsIMenu +{ + +public: + nsMenu(); + virtual ~nsMenu(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Create(nsIMenuBar * aParent, const nsString &aLabel); + NS_IMETHOD Create(nsIMenu * aParent, const nsString &aLabel); + + // nsIMenu Methods + NS_IMETHOD GetLabel(nsString &aText); + NS_IMETHOD AddItem(const nsString &aText); + NS_IMETHOD AddItem(nsIMenuItem * aMenuItem); + NS_IMETHOD AddMenu(nsIMenu * aMenu); + NS_IMETHOD AddSeparator(); + NS_IMETHOD GetItemCount(PRUint32 &aCount); + NS_IMETHOD GetItemAt(const PRUint32 aCount, nsIMenuItem *& aMenuItem); + NS_IMETHOD InsertItemAt(const PRUint32 aCount, nsIMenuItem *& aMenuItem); + NS_IMETHOD InsertItemAt(const PRUint32 aCount, const nsString & aMenuItemName); + NS_IMETHOD InsertSeparator(const PRUint32 aCount); + NS_IMETHOD RemoveItem(const PRUint32 aCount); + NS_IMETHOD RemoveAll(); + NS_IMETHOD GetNativeData(void*& aData); + +protected: + void Create(Widget aParent, const nsString &aLabel); + Widget GetNativeParent(); + + nsString mLabel; + PRUint32 mNumMenuItems; + Widget mMenu; + + nsIMenu * mMenuParent; + nsIMenuBar * mMenuBarParent; + +}; + +#endif // nsMenu_h__ diff --git a/widget/src/motif/nsMenuBar.cpp b/widget/src/motif/nsMenuBar.cpp new file mode 100644 index 000000000000..f8b15d6364e1 --- /dev/null +++ b/widget/src/motif/nsMenuBar.cpp @@ -0,0 +1,116 @@ +/* -*- 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 "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsMenuBar.h" +#include "nsIMenu.h" +#include "nsIWidget.h" + +#include "nsString.h" +#include "nsStringUtil.h" + +static NS_DEFINE_IID(kMenuBarIID, NS_IMENUBAR_IID); +NS_IMPL_ISUPPORTS(nsMenuBar, kMenuBarIID) + + +//------------------------------------------------------------------------- +// +// nsMenuBar constructor +// +//------------------------------------------------------------------------- +nsMenuBar::nsMenuBar() : nsIMenuBar() +{ + NS_INIT_REFCNT(); + mNumMenus = 0; + mMenu = nsnull; + mParent = nsnull; + mIsMenuBarAdded = PR_FALSE; +} + +//------------------------------------------------------------------------- +// +// nsMenuBar destructor +// +//------------------------------------------------------------------------- +nsMenuBar::~nsMenuBar() +{ + NS_IF_RELEASE(mParent); +} + +//------------------------------------------------------------------------- +// +// Create the proper widget +// +//------------------------------------------------------------------------- +NS_METHOD nsMenuBar::Create(nsIWidget *aParent) +{ + Widget parentWidget = mParent->GetNativeData(NS_NATIVE_WINDOW); + + mMenu = ::XmCreateMenuBar(parentWidget, "menubar", nsnull); + + mParent = aParent; + NS_ADDREF(mParent); + return NS_OK; + +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenuBar::AddMenu(nsIMenu * aMenu) +{ + + // XXX add to internal data structure + + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenuBar::GetMenuCount(PRUint32 &aCount) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenuBar::GetMenuAt(const PRUint32 aCount, nsIMenu *& aMenu) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenuBar::InsertMenuAt(const PRUint32 aCount, nsIMenu *& aMenu) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenuBar::RemoveMenu(const PRUint32 aCount) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenuBar::RemoveAll() +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenuBar::GetNativeData(void *& aData) +{ + aData = (void *)mMenu; + return NS_OK; +} + diff --git a/widget/src/motif/nsMenuBar.h b/widget/src/motif/nsMenuBar.h new file mode 100644 index 000000000000..889162858192 --- /dev/null +++ b/widget/src/motif/nsMenuBar.h @@ -0,0 +1,64 @@ +/* -*- 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 "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsMenuBar_h__ +#define nsMenuBar_h__ + +#include "Xm/Xm.h" +#include "nsXtManageWidget.h" + +#include "nsIMenuBar.h" + +class nsIWidget; + +/** + * Native Motif MenuBar wrapper + */ + +class nsMenuBar : public nsIMenuBar +{ + +public: + nsMenuBar(); + virtual ~nsMenuBar(); + + NS_DECL_ISUPPORTS + + + NS_IMETHOD Create(nsIWidget * aParent); + + // nsIMenuBar Methods + NS_IMETHOD AddMenu(nsIMenu * aMenu); + NS_IMETHOD GetMenuCount(PRUint32 &aCount); + NS_IMETHOD GetMenuAt(const PRUint32 aCount, nsIMenu *& aMenu); + NS_IMETHOD InsertMenuAt(const PRUint32 aCount, nsIMenu *& aMenu); + NS_IMETHOD RemoveMenu(const PRUint32 aCount); + NS_IMETHOD RemoveAll(); + NS_IMETHOD GetNativeData(void*& aData); + +protected: + PRUint32 mNumMenus; + Widget mMenu; + nsIWidget * mParent; + + PRBool mIsMenuBarAdded; + +}; + +#endif // nsMenuBar_h__ + diff --git a/widget/src/motif/nsMenuItem.cpp b/widget/src/motif/nsMenuItem.cpp new file mode 100644 index 000000000000..c311f07fd68a --- /dev/null +++ b/widget/src/motif/nsMenuItem.cpp @@ -0,0 +1,143 @@ +/* -*- 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 "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsMenuItem.h" +#include "nsIMenu.h" +#include "nsIMenu.h" + +#include "nsStringUtil.h" + +#include "nsIPopUpMenu.h" +#include + +static NS_DEFINE_IID(kMenuItemIID, NS_IMENUITEM_IID); +NS_IMPL_ISUPPORTS(nsMenuItem, kMenuItemIID) + + +//------------------------------------------------------------------------- +// +// nsMenuItem constructor +// +//------------------------------------------------------------------------- +nsMenuItem::nsMenuItem() : nsIMenuItem() +{ + NS_INIT_REFCNT(); + mMenu = nsnull; + mMenuParent = nsnull; + mPopUpParent = nsnull; +} + +//------------------------------------------------------------------------- +// +// nsMenuItem destructor +// +//------------------------------------------------------------------------- +nsMenuItem::~nsMenuItem() +{ + NS_IF_RELEASE(mMenuParent); + NS_IF_RELEASE(mPopUpParent); +} + +//------------------------------------------------------------------------- +void nsMenuItem::Create(Widget aParent, const nsString &aLabel, PRUint32 aCommand) +{ + mCommand = aCommand; + mLabel = aLabel; + + if (NULL == aParent) { + return; + } + + char * nameStr = mLabel.ToNewCString(); + + Widget parentMenuHandle = GetNativeParent(); + + mMenu = XtVaCreateManagedWidget(nameStr, xmCascadeButtonGadgetClass, + parentMenuHandle, + NULL); + + /*MenuCallbackStruct * cbs = new MenuCallbackStruct(); + cbs->mCallback = aCallback; + cbs->mId = aID; + XtAddCallback(widget, XmNactivateCallback, nsXtWidget_Menu_Callback, cbs);*/ + + delete[] nameStr; + +} + +//------------------------------------------------------------------------- +Widget nsMenuItem::GetNativeParent() +{ + + void * voidData; + if (nsnull != mMenuParent) { + mMenuParent->GetNativeData(voidData); + } else if (nsnull != mPopUpParent) { + mPopUpParent->GetNativeData(voidData); + } else { + return NULL; + } + return (Widget)voidData; + +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenuItem::Create(nsIMenu * aParent, const nsString &aLabel, PRUint32 aCommand) +{ + mMenuParent = aParent; + NS_ADDREF(mMenuParent); + + Create(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); + + Create(GetNativeParent(), aLabel, aCommand); + aParent->AddItem(this); + + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenuItem::GetLabel(nsString &aText) +{ + aText = mLabel; + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenuItem::GetCommand(PRUint32 & aCommand) +{ + aCommand = mCommand; + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsMenuItem::GetNativeData(void *& aData) +{ + aData = (void *)mMenu; + return NS_OK; +} + diff --git a/widget/src/motif/nsMenuItem.h b/widget/src/motif/nsMenuItem.h new file mode 100644 index 000000000000..e3f311b768e0 --- /dev/null +++ b/widget/src/motif/nsMenuItem.h @@ -0,0 +1,67 @@ +/* -*- 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 "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsMenuItem_h__ +#define nsMenuItem_h__ + +#include "Xm/Xm.h" +#include "nsXtManageWidget.h" + +#include "nsIMenuItem.h" +#include "nsString.h" + +class nsIMenu; +class nsIPopUpMenu; + +/** + * Native Motif MenuItem wrapper + */ + +class nsMenuItem : public nsIMenuItem +{ + +public: + nsMenuItem(); + virtual ~nsMenuItem(); + + // 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 GetCommand(PRUint32 & aCommand); + NS_IMETHOD GetNativeData(void*& aData); + + +protected: + void Create(Widget aParent, const nsString &aLabel, PRUint32 aCommand); + Widget GetNativeParent(); + + nsString mLabel; + PRUint32 mCommand; + + nsIMenu * mMenuParent; + nsIPopUpMenu * mPopUpParent; + + Widget mMenu; +}; + +#endif // nsMenuItem_h__ diff --git a/widget/src/motif/nsPopUpMenu.cpp b/widget/src/motif/nsPopUpMenu.cpp new file mode 100644 index 000000000000..eb0a58b09fb2 --- /dev/null +++ b/widget/src/motif/nsPopUpMenu.cpp @@ -0,0 +1,165 @@ +/* -*- 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 "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ +#include "nsPopUpMenu.h" +#include "nsIPopUpMenu.h" +#include "nsIMenu.h" +#include "nsIWidget.h" + +#include "nsString.h" +#include "nsStringUtil.h" + +#include +#include + +static NS_DEFINE_IID(kPopUpMenuIID, NS_IPOPUPMENU_IID); +NS_IMPL_ISUPPORTS(nsPopUpMenu, kPopUpMenuIID) + + +//------------------------------------------------------------------------- +// +// nsPopUpMenu constructor +// +//------------------------------------------------------------------------- +nsPopUpMenu::nsPopUpMenu() : nsIPopUpMenu() +{ + NS_INIT_REFCNT(); + mNumMenuItems = 0; + mParent = nsnull; + mMenu = nsnull; +} + +//------------------------------------------------------------------------- +// +// nsPopUpMenu destructor +// +//------------------------------------------------------------------------- +nsPopUpMenu::~nsPopUpMenu() +{ + NS_IF_RELEASE(mParent); +} + + + +//------------------------------------------------------------------------- +// +// Create the proper widget +// +//------------------------------------------------------------------------- +NS_METHOD nsPopUpMenu::Create(nsIWidget *aParent) +{ + + mParent = aParent; + NS_ADDREF(mParent); + + Widget parentWidget = mParent->GetNativeData(NS_NATIVE_WINDOW); + + mMenu = XmCreatePopupMenu(parentWidget, "_popup", NULL, 0); + + return NS_OK; + +} + + +//------------------------------------------------------------------------- +NS_METHOD nsPopUpMenu::AddItem(const nsString &aText) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsPopUpMenu::AddItem(nsIMenuItem * aMenuItem) +{ + + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsPopUpMenu::AddMenu(nsIMenu * aMenu) +{ + return NS_OK; + +} + +//------------------------------------------------------------------------- +NS_METHOD nsPopUpMenu::AddSeparator() +{ + Widget widget = XtVaCreateManagedWidget("__sep", xmSeparatorGadgetClass, + mMenu, + NULL); + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsPopUpMenu::GetItemCount(PRUint32 &aCount) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsPopUpMenu::GetItemAt(const PRUint32 aCount, nsIMenuItem *& aMenuItem) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsPopUpMenu::InsertItemAt(const PRUint32 aCount, nsIMenuItem *& aMenuItem) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsPopUpMenu::InsertItemAt(const PRUint32 aCount, const nsString & aMenuItemName) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsPopUpMenu::InsertSeparator(const PRUint32 aCount) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsPopUpMenu::RemoveItem(const PRUint32 aCount) +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsPopUpMenu::RemoveAll() +{ + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsPopUpMenu::ShowMenu(PRInt32 aX, PRInt32 aY) +{ + + return NS_OK; +} + +//------------------------------------------------------------------------- +NS_METHOD nsPopUpMenu::GetNativeData(void *& aData) +{ + //void * data = (void *)mMenu; + //aData = data; + aData = (void *)mMenu; + return NS_OK; +} + + diff --git a/widget/src/motif/nsPopUpMenu.h b/widget/src/motif/nsPopUpMenu.h new file mode 100644 index 000000000000..b13ec0c1a253 --- /dev/null +++ b/widget/src/motif/nsPopUpMenu.h @@ -0,0 +1,68 @@ +/* -*- 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 "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsPopUpMenu_h__ +#define nsPopUpMenu_h__ + +#include "Xm/Xm.h" +#include "nsXtManageWidget.h" + +#include "nsIPopUpMenu.h" + +class nsIWidget; + +/** + * Native Motif PopUp wrapper + */ + +class nsPopUpMenu : public nsIPopUpMenu +{ + +public: + nsPopUpMenu(); + virtual ~nsPopUpMenu(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Create(nsIWidget * aParent); + + // nsIPopUpMenu Methods + NS_IMETHOD AddItem(const nsString &aText); + NS_IMETHOD AddItem(nsIMenuItem * aMenuItem); + NS_IMETHOD AddMenu(nsIMenu * aMenu); + NS_IMETHOD AddSeparator(); + NS_IMETHOD GetItemCount(PRUint32 &aCount); + NS_IMETHOD GetItemAt(const PRUint32 aCount, nsIMenuItem *& aMenuItem); + NS_IMETHOD InsertItemAt(const PRUint32 aCount, nsIMenuItem *& aMenuItem); + NS_IMETHOD InsertItemAt(const PRUint32 aCount, const nsString & aMenuItemName); + NS_IMETHOD InsertSeparator(const PRUint32 aCount); + NS_IMETHOD RemoveItem(const PRUint32 aCount); + NS_IMETHOD RemoveAll(); + NS_IMETHOD ShowMenu(PRInt32 aX, PRInt32 aY); + NS_IMETHOD GetNativeData(void*& aData); + +protected: + + PRUint32 mNumMenuItems; + + nsIWidget * mParent; + Widget mMenu; +}; + +#endif // nsPopUpMenu_h__ +