Files
Mozilla/mozilla/xpfc/parser/src/nsMenuManager.cpp
spider%netscape.com da31012521 First pass at XPFC migration to Free Source repo
git-svn-id: svn://10.0.0.236/trunk@9224 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-03 19:32:45 +00:00

118 lines
2.7 KiB
C++

/* -*- 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 "nsMenuManager.h"
#include "nsxpfcCIID.h"
#include "nsxpfcutil.h"
#include "nsIMenuBar.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kCMenuManagerCID, NS_MENU_MANAGER_CID);
static NS_DEFINE_IID(kIMenuManagerIID, NS_IMENU_MANAGER_IID);
#define MENU_ID_OFFSET 1
nsMenuManager :: nsMenuManager()
{
NS_INIT_REFCNT();
mMenuBar = nsnull;
mMenuContainers = nsnull;
mValidMenuID = MENU_ID_OFFSET;
}
nsMenuManager :: ~nsMenuManager()
{
NS_IF_RELEASE(mMenuBar);
if (mMenuContainers != nsnull)
{
mMenuContainers->RemoveAll();
NS_RELEASE(mMenuContainers);
}
}
NS_IMPL_QUERY_INTERFACE(nsMenuManager, kIMenuManagerIID)
NS_IMPL_ADDREF(nsMenuManager)
NS_IMPL_RELEASE(nsMenuManager)
nsresult nsMenuManager :: Init()
{
static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID);
nsresult res = nsRepository::CreateInstance(kCVectorCID,
nsnull,
kCVectorCID,
(void **)&mMenuContainers);
if (NS_OK != res)
return res ;
mMenuContainers->Init();
return NS_OK ;
}
nsresult nsMenuManager :: SetMenuBar(nsIMenuBar * aMenuBar)
{
mMenuBar = aMenuBar;
NS_ADDREF(mMenuBar);
return NS_OK ;
}
nsIMenuBar * nsMenuManager :: GetMenuBar()
{
return (mMenuBar) ;
}
nsIXPFCCommandReceiver * nsMenuManager :: GetDefaultReceiver()
{
return (mDefaultReceiver) ;
}
nsresult nsMenuManager :: SetDefaultReceiver(nsIXPFCCommandReceiver * aReceiver)
{
mDefaultReceiver = aReceiver;
return (NS_OK) ;
}
nsresult nsMenuManager::AddMenuContainer(nsIMenuContainer * aMenuContainer)
{
mMenuContainers->Append(aMenuContainer);
return NS_OK;
}
nsIMenuItem * nsMenuManager::MenuItemFromID(PRUint32 aID)
{
nsIMenuItem * item = nsnull;
if (mMenuBar)
item = mMenuBar->MenuItemFromID(aID);
if (item != nsnull)
return item;
return nsnull;
}
PRUint32 nsMenuManager::GetID()
{
mValidMenuID++;
return mValidMenuID;
}