pjs/editor/base/editor.cpp

105 строки
2.5 KiB
C++
Исходник Обычный вид История

1998-11-11 06:34:37 +03:00
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "editor.h"
1998-11-12 03:15:58 +03:00
#include "nsIDOMEventReceiver.h"
1998-11-11 12:26:42 +03:00
//class implementations are in order they are declared in editor.h
Editor::Editor()
{
//initialize member variables here
1998-11-11 23:44:02 +03:00
}
1998-11-11 12:26:42 +03:00
Editor::~Editor()
{
//the autopointers will clear themselves up.
1998-11-11 23:44:02 +03:00
}
1998-11-11 12:26:42 +03:00
//BEGIN nsIEditor interface implementations
nsresult
Editor::Init(nsIDOMDocument *aDomInterface)
{
if (!aDomInterface)
return NS_ERROR_ILLEGAL_VALUE;
mDomInterfaceP = aDomInterface;
1998-11-12 03:15:58 +03:00
static NS_DEFINE_IID(kIDOMEventReceiverIID, NS_IDOMEVENTRECEIVER_IID);
static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID);
static NS_DEFINE_IID(kIDOMKeyListenerIID, NS_IDOMKEYLISTENER_IID);
1998-11-13 01:18:43 +03:00
nsresult t_result = NS_NewEditorKeyListener(func_AddRefs(mKeyListenerP), this);
1998-11-11 12:26:42 +03:00
if (NS_OK != t_result)
{
1998-11-12 03:15:58 +03:00
assert(0);
1998-11-11 12:26:42 +03:00
return t_result;
}
1998-11-13 01:18:43 +03:00
t_result = NS_NewEditorMouseListener(func_AddRefs(mMouseListenerP), this);
1998-11-11 12:26:42 +03:00
if (NS_OK != t_result)
{
1998-11-12 03:15:58 +03:00
mKeyListenerP = 0; //dont keep the key listener if the mouse listener fails.
assert(0);
1998-11-11 12:26:42 +03:00
return t_result;
}
COM_auto_ptr<nsIDOMEventReceiver> erP;
1998-11-13 01:18:43 +03:00
t_result = mDomInterfaceP->QueryInterface(kIDOMEventReceiverIID, func_AddRefs(erP));
1998-11-11 12:26:42 +03:00
if (NS_OK != t_result)
{
1998-11-12 03:15:58 +03:00
mKeyListenerP = 0;
mMouseListenerP = 0; //dont need these if we cant register them
assert(0);
1998-11-11 12:26:42 +03:00
return t_result;
}
1998-11-11 23:44:02 +03:00
erP->AddEventListener(mKeyListenerP, kIDOMKeyListenerIID);
erP->AddEventListener(mMouseListenerP, kIDOMMouseListenerIID);
1998-11-12 03:15:58 +03:00
return NS_OK;
1998-11-11 12:26:42 +03:00
}
//END nsIEditorInterfaces
//BEGIN Editor Calls from public
1998-11-11 23:44:02 +03:00
PRBool
1998-11-11 12:26:42 +03:00
Editor::KeyDown(int aKeycode)
{
1998-11-12 03:15:58 +03:00
return PR_TRUE;
1998-11-11 12:26:42 +03:00
}
1998-11-11 23:44:02 +03:00
PRBool
1998-11-11 12:26:42 +03:00
Editor::MouseClick(int aX,int aY)
{
1998-11-12 03:15:58 +03:00
return PR_FALSE;
1998-11-11 12:26:42 +03:00
}
//END Editor Calls from public
//BEGIN Editor Private methods
//END Editor Private methods