nsIMenu.h changes
git-svn-id: svn://10.0.0.236/trunk@24568 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -38,7 +38,10 @@
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIMenuIID, NS_IMENU_IID);
|
||||
//NS_IMPL_ISUPPORTS(nsMenu, kIMenuIID)
|
||||
static NS_DEFINE_IID(kIMenuBarIID, NS_IMENUBAR_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIMenuItemIID, NS_IMENUITEM_IID);
|
||||
|
||||
|
||||
nsresult nsMenu::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
@@ -106,29 +109,87 @@ nsMenu::~nsMenu()
|
||||
// Create the proper widget
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenu::Create(nsIMenuBar *aParent, const nsString &aLabel)
|
||||
NS_METHOD nsMenu::Create(nsISupports *aParent, const nsString &aLabel)
|
||||
|
||||
{
|
||||
mMenuBarParent = aParent;
|
||||
NS_ADDREF(mMenuBarParent);
|
||||
|
||||
if(aParent)
|
||||
|
||||
{
|
||||
|
||||
nsIMenuBar * menubar = nsnull;
|
||||
|
||||
aParent->QueryInterface(kIMenuBarIID, (void**) &menubar);
|
||||
|
||||
if(menubar)
|
||||
|
||||
{
|
||||
|
||||
mMenuBarParent = menubar;
|
||||
|
||||
NS_ADDREF(mMenuBarParent);
|
||||
|
||||
NS_RELEASE(menubar); // Balance the QI
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
nsIMenu * menu = nsnull;
|
||||
|
||||
aParent->QueryInterface(kIMenuIID, (void**) &menu);
|
||||
|
||||
if(menu)
|
||||
|
||||
{
|
||||
|
||||
mMenuParent = menu;
|
||||
|
||||
NS_ADDREF(mMenuParent);
|
||||
|
||||
NS_RELEASE(menu); // Balance the QI
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
mLabel = aLabel;
|
||||
|
||||
mMenu = CreateMenu();
|
||||
|
||||
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenu::Create(nsIMenu *aParent, const nsString &aLabel)
|
||||
{
|
||||
mMenuParent = aParent;
|
||||
NS_ADDREF(mMenuParent);
|
||||
|
||||
|
||||
mLabel = aLabel;
|
||||
|
||||
mMenu = CreateMenu();
|
||||
|
||||
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenu::GetParent(nsISupports*& aParent)
|
||||
{
|
||||
@@ -151,7 +212,8 @@ NS_METHOD nsMenu::GetLabel(nsString &aText)
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenu::SetLabel(nsString &aText)
|
||||
NS_METHOD nsMenu::SetLabel(const nsString &aText)
|
||||
|
||||
{
|
||||
mLabel = aText;
|
||||
|
||||
@@ -159,8 +221,56 @@ NS_METHOD nsMenu::SetLabel(nsString &aText)
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenu::AddItem(const nsString &aText)
|
||||
NS_METHOD nsMenu::AddItem(nsISupports * aItem)
|
||||
|
||||
{
|
||||
|
||||
if(aItem)
|
||||
|
||||
{
|
||||
|
||||
// Figure out what we're adding
|
||||
|
||||
nsIMenuItem * menuitem = nsnull;
|
||||
|
||||
aItem->QueryInterface(kIMenuItemIID, (void**) &menuitem);
|
||||
|
||||
if(menuitem)
|
||||
|
||||
{
|
||||
|
||||
// case menuitem
|
||||
|
||||
AddMenuItem(menuitem);
|
||||
|
||||
NS_RELEASE(menuitem);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
nsIMenu * menu = nsnull;
|
||||
|
||||
aItem->QueryInterface(kIMenuIID, (void**) &menu);
|
||||
|
||||
if(menu)
|
||||
|
||||
{
|
||||
|
||||
// case menu
|
||||
|
||||
AddMenu(menu);
|
||||
|
||||
NS_RELEASE(menu);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -274,7 +384,8 @@ NS_METHOD nsMenu::InsertItemAt(const PRUint32 aCount, nsISupports * aMenuItem)
|
||||
|
||||
HMENU nativeMenuHandle;
|
||||
void * voidData;
|
||||
menu->GetNativeData(voidData);
|
||||
menu->GetNativeData(&voidData);
|
||||
|
||||
nativeMenuHandle = (HMENU)voidData;
|
||||
|
||||
MENUITEMINFO menuInfo;
|
||||
@@ -334,9 +445,12 @@ NS_METHOD nsMenu::RemoveAll()
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenu::GetNativeData(void *& aData)
|
||||
NS_METHOD nsMenu::GetNativeData(void ** aData)
|
||||
|
||||
{
|
||||
aData = (void *)mMenu;
|
||||
|
||||
*aData = (void *)mMenu;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,27 +45,32 @@ public:
|
||||
nsEventStatus MenuSelected(const nsMenuEvent & aMenuEvent);
|
||||
nsEventStatus MenuDeselected(const nsMenuEvent & aMenuEvent);
|
||||
|
||||
NS_IMETHOD Create(nsIMenuBar * aParent, const nsString &aLabel);
|
||||
NS_IMETHOD Create(nsIMenu * aParent, const nsString &aLabel);
|
||||
NS_IMETHOD Create(nsISupports * aParent, const nsString &aLabel);
|
||||
|
||||
|
||||
// nsIMenu Methods
|
||||
NS_IMETHOD GetParent(nsISupports *&aParent);
|
||||
NS_IMETHOD GetLabel(nsString &aText);
|
||||
NS_IMETHOD SetLabel(nsString &aText);
|
||||
NS_IMETHOD AddItem(const nsString &aText);
|
||||
NS_IMETHOD AddMenuItem(nsIMenuItem * aMenuItem);
|
||||
NS_IMETHOD AddMenu(nsIMenu * aMenu);
|
||||
NS_IMETHOD SetLabel(const nsString &aText);
|
||||
|
||||
NS_IMETHOD AddItem(nsISupports * aItem);
|
||||
|
||||
NS_IMETHOD AddSeparator();
|
||||
NS_IMETHOD GetItemCount(PRUint32 &aCount);
|
||||
NS_IMETHOD GetItemAt(const PRUint32 aPos, nsISupports *& aMenuItem);
|
||||
NS_IMETHOD InsertItemAt(const PRUint32 aPos, nsISupports * aMenuItem);
|
||||
NS_IMETHOD InsertSeparator(const PRUint32 aPos);
|
||||
NS_IMETHOD RemoveItem(const PRUint32 aPos);
|
||||
NS_IMETHOD RemoveAll();
|
||||
NS_IMETHOD GetNativeData(void*& aData);
|
||||
NS_IMETHOD GetNativeData(void** aData);
|
||||
|
||||
NS_IMETHOD AddMenuListener(nsIMenuListener * aMenuListener);
|
||||
NS_IMETHOD RemoveMenuListener(nsIMenuListener * aMenuListener);
|
||||
|
||||
//
|
||||
NS_IMETHOD AddMenuItem(nsIMenuItem * aMenuItem);
|
||||
NS_IMETHOD AddMenu(nsIMenu * aMenu);
|
||||
NS_IMETHOD InsertSeparator(const PRUint32 aCount);
|
||||
|
||||
// Native Impl Methods
|
||||
// These are not ref counted
|
||||
nsIMenu * GetMenuParent() { return mMenuParent; }
|
||||
|
||||
@@ -171,7 +171,8 @@ NS_METHOD nsMenuBar::InsertMenuAt(const PRUint32 aPos, nsIMenu *& aMenu)
|
||||
|
||||
HMENU nativeMenuHandle;
|
||||
void * voidData;
|
||||
aMenu->GetNativeData(voidData);
|
||||
aMenu->GetNativeData(&voidData);
|
||||
|
||||
nativeMenuHandle = (HMENU)voidData;
|
||||
|
||||
MENUITEMINFO menuInfo;
|
||||
|
||||
@@ -119,7 +119,8 @@ NS_METHOD nsPopUpMenu::AddMenu(nsIMenu * aMenu)
|
||||
|
||||
HMENU nativeMenuHandle;
|
||||
void * voidData;
|
||||
aMenu->GetNativeData(voidData);
|
||||
aMenu->GetNativeData(&voidData);
|
||||
|
||||
nativeMenuHandle = (HMENU)voidData;
|
||||
|
||||
MENUITEMINFO menuInfo;
|
||||
|
||||
Reference in New Issue
Block a user