зеркало из https://github.com/mozilla/gecko-dev.git
Added stubs for modal dialog stuff, along with various minor fixups to help bring the Motif port up to speed on the changes that have been occuring in the rest of Mozilla.
This commit is contained in:
Родитель
9bce975b58
Коммит
e77e9ced73
|
@ -17,6 +17,9 @@
|
|||
*/
|
||||
|
||||
#include "nsMenu.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIMenu.h"
|
||||
#include "nsIMenuBar.h"
|
||||
#include "nsIMenuItem.h"
|
||||
|
@ -25,14 +28,18 @@
|
|||
#include "nsString.h"
|
||||
#include "nsStringUtil.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
#include <Xm/CascadeBG.h>
|
||||
#include <Xm/SeparatoG.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/PushB.h>
|
||||
|
||||
static NS_DEFINE_CID(kMenuCID, NS_MENU_CID);
|
||||
static NS_DEFINE_CID(kMenuItemCID, NS_MENUITEM_CID);
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIMenuIID, NS_IMENU_IID);
|
||||
//NS_IMPL_ISUPPORTS(nsMenu, kMenuIID)
|
||||
|
||||
nsresult nsMenu::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
|
@ -42,7 +49,7 @@ nsresult nsMenu::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if (aIID.Equals(kIMenuIID)) {
|
||||
if (aIID.Equals(nsIMenu::GetIID())) {
|
||||
*aInstancePtr = (void*)(nsIMenu*) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
|
@ -201,21 +208,36 @@ NS_METHOD nsMenu::AddMenuItem(nsIMenuItem * aMenuItem)
|
|||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenu::AddMenu(nsIMenu * aMenu)
|
||||
{
|
||||
|
||||
// XXX add aMenu to internal data structor list
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenu::AddSeparator()
|
||||
{
|
||||
// Create nsMenuItem
|
||||
nsIMenuItem * pnsMenuItem = nsnull;
|
||||
nsresult rv = nsComponentManager::CreateInstance(
|
||||
kMenuItemCID, nsnull, nsIMenuItem::GetIID(), (void**)&pnsMenuItem);
|
||||
if (NS_OK == rv) {
|
||||
nsString tmp = "separator";
|
||||
nsISupports * supports = nsnull;
|
||||
QueryInterface(kISupportsIID, (void**) &supports);
|
||||
pnsMenuItem->Create(supports, tmp, PR_TRUE);
|
||||
NS_RELEASE(supports);
|
||||
|
||||
Widget widget = XtVaCreateManagedWidget("__sep", xmSeparatorGadgetClass,
|
||||
mMenu,
|
||||
NULL);
|
||||
pnsMenuItem->QueryInterface(kISupportsIID, (void**) &supports);
|
||||
AddItem(supports); // Parent should now own menu item
|
||||
NS_RELEASE(supports);
|
||||
|
||||
NS_RELEASE(pnsMenuItem);
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
//XXX:Delete this.
|
||||
// Widget widget = XtVaCreateManagedWidget("__sep", xmSeparatorGadgetClass,
|
||||
// mMenu,
|
||||
// NULL);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -262,31 +284,31 @@ NS_METHOD nsMenu::GetNativeData(void ** aData)
|
|||
|
||||
NS_METHOD nsMenu::AddMenuListener(nsIMenuListener * aMenuListener)
|
||||
{
|
||||
//FIXME: Need to implement. --ZuperDee
|
||||
//XXX:Implement this.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsMenu::RemoveMenuListener(nsIMenuListener * aMenuListener)
|
||||
{
|
||||
//FIXME: Need to implement. --ZuperDee
|
||||
//XXX:Implement this.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsMenu::SetDOMNode(nsIDOMNode * aMenuNode)
|
||||
{
|
||||
//FIXME: Need to implement. --ZuperDee
|
||||
//XXX:Implement this.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsMenu::SetDOMElement(nsIDOMElement * aMenuElement)
|
||||
{
|
||||
//FIXME: Need to implement. --ZuperDee
|
||||
//XXX:Implement this.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsMenu::SetWebShell(nsIWebShell * aWebShell)
|
||||
{
|
||||
//FIXME: Need to implement. --ZuperDee
|
||||
//XXX:Implement this.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -300,20 +322,20 @@ nsEventStatus nsMenu::MenuSelected(const nsMenuEvent & aMenuEvent)
|
|||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
// FIXME: Need to implement. --ZuperDee
|
||||
nsEventStatus nsMenu::MenuDeselected(const nsMenuEvent & aMenuEvent)
|
||||
{
|
||||
//XXX:Implement this.
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
// FIXME: Need to implement. --ZuperDee
|
||||
nsEventStatus nsMenu::MenuConstruct(const struct nsMenuEvent & aMenuEvent, nsIWidget * aParentWindow, void * menubarNode, void * aWebShell)
|
||||
{
|
||||
//XXX:Implement this.
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
// FIXME: Need to implement. --ZuperDee
|
||||
nsEventStatus nsMenu::MenuDestruct(const nsMenuEvent & aMenuEvent)
|
||||
{
|
||||
//XXX:Implement this.
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
|
|
@ -17,17 +17,26 @@
|
|||
*/
|
||||
|
||||
#include "nsMenuBar.h"
|
||||
#include "nsMenuItem.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIMenu.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsStringUtil.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
//#include "nsStringUtil.h"
|
||||
|
||||
#include <Xm/RowColumn.h>
|
||||
|
||||
static NS_DEFINE_IID(kIMenuBarIID, NS_IMENUBAR_IID);
|
||||
static NS_DEFINE_CID(kMenuBarCID, NS_MENUBAR_CID);
|
||||
static NS_DEFINE_CID(kMenuCID, NS_MENU_CID);
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
//NS_IMPL_ISUPPORTS(nsMenuBar, kMenuBarIID)
|
||||
|
||||
nsresult nsMenuBar::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
|
@ -37,7 +46,7 @@ nsresult nsMenuBar::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if (aIID.Equals(kIMenuBarIID)) {
|
||||
if (aIID.Equals(nsIMenuBar::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsIMenuBar*) this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
|
@ -58,40 +67,6 @@ nsresult nsMenuBar::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
NS_IMPL_ADDREF(nsMenuBar)
|
||||
NS_IMPL_RELEASE(nsMenuBar)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsMenuListener interface
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsEventStatus nsMenuBar::MenuSelected(const nsMenuEvent & aMenuEvent)
|
||||
{
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
nsEventStatus nsMenuBar::MenuItemSelected(const nsMenuEvent & aMenuEvent)
|
||||
{
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
nsEventStatus nsMenuBar::MenuDeselected(const nsMenuEvent & aMenuEvent)
|
||||
{
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
nsEventStatus nsMenuBar::MenuConstruct(
|
||||
const nsMenuEvent& aMenuEvent,
|
||||
nsIWidget * aParentWindow,
|
||||
void * menubarNode,
|
||||
void * aWebShell)
|
||||
{
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
nsEventStatus nsMenuBar::MenuDestruct(const nsMenuEvent & aMenuEvent)
|
||||
{
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsMenuBar constructor
|
||||
|
@ -104,6 +79,8 @@ nsMenuBar::nsMenuBar() : nsIMenuBar(), nsIMenuListener()
|
|||
mMenu = nsnull;
|
||||
mParent = nsnull;
|
||||
mIsMenuBarAdded = PR_FALSE;
|
||||
mWebShell = nsnull;
|
||||
mDOMNode = nsnull;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -129,13 +106,11 @@ NS_METHOD nsMenuBar::Create(nsIWidget *aParent)
|
|||
mMenu = XmCreateMenuBar(mainWindow, "menubar", nsnull, 0);
|
||||
XtManageChild(mMenu);
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenuBar::GetParent(nsIWidget *&aParent)
|
||||
{
|
||||
// XXX: Shouldn't this do an addref here? or is this just internal
|
||||
aParent = mParent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -184,6 +159,23 @@ NS_METHOD nsMenuBar::RemoveMenu(const PRUint32 aCount)
|
|||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenuBar::RemoveAll()
|
||||
{
|
||||
for (int i = mMenusVoidArray.Count(); i > 0; i--) {
|
||||
if(nsnull != mMenusVoidArray[i-1]) {
|
||||
nsIMenu * menu = nsnull;
|
||||
((nsISupports*)mMenusVoidArray[i-1])->QueryInterface(nsIMenu::GetIID(), (void**)&menu);
|
||||
if(menu) {
|
||||
//XXX:implement something here.
|
||||
NS_RELEASE(menu);
|
||||
|
||||
//XXX:g_print("menu release \n");
|
||||
int num =((nsISupports*)mMenusVoidArray[i-1])->Release();
|
||||
while(num) {
|
||||
//XXX:g_print("menu release again!\n");
|
||||
num = ((nsISupports*)mMenusVoidArray[i-1])->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -207,3 +199,106 @@ NS_METHOD nsMenuBar::Paint()
|
|||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsMenuListener interface
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsEventStatus nsMenuBar::MenuItemSelected(const nsMenuEvent & aMenuEvent)
|
||||
{
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
nsEventStatus nsMenuBar::MenuSelected(const nsMenuEvent & aMenuEvent)
|
||||
{
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
nsEventStatus nsMenuBar::MenuDeselected(const nsMenuEvent & aMenuEvent)
|
||||
{
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
nsEventStatus nsMenuBar::MenuConstruct(
|
||||
const nsMenuEvent& aMenuEvent,
|
||||
nsIWidget * aParentWindow,
|
||||
void * menubarNode,
|
||||
void * aWebShell)
|
||||
{
|
||||
mWebShell = (nsIWebShell*) aWebShell;
|
||||
mDOMNode = (nsIDOMNode*)menubarNode;
|
||||
|
||||
nsIMenuBar * pnsMenuBar = nsnull;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kMenuBarCID,
|
||||
nsnull,
|
||||
nsIMenuBar::GetIID(),
|
||||
(void**)&pnsMenuBar);
|
||||
if (NS_OK == rv) {
|
||||
if (nsnull != pnsMenuBar) {
|
||||
pnsMenuBar->Create(aParentWindow);
|
||||
|
||||
// set pnsMenuBar as a nsMenuListener on aParentWindow
|
||||
nsCOMPtr<nsIMenuListener> menuListener;
|
||||
pnsMenuBar->QueryInterface(nsIMenuListener::GetIID(), getter_AddRefs(menuListener));
|
||||
aParentWindow->AddMenuListener(menuListener);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> menuNode;
|
||||
((nsIDOMNode*)menubarNode)->GetFirstChild(getter_AddRefs(menuNode));
|
||||
while (menuNode) {
|
||||
nsCOMPtr<nsIDOMElement> menuElement(do_QueryInterface(menuNode));
|
||||
if (menuElement) {
|
||||
nsString menuNodeType;
|
||||
nsString menuName;
|
||||
menuElement->GetNodeName(menuNodeType);
|
||||
if (menuNodeType.Equals("menu")) {
|
||||
menuElement->GetAttribute(nsAutoString("name"), menuName);
|
||||
// Don't create the menu yet, just add in the top level names
|
||||
|
||||
// Create nsMenu
|
||||
nsIMenu * pnsMenu = nsnull;
|
||||
rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, nsIMenu::GetIID(), (void**)&pnsMenu);
|
||||
if (NS_OK == rv) {
|
||||
// Call Create
|
||||
nsISupports * supports = nsnull;
|
||||
pnsMenuBar->QueryInterface(kISupportsIID, (void**) &supports);
|
||||
pnsMenu->Create(supports, menuName);
|
||||
NS_RELEASE(supports);
|
||||
|
||||
pnsMenu->SetLabel(menuName);
|
||||
pnsMenu->SetDOMNode(menuNode);
|
||||
pnsMenu->SetDOMElement(menuElement);
|
||||
pnsMenu->SetWebShell(mWebShell);
|
||||
|
||||
// Make nsMenu a child of nsMenuBar
|
||||
// nsMenuBar takes ownership of the nsMenu
|
||||
pnsMenuBar->AddMenu(pnsMenu);
|
||||
|
||||
// Release the menu now that the menubar owns it
|
||||
NS_RELEASE(pnsMenu);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> oldmenuNode(menuNode);
|
||||
oldmenuNode->GetNextSibling(getter_AddRefs(menuNode));
|
||||
} // end while (nsnull != menuNode)
|
||||
|
||||
// Give the aParentWindow this nsMenuBar to hold onto.
|
||||
// The parent window should take ownership at this point
|
||||
aParentWindow->SetMenuBar(pnsMenuBar);
|
||||
|
||||
// HACK: force a paint for now
|
||||
pnsMenuBar->Paint();
|
||||
|
||||
NS_RELEASE(pnsMenuBar);
|
||||
} // end if ( nsnull != pnsMenuBar )
|
||||
}
|
||||
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
nsEventStatus nsMenuBar::MenuDestruct(const nsMenuEvent & aMenuEvent)
|
||||
{
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "nsIMenuListener.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
class nsIDOMNode;
|
||||
class nsIWebShell;
|
||||
class nsIWidget;
|
||||
|
||||
/**
|
||||
|
@ -67,11 +69,15 @@ public:
|
|||
NS_IMETHOD Paint();
|
||||
NS_IMETHOD SetNativeData(void* aData);
|
||||
protected:
|
||||
PRUint32 mNumMenus;
|
||||
Widget mMenu;
|
||||
nsIWidget *mParent;
|
||||
nsIWidget * mParent;
|
||||
PRBool mIsMenuBarAdded;
|
||||
|
||||
nsIWebShell * mWebShell;
|
||||
nsIDOMNode * mDOMNode;
|
||||
|
||||
nsVoidArray mMenusVoidArray;
|
||||
PRUint32 mNumMenus;
|
||||
};
|
||||
|
||||
#endif // nsMenuBar_h__
|
||||
|
||||
|
|
|
@ -624,10 +624,10 @@ void nsWindow::RemoveChild(nsIWidget* aChild)
|
|||
// Hide or show this component
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsWindow::Show(PRBool bState)
|
||||
NS_METHOD nsWindow::Show(PRBool aState)
|
||||
{
|
||||
mShown = bState;
|
||||
if (bState) {
|
||||
mShown = aState;
|
||||
if (aState) {
|
||||
XtManageChild(mWidget);
|
||||
}
|
||||
else
|
||||
|
@ -636,6 +636,11 @@ NS_METHOD nsWindow::Show(PRBool bState)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsWindow::SetModal(void)
|
||||
{
|
||||
//XXX:Implement this
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsWindow::IsVisible(PRBool & aState)
|
||||
{
|
||||
|
|
|
@ -80,13 +80,14 @@ public:
|
|||
NS_IMETHOD SetClientData(void* aClientData);
|
||||
NS_IMETHOD Destroy();
|
||||
virtual nsIWidget* GetParent(void);
|
||||
virtual nsIEnumerator* GetChildren();
|
||||
virtual nsIEnumerator* GetChildren(void);
|
||||
NS_IMETHOD Show(PRBool aState);
|
||||
NS_IMETHOD SetModal(void);
|
||||
NS_IMETHOD IsVisible(PRBool & aState);
|
||||
NS_IMETHOD Move(PRUint32 aX, PRUint32 aY);
|
||||
virtual void AddChild(nsIWidget* aChild);
|
||||
virtual void RemoveChild(nsIWidget* aChild);
|
||||
NS_IMETHOD Show(PRBool bState);
|
||||
NS_IMETHOD IsVisible(PRBool & aState);
|
||||
|
||||
NS_IMETHOD Move(PRUint32 aX, PRUint32 aY);
|
||||
NS_IMETHOD Resize(PRUint32 aWidth,
|
||||
PRUint32 aHeight,
|
||||
PRBool aRepaint);
|
||||
|
|
Загрузка…
Ссылка в новой задаче