removed errant |QueryInterface()|s in favor of appropriate macros, as part of bug#23737. Changed |NS_DEFINE_IID| to |NS_DEFINE_CID| where appropriate; or else removed it, and fixed up clients to use |NS_GET_IID| in the appropriate spots. Built and ran pre-checkin tests. r=pavlov ... who claims this shouldn't effect other platforms; but I'm watching anyway
This commit is contained in:
Родитель
ada87acf3e
Коммит
6b45b35877
|
@ -31,8 +31,6 @@
|
|||
#define NS_IMENULISTENER_IID \
|
||||
{ 0xbc658c81, 0x4beb, 0x11d2, \
|
||||
{ 0x8d, 0xbb, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x9e } }
|
||||
|
||||
static NS_DEFINE_IID(kIMenuListenerIID, NS_IMENULISTENER_IID);
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -58,10 +58,9 @@ PRBool nsAppShell::mInitializedToolbox = PR_FALSE;
|
|||
// nsISupports implementation macro
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID);
|
||||
NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsAppShell,kIAppShellIID);
|
||||
NS_IMPL_ISUPPORTS1(nsAppShell, nsIAppShell)
|
||||
|
||||
NS_IMETHODIMP nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener)
|
||||
{
|
||||
|
|
|
@ -51,21 +51,9 @@ nsButton::~nsButton()
|
|||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsButton::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIButton, NS_IBUTTON_IID);
|
||||
if (aIID.Equals(kIButton)) {
|
||||
*aInstancePtr = (void*) ((nsIButton*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsWindow::QueryInterface(aIID,aInstancePtr);
|
||||
}
|
||||
NS_INTERFACE_MAP_BEGIN(nsButton)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIButton)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsWindow)
|
||||
|
||||
#pragma mark -
|
||||
//-------------------------------------------------------------------------
|
||||
|
|
|
@ -51,20 +51,9 @@ nsCheckButton::~nsCheckButton()
|
|||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsCheckButton::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
|
||||
if (aIID.Equals(kICheckButtonIID)) {
|
||||
*aInstancePtr = (void*) ((nsICheckButton*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return nsWindow::QueryInterface(aIID,aInstancePtr);
|
||||
}
|
||||
NS_INTERFACE_MAP_BEGIN(nsCheckButton)
|
||||
NS_INTERFACE_MAP_ENTRY(nsICheckButton)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsWindow)
|
||||
|
||||
#pragma mark -
|
||||
//-------------------------------------------------------------------------
|
||||
|
|
|
@ -1,356 +0,0 @@
|
|||
/* -*- 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.1 (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.org 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsComboBox.h"
|
||||
#include "nsMenu.h"
|
||||
#include <StringCompare.h>
|
||||
#include "nsCarbonHelpers.h"
|
||||
|
||||
#if TARGET_CARBON
|
||||
#include <ControlDefinitions.h>
|
||||
#endif
|
||||
|
||||
NS_IMPL_ADDREF(nsComboBox);
|
||||
NS_IMPL_RELEASE(nsComboBox);
|
||||
|
||||
#define DASH '-'
|
||||
#define OPTION_DASH 'Ð'
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsComboBox constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsComboBox::nsComboBox() : nsMacControl(), nsIListWidget(), nsIComboBox()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
gInstanceClassName = "nsComboBox";
|
||||
SetControlType(kControlPopupButtonProc + kControlPopupFixedWidthVariant);
|
||||
|
||||
mMenuHandle = nsnull;
|
||||
mMenuID = -12345; // so that the control doesn't look for a menu in resource
|
||||
mMin = mMenuID; // when creating a popup, 'min' must contain the menuID
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsComboBox:: destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsComboBox::~nsComboBox()
|
||||
{
|
||||
if (mMenuHandle)
|
||||
{
|
||||
// ::DeleteMenu(mMenuID);
|
||||
// ::DisposeMenu(mMenuHandle);
|
||||
mMenuHandle = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsComboBox::Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
{
|
||||
nsresult res = Inherited::Create(aParent, aRect, aHandleEventFunction,
|
||||
aContext, aAppShell, aToolkit, aInitData);
|
||||
|
||||
if (res == NS_OK)
|
||||
{
|
||||
mMenuID = nsMenu::GetUniqueMenuID();
|
||||
mMenuHandle = ::NewMenu(mMenuID, "\p");
|
||||
if (mMenuHandle)
|
||||
{
|
||||
StartDraw();
|
||||
::InsertMenu(mMenuHandle, hierMenu);
|
||||
SetControlPopupMenuStuff ( mControl, mMenuHandle, mMenuID );
|
||||
::SetControlMinimum(mControl, 0);
|
||||
::SetControlMaximum(mControl, 0);
|
||||
::SetControlValue(mControl, 0);
|
||||
EndDraw();
|
||||
}
|
||||
else
|
||||
res = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsComboBox::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kInsComboBoxIID, NS_ICOMBOBOX_IID);
|
||||
static NS_DEFINE_IID(kInsListWidgetIID, NS_ILISTWIDGET_IID);
|
||||
|
||||
if (aIID.Equals(kInsComboBoxIID)) {
|
||||
*aInstancePtr = (void*) ((nsIComboBox*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(kInsListWidgetIID)) {
|
||||
*aInstancePtr = (void*) ((nsIListWidget*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsWindow::QueryInterface(aIID,aInstancePtr);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// AddItemAt
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
nsresult nsComboBox::AddItemAt(nsString &aItem, PRInt32 aPosition)
|
||||
{
|
||||
if (! mMenuHandle)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
Str255 pString;
|
||||
StringToStr255(aItem, pString);
|
||||
|
||||
// Mac hacks: a menu item should not be an empty string
|
||||
// (otherwise a new item is not appended to the menu)
|
||||
// and it should not contain a dash '-' as first character
|
||||
// (otherwise it is considered as a menu separator even though
|
||||
// we are doing a 2-step initialization with MacInsertMenuItem()
|
||||
// and SetMenuItemText()).
|
||||
if (pString[0] == 0)
|
||||
{
|
||||
pString[0] = 1;
|
||||
pString[1] = ' ';
|
||||
}
|
||||
else if (pString[1] == DASH) {
|
||||
pString[1] = OPTION_DASH;
|
||||
}
|
||||
|
||||
StartDraw();
|
||||
|
||||
short menuItems = GetItemCount();
|
||||
if (aPosition == -1 || aPosition > menuItems) {
|
||||
aPosition = menuItems;
|
||||
}
|
||||
::MacInsertMenuItem(mMenuHandle, "\p ", aPosition);
|
||||
::SetMenuItemText(mMenuHandle, aPosition + 1, pString);
|
||||
|
||||
menuItems = GetItemCount();
|
||||
::SetControlMinimum(mControl, (menuItems ? 1 : 0));
|
||||
::SetControlMaximum(mControl, (menuItems ? menuItems : 0));
|
||||
EndDraw();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Finds an item at a postion
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsComboBox::FindItem(nsString &aItem, PRInt32 aStartPos)
|
||||
{
|
||||
if (! mMenuHandle)
|
||||
return -1;
|
||||
|
||||
PRInt32 index = -1;
|
||||
short itemCount = GetItemCount();
|
||||
for (short i = aStartPos; i < itemCount; i ++)
|
||||
{
|
||||
nsString temp;
|
||||
GetItemAt(temp, i);
|
||||
if (aItem == temp)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// CountItems - Get Item Count
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsComboBox::GetItemCount()
|
||||
{
|
||||
if (! mMenuHandle)
|
||||
return 0;
|
||||
|
||||
return ::CountMenuItems(mMenuHandle);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Removes an Item at a specified location
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsComboBox::RemoveItemAt(PRInt32 aPosition)
|
||||
{
|
||||
if (! mMenuHandle)
|
||||
return PR_FALSE;
|
||||
|
||||
if (GetItemCount() < aPosition)
|
||||
return PR_FALSE;
|
||||
|
||||
StartDraw();
|
||||
if (aPosition == -1)
|
||||
::DeleteMenuItem(mMenuHandle, GetItemCount());
|
||||
else
|
||||
::DeleteMenuItem(mMenuHandle, aPosition + 1);
|
||||
|
||||
short menuItems = GetItemCount();
|
||||
::SetControlMinimum(mControl, (menuItems ? 1 : 0));
|
||||
::SetControlMaximum(mControl, (menuItems ? menuItems : 0));
|
||||
EndDraw();
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Returns an Item at a specified location
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsComboBox::GetItemAt(nsString& anItem, PRInt32 aPosition)
|
||||
{
|
||||
anItem = "";
|
||||
|
||||
if (! mMenuHandle)
|
||||
return PR_FALSE;
|
||||
|
||||
if (aPosition >= GetItemCount())
|
||||
return PR_FALSE;
|
||||
|
||||
Str255 itemStr;
|
||||
::GetMenuItemText(mMenuHandle, aPosition + 1, itemStr);
|
||||
if (itemStr[1] == OPTION_DASH) // see AddItemAt() for more info
|
||||
itemStr[1] = DASH;
|
||||
Str255ToString(itemStr, anItem);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Gets the selected of selected item
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsComboBox::GetSelectedItem(nsString& anItem)
|
||||
{
|
||||
return GetItemAt(anItem, GetSelectedIndex());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Gets the list of selected otems
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsComboBox::GetSelectedIndex()
|
||||
{
|
||||
if (! mMenuHandle)
|
||||
return -1;
|
||||
|
||||
return ::GetControlValue(mControl) - 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// SelectItem
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsComboBox::SelectItem(PRInt32 aPosition)
|
||||
{
|
||||
if (! mMenuHandle)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
StartDraw();
|
||||
if (aPosition == -1)
|
||||
::SetControlValue(mControl, GetItemCount());
|
||||
else
|
||||
::SetControlValue(mControl, aPosition + 1);
|
||||
EndDraw();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Deselect
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsComboBox::Deselect()
|
||||
{
|
||||
return SelectItem(0);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// DispatchMouseEvent
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsComboBox::DispatchMouseEvent(nsMouseEvent &aEvent)
|
||||
{
|
||||
PRBool eventHandled = PR_FALSE;
|
||||
switch (aEvent.message)
|
||||
{
|
||||
case NS_MOUSE_LEFT_DOUBLECLICK:
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
eventHandled = Inherited::DispatchMouseEvent(aEvent);
|
||||
if (!eventHandled) {
|
||||
StartDraw();
|
||||
Point thePoint;
|
||||
thePoint.h = aEvent.point.x;
|
||||
thePoint.v = aEvent.point.y;
|
||||
::TrackControl(mControl, thePoint, nil);
|
||||
ControlChanged(::GetControlValue(mControl));
|
||||
EndDraw();
|
||||
|
||||
// since the mouseUp event will be consumed by TrackControl,
|
||||
// simulate the mouse up event immediately.
|
||||
nsMouseEvent mouseUpEvent = aEvent;
|
||||
mouseUpEvent.message = NS_MOUSE_LEFT_BUTTON_UP;
|
||||
Inherited::DispatchMouseEvent(mouseUpEvent);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
eventHandled = Inherited::DispatchMouseEvent(aEvent);
|
||||
break;
|
||||
}
|
||||
return eventHandled;
|
||||
}
|
|
@ -40,45 +40,13 @@
|
|||
#include <Devices.h>
|
||||
#include <Menus.h>
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIContextMenuIID, NS_ICONTEXTMENU_IID);
|
||||
static NS_DEFINE_IID(kIMenuIID, NS_IMENU_IID);
|
||||
static NS_DEFINE_IID(kIMenuItemIID, NS_IMENUITEM_IID);
|
||||
|
||||
// CIDs
|
||||
#include "nsWidgetsCID.h"
|
||||
static NS_DEFINE_IID(kMenuBarCID, NS_MENUBAR_CID);
|
||||
static NS_DEFINE_IID(kMenuCID, NS_MENU_CID);
|
||||
static NS_DEFINE_IID(kMenuItemCID, NS_MENUITEM_CID);
|
||||
static NS_DEFINE_CID(kMenuBarCID, NS_MENUBAR_CID);
|
||||
static NS_DEFINE_CID(kMenuCID, NS_MENU_CID);
|
||||
static NS_DEFINE_CID(kMenuItemCID, NS_MENUITEM_CID);
|
||||
|
||||
nsresult nsContextMenu::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if (aIID.Equals(kIContextMenuIID)) {
|
||||
*aInstancePtr = (void*)(nsIContextMenu*) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIMenuListenerIID)) {
|
||||
*aInstancePtr = (void*) ((nsIMenuListener*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsContextMenu)
|
||||
NS_IMPL_RELEASE(nsContextMenu)
|
||||
NS_IMPL_ISUPPORTS2(nsContextMenu, nsIContextMenu, nsIMenuListener)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -125,7 +93,7 @@ nsContextMenu::~nsContextMenu()
|
|||
if(mMenuItemVoidArray[mNumMenuItems]) {
|
||||
// Figure out what we're releasing
|
||||
nsIMenuItem * menuitem = nsnull;
|
||||
((nsISupports*)mMenuItemVoidArray[mNumMenuItems])->QueryInterface(kIMenuItemIID, (void**) &menuitem);
|
||||
((nsISupports*)mMenuItemVoidArray[mNumMenuItems])->QueryInterface(NS_GET_IID(nsIMenuItem), (void**) &menuitem);
|
||||
if(menuitem)
|
||||
{
|
||||
// case menuitem
|
||||
|
@ -135,7 +103,7 @@ nsContextMenu::~nsContextMenu()
|
|||
else
|
||||
{
|
||||
nsIMenu * menu = nsnull;
|
||||
((nsISupports*)mMenuItemVoidArray[mNumMenuItems])->QueryInterface(kIMenuIID, (void**) &menu);
|
||||
((nsISupports*)mMenuItemVoidArray[mNumMenuItems])->QueryInterface(NS_GET_IID(nsIMenu), (void**) &menu);
|
||||
if(menu)
|
||||
{
|
||||
// case menu
|
||||
|
@ -171,7 +139,7 @@ NS_METHOD nsContextMenu::GetParent(nsISupports*& aParent)
|
|||
{
|
||||
aParent = nsnull;
|
||||
if (mParent) {
|
||||
return mParent->QueryInterface(kISupportsIID,(void**)&aParent);
|
||||
return mParent->QueryInterface(NS_GET_IID(nsISupports),(void**)&aParent);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -183,7 +151,7 @@ NS_METHOD nsContextMenu::AddItem(nsISupports* aItem)
|
|||
{
|
||||
// Figure out what we're adding
|
||||
nsIMenuItem * menuitem = nsnull;
|
||||
aItem->QueryInterface(kIMenuItemIID, (void**) &menuitem);
|
||||
aItem->QueryInterface(NS_GET_IID(nsIMenuItem), (void**) &menuitem);
|
||||
if(menuitem)
|
||||
{
|
||||
// case menuitem
|
||||
|
@ -193,7 +161,7 @@ NS_METHOD nsContextMenu::AddItem(nsISupports* aItem)
|
|||
else
|
||||
{
|
||||
nsIMenu * menu = nsnull;
|
||||
aItem->QueryInterface(kIMenuIID, (void**) &menu);
|
||||
aItem->QueryInterface(NS_GET_IID(nsIMenu), (void**) &menu);
|
||||
if(menu)
|
||||
{
|
||||
// case menu
|
||||
|
@ -210,7 +178,7 @@ NS_METHOD nsContextMenu::AddMenuItem(nsIMenuItem * aMenuItem)
|
|||
{
|
||||
if(aMenuItem) {
|
||||
nsISupports * supports = nsnull;
|
||||
aMenuItem->QueryInterface(kISupportsIID, (void**)&supports);
|
||||
aMenuItem->QueryInterface(NS_GET_IID(nsISupports), (void**)&supports);
|
||||
if(supports) {
|
||||
mMenuItemVoidArray.AppendElement(supports);
|
||||
|
||||
|
@ -242,7 +210,7 @@ NS_METHOD nsContextMenu::AddMenu(nsIMenu * aMenu)
|
|||
// Add a submenu
|
||||
if(aMenu) {
|
||||
nsISupports * supports = nsnull;
|
||||
aMenu->QueryInterface(kISupportsIID, (void**)&supports);
|
||||
aMenu->QueryInterface(NS_GET_IID(nsISupports), (void**)&supports);
|
||||
if(supports) {
|
||||
mMenuItemVoidArray.AppendElement(supports);
|
||||
|
||||
|
@ -364,7 +332,7 @@ nsEventStatus nsContextMenu::MenuItemSelected(const nsMenuEvent & aMenuEvent)
|
|||
//PRInt16 menuItemID = LoWord(((nsMenuEvent)aMenuEvent).mCommand);
|
||||
PRInt16 menuItemID = mSelectedMenuItem;
|
||||
nsIMenuListener * menuListener = nsnull;
|
||||
((nsIMenuItem*)mMenuItemVoidArray[menuItemID-1])->QueryInterface(kIMenuListenerIID, &menuListener);
|
||||
((nsIMenuItem*)mMenuItemVoidArray[menuItemID-1])->QueryInterface(NS_GET_IID(nsIMenuListener), &menuListener);
|
||||
if(menuListener) {
|
||||
eventStatus = menuListener->MenuSelected(aMenuEvent);
|
||||
NS_IF_RELEASE(menuListener);
|
||||
|
@ -378,11 +346,11 @@ nsEventStatus nsContextMenu::MenuItemSelected(const nsMenuEvent & aMenuEvent)
|
|||
if(nsnull != mMenuItemVoidArray[i-1])
|
||||
{
|
||||
nsIMenu * submenu = nsnull;
|
||||
((nsISupports*)mMenuItemVoidArray[i-1])->QueryInterface(kIMenuIID, &submenu);
|
||||
((nsISupports*)mMenuItemVoidArray[i-1])->QueryInterface(NS_GET_IID(nsIMenu), &submenu);
|
||||
if(submenu)
|
||||
{
|
||||
nsIMenuListener * menuListener = nsnull;
|
||||
((nsISupports*)mMenuItemVoidArray[i-1])->QueryInterface(kIMenuListenerIID, &menuListener);
|
||||
((nsISupports*)mMenuItemVoidArray[i-1])->QueryInterface(NS_GET_IID(nsIMenuListener), &menuListener);
|
||||
if(menuListener){
|
||||
eventStatus = menuListener->MenuSelected(aMenuEvent);
|
||||
NS_IF_RELEASE(menuListener);
|
||||
|
@ -564,12 +532,12 @@ void nsContextMenu::LoadMenuItem(
|
|||
menuitemElement->GetAttribute(nsAutoString("cmd"), menuitemCmd);
|
||||
// Create nsMenuItem
|
||||
nsIMenuItem * pnsMenuItem = nsnull;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kMenuItemCID, nsnull, kIMenuItemIID, (void**)&pnsMenuItem);
|
||||
nsresult rv = nsComponentManager::CreateInstance(kMenuItemCID, nsnull, NS_GET_IID(nsIMenuItem), (void**)&pnsMenuItem);
|
||||
if (NS_OK == rv) {
|
||||
pnsMenuItem->Create(pParentMenu, menuitemName, 0);
|
||||
|
||||
nsISupports * supports = nsnull;
|
||||
pnsMenuItem->QueryInterface(kISupportsIID, (void**) &supports);
|
||||
pnsMenuItem->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
||||
pParentMenu->AddItem(supports); // Parent should now own menu item
|
||||
NS_RELEASE(supports);
|
||||
|
||||
|
@ -616,11 +584,11 @@ void nsContextMenu::LoadSubMenu(
|
|||
|
||||
// Create nsMenu
|
||||
nsIMenu * pnsMenu = nsnull;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, kIMenuIID, (void**)&pnsMenu);
|
||||
nsresult rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, NS_GET_IID(nsIMenu), (void**)&pnsMenu);
|
||||
if (NS_OK == rv) {
|
||||
// Call Create
|
||||
nsISupports * supports = nsnull;
|
||||
pParentMenu->QueryInterface(kISupportsIID, (void**) &supports);
|
||||
pParentMenu->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
||||
pnsMenu->Create(supports, menuName);
|
||||
NS_RELEASE(supports); // Balance QI
|
||||
|
||||
|
@ -629,7 +597,7 @@ void nsContextMenu::LoadSubMenu(
|
|||
|
||||
// Make nsMenu a child of parent nsMenu. The parent takes ownership
|
||||
supports = nsnull;
|
||||
pnsMenu->QueryInterface(kISupportsIID, (void**) &supports);
|
||||
pnsMenu->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
||||
pParentMenu->AddItem(supports);
|
||||
NS_RELEASE(supports);
|
||||
|
||||
|
|
|
@ -108,27 +108,9 @@ NS_IMETHODIMP nsFileWidget:: Create(nsIWidget *aParent,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement the standard QueryInterface for NS_IWIDGET_IID and NS_ISUPPORTS_IID
|
||||
* @param aIID The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*/
|
||||
nsresult nsFileWidget::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
|
||||
if (aIID.Equals(kIFileWidgetIID)) {
|
||||
*aInstancePtr = (void*) ((nsIFileWidget*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsWindow::QueryInterface(aIID,aInstancePtr);
|
||||
}
|
||||
NS_INTERFACE_MAP_BEGIN(nsFileWidget)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIFileWidget)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsWindow)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -47,21 +47,9 @@ nsLabel::~nsLabel()
|
|||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsLabel::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kILabel, NS_ILABEL_IID);
|
||||
if (aIID.Equals(kILabel)) {
|
||||
*aInstancePtr = (void*) ((nsILabel*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsTextWidget::QueryInterface(aIID,aInstancePtr);
|
||||
}
|
||||
NS_INTERFACE_MAP_BEGIN(nsLabel)
|
||||
NS_INTERFACE_MAP_ENTRY(nsILabel)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsTextWidget)
|
||||
|
||||
#pragma mark -
|
||||
//-------------------------------------------------------------------------
|
||||
|
|
|
@ -1,579 +0,0 @@
|
|||
/* -*- 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.1 (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.org 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsListBox.h"
|
||||
#include "nsMacResources.h"
|
||||
#include <StringCompare.h>
|
||||
#include <Resources.h>
|
||||
#include <Folders.h>
|
||||
#include <Appearance.h>
|
||||
#if TARGET_CARBON
|
||||
#include <ControlDefinitions.h>
|
||||
#endif
|
||||
|
||||
NS_IMPL_ADDREF(nsListBox);
|
||||
NS_IMPL_RELEASE(nsListBox);
|
||||
|
||||
typedef struct ldesRsrc
|
||||
{
|
||||
short version;
|
||||
short rows;
|
||||
short cols;
|
||||
short cellHeight;
|
||||
short cellWidth;
|
||||
Boolean vertScroll;
|
||||
Boolean __pad1;
|
||||
Boolean horizScroll;
|
||||
Boolean __pad2;
|
||||
short ldefID;
|
||||
Boolean hasGrow;
|
||||
Boolean __pad3;
|
||||
} ldesRsrc;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsListBox constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsListBox::nsListBox() : nsMacControl(), nsIListWidget(), nsIListBox()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
gInstanceClassName = "nsListBox";
|
||||
SetControlType(kControlListBoxProc);
|
||||
|
||||
mListHandle = nsnull;
|
||||
mMultiSelect = PR_FALSE;
|
||||
|
||||
AcceptFocusOnClick(PR_TRUE);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsListBox:: destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsListBox::~nsListBox()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsListBox::GetRectForMacControl(nsRect &outRect)
|
||||
{
|
||||
outRect = mBounds;
|
||||
outRect.x = outRect.y = 0;
|
||||
// inset to make space for border
|
||||
outRect.Deflate(2, 2);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsListBox::Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
{
|
||||
#define kLDESRsrcID 128 // The Appearance Manager needs a 'ldes' resource to create list controls
|
||||
|
||||
nsMacResources::OpenLocalResourceFile();
|
||||
|
||||
mValue = kLDESRsrcID;
|
||||
nsresult res = Inherited::Create(aParent, aRect, aHandleEventFunction, aContext, aAppShell, aToolkit, aInitData);
|
||||
mValue = 0;
|
||||
|
||||
nsMacResources::CloseLocalResourceFile();
|
||||
|
||||
if (res == NS_OK)
|
||||
{
|
||||
Size actualSize;
|
||||
::GetControlData(mControl, kControlNoPart, kControlListBoxListHandleTag, sizeof(ListHandle), (Ptr)&mListHandle, &actualSize);
|
||||
if (mListHandle)
|
||||
{
|
||||
SetMultipleSelection(mMultiSelect);
|
||||
StartDraw();
|
||||
::LSetDrawingMode(mVisible, mListHandle);
|
||||
::SetControlMinimum(mControl, 0);
|
||||
::SetControlMaximum(mControl, 0);
|
||||
::SetControlValue(mControl, 0);
|
||||
EndDraw();
|
||||
}
|
||||
else
|
||||
res = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsListBox::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kInsListBoxIID, NS_ILISTBOX_IID);
|
||||
static NS_DEFINE_IID(kInsListWidgetIID, NS_ILISTWIDGET_IID);
|
||||
|
||||
if (aIID.Equals(kInsListBoxIID)) {
|
||||
*aInstancePtr = (void*) ((nsIListBox*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(kInsListWidgetIID)) {
|
||||
*aInstancePtr = (void*) ((nsIListWidget*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsWindow::QueryInterface(aIID,aInstancePtr);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsListBox::Show(PRBool bState)
|
||||
{
|
||||
if (! mListHandle)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
if (mVisible == bState)
|
||||
return NS_OK;
|
||||
|
||||
Inherited::Show(bState);
|
||||
StartDraw();
|
||||
::LSetDrawingMode(bState, mListHandle);
|
||||
EndDraw();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// SetMultipleSelection
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsListBox::SetMultipleSelection(PRBool aMultipleSelections)
|
||||
{
|
||||
mMultiSelect = aMultipleSelections;
|
||||
|
||||
if (mListHandle)
|
||||
(*mListHandle)->selFlags = (mMultiSelect ? (lUseSense | lNoRect | lNoExtend) : lOnlyOne);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// PreCreateWidget
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsListBox::PreCreateWidget(nsWidgetInitData *aInitData)
|
||||
{
|
||||
if (nsnull != aInitData) {
|
||||
nsListBoxInitData* data = (nsListBoxInitData *) aInitData;
|
||||
mMultiSelect = data->mMultiSelect;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// AddItemAt
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsListBox::AddItemAt(nsString &aItem, PRInt32 aPosition)
|
||||
{
|
||||
if (! mListHandle)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
Str255 pString;
|
||||
StringToStr255(aItem, pString);
|
||||
|
||||
StartDraw();
|
||||
if (aPosition == -1)
|
||||
aPosition = GetItemCount() + 1;
|
||||
short rowNum = ::LAddRow(1, aPosition, mListHandle);
|
||||
|
||||
Cell newCell;
|
||||
::SetPt(&newCell, 0, rowNum);
|
||||
::LSetCell(pString+1, *pString, newCell, mListHandle);
|
||||
|
||||
::SetControlMaximum(mControl, GetItemCount());
|
||||
EndDraw();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Finds an item at a postion
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsListBox::FindItem(nsString &aItem, PRInt32 aStartPos)
|
||||
{
|
||||
if (! mListHandle)
|
||||
return -1;
|
||||
|
||||
PRInt32 index = -1;
|
||||
short itemCount = GetItemCount();
|
||||
|
||||
if (aStartPos < itemCount)
|
||||
{
|
||||
Str255 searchStr;
|
||||
StringToStr255(aItem, searchStr);
|
||||
|
||||
for (short i = aStartPos; i < itemCount; i ++)
|
||||
{
|
||||
Str255 itemStr;
|
||||
short strSize = sizeof(itemStr) - 1;
|
||||
|
||||
Cell theCell;
|
||||
::SetPt(&theCell, 0, i);
|
||||
|
||||
::LGetCell(itemStr+1, &strSize, theCell, mListHandle);
|
||||
if (strSize > sizeof(itemStr) - 1)
|
||||
strSize = sizeof(itemStr) - 1;
|
||||
itemStr[0] = strSize;
|
||||
|
||||
if (::EqualString(itemStr, searchStr, FALSE, FALSE))
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// CountItems - Get Item Count
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsListBox::GetItemCount()
|
||||
{
|
||||
if (! mListHandle)
|
||||
return 0;
|
||||
|
||||
return (*mListHandle)->dataBounds.bottom;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Removes an Item at a specified location
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsListBox::RemoveItemAt(PRInt32 aPosition)
|
||||
{
|
||||
if (! mListHandle)
|
||||
return PR_FALSE;
|
||||
|
||||
if (GetItemCount() < aPosition)
|
||||
return PR_FALSE;
|
||||
|
||||
StartDraw();
|
||||
::LDelRow(1, aPosition, mListHandle);
|
||||
::SetControlMaximum(mControl, GetItemCount());
|
||||
EndDraw();
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Removes an Item at a specified location
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsListBox::GetItemAt(nsString& anItem, PRInt32 aPosition)
|
||||
{
|
||||
anItem = "";
|
||||
|
||||
if (! mListHandle)
|
||||
return PR_FALSE;
|
||||
|
||||
if (GetItemCount() < aPosition)
|
||||
return PR_FALSE;
|
||||
|
||||
Str255 itemStr;
|
||||
short strSize = sizeof(itemStr) - 1;
|
||||
|
||||
Cell theCell;
|
||||
::SetPt(&theCell, 0, aPosition);
|
||||
|
||||
::LGetCell(itemStr+1, &strSize, theCell, mListHandle);
|
||||
if (strSize > sizeof(itemStr) - 1)
|
||||
strSize = sizeof(itemStr) - 1;
|
||||
itemStr[0] = strSize;
|
||||
Str255ToString(itemStr, anItem);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Gets the content of selected item
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsListBox::GetSelectedItem(nsString& aItem)
|
||||
{
|
||||
aItem = "";
|
||||
|
||||
if (! mListHandle)
|
||||
return PR_FALSE;
|
||||
|
||||
PRInt32 selectedIndex = GetSelectedIndex();
|
||||
if (selectedIndex < 0)
|
||||
return PR_FALSE;
|
||||
|
||||
GetItemAt(aItem, selectedIndex);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Gets the list of selected items
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsListBox::GetSelectedIndex()
|
||||
{
|
||||
if (! mListHandle)
|
||||
return -1;
|
||||
|
||||
Cell theCell;
|
||||
::SetPt(&theCell, 0, 0);
|
||||
|
||||
if (::LGetSelect(true, &theCell, mListHandle))
|
||||
return theCell.v;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Gets the count of selected items
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRInt32 nsListBox::GetSelectedCount()
|
||||
{
|
||||
if (! mListHandle)
|
||||
return 0;
|
||||
|
||||
PRInt32 itemCount = 0;
|
||||
Cell theCell;
|
||||
::SetPt(&theCell, 0, 0);
|
||||
while (::LGetSelect(true, &theCell, mListHandle))
|
||||
{
|
||||
itemCount ++;
|
||||
::LNextCell(true, true, &theCell, mListHandle);
|
||||
}
|
||||
return itemCount;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Gets the indices of selected items
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsListBox::GetSelectedIndices(PRInt32 aIndices[], PRInt32 aSize)
|
||||
{
|
||||
if (! mListHandle)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
PRInt32 itemCount = 0;
|
||||
Cell theCell;
|
||||
::SetPt(&theCell, 0, 0);
|
||||
while (::LGetSelect(true, &theCell, mListHandle) && (itemCount < aSize))
|
||||
{
|
||||
aIndices[itemCount] = theCell.v;
|
||||
itemCount ++;
|
||||
::LNextCell(true, true, &theCell, mListHandle);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Sets selected items
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsListBox::SetSelectedIndices(PRInt32 aIndices[], PRInt32 aSize)
|
||||
{
|
||||
if (! mListHandle)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
StartDraw();
|
||||
::LSetDrawingMode(false, mListHandle);
|
||||
for (PRInt32 i = 0; i < aSize; i ++)
|
||||
{
|
||||
Cell theCell;
|
||||
::SetPt(&theCell, 0, 1);
|
||||
::LSetSelect(true, theCell, mListHandle);
|
||||
}
|
||||
::LAutoScroll(mListHandle);
|
||||
::LSetDrawingMode(mVisible, mListHandle);
|
||||
EndDraw();
|
||||
|
||||
Invalidate(PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// SelectItem
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsListBox::SelectItem(PRInt32 aPosition)
|
||||
{
|
||||
if (! mListHandle)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
if (GetItemCount() < aPosition)
|
||||
return PR_FALSE;
|
||||
|
||||
if (! mMultiSelect)
|
||||
Deselect();
|
||||
|
||||
StartDraw();
|
||||
Cell theCell;
|
||||
::SetPt(&theCell, 0, aPosition);
|
||||
::LSetSelect(true, theCell, mListHandle);
|
||||
::LAutoScroll(mListHandle);
|
||||
EndDraw();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Deselect
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsListBox::Deselect()
|
||||
{
|
||||
if (! mListHandle)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
if (GetItemCount() == 0)
|
||||
return PR_FALSE;
|
||||
|
||||
StartDraw();
|
||||
::LSetDrawingMode(false, mListHandle);
|
||||
Cell theCell;
|
||||
::SetPt(&theCell, 0, 0);
|
||||
while (::LGetSelect(true, &theCell, mListHandle))
|
||||
{
|
||||
::LSetSelect(false, theCell, mListHandle);
|
||||
::LNextCell(true, true, &theCell, mListHandle);
|
||||
}
|
||||
::LSetDrawingMode(mVisible, mListHandle);
|
||||
EndDraw();
|
||||
|
||||
Invalidate(PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// DispatchMouseEvent
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsListBox::DispatchMouseEvent(nsMouseEvent &aEvent)
|
||||
{
|
||||
PRBool eventHandled = PR_FALSE;
|
||||
switch (aEvent.message)
|
||||
{
|
||||
case NS_MOUSE_LEFT_DOUBLECLICK:
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
eventHandled = Inherited::DispatchMouseEvent(aEvent);
|
||||
if (!eventHandled && mListHandle != NULL) {
|
||||
EventRecord* macEvent = (EventRecord*)aEvent.nativeMsg;
|
||||
|
||||
StartDraw();
|
||||
Point where = macEvent->where;
|
||||
::GlobalToLocal(&where);
|
||||
::HandleControlClick(mControl, where, macEvent->modifiers, NULL);
|
||||
// ::LClick(where, macEvent->modifiers, mListHandle);
|
||||
EndDraw();
|
||||
|
||||
ControlChanged(GetSelectedIndex());
|
||||
|
||||
// since the mouseUp event will be consumed by TrackControl,
|
||||
// simulate the mouse up event immediately.
|
||||
nsMouseEvent mouseUpEvent = aEvent;
|
||||
mouseUpEvent.message = NS_MOUSE_LEFT_BUTTON_UP;
|
||||
Inherited::DispatchMouseEvent(mouseUpEvent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return (Inherited::DispatchMouseEvent(aEvent));
|
||||
}
|
||||
|
||||
PRBool nsListBox::DispatchWindowEvent(nsGUIEvent& aEvent)
|
||||
{
|
||||
PRBool eventHandled = Inherited::DispatchWindowEvent(aEvent);
|
||||
if (!eventHandled && mListHandle != NULL) {
|
||||
if (aEvent.message == NS_KEY_DOWN) {
|
||||
EventRecord* macEvent = (EventRecord*)aEvent.nativeMsg;
|
||||
SInt16 keyCode = (macEvent->message & keyCodeMask) >> 8;
|
||||
SInt16 charCode = (macEvent->message & charCodeMask);
|
||||
StartDraw();
|
||||
::HandleControlKey(mControl, keyCode, charCode, macEvent->modifiers);
|
||||
nsKeyEvent* keyEvent = (nsKeyEvent*)&aEvent;
|
||||
switch (keyEvent->keyCode) {
|
||||
case NS_VK_UP:
|
||||
case NS_VK_DOWN:
|
||||
::LAutoScroll(mListHandle);
|
||||
break;
|
||||
}
|
||||
EndDraw();
|
||||
eventHandled = PR_TRUE;
|
||||
} else {
|
||||
switch (aEvent.message) {
|
||||
case NS_GOTFOCUS:
|
||||
case NS_LOSTFOCUS:
|
||||
StartDraw();
|
||||
::SetKeyboardFocus(mWindowPtr, mControl, (aEvent.message == NS_GOTFOCUS ? kControlFocusNextPart : kControlFocusNoPart));
|
||||
EndDraw();
|
||||
eventHandled = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return eventHandled;
|
||||
}
|
|
@ -24,15 +24,13 @@
|
|||
#include "nsCarbonHelpers.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Query interface implementation
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsLookAndFeel, kILookAndFeelIID);
|
||||
NS_IMPL_ISUPPORTS1(nsLookAndFeel, nsILookAndFeel);
|
||||
|
||||
nsLookAndFeel::nsLookAndFeel()
|
||||
{
|
||||
|
|
|
@ -156,8 +156,7 @@ static long ConvertOSMenuResultToPPMenuResult(long menuResult)
|
|||
|
||||
#pragma mark -
|
||||
|
||||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
//=================================================================
|
||||
/* Constructor
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
|
||||
// Define Class IDs -- i hate having to do this
|
||||
static NS_DEFINE_IID(kCDragServiceCID, NS_DRAGSERVICE_CID);
|
||||
static NS_DEFINE_CID(kCDragServiceCID, NS_DRAGSERVICE_CID);
|
||||
|
||||
|
||||
// from MacHeaders.c
|
||||
|
|
|
@ -64,54 +64,14 @@ extern Handle gMDEF; // Our stub MDEF
|
|||
extern Handle gSystemMDEFHandle;
|
||||
PRInt16 mMacMenuIDCount = kMacMenuID;
|
||||
|
||||
// IIDs
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIMenuIID, NS_IMENU_IID);
|
||||
static NS_DEFINE_IID(kIMenuBarIID, NS_IMENUBAR_IID);
|
||||
static NS_DEFINE_IID(kIMenuItemIID, NS_IMENUITEM_IID);
|
||||
static NS_DEFINE_IID(kIDocumentObserverIID, NS_IDOCUMENT_OBSERVER_IID);
|
||||
|
||||
|
||||
// CIDs
|
||||
#include "nsWidgetsCID.h"
|
||||
static NS_DEFINE_IID(kMenuBarCID, NS_MENUBAR_CID);
|
||||
static NS_DEFINE_IID(kMenuCID, NS_MENU_CID);
|
||||
static NS_DEFINE_IID(kMenuItemCID, NS_MENUITEM_CID);
|
||||
static NS_DEFINE_CID(kMenuBarCID, NS_MENUBAR_CID);
|
||||
static NS_DEFINE_CID(kMenuCID, NS_MENU_CID);
|
||||
static NS_DEFINE_CID(kMenuItemCID, NS_MENUITEM_CID);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsMenu::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if (aIID.Equals(kIMenuIID)) {
|
||||
*aInstancePtr = (void*)(nsIMenu*) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIMenuListenerIID)) {
|
||||
*aInstancePtr = (void*) ((nsIMenuListener*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDocumentObserverIID)) {
|
||||
*aInstancePtr = (void*) ((nsIDocumentObserver*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsMenu)
|
||||
NS_IMPL_RELEASE(nsMenu)
|
||||
NS_IMPL_ISUPPORTS3(nsMenu, nsIMenu, nsIMenuListener, nsIDocumentObserver)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -198,7 +158,7 @@ NS_METHOD nsMenu::Create(nsISupports *aParent, const nsString &aLabel)
|
|||
if(aParent)
|
||||
{
|
||||
nsIMenuBar * menubar = nsnull;
|
||||
aParent->QueryInterface(kIMenuBarIID, (void**) &menubar);
|
||||
aParent->QueryInterface(NS_GET_IID(nsIMenuBar), (void**) &menubar);
|
||||
if(menubar)
|
||||
{
|
||||
mMenuBarParent = menubar;
|
||||
|
@ -207,7 +167,7 @@ NS_METHOD nsMenu::Create(nsISupports *aParent, const nsString &aLabel)
|
|||
else
|
||||
{
|
||||
nsIMenu * menu = nsnull;
|
||||
aParent->QueryInterface(kIMenuIID, (void**) &menu);
|
||||
aParent->QueryInterface(NS_GET_IID(nsIMenu), (void**) &menu);
|
||||
{
|
||||
mMenuParent = menu;
|
||||
NS_RELEASE(menu); // Balance the QI
|
||||
|
@ -224,9 +184,9 @@ NS_METHOD nsMenu::GetParent(nsISupports*& aParent)
|
|||
|
||||
aParent = nsnull;
|
||||
if (nsnull != mMenuParent) {
|
||||
return mMenuParent->QueryInterface(kISupportsIID,(void**)&aParent);
|
||||
return mMenuParent->QueryInterface(NS_GET_IID(nsISupports),(void**)&aParent);
|
||||
} else if (nsnull != mMenuBarParent) {
|
||||
return mMenuBarParent->QueryInterface(kISupportsIID,(void**)&aParent);
|
||||
return mMenuBarParent->QueryInterface(NS_GET_IID(nsISupports),(void**)&aParent);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -319,7 +279,7 @@ NS_METHOD nsMenu::AddItem(nsISupports* aItem)
|
|||
{
|
||||
// Figure out what we're adding
|
||||
nsIMenuItem * menuitem = nsnull;
|
||||
aItem->QueryInterface(kIMenuItemIID, (void**) &menuitem);
|
||||
aItem->QueryInterface(NS_GET_IID(nsIMenuItem), (void**) &menuitem);
|
||||
if(menuitem)
|
||||
{
|
||||
// case menuitem
|
||||
|
@ -329,7 +289,7 @@ NS_METHOD nsMenu::AddItem(nsISupports* aItem)
|
|||
else
|
||||
{
|
||||
nsIMenu * menu = nsnull;
|
||||
aItem->QueryInterface(kIMenuIID, (void**) &menu);
|
||||
aItem->QueryInterface(NS_GET_IID(nsIMenu), (void**) &menu);
|
||||
if(menu)
|
||||
{
|
||||
// case menu
|
||||
|
@ -346,7 +306,7 @@ NS_METHOD nsMenu::AddMenuItem(nsIMenuItem * aMenuItem)
|
|||
{
|
||||
if(aMenuItem) {
|
||||
nsISupports * supports = nsnull;
|
||||
aMenuItem->QueryInterface(kISupportsIID, (void**)&supports);
|
||||
aMenuItem->QueryInterface(NS_GET_IID(nsISupports), (void**)&supports);
|
||||
if(supports) {
|
||||
mMenuItemVoidArray.AppendElement(supports);
|
||||
|
||||
|
@ -417,7 +377,7 @@ NS_METHOD nsMenu::AddMenu(nsIMenu * aMenu)
|
|||
// Add a submenu
|
||||
if(aMenu) {
|
||||
nsISupports * supports = nsnull;
|
||||
aMenu->QueryInterface(kISupportsIID, (void**)&supports);
|
||||
aMenu->QueryInterface(NS_GET_IID(nsISupports), (void**)&supports);
|
||||
if(supports) {
|
||||
mMenuItemVoidArray.AppendElement(supports);
|
||||
|
||||
|
@ -490,7 +450,7 @@ NS_METHOD nsMenu::RemoveAll()
|
|||
if(mMenuItemVoidArray[mMenuItemVoidArray.Count() - 1]) {
|
||||
// Figure out what we're releasing
|
||||
nsIMenuItem * menuitem = nsnull;
|
||||
((nsISupports*)mMenuItemVoidArray[mMenuItemVoidArray.Count() - 1])->QueryInterface(kIMenuItemIID, (void**) &menuitem);
|
||||
((nsISupports*)mMenuItemVoidArray[mMenuItemVoidArray.Count() - 1])->QueryInterface(NS_GET_IID(nsIMenuItem), (void**) &menuitem);
|
||||
if(menuitem)
|
||||
{
|
||||
// case menuitem
|
||||
|
@ -500,7 +460,7 @@ NS_METHOD nsMenu::RemoveAll()
|
|||
else
|
||||
{
|
||||
nsIMenu * menu = nsnull;
|
||||
((nsISupports*)mMenuItemVoidArray[mMenuItemVoidArray.Count() - 1])->QueryInterface(kIMenuIID, (void**) &menu);
|
||||
((nsISupports*)mMenuItemVoidArray[mMenuItemVoidArray.Count() - 1])->QueryInterface(NS_GET_IID(nsIMenu), (void**) &menu);
|
||||
if(menu)
|
||||
{
|
||||
// case menu
|
||||
|
@ -641,7 +601,7 @@ nsEventStatus nsMenu::MenuItemSelected(const nsMenuEvent & aMenuEvent)
|
|||
PRInt16 menuItemID = LoWord(((nsMenuEvent)aMenuEvent).mCommand);
|
||||
nsIMenuListener * menuListener = nsnull;
|
||||
if(mMenuItemVoidArray[menuItemID-1]) {
|
||||
((nsIMenuItem*)mMenuItemVoidArray[menuItemID-1])->QueryInterface(kIMenuListenerIID, &menuListener);
|
||||
((nsIMenuItem*)mMenuItemVoidArray[menuItemID-1])->QueryInterface(NS_GET_IID(nsIMenuListener), &menuListener);
|
||||
if(menuListener) {
|
||||
eventStatus = menuListener->MenuItemSelected(aMenuEvent);
|
||||
NS_IF_RELEASE(menuListener);
|
||||
|
@ -657,11 +617,11 @@ nsEventStatus nsMenu::MenuItemSelected(const nsMenuEvent & aMenuEvent)
|
|||
if(nsnull != mMenuItemVoidArray[i-1])
|
||||
{
|
||||
nsIMenu * submenu = nsnull;
|
||||
((nsISupports*)mMenuItemVoidArray[i-1])->QueryInterface(kIMenuIID, &submenu);
|
||||
((nsISupports*)mMenuItemVoidArray[i-1])->QueryInterface(NS_GET_IID(nsIMenu), &submenu);
|
||||
if(submenu)
|
||||
{
|
||||
nsIMenuListener * menuListener = nsnull;
|
||||
((nsISupports*)mMenuItemVoidArray[i-1])->QueryInterface(kIMenuListenerIID, &menuListener);
|
||||
((nsISupports*)mMenuItemVoidArray[i-1])->QueryInterface(NS_GET_IID(nsIMenuListener), &menuListener);
|
||||
if(menuListener){
|
||||
eventStatus = menuListener->MenuItemSelected(aMenuEvent);
|
||||
NS_IF_RELEASE(menuListener);
|
||||
|
@ -720,11 +680,11 @@ nsEventStatus nsMenu::MenuSelected(const nsMenuEvent & aMenuEvent)
|
|||
if(nsnull != mMenuItemVoidArray[i-1])
|
||||
{
|
||||
nsIMenu * submenu = nsnull;
|
||||
((nsISupports*)mMenuItemVoidArray[i-1])->QueryInterface(kIMenuIID, &submenu);
|
||||
((nsISupports*)mMenuItemVoidArray[i-1])->QueryInterface(NS_GET_IID(nsIMenu), &submenu);
|
||||
if(submenu)
|
||||
{
|
||||
nsIMenuListener * menuListener = nsnull;
|
||||
((nsISupports*)mMenuItemVoidArray[i-1])->QueryInterface(kIMenuListenerIID, &menuListener);
|
||||
((nsISupports*)mMenuItemVoidArray[i-1])->QueryInterface(NS_GET_IID(nsIMenuListener), &menuListener);
|
||||
if(menuListener){
|
||||
eventStatus = menuListener->MenuSelected(aMenuEvent);
|
||||
NS_IF_RELEASE(menuListener);
|
||||
|
@ -1033,8 +993,7 @@ NS_METHOD nsMenu::SetWebShell(nsIWebShell * aWebShell)
|
|||
if (!doc)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDocumentObserver> observer;
|
||||
QueryInterface(kIDocumentObserverIID, getter_AddRefs(observer));
|
||||
nsCOMPtr<nsIDocumentObserver> observer = do_QueryInterface(NS_STATIC_CAST(nsIMenu*, this));
|
||||
if(observer){
|
||||
doc->AddObserver(observer);
|
||||
}
|
||||
|
@ -1237,7 +1196,7 @@ void nsMenu::LoadMenuItem(
|
|||
menuitemElement->GetAttribute(nsAutoString("cmd"), menuitemCmd);
|
||||
// Create nsMenuItem
|
||||
nsIMenuItem * pnsMenuItem = nsnull;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kMenuItemCID, nsnull, kIMenuItemIID, (void**)&pnsMenuItem);
|
||||
nsresult rv = nsComponentManager::CreateInstance(kMenuItemCID, nsnull, NS_GET_IID(nsIMenuItem), (void**)&pnsMenuItem);
|
||||
if (NS_OK == rv) {
|
||||
pnsMenuItem->Create(pParentMenu, menuitemName, 0);
|
||||
//printf("menuitem %s \n", menuitemName.ToNewCString());
|
||||
|
@ -1346,7 +1305,7 @@ void nsMenu::LoadMenuItem(
|
|||
pnsMenuItem->SetCheckboxType(PR_FALSE);
|
||||
|
||||
nsISupports * supports = nsnull;
|
||||
pnsMenuItem->QueryInterface(kISupportsIID, (void**) &supports);
|
||||
pnsMenuItem->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
||||
pParentMenu->AddItem(supports); // Parent should now own menu item
|
||||
NS_RELEASE(supports);
|
||||
|
||||
|
@ -1367,11 +1326,11 @@ void nsMenu::LoadSubMenu(
|
|||
|
||||
// Create nsMenu
|
||||
nsIMenu * pnsMenu = nsnull;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, kIMenuIID, (void**)&pnsMenu);
|
||||
nsresult rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, NS_GET_IID(nsIMenu), (void**)&pnsMenu);
|
||||
if (NS_OK == rv) {
|
||||
// Call Create
|
||||
nsISupports * supports = nsnull;
|
||||
pParentMenu->QueryInterface(kISupportsIID, (void**) &supports);
|
||||
pParentMenu->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
||||
pnsMenu->Create(supports, menuName);
|
||||
NS_RELEASE(supports); // Balance QI
|
||||
|
||||
|
@ -1380,7 +1339,7 @@ void nsMenu::LoadSubMenu(
|
|||
|
||||
// Make nsMenu a child of parent nsMenu. The parent takes ownership
|
||||
supports = nsnull;
|
||||
pnsMenu->QueryInterface(kISupportsIID, (void**) &supports);
|
||||
pnsMenu->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
||||
pParentMenu->AddItem(supports);
|
||||
NS_RELEASE(supports);
|
||||
|
||||
|
|
|
@ -65,12 +65,6 @@ extern PRInt16 gCurrentMenuDepth;
|
|||
#include "nsMenu.h" // need to get APPLE_MENU_HACK macro
|
||||
// #endif
|
||||
|
||||
// IIDs
|
||||
static NS_DEFINE_IID(kIMenuBarIID, NS_IMENUBAR_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIMenuIID, NS_IMENU_IID);
|
||||
static NS_DEFINE_IID(kIMenuItemIID, NS_IMENUITEM_IID);
|
||||
|
||||
// CIDs
|
||||
#include "nsWidgetsCID.h"
|
||||
static NS_DEFINE_CID(kMenuBarCID, NS_MENUBAR_CID);
|
||||
|
@ -84,34 +78,7 @@ void InstallDefProc(
|
|||
Ptr dpAddr);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsMenuBar::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if (aIID.Equals(kIMenuBarIID)) {
|
||||
*aInstancePtr = (void*) ((nsIMenuBar*) this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*) ((nsISupports*)(nsIMenuBar*) this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIMenuListenerIID)) {
|
||||
*aInstancePtr = (void*) ((nsIMenuListener*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsMenuBar)
|
||||
NS_IMPL_RELEASE(nsMenuBar)
|
||||
NS_IMPL_ISUPPORTS2(nsMenuBar, nsIMenuBar, nsIMenuListener)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -128,7 +95,7 @@ nsEventStatus nsMenuBar::MenuItemSelected(const nsMenuEvent & aMenuEvent)
|
|||
for (int i = mMenuVoidArray.Count(); i > 0; --i)
|
||||
{
|
||||
nsIMenuListener * menuListener = nsnull;
|
||||
((nsISupports*)mMenuVoidArray[i-1])->QueryInterface(kIMenuListenerIID, &menuListener);
|
||||
((nsISupports*)mMenuVoidArray[i-1])->QueryInterface(NS_GET_IID(nsIMenuListener), &menuListener);
|
||||
if(menuListener){
|
||||
eventStatus = menuListener->MenuItemSelected(aMenuEvent);
|
||||
NS_RELEASE(menuListener);
|
||||
|
@ -146,10 +113,10 @@ nsEventStatus nsMenuBar::MenuSelected(const nsMenuEvent & aMenuEvent)
|
|||
nsEventStatus eventStatus = nsEventStatus_eIgnore;
|
||||
|
||||
nsIMenuListener * menuListener = nsnull;
|
||||
//((nsISupports*)mMenuVoidArray[i-1])->QueryInterface(kIMenuListenerIID, &menuListener);
|
||||
//((nsISupports*)mMenuVoidArray[i-1])->QueryInterface(NS_GET_IID(nsIMenuListener), &menuListener);
|
||||
//printf("gPreviousMenuStack.Count() = %d \n", gPreviousMenuStack.Count());
|
||||
if (gPreviousMenuStack[gPreviousMenuStack.Count() - 1])
|
||||
((nsIMenu*)gPreviousMenuStack[gPreviousMenuStack.Count() - 1])->QueryInterface(kIMenuListenerIID, &menuListener);
|
||||
((nsIMenu*)gPreviousMenuStack[gPreviousMenuStack.Count() - 1])->QueryInterface(NS_GET_IID(nsIMenuListener), &menuListener);
|
||||
|
||||
if (menuListener) {
|
||||
//TODO: MenuSelected is the right thing to call...
|
||||
|
@ -162,7 +129,7 @@ nsEventStatus nsMenuBar::MenuSelected(const nsMenuEvent & aMenuEvent)
|
|||
// If it's the help menu, gPreviousMenuStack won't be accurate so we need to get the listener a different way
|
||||
// We'll do it the old fashioned way of looping through and finding it
|
||||
for (int i = mMenuVoidArray.Count(); i > 0; --i) {
|
||||
((nsISupports*)mMenuVoidArray[i-1])->QueryInterface(kIMenuListenerIID, &menuListener);
|
||||
((nsISupports*)mMenuVoidArray[i-1])->QueryInterface(NS_GET_IID(nsIMenuListener), &menuListener);
|
||||
if (menuListener) {
|
||||
//TODO: MenuSelected is the right thing to call...
|
||||
//eventStatus = menuListener->MenuSelected(aMenuEvent);
|
||||
|
@ -259,14 +226,14 @@ nsEventStatus nsMenuBar::MenuConstruct(
|
|||
}
|
||||
|
||||
nsresult rv;
|
||||
//nsresult rv = nsComponentManager::CreateInstance(kMenuBarCID, nsnull, kIMenuBarIID, (void**)&pnsMenuBar);
|
||||
//nsresult rv = nsComponentManager::CreateInstance(kMenuBarCID, nsnull, NS_GET_IID(nsIMenuBar), (void**)&pnsMenuBar);
|
||||
//if (NS_OK == rv) {
|
||||
//if (nsnull != pnsMenuBar) {
|
||||
pnsMenuBar->Create(aParentWindow);
|
||||
|
||||
// set pnsMenuBar as a nsMenuListener on aParentWindow
|
||||
nsCOMPtr<nsIMenuListener> menuListener;
|
||||
pnsMenuBar->QueryInterface(kIMenuListenerIID, getter_AddRefs(menuListener));
|
||||
pnsMenuBar->QueryInterface(NS_GET_IID(nsIMenuListener), getter_AddRefs(menuListener));
|
||||
aParentWindow->AddMenuListener(menuListener);
|
||||
|
||||
//nsCOMPtr<nsIDOMNode> menuNode;
|
||||
|
@ -289,11 +256,11 @@ nsEventStatus nsMenuBar::MenuConstruct(
|
|||
|
||||
// Create nsMenu
|
||||
nsIMenu * pnsMenu = nsnull;
|
||||
rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, kIMenuIID, (void**)&pnsMenu);
|
||||
rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, NS_GET_IID(nsIMenu), (void**)&pnsMenu);
|
||||
if (NS_OK == rv) {
|
||||
// Call Create
|
||||
nsISupports * supports = nsnull;
|
||||
pnsMenuBar->QueryInterface(kISupportsIID, (void**) &supports);
|
||||
pnsMenuBar->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
||||
pnsMenu->Create(supports, menuName);
|
||||
NS_RELEASE(supports);
|
||||
|
||||
|
@ -444,7 +411,7 @@ NS_METHOD nsMenuBar::AddMenu(nsIMenu * aMenu)
|
|||
{
|
||||
// XXX add to internal data structure
|
||||
nsISupports * supports = nsnull;
|
||||
aMenu->QueryInterface(kISupportsIID, (void**)&supports);
|
||||
aMenu->QueryInterface(NS_GET_IID(nsISupports), (void**)&supports);
|
||||
if(supports){
|
||||
mMenuVoidArray.AppendElement( supports );
|
||||
}
|
||||
|
@ -494,7 +461,7 @@ NS_METHOD nsMenuBar::GetMenuAt(const PRUint32 aCount, nsIMenu *& aMenu)
|
|||
}
|
||||
|
||||
nsIMenu * menu = nsnull;
|
||||
supports->QueryInterface(kISupportsIID, (void**)&menu);
|
||||
supports->QueryInterface(NS_GET_IID(nsISupports), (void**)&menu);
|
||||
aMenu = menu;
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -34,41 +34,8 @@
|
|||
|
||||
#include "nsStringUtil.h"
|
||||
|
||||
static NS_DEFINE_IID(kIMenuIID, NS_IMENU_IID);
|
||||
static NS_DEFINE_IID(kIMenuBarIID, NS_IMENUBAR_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIPopUpMenuIID, NS_IPOPUPMENU_IID);
|
||||
static NS_DEFINE_IID(kIMenuItemIID, NS_IMENUITEM_IID);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsMenuItem::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if (aIID.Equals(kIMenuItemIID)) {
|
||||
*aInstancePtr = (void*)(nsIMenuItem*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*)(nsISupports*)(nsIMenuItem*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIMenuListenerIID)) {
|
||||
*aInstancePtr = (void*)(nsIMenuListener*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsMenuItem)
|
||||
NS_IMPL_RELEASE(nsMenuItem)
|
||||
NS_IMPL_ISUPPORTS2(nsMenuItem, nsIMenuItem, nsIMenuListener)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -168,7 +135,7 @@ nsIWidget * nsMenuItem::GetMenuBarParent(nsISupports * aParent)
|
|||
// Bump the ref count on the parent, since it gets released unconditionally..
|
||||
NS_ADDREF(parent);
|
||||
while (1) {
|
||||
if (NS_OK == parent->QueryInterface(kIMenuIID,(void**)&menu)) {
|
||||
if (NS_OK == parent->QueryInterface(NS_GET_IID(nsIMenu),(void**)&menu)) {
|
||||
NS_RELEASE(parent);
|
||||
if (NS_OK != menu->GetParent(parent)) {
|
||||
NS_RELEASE(menu);
|
||||
|
@ -176,7 +143,7 @@ nsIWidget * nsMenuItem::GetMenuBarParent(nsISupports * aParent)
|
|||
}
|
||||
NS_RELEASE(menu);
|
||||
|
||||
} else if (NS_OK == parent->QueryInterface(kIPopUpMenuIID,(void**)&popup)) {
|
||||
} else if (NS_OK == parent->QueryInterface(NS_GET_IID(nsIPopUpMenu),(void**)&popup)) {
|
||||
if (NS_OK != popup->GetParent(widget)) {
|
||||
widget = nsnull;
|
||||
}
|
||||
|
@ -184,7 +151,7 @@ nsIWidget * nsMenuItem::GetMenuBarParent(nsISupports * aParent)
|
|||
NS_RELEASE(popup);
|
||||
return widget;
|
||||
|
||||
} else if (NS_OK == parent->QueryInterface(kIMenuBarIID,(void**)&menuBar)) {
|
||||
} else if (NS_OK == parent->QueryInterface(NS_GET_IID(nsIMenuBar),(void**)&menuBar)) {
|
||||
if (NS_OK != menuBar->GetParent(widget)) {
|
||||
widget = nsnull;
|
||||
}
|
||||
|
|
|
@ -1,111 +0,0 @@
|
|||
/* -*- 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.1 (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.org 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsRadioButton.h"
|
||||
#if TARGET_CARBON
|
||||
#include <ControlDefinitions.h>
|
||||
#endif
|
||||
|
||||
NS_IMPL_ADDREF(nsRadioButton);
|
||||
NS_IMPL_RELEASE(nsRadioButton);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsRadioButton::nsRadioButton() : nsMacControl(), nsIRadioButton()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
gInstanceClassName = "nsRadioButton";
|
||||
SetControlType(radioButProc);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsRadioButton::~nsRadioButton()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsRadioButton::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIRadioButtonIID, NS_IRADIOBUTTON_IID);
|
||||
if (aIID.Equals(kIRadioButtonIID)) {
|
||||
*aInstancePtr = (void*) ((nsIRadioButton*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsWindow::QueryInterface(aIID,aInstancePtr);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsRadioButton::SetState(PRBool aState)
|
||||
{
|
||||
mValue = (aState ? 1 : 0);
|
||||
Invalidate(PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsRadioButton::GetState(PRBool& aState)
|
||||
{
|
||||
aState = (mValue != 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsRadioButton::SetLabel(const nsString& aText)
|
||||
{
|
||||
mLabel = aText;
|
||||
Invalidate(PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsRadioButton::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
aBuffer = mLabel;
|
||||
return NS_OK;
|
||||
}
|
|
@ -87,28 +87,9 @@ nsScrollbar::~nsScrollbar()
|
|||
{
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------------------------------
|
||||
* Implement the standard QueryInterface for NS_IWIDGET_IID and NS_ISUPPORTS_IID
|
||||
* @update dc 08/31/98
|
||||
* @param aIID The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*/
|
||||
nsresult nsScrollbar::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIScrollbarIID, NS_ISCROLLBAR_IID);
|
||||
if (aIID.Equals(kIScrollbarIID)) {
|
||||
*aInstancePtr = (void*) ((nsIScrollbar*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsWindow::QueryInterface(aIID,aInstancePtr);
|
||||
}
|
||||
NS_INTERFACE_MAP_BEGIN(nsScrollbar)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIScrollbar)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsWindow)
|
||||
|
||||
/**-------------------------------------------------------------------------------
|
||||
* ScrollActionProc Callback for TrackControl
|
||||
|
|
|
@ -145,25 +145,9 @@ nsTextAreaWidget::~nsTextAreaWidget()
|
|||
WEDispose(mTE_Data);
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------------------------------
|
||||
* Implement the standard QueryInterface for NS_IWIDGET_IID and NS_ISUPPORTS_IID
|
||||
* @update dc 08/31/98
|
||||
* @param aIID The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*/
|
||||
nsresult nsTextAreaWidget::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
static NS_DEFINE_IID(kITextAreaWidgetIID, NS_ITEXTAREAWIDGET_IID);
|
||||
|
||||
if (aIID.Equals(kITextAreaWidgetIID)) {
|
||||
AddRef();
|
||||
*aInstancePtr = (void**)(nsITextAreaWidget*)this;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsWindow::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
NS_INTERFACE_MAP_BEGIN(nsTextAreaWidget)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITextAreaWidget)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsWindow)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -134,20 +134,9 @@ nsTextWidget::Destroy()
|
|||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsTextWidget::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID);
|
||||
if (aIID.Equals(kITextWidgetIID)) {
|
||||
AddRef();
|
||||
*aInstancePtr = (void**)(nsITextWidget*)this;
|
||||
return NS_OK;
|
||||
}
|
||||
return Inherited::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
NS_INTERFACE_MAP_BEGIN(nsTextWidget)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITextWidget)
|
||||
NS_INTERFACE_MAP_END_INHERITING(Inherited)
|
||||
|
||||
#pragma mark -
|
||||
//-------------------------------------------------------------------------
|
||||
|
|
|
@ -31,13 +31,8 @@
|
|||
#include "nsIServiceManager.h"
|
||||
|
||||
// Class IDs...
|
||||
static NS_DEFINE_IID(kEventQueueCID, NS_EVENTQUEUE_CID);
|
||||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
|
||||
// Interface IDs...
|
||||
static NS_DEFINE_IID(kIEventQueueIID, NS_IEVENTQUEUE_IID);
|
||||
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
||||
static NS_DEFINE_CID(kEventQueueCID, NS_EVENTQUEUE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
|
||||
static nsMacNSPREventQueueHandler* gEventQueueHandler = nsnull;
|
||||
|
@ -110,8 +105,7 @@ void nsMacNSPREventQueueHandler::RepeatAction(const EventRecord& inMacEvent)
|
|||
|
||||
#pragma mark -
|
||||
|
||||
NS_DEFINE_IID(kIToolkitIID, NS_ITOOLKIT_IID);
|
||||
NS_IMPL_ISUPPORTS(nsToolkit,kIToolkitIID);
|
||||
NS_IMPL_ISUPPORTS1(nsToolkit, nsIToolkit);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -60,38 +60,35 @@
|
|||
// NOTE the following does not match MAC_STATIC actually used below in this file!
|
||||
#define MACSTATIC
|
||||
|
||||
static NS_DEFINE_IID(kCWindow, NS_WINDOW_CID);
|
||||
static NS_DEFINE_IID(kCPopUp, NS_POPUP_CID);
|
||||
static NS_DEFINE_IID(kCChild, NS_CHILD_CID);
|
||||
static NS_DEFINE_IID(kCButton, NS_BUTTON_CID);
|
||||
static NS_DEFINE_IID(kCCheckButton, NS_CHECKBUTTON_CID);
|
||||
static NS_DEFINE_IID(kCCombobox, NS_COMBOBOX_CID);
|
||||
static NS_DEFINE_IID(kCFileOpen, NS_FILEWIDGET_CID);
|
||||
static NS_DEFINE_IID(kCListbox, NS_LISTBOX_CID);
|
||||
static NS_DEFINE_IID(kCRadioButton, NS_RADIOBUTTON_CID);
|
||||
static NS_DEFINE_IID(kCHorzScrollbar, NS_HORZSCROLLBAR_CID);
|
||||
static NS_DEFINE_IID(kCVertScrollbar, NS_VERTSCROLLBAR_CID);
|
||||
static NS_DEFINE_IID(kCTextArea, NS_TEXTAREA_CID);
|
||||
static NS_DEFINE_IID(kCTextField, NS_TEXTFIELD_CID);
|
||||
static NS_DEFINE_IID(kCAppShell, NS_APPSHELL_CID);
|
||||
static NS_DEFINE_IID(kCToolkit, NS_TOOLKIT_CID);
|
||||
static NS_DEFINE_IID(kCLookAndFeel, NS_LOOKANDFEEL_CID);
|
||||
static NS_DEFINE_IID(kCLabel, NS_LABEL_CID);
|
||||
static NS_DEFINE_IID(kCMenuBar, NS_MENUBAR_CID);
|
||||
static NS_DEFINE_IID(kCMenu, NS_MENU_CID);
|
||||
static NS_DEFINE_IID(kCMenuItem, NS_MENUITEM_CID);
|
||||
static NS_DEFINE_IID(kCContextMenu, NS_CONTEXTMENU_CID);
|
||||
static NS_DEFINE_IID(kCPopUpMenu, NS_POPUPMENU_CID);
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_CID(kCWindow, NS_WINDOW_CID);
|
||||
static NS_DEFINE_CID(kCPopUp, NS_POPUP_CID);
|
||||
static NS_DEFINE_CID(kCChild, NS_CHILD_CID);
|
||||
static NS_DEFINE_CID(kCButton, NS_BUTTON_CID);
|
||||
static NS_DEFINE_CID(kCCheckButton, NS_CHECKBUTTON_CID);
|
||||
static NS_DEFINE_CID(kCCombobox, NS_COMBOBOX_CID);
|
||||
static NS_DEFINE_CID(kCFileOpen, NS_FILEWIDGET_CID);
|
||||
static NS_DEFINE_CID(kCListbox, NS_LISTBOX_CID);
|
||||
static NS_DEFINE_CID(kCRadioButton, NS_RADIOBUTTON_CID);
|
||||
static NS_DEFINE_CID(kCHorzScrollbar, NS_HORZSCROLLBAR_CID);
|
||||
static NS_DEFINE_CID(kCVertScrollbar, NS_VERTSCROLLBAR_CID);
|
||||
static NS_DEFINE_CID(kCTextArea, NS_TEXTAREA_CID);
|
||||
static NS_DEFINE_CID(kCTextField, NS_TEXTFIELD_CID);
|
||||
static NS_DEFINE_CID(kCAppShell, NS_APPSHELL_CID);
|
||||
static NS_DEFINE_CID(kCToolkit, NS_TOOLKIT_CID);
|
||||
static NS_DEFINE_CID(kCLookAndFeel, NS_LOOKANDFEEL_CID);
|
||||
static NS_DEFINE_CID(kCLabel, NS_LABEL_CID);
|
||||
static NS_DEFINE_CID(kCMenuBar, NS_MENUBAR_CID);
|
||||
static NS_DEFINE_CID(kCMenu, NS_MENU_CID);
|
||||
static NS_DEFINE_CID(kCMenuItem, NS_MENUITEM_CID);
|
||||
static NS_DEFINE_CID(kCContextMenu, NS_CONTEXTMENU_CID);
|
||||
static NS_DEFINE_CID(kCPopUpMenu, NS_POPUPMENU_CID);
|
||||
|
||||
// Drag and Drop/Clipboard
|
||||
static NS_DEFINE_IID(kCDataFlavor, NS_DATAFLAVOR_CID);
|
||||
static NS_DEFINE_IID(kCClipboard, NS_CLIPBOARD_CID);
|
||||
static NS_DEFINE_IID(kCTransferable, NS_TRANSFERABLE_CID);
|
||||
static NS_DEFINE_IID(kCXIFFormatConverter, NS_XIFFORMATCONVERTER_CID);
|
||||
static NS_DEFINE_IID(kCDragService, NS_DRAGSERVICE_CID);
|
||||
static NS_DEFINE_CID(kCDataFlavor, NS_DATAFLAVOR_CID);
|
||||
static NS_DEFINE_CID(kCClipboard, NS_CLIPBOARD_CID);
|
||||
static NS_DEFINE_CID(kCTransferable, NS_TRANSFERABLE_CID);
|
||||
static NS_DEFINE_CID(kCXIFFormatConverter, NS_XIFFORMATCONVERTER_CID);
|
||||
static NS_DEFINE_CID(kCDragService, NS_DRAGSERVICE_CID);
|
||||
|
||||
// Sound services (just Beep for now)
|
||||
static NS_DEFINE_CID(kCSound, NS_SOUND_CID);
|
||||
|
@ -139,30 +136,7 @@ nsWidgetFactory::~nsWidgetFactory()
|
|||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsWidgetFactory::QueryInterface(const nsIID &aIID,
|
||||
void **aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if (aIID.Equals(kIFactoryIID)) {
|
||||
*aInstancePtr = (void*)(nsWidgetFactory*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*)(nsISupports*)(nsWidgetFactory*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsWidgetFactory)
|
||||
NS_IMPL_RELEASE(nsWidgetFactory)
|
||||
NS_IMPL_ISUPPORTS1(nsWidgetFactory, nsIFactory)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -319,5 +293,5 @@ NSGetFactory(nsISupports* serviceMgr,
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory);
|
||||
return (*aFactory)->QueryInterface(NS_GET_IID(nsIFactory), (void**)aFactory);
|
||||
}
|
||||
|
|
|
@ -44,18 +44,6 @@
|
|||
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
||||
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
||||
static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID);
|
||||
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
|
||||
static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID);
|
||||
static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
|
||||
static NS_DEFINE_IID(kIRadioButtonIID, NS_IRADIOBUTTON_IID);
|
||||
static NS_DEFINE_IID(kILabelIID, NS_ILABEL_IID);
|
||||
static NS_DEFINE_IID(kIScrollBarIID, NS_ISCROLLBAR_IID);
|
||||
|
||||
|
||||
NS_WIDGET nsresult
|
||||
NS_CreateButton(nsISupports* aParent,
|
||||
nsIButton* aButton,
|
||||
|
@ -65,10 +53,10 @@ NS_CreateButton(nsISupports* aParent,
|
|||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
aParent->QueryInterface(NS_GET_IID(nsIWidget),(void**)&parent);
|
||||
|
||||
nsIWidget* widget;
|
||||
if (NS_OK == aButton->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
if (NS_OK == aButton->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
|
@ -90,10 +78,10 @@ NS_CreateCheckButton(nsISupports* aParent,
|
|||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
aParent->QueryInterface(NS_GET_IID(nsIWidget),(void**)&parent);
|
||||
|
||||
nsIWidget* widget;
|
||||
if (NS_OK == aCheckButton->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
if (NS_OK == aCheckButton->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
|
@ -117,10 +105,10 @@ NS_CreateRadioButton( nsISupports* aParent,
|
|||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
aParent->QueryInterface(NS_GET_IID(nsIWidget),(void**)&parent);
|
||||
|
||||
nsIWidget* widget;
|
||||
if (NS_OK == aRadioButton->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
if (NS_OK == aRadioButton->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
|
@ -141,10 +129,10 @@ NS_CreateLabel( nsISupports* aParent,
|
|||
const nsFont* aFont)
|
||||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (NS_OK == aParent->QueryInterface(kIWidgetIID,(void**)&parent))
|
||||
if (NS_OK == aParent->QueryInterface(NS_GET_IID(nsIWidget),(void**)&parent))
|
||||
{
|
||||
nsIWidget* widget;
|
||||
if (NS_OK == aLabel->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
if (NS_OK == aLabel->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
|
@ -167,10 +155,10 @@ NS_CreateTextAreaWidget(nsISupports* aParent,
|
|||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
aParent->QueryInterface(NS_GET_IID(nsIWidget),(void**)&parent);
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
if (NS_OK == aWidget->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
|
@ -179,7 +167,7 @@ NS_CreateTextAreaWidget(nsISupports* aParent,
|
|||
}
|
||||
else
|
||||
{
|
||||
NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object");
|
||||
NS_ERROR("Called QueryInterface on a non nsIWidget supported object");
|
||||
}
|
||||
|
||||
if (aParent)
|
||||
|
@ -197,10 +185,10 @@ NS_CreateTextWidget(nsISupports* aParent,
|
|||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
aParent->QueryInterface(NS_GET_IID(nsIWidget),(void**)&parent);
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
if (NS_OK == aWidget->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
|
@ -209,7 +197,7 @@ NS_CreateTextWidget(nsISupports* aParent,
|
|||
}
|
||||
else
|
||||
{
|
||||
NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object");
|
||||
NS_ERROR("Called QueryInterface on a non nsIWidget supported object");
|
||||
}
|
||||
|
||||
if (aParent)
|
||||
|
@ -228,17 +216,17 @@ NS_CreateScrollBar(nsISupports* aParent,
|
|||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
aParent->QueryInterface(NS_GET_IID(nsIWidget),(void**)&parent);
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
if (NS_OK == aWidget->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object");
|
||||
NS_ERROR("Called QueryInterface on a non nsIWidget supported object");
|
||||
}
|
||||
|
||||
if (aParent)
|
||||
|
@ -256,10 +244,10 @@ NS_CreateListBox(nsISupports* aParent,
|
|||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
aParent->QueryInterface(NS_GET_IID(nsIWidget),(void**)&parent);
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
if (NS_OK == aWidget->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
|
@ -268,7 +256,7 @@ NS_CreateListBox(nsISupports* aParent,
|
|||
}
|
||||
else
|
||||
{
|
||||
NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object");
|
||||
NS_ERROR("Called QueryInterface on a non nsIWidget supported object");
|
||||
}
|
||||
|
||||
if (aParent)
|
||||
|
@ -287,10 +275,10 @@ NS_CreateComboBox(nsISupports* aParent,
|
|||
{
|
||||
nsIWidget* parent = nsnull;
|
||||
if (aParent != nsnull)
|
||||
aParent->QueryInterface(kIWidgetIID,(void**)&parent);
|
||||
aParent->QueryInterface(NS_GET_IID(nsIWidget),(void**)&parent);
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
if (NS_OK == aWidget->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget)) {
|
||||
widget->Create(parent, aRect, aHandleEventFunction, NULL);
|
||||
widget->Show(PR_TRUE);
|
||||
if (aFont != nsnull)
|
||||
|
@ -299,7 +287,7 @@ NS_CreateComboBox(nsISupports* aParent,
|
|||
}
|
||||
else
|
||||
{
|
||||
NS_ERROR("Called QueryInterface on a non kIWidgetIID supported object");
|
||||
NS_ERROR("Called QueryInterface on a non nsIWidget supported object");
|
||||
}
|
||||
|
||||
if (aParent)
|
||||
|
@ -313,7 +301,7 @@ NS_ShowWidget(nsISupports* aWidget, PRBool aShow)
|
|||
{
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
if (NS_OK == aWidget->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget)) {
|
||||
widget->Show(aShow);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
|
@ -326,7 +314,7 @@ NS_MoveWidget(nsISupports* aWidget, PRUint32 aX, PRUint32 aY)
|
|||
{
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
if (NS_OK == aWidget->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget)) {
|
||||
widget->Move(aX,aY);
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
|
@ -338,7 +326,7 @@ NS_EnableWidget(nsISupports* aWidget, PRBool aEnable)
|
|||
{
|
||||
void* result = nsnull;
|
||||
nsIWidget* widget;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget))
|
||||
if (NS_OK == aWidget->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget))
|
||||
{
|
||||
widget->Enable(aEnable);
|
||||
NS_RELEASE(widget);
|
||||
|
@ -352,7 +340,7 @@ NS_SetFocusToWidget(nsISupports* aWidget)
|
|||
{
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget)) {
|
||||
if (NS_OK == aWidget->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget)) {
|
||||
widget->SetFocus();
|
||||
NS_IF_RELEASE(widget);
|
||||
}
|
||||
|
@ -365,7 +353,7 @@ NS_GetWidgetNativeData(nsISupports* aWidget, void** aNativeData)
|
|||
{
|
||||
void* result = nsnull;
|
||||
nsIWidget* widget;
|
||||
if (NS_OK == aWidget->QueryInterface(kIWidgetIID,(void**)&widget))
|
||||
if (NS_OK == aWidget->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget))
|
||||
{
|
||||
result = widget->GetNativeData(NS_NATIVE_WIDGET);
|
||||
NS_RELEASE(widget);
|
||||
|
|
|
@ -160,20 +160,10 @@ nsWindow::~nsWindow()
|
|||
|
||||
NS_IMPL_ADDREF(nsWindow);
|
||||
NS_IMPL_RELEASE(nsWindow);
|
||||
nsresult nsWindow::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if (aIID.Equals(nsIKBStateControl::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsIKBStateControl*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsBaseWidget::QueryInterface(aIID,aInstancePtr);
|
||||
}
|
||||
NS_INTERFACE_MAP_BEGIN(nsWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIKBStateControl)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsBaseWidget)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -34,35 +34,9 @@
|
|||
#undef NS_FILE_FAILURE
|
||||
#define NS_FILE_FAILURE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES,(0xFFFF))
|
||||
|
||||
NS_IMPL_ADDREF(nsFileSpecWithUIImpl)
|
||||
NS_IMPL_RELEASE(nsFileSpecWithUIImpl)
|
||||
NS_IMPL_ISUPPORTS2(nsFileSpecWithUIImpl, nsIFileSpecWithUI, nsIFileSpec)
|
||||
|
||||
NS_IMETHODIMP nsFileSpecWithUIImpl::QueryInterface(REFNSIID aIID,
|
||||
void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
static NS_DEFINE_IID(kClassIID, nsCOMTypeInfo<nsIFileSpecWithUI>::GetIID());
|
||||
if (aIID.Equals(kClassIID))
|
||||
*aInstancePtr = (void*) this;
|
||||
else if (aIID.Equals(nsCOMTypeInfo<nsIFileSpec>::GetIID()))
|
||||
*aInstancePtr = (void*) this;
|
||||
else if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID()))
|
||||
*aInstancePtr = (void*) ((nsISupports*)this);
|
||||
|
||||
if (*aInstancePtr)
|
||||
{
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
|
||||
static NS_DEFINE_CID(kCFileWidgetCID, NS_FILEWIDGET_CID);
|
||||
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
#include "nsPrimitiveHelpers.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID); // don't panic. NS_PARSER_IID just has the wrong name.
|
||||
static NS_DEFINE_CID(kCParserCID, NS_PARSER_IID); // don't panic. NS_PARSER_IID just has the wrong name.
|
||||
|
||||
NS_IMPL_ADDREF(nsXIFFormatConverter)
|
||||
NS_IMPL_RELEASE(nsXIFFormatConverter)
|
||||
|
|
Загрузка…
Ссылка в новой задаче