This commit is contained in:
buster%netscape.com 1999-02-12 17:49:19 +00:00
Родитель 36c243cdc0
Коммит f7598d9c91
4 изменённых файлов: 0 добавлений и 2226 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,242 +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.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://wwwt.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.
*/
#ifndef __editor_h__
#define __editor_h__
#include "prmon.h"
#include "nsIEditor.h"
#include "nsIContextLoader.h"
#include "nsIDOMDocument.h"
#include "nsIDOMEventListener.h"
#include "nsCOMPtr.h"
#include "editorInterfaces.h"
#include "nsITransactionManager.h"
#include "TransactionFactory.h"
#include "nsRepository.h"
//#include "nsISelection.h"
class nsIDOMCharacterData;
class nsIDOMRange;
class nsIPresShell;
class nsIViewManager;
class ChangeAttributeTxn;
class CreateElementTxn;
class DeleteElementTxn;
class InsertTextTxn;
class DeleteTextTxn;
class SplitElementTxn;
class JoinElementTxn;
class EditAggregateTxn;
//This is the monitor for the editor.
PRMonitor *getEditorMonitor();
/** implementation of an editor object. it will be the controler/focal point
* for the main editor services. i.e. the GUIManager, publishing, transaction
* manager, event interfaces. the idea for the event interfaces is to have them
* delegate the actual commands to the editor independent of the XPFE implementation.
*/
class nsEditor : public nsIEditor
{
private:
nsIPresShell *mPresShell;
nsIViewManager *mViewManager;
PRUint32 mUpdateCount;
nsCOMPtr<nsIDOMDocument> mDoc;
nsCOMPtr<nsIDOMEventListener> mKeyListenerP;
nsCOMPtr<nsIDOMEventListener> mMouseListenerP;
// nsCOMPtr<nsISelection> mSelectionP;
//nsCOMPtr<nsITransactionManager> mTxnMgrP;
nsITransactionManager * mTxnMgr;
friend PRBool NSCanUnload(void);
static PRInt32 gInstanceCount;
public:
/** The default constructor. This should suffice. the setting of the interfaces is done
* after the construction of the editor class.
*/
nsEditor();
/** The default destructor. This should suffice. Should this be pure virtual
* for someone to derive from the nsEditor later? I dont believe so.
*/
virtual ~nsEditor();
/*BEGIN nsIEdieditor for more details*/
/*interfaces for addref and release and queryinterface*/
NS_DECL_ISUPPORTS
virtual nsresult Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell);
virtual nsresult GetDocument(nsIDOMDocument **aDoc);
virtual nsresult SetProperties(Properties aProperties);
virtual nsresult GetProperties(Properties **aProperties);
virtual nsresult SetAttribute(nsIDOMElement * aElement,
const nsString& aAttribute,
const nsString& aValue);
virtual nsresult GetAttributeValue(nsIDOMElement * aElement,
const nsString& aAttribute,
nsString& aResultValue,
PRBool& aResultIsSet);
virtual nsresult RemoveAttribute(nsIDOMElement *aElement, const nsString& aAttribute);
virtual nsresult CreateElement(const nsString& aTag,
nsIDOMNode * aParent,
PRInt32 aPosition);
virtual nsresult DeleteElement(nsIDOMNode * aParent,
nsIDOMNode * aChild);
virtual nsresult DeleteSelection(nsIEditor::Direction aDir);
virtual nsresult InsertText(const nsString& aStringToInsert);
virtual nsresult SplitNode(nsIDOMNode * aExistingRightNode,
PRInt32 aOffset,
nsIDOMNode * aNewLeftNode,
nsIDOMNode * aParent);
virtual nsresult JoinNodes(nsIDOMNode * aNodeToKeep,
nsIDOMNode * aNodeToJoin,
nsIDOMNode * aParent,
PRBool aNodeToKeepIsFirst);
virtual nsresult Commit(PRBool aCtrlKey);
virtual nsresult EnableUndo(PRBool aEnable);
virtual nsresult Do(nsITransaction *aTxn);
virtual nsresult Undo(PRUint32 aCount);
virtual nsresult CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo);
virtual nsresult Redo(PRUint32 aCount);
virtual nsresult CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo);
virtual nsresult BeginUpdate();
virtual nsresult EndUpdate();
/*END nsIEditor interfaces*/
/*BEGIN private methods used by the implementations of the above functions*/
/** GetFirstTextNode ADDREFFS and will get the next available text node from the passed
* in node parameter it can also return NS_ERROR_FAILURE if no text nodes are available
* now it simply returns the first node in the dom
* @param nsIDOMNode *aNode is the node to start looking from
* @param nsIDOMNode **aRetNode is the return location of the text dom node
*
* NOTE: this method will probably be removed.
*/
nsresult GetFirstTextNode(nsIDOMNode *aNode, nsIDOMNode **aRetNode);
/** GetFirstNodeOfType ADDREFFS and will get the next available node from the passed
* in aStartNode parameter of type aTag.
* It can also return NS_ERROR_FAILURE if no such nodes are available
* @param nsIDOMNode *aStartNode is the node to start looking from
* @param nsIAtom *aTag is the type of node we are searching for
* @param nsIDOMNode **aResult is the node we found, or nsnull if there is none
*/
nsresult GetFirstNodeOfType(nsIDOMNode *aStartNode, const nsString &aTag, nsIDOMNode **aResult);
/*END private methods of nsEditor*/
protected:
virtual nsresult CreateTxnForSetAttribute(nsIDOMElement *aElement,
const nsString& aAttribute,
const nsString& aValue,
ChangeAttributeTxn ** aTxn);
virtual nsresult CreateTxnForRemoveAttribute(nsIDOMElement *aElement,
const nsString& aAttribute,
ChangeAttributeTxn ** aTxn);
virtual nsresult CreateTxnForCreateElement(const nsString& aTag,
nsIDOMNode *aParent,
PRInt32 aPosition,
CreateElementTxn ** aTxn);
virtual nsresult CreateTxnForDeleteElement(nsIDOMNode * aParent,
nsIDOMNode * aElement,
DeleteElementTxn ** aTxn);
virtual nsresult CreateTxnForInsertText(const nsString & aStringToInsert,
InsertTextTxn ** aTxn);
virtual nsresult DeleteText(nsIDOMCharacterData *aElement,
PRUint32 aOffset,
PRUint32 aLength);
virtual nsresult CreateTxnForDeleteText(nsIDOMCharacterData *aElement,
PRUint32 aOffset,
PRUint32 aLength,
DeleteTextTxn **aTxn);
virtual nsresult CreateTxnForDeleteSelection(nsIEditor::Direction aDir,
EditAggregateTxn ** aTxn);
virtual nsresult CreateTxnForDeleteInsertionPoint(nsIDOMRange *aRange,
nsIEditor::Direction aDir,
EditAggregateTxn *aTxn);
virtual nsresult CreateTxnForSplitNode(nsIDOMNode *aNode,
PRUint32 aOffset,
SplitElementTxn **aTxn);
virtual nsresult CreateTxnForJoinNode(nsIDOMNode *aLeftNode,
nsIDOMNode *aRightNode,
JoinElementTxn **aTxn);
#if 0
nsresult CreateTxnToHandleEnterKey(EditAggregateTxn **aTxn);
#endif
nsresult GetPriorNode(nsIDOMNode *aCurrentNode, nsIDOMNode **aResultNode);
nsresult GetNextNode(nsIDOMNode *aCurrentNode, nsIDOMNode **aResultNode);
nsresult GetRightmostChild(nsIDOMNode *aCurrentNode, nsIDOMNode **aResultNode);
nsresult GetLeftmostChild(nsIDOMNode *aCurrentNode, nsIDOMNode **aResultNode);
};
/*
factory method(s)
*/
nsresult NS_MakeEditorLoader(nsIContextLoader **aResult);
#endif

Просмотреть файл

@ -1,481 +0,0 @@
/* -*- Mode: C++; tab-width: 4; 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 "editorInterfaces.h"
#include "editor.h"
#include "CreateElementTxn.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMCharacterData.h"
#include "nsString.h"
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
static NS_DEFINE_IID(kIDOMCharacterDataIID, NS_IDOMCHARACTERDATA_IID);
/*
* nsEditorKeyListener implementation
*/
NS_IMPL_ADDREF(nsEditorKeyListener)
NS_IMPL_RELEASE(nsEditorKeyListener)
nsEditorKeyListener::nsEditorKeyListener()
{
NS_INIT_REFCNT();
}
nsEditorKeyListener::~nsEditorKeyListener()
{
}
nsresult
nsEditorKeyListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
static NS_DEFINE_IID(kIDOMKeyListenerIID, NS_IDOMKEYLISTENER_IID);
static NS_DEFINE_IID(kIDOMEventListenerIID, NS_IDOMEVENTLISTENER_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*)(nsISupports*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIDOMEventListenerIID)) {
*aInstancePtr = (void*)(nsIDOMEventListener*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIDOMKeyListenerIID)) {
*aInstancePtr = (void*)(nsIDOMKeyListener*)this;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
nsresult
nsEditorKeyListener::ProcessEvent(nsIDOMEvent* aEvent)
{
return NS_OK;
}
nsresult
nsEditorKeyListener::GetCharFromKeyCode(PRUint32 aKeyCode, PRBool aIsShift, char *aChar)
{
/* This is completely temporary to get this working while I check out Unicode conversion code. */
#ifdef XP_MAC
if (aChar) {
*aChar = (char)aKeyCode;
return NS_OK;
}
#else
if (aKeyCode >= 0x41 && aKeyCode <= 0x5A) {
if (aIsShift) {
*aChar = (char)aKeyCode;
}
else {
*aChar = (char)(aKeyCode + 0x20);
}
return NS_OK;
}
else if ((aKeyCode >= 0x30 && aKeyCode <= 0x39) || aKeyCode == 0x20) {
*aChar = (char)aKeyCode;
return NS_OK;
}
#endif
return NS_ERROR_FAILURE;
}
nsresult
nsEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
{
PRUint32 keyCode;
PRBool isShift;
PRBool ctrlKey;
char character;
if (NS_SUCCEEDED(aKeyEvent->GetKeyCode(&keyCode)) &&
NS_SUCCEEDED(aKeyEvent->GetShiftKey(&isShift)) &&
NS_SUCCEEDED(aKeyEvent->GetCtrlKey(&ctrlKey))
) {
PRBool keyProcessed;
ProcessShortCutKeys(aKeyEvent, keyProcessed);
if (PR_FALSE==keyProcessed)
{
switch(keyCode) {
case nsIDOMEvent::VK_BACK:
mEditor->DeleteSelection(nsIEditor::eRTL);
break;
case nsIDOMEvent::VK_DELETE:
mEditor->DeleteSelection(nsIEditor::eLTR);
break;
case nsIDOMEvent::VK_RETURN:
// Need to implement creation of either <P> or <BR> nodes.
mEditor->Commit(ctrlKey);
break;
default:
{
// XXX Replace with x-platform NS-virtkeycode transform.
if (NS_OK == GetCharFromKeyCode(keyCode, isShift, & character)) {
nsAutoString key;
key += character;
if (!isShift) {
key.ToLowerCase();
}
mEditor->InsertText(key);
}
}
break;
}
}
}
return NS_ERROR_BASE;
}
nsresult
nsEditorKeyListener::KeyUp(nsIDOMEvent* aKeyEvent)
{
return NS_OK;
}
nsresult
nsEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent)
{
return NS_OK;
}
/* these includes are for debug only. this module should never instantiate it's own transactions */
#include "SplitElementTxn.h"
#include "TransactionFactory.h"
static NS_DEFINE_IID(kSplitElementTxnIID, SPLIT_ELEMENT_TXN_IID);
nsresult
nsEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aProcessed)
{
aProcessed=PR_FALSE;
PRUint32 keyCode;
PRBool isShift;
PRBool ctrlKey;
if (NS_SUCCEEDED(aKeyEvent->GetKeyCode(&keyCode)) &&
NS_SUCCEEDED(aKeyEvent->GetShiftKey(&isShift)) &&
NS_SUCCEEDED(aKeyEvent->GetCtrlKey(&ctrlKey))
)
{
// XXX: please please please get these mappings from an external source!
switch (keyCode)
{
// XXX: hard-coded undo
case nsIDOMEvent::VK_Z:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
if (nsnull!=mEditor)
mEditor->Undo(1);
}
break;
// XXX: hard-coded redo
case nsIDOMEvent::VK_Y:
if (PR_TRUE==ctrlKey)
{
aProcessed=PR_TRUE;
if (nsnull!=mEditor)
mEditor->Redo(1);
}
break;
// hard-coded split node test: works on first <P> in the document
case nsIDOMEvent::VK_S:
if (PR_TRUE==ctrlKey)
{
nsAutoString pTag("P");
nsCOMPtr<nsIDOMNode> currentNode;
nsCOMPtr<nsIDOMElement> element;
if (NS_SUCCEEDED(mEditor->GetFirstNodeOfType(nsnull, pTag, getter_AddRefs(currentNode))))
{
nsresult result;
SplitElementTxn *txn;
if (PR_FALSE==isShift) // split the element so there are 0 children in the first half
{
result = TransactionFactory::GetNewTransaction(kSplitElementTxnIID, (EditTxn **)&txn);
if (txn)
txn->Init(mEditor, currentNode, -1);
}
else // split the element so there are 2 children in the first half
{
result = TransactionFactory::GetNewTransaction(kSplitElementTxnIID, (EditTxn **)&txn);
if (txn)
txn->Init(mEditor, currentNode, 1);
}
if (txn)
mEditor->Do(txn);
}
aProcessed=PR_TRUE;
}
break;
//XXX: test for change and remove attribute, hard-coded to be width on first table in doc
case nsIDOMEvent::VK_TAB:
{
//XXX: should be from a factory
//XXX: should manage the refcount of txn
nsAutoString attribute("width");
nsAutoString value("400");
nsAutoString tableTag("TABLE");
nsCOMPtr<nsIDOMNode> currentNode;
nsCOMPtr<nsIDOMElement> element;
if (NS_SUCCEEDED(mEditor->GetFirstNodeOfType(nsnull, tableTag, getter_AddRefs(currentNode))))
{
if (NS_SUCCEEDED(currentNode->QueryInterface(kIDOMElementIID, getter_AddRefs(element))))
{
nsresult result;
if (PR_TRUE==ctrlKey) // remove the attribute
result = mEditor->RemoveAttribute(element, attribute);
else // change the attribute
result = mEditor->SetAttribute(element, attribute, value);
}
}
}
aProcessed=PR_TRUE;
break;
case nsIDOMEvent::VK_INSERT:
{
nsresult result;
//XXX: should be from a factory
//XXX: should manage the refcount of txn
nsAutoString attribute("src");
nsAutoString value("resource:/res/samples/raptor.jpg");
nsAutoString imgTag("HR");
nsAutoString bodyTag("BODY");
nsCOMPtr<nsIDOMNode> currentNode;
result = mEditor->GetFirstNodeOfType(nsnull, bodyTag, getter_AddRefs(currentNode));
if (NS_SUCCEEDED(result))
{
PRInt32 position;
if (PR_TRUE==ctrlKey)
position=CreateElementTxn::eAppend;
else
position=0;
result = mEditor->CreateElement(imgTag, currentNode, position);
}
/*
//for building a composite transaction...
nsCOMPtr<nsIDOMElement> element;
if (NS_SUCCEEDED(mEditor->GetFirstNodeOfType(nsnull, imgTag, getter_AddRefs(currentNode))))
{
if (NS_SUCCEEDED(currentNode->QueryInterface(kIDOMElementIID, getter_AddRefs(element))))
{
ChangeAttributeTxn *txn;
txn = new ChangeAttributeTxn(mEditor, element, attribute, value, PR_FALSE);
mEditor->Do(txn);
}
}
*/
}
aProcessed=PR_TRUE;
break;
}
}
return NS_OK;
}
/*
* nsEditorMouseListener implementation
*/
NS_IMPL_ADDREF(nsEditorMouseListener)
NS_IMPL_RELEASE(nsEditorMouseListener)
nsEditorMouseListener::nsEditorMouseListener()
{
NS_INIT_REFCNT();
}
nsEditorMouseListener::~nsEditorMouseListener()
{
}
nsresult
nsEditorMouseListener::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID);
static NS_DEFINE_IID(kIDOMEventListenerIID, NS_IDOMEVENTLISTENER_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*)(nsISupports*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIDOMEventListenerIID)) {
*aInstancePtr = (void*)(nsIDOMEventListener*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIDOMMouseListenerIID)) {
*aInstancePtr = (void*)(nsIDOMMouseListener*)this;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
nsresult
nsEditorMouseListener::ProcessEvent(nsIDOMEvent* aEvent)
{
return NS_OK;
}
nsresult
nsEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
{
nsCOMPtr<nsIDOMNode> target;
if (NS_OK == aMouseEvent->GetTarget(getter_AddRefs(target))) {
// nsSetCurrentNode(aTarget);
}
//Should not be error. Need a new way to do return values
return NS_ERROR_BASE;
}
nsresult
nsEditorMouseListener::MouseUp(nsIDOMEvent* aMouseEvent)
{
return NS_OK;
}
nsresult
nsEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
{
return NS_OK;
}
nsresult
nsEditorMouseListener::MouseDblClick(nsIDOMEvent* aMouseEvent)
{
return NS_OK;
}
nsresult
nsEditorMouseListener::MouseOver(nsIDOMEvent* aMouseEvent)
{
return NS_OK;
}
nsresult
nsEditorMouseListener::MouseOut(nsIDOMEvent* aMouseEvent)
{
return NS_OK;
}
/*
* Factory functions
*/
nsresult
NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult, nsEditor *aEditor)
{
nsEditorKeyListener* it = new nsEditorKeyListener();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
it->SetEditor(aEditor);
static NS_DEFINE_IID(kIDOMEventListenerIID, NS_IDOMEVENTLISTENER_IID);
return it->QueryInterface(kIDOMEventListenerIID, (void **) aInstancePtrResult);
}
nsresult
NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult, nsEditor *aEditor)
{
nsEditorMouseListener* it = new nsEditorMouseListener();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
it->SetEditor(aEditor);
static NS_DEFINE_IID(kIDOMEventListenerIID, NS_IDOMEVENTLISTENER_IID);
return it->QueryInterface(kIDOMEventListenerIID, (void **) aInstancePtrResult);
}

Просмотреть файл

@ -1,120 +0,0 @@
/* -*- Mode: C++; tab-width: 4; 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.
*/
#ifndef editorInterfaces_h__
#define editorInterfaces_h__
#include "nsIDOMEvent.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMMouseListener.h"
//prototype for the nsEditor class that will be included in the .cpp file
class nsEditor;
//nsIDOMKeyListener interface
/** The nsEditorKeyListener public nsIDOMKeyListener
* This class will delegate events to its editor according to the translation
* it is responsible for. i.e. 'c' becomes a keydown, but 'ESC' becomes nothing.
* This should be done through contexts that are loaded from URLs
*/
class nsEditorKeyListener : public nsIDOMKeyListener {
nsEditor *mEditor;
public:
/** the default constructor
*/
nsEditorKeyListener();
/** the default destructor. virtual due to the possibility of derivation.
*/
virtual ~nsEditorKeyListener();
/** SetEditor gives an address to the editor that will be accessed
* @param nsEditor *aEditor simple
*/
void SetEditor(nsEditor *aEditor){mEditor = aEditor;}
/** GetEditor returns a copy of the address the keylistener has
* @return copy of the editor address
*/
nsEditor *GetEditor(){ return mEditor; }
/*interfaces for addref and release and queryinterface*/
NS_DECL_ISUPPORTS
/*BEGIN interfaces in to the keylister base interface. must be supplied to handle pure virtual interfaces
see the nsIDOMKeyListener interface implementation for details
*/
virtual nsresult ProcessEvent(nsIDOMEvent* aEvent);
virtual nsresult KeyDown(nsIDOMEvent* aKeyEvent);
virtual nsresult KeyUp(nsIDOMEvent* aKeyEvent);
virtual nsresult KeyPress(nsIDOMEvent* aKeyEvent);
/*END interfaces from nsIDOMKeyListener*/
private:
virtual nsresult GetCharFromKeyCode(PRUint32 aKeyCode, PRBool aIsShift, char *aChar);
virtual nsresult ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aProcessed);
};
/** editor Implementation of the MouseListener interface
* nsIDOMMouseListener interface
*/
class nsEditorMouseListener : public nsIDOMMouseListener
{
nsEditor *mEditor;
public:
/** default constructor
*/
nsEditorMouseListener();
/** default destructor
*/
virtual ~nsEditorMouseListener();
/** SetEditor gives an address to the editor that will be accessed
* @param nsEditor *aEditor simple
*/
void SetEditor(nsEditor *aEditor){mEditor = aEditor;}
/** GetEditor returns a copy of the address the keylistener has
* @return copy of the editor address
*/
nsEditor *GetEditor(){ return mEditor; }
/*interfaces for addref and release and queryinterface*/
NS_DECL_ISUPPORTS
/*BEGIN implementations of mouseevent handler interface*/
virtual nsresult ProcessEvent(nsIDOMEvent* aEvent);
public:
virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent);
virtual nsresult MouseUp(nsIDOMEvent* aMouseEvent);
virtual nsresult MouseClick(nsIDOMEvent* aMouseEvent);
virtual nsresult MouseDblClick(nsIDOMEvent* aMouseEvent);
virtual nsresult MouseOver(nsIDOMEvent* aMouseEvent);
virtual nsresult MouseOut(nsIDOMEvent* aMouseEvent);
/*END implementations of mouseevent handler interface*/
};
/** factory for the editor key listener
*/
extern nsresult NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult, nsEditor *aEditor);
/** factory for the editor mouse listener
*/
extern nsresult NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult, nsEditor *aEditor);
#endif //editorInterfaces_h__