removing per bug 110851, replaced with nsIEventSink on each window. r=ccarlen/sr=sfraser.

This commit is contained in:
pinkerton%netscape.com 2001-11-29 14:43:45 +00:00
parent b2ede84bf3
commit 7d257e40f5
2 changed files with 0 additions and 251 deletions

View File

@ -1,155 +0,0 @@
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsMacMessageSink.h"
#include "nsMacWindow.h"
//-------------------------------------------------------------------------
//
// DispatchOSEvent
//
// Return PR_TRUE if the event was handled
//
//-------------------------------------------------------------------------
PRBool nsMacMessageSink::DispatchOSEvent(
EventRecord &anEvent,
WindowPtr aWindow)
{
PRBool eventHandled = PR_FALSE;
nsMacWindow* raptorWindow = GetNSWindowFromMacWindow(aWindow);
// prevent the window being deleted while we're in its methods
nsCOMPtr<nsIWidget> kungFuDeathGrip(NS_STATIC_CAST(nsIWidget*, raptorWindow));
if (raptorWindow)
{
eventHandled = raptorWindow->HandleOSEvent(anEvent);
}
return eventHandled;
}
//-------------------------------------------------------------------------
//
// DispatchMenuCommand
//
//-------------------------------------------------------------------------
PRBool nsMacMessageSink::DispatchMenuCommand(
EventRecord &anEvent,
long menuResult,
WindowPtr aWindow)
{
PRBool eventHandled = PR_FALSE;
#if USE_MENUSELECT
nsMacWindow* raptorWindow = GetNSWindowFromMacWindow(aWindow);
// prevent the window being deleted while we're in its methods
nsCOMPtr<nsIWidget> kungFuDeathGrip(NS_STATIC_CAST(nsIWidget*, raptorWindow));
if (raptorWindow)
{
eventHandled = raptorWindow->HandleMenuCommand(anEvent, menuResult);
}
#endif
return eventHandled;
}
#pragma mark -
//-------------------------------------------------------------------------
//
// GetNSWindowFromWindow
//
//-------------------------------------------------------------------------
nsMacWindow *nsMacMessageSink::GetNSWindowFromMacWindow(WindowPtr inWindow)
{
if (!inWindow) return nsnull;
nsMacWindow *foundMacWindow = GetRaptorWindowList()[inWindow];
return foundMacWindow;
}
//-------------------------------------------------------------------------
//
// GetRaptorWindowList
//
//-------------------------------------------------------------------------
/* static */nsMacMessageSink::TWindowMap& nsMacMessageSink::GetRaptorWindowList()
{
static TWindowMap sRaptorWindowList;
return sRaptorWindowList;
}
//-------------------------------------------------------------------------
//
// IsRaptorWindow
//
//-------------------------------------------------------------------------
PRBool nsMacMessageSink::IsRaptorWindow(WindowPtr inWindow)
{
if (!inWindow) return PR_FALSE;
return (GetRaptorWindowList()[inWindow] != nsnull);
}
//-------------------------------------------------------------------------
//
// AddRaptorWindowToList
//
//-------------------------------------------------------------------------
/* static */ void nsMacMessageSink::AddRaptorWindowToList(WindowPtr wind, nsMacWindow* theRaptorWindow)
{
TWindowMap& windowList = GetRaptorWindowList();
windowList[wind] = theRaptorWindow;
}
//-------------------------------------------------------------------------
//
// RemoveRaptorWindowFromList
//
//-------------------------------------------------------------------------
/* static */ void nsMacMessageSink::RemoveRaptorWindowFromList(WindowPtr wind)
{
TWindowMap& windowList = GetRaptorWindowList();
windowList.erase(wind);
}

View File

@ -1,96 +0,0 @@
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsMacMessageSink_h__
#define nsMacMessageSink_h__
#include "prtypes.h"
#include "nscore.h"
#include <map>
using std::map;
#include <Events.h>
#include <MacWindows.h>
class nsMacWindow;
/*================================================
¥¥¥IMPORTANT
This class should be COM'd and made XP somehow
Right now it is just a normal class as the first step of breaking
it out from the "client" code. It's goal is to be the point of contact between
client code (say, the viewer) and the embedded webshell for event dispatching. From
here, it goes to the appropriate window, however that may be done (and that still
needs to be figured out).
(pinkerton)
This class now has an added responsibility, which
is to maintain a list of raptor windows. This is
stored as an STL map, which maps from a WindowPtr
to a nsMacWindow *.
================================================*/
// Macintosh Message Sink Class
class NS_WIDGET nsMacMessageSink
{
private:
typedef map<WindowPtr, nsMacWindow*> TWindowMap;
public:
PRBool DispatchOSEvent(EventRecord &anEvent, WindowPtr aWindow);
PRBool DispatchMenuCommand(EventRecord &anEvent, long menuResult, WindowPtr aWindow);
static void AddRaptorWindowToList(WindowPtr wind, nsMacWindow* theRaptorWindow);
static void RemoveRaptorWindowFromList(WindowPtr wind);
static nsMacWindow* GetNSWindowFromMacWindow(WindowPtr wind);
PRBool IsRaptorWindow(WindowPtr inWindow);
protected:
static TWindowMap& GetRaptorWindowList();
};
#endif // nsMacMessageSink_h__