From 091a6a14b8792905af4a6d5aa34db0158b33f3f5 Mon Sep 17 00:00:00 2001 From: "mjudge%netscape.com" Date: Wed, 11 Nov 1998 03:34:37 +0000 Subject: [PATCH] moving editor core to "core" --- editor/base/Makefile | 39 +++++ editor/base/Makefile.in | 86 +++++++++++ editor/base/editor.cpp | 20 +++ editor/base/editor.h | 64 ++++++++ editor/base/makefile.win | 65 ++++++++ editor/base/nsEditorInterfaces.cpp | 240 +++++++++++++++++++++++++++++ editor/core/Makefile | 39 +++++ editor/core/Makefile.in | 86 +++++++++++ editor/core/editor.cpp | 20 +++ editor/core/editor.h | 64 ++++++++ editor/core/makefile.win | 65 ++++++++ editor/core/nsEditorInterfaces.cpp | 240 +++++++++++++++++++++++++++++ 12 files changed, 1028 insertions(+) create mode 100644 editor/base/Makefile create mode 100644 editor/base/Makefile.in create mode 100644 editor/base/editor.cpp create mode 100644 editor/base/editor.h create mode 100644 editor/base/makefile.win create mode 100644 editor/base/nsEditorInterfaces.cpp create mode 100644 editor/core/Makefile create mode 100644 editor/core/Makefile.in create mode 100644 editor/core/editor.cpp create mode 100644 editor/core/editor.h create mode 100644 editor/core/makefile.win create mode 100644 editor/core/nsEditorInterfaces.cpp diff --git a/editor/base/Makefile b/editor/base/Makefile new file mode 100644 index 000000000000..6f4385b1c1c4 --- /dev/null +++ b/editor/base/Makefile @@ -0,0 +1,39 @@ +#!gmake +# +# 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. + +DEPTH=../.. + + +LIBRARY_NAME = ender + +CPPSRCS = \ + editor.cpp \ + $(NULL) + + +MODULE = raptor + +REQUIRES = xpcom raptor + +include $(DEPTH)/config/config.mk + +TARGET = $(LIBARY) + +include $(DEPTH)/config/rules.mk + +test: + @echo OS_ARCH = $(OS_ARCH) \ No newline at end of file diff --git a/editor/base/Makefile.in b/editor/base/Makefile.in new file mode 100644 index 000000000000..3c4168bc4777 --- /dev/null +++ b/editor/base/Makefile.in @@ -0,0 +1,86 @@ +#!gmake +# +# 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. + +DEPTH=../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +DEFINES =-D_IMPL_NS_BASE + +ifeq ($(OS_TARGET),Rhapsody) +DIRS = rhapsody +else +DIRS = unix +endif + +LIBRARY_NAME = raptorbase + +CPPSRCS = \ + nsArena.cpp \ + nsAtomTable.cpp \ + nsBTree.cpp \ + nsByteBuffer.cpp \ + nsCRT.cpp \ + nsDeque.cpp \ + nsRBTree.cpp \ + nsSizeOfHandler.cpp \ + nsString.cpp \ + nsUnicharBuffer.cpp \ + nsUnicharInputStream.cpp \ + nsVoidArray.cpp \ + $(NULL) + +EXPORTS = \ + nscore.h \ + nsBTree.h \ + nsCRT.h \ + nsDeque.h \ + nsIArena.h \ + nsIAtom.h \ + nsIByteBuffer.h \ + nsIBaseStream.h \ + nsIInputStream.h \ + nsIOutputStream.h \ + nsITimer.h \ + nsITimerCallback.h \ + nsIUnicharBuffer.h \ + nsIUnicharInputStream.h \ + nsInt64.h \ + nsRBTree.h \ + nsString.h \ + nsTime.h \ + nsVoidArray.h \ + nsUnitConversion.h \ + $(NULL) + +EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) + +MODULE = raptor + +REQUIRES = xpcom netlib raptor + +include $(topsrcdir)/config/config.mk + +TARGET = $(LIBARY) + +include $(topsrcdir)/config/rules.mk + +test: + @echo OS_ARCH = $(OS_ARCH) diff --git a/editor/base/editor.cpp b/editor/base/editor.cpp new file mode 100644 index 000000000000..92144183e1d1 --- /dev/null +++ b/editor/base/editor.cpp @@ -0,0 +1,20 @@ +/* -*- 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" diff --git a/editor/base/editor.h b/editor/base/editor.h new file mode 100644 index 000000000000..8b03ed2eecbf --- /dev/null +++ b/editor/base/editor.h @@ -0,0 +1,64 @@ +/* -*- 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. + */ + +#include "nsIEditor.h" +#include "COM_auto_ptr.h" + + +/*implementation of an editor object. it ALSO supplies an nsIEditor Interface*/ + +class Editor : public nsIEditor +{ +private: + COM_auto_ptr mDomInterfaceP; +public: +/*nsIEditorInterfaces*/ + virtual nsresult Init(); + virtual nsresult Init() = 0; + +/*BEGIN interface manipulators and accessors*/ + + /*SetDomInterface accepts an interface to a nsIDOMDocument and it will add a reference to it + since it will keep it for some time*/ + virtual nsresult SetDomInterface(nsIDOMDocument *aDomInterface){mDomInterfaceP = aDomInterface} + + /*GetDomInterface returns a "look" at the dom interface. it will NOT ADD A REFERENCE!!!!!.*/ + virtual nsresult GetDomInterface(nsIDOMDocument **aDomInterface){*aDomInterface = mDomInterfaceP;} +/*END interface manipulators*/ + + virtual nsresult SetProperties(PROPERTIES aProperty){} + virtual nsresult GetProperties(PROPERTIES &){} + +/*EditorInterfaces*/ + Editor(); + ~Editor(); + +/*KeyListener Methods*/ + + /*KeyDown :accepts a keycode + :returns False if ignored*/ + PR_Bool KeyDown(int keycode); + +/*MouseListener Methods*/ + + /* Mouse Click accepts an x and + a y for location in the webshell*/ + PR_Bool MouseClick(int x,int y); //it should also tell us the dom element that was selected. +}; + + diff --git a/editor/base/makefile.win b/editor/base/makefile.win new file mode 100644 index 000000000000..797745294d68 --- /dev/null +++ b/editor/base/makefile.win @@ -0,0 +1,65 @@ +#!nmake +# +# 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. + +DEPTH=..\.. +IGNORE_MANIFEST=1 + +LIBRARY_NAME=ender + +CPPSRCS = \ + editor.cpp \ + $(NULL) + +CPP_OBJS = \ + .\$(OBJDIR)\editor.obj \ + $(NULL) + +MODULE=raptor + +REQUIRES=xpcom raptor + +LINCS=-I$(PUBLIC)\xpcom \ + -I$(PUBLIC)\raptor + +MAKE_OBJ_TYPE = DLL +DLLNAME = ender +DLL=.\$(OBJDIR)\$(DLLNAME).dll + +LCFLAGS = \ + $(LCFLAGS) \ + $(DEFINES) \ + $(NULL) + +# These are the libraries we need to link with to create the dll +LLIBS= \ + $(DIST)\lib\xpcom32.lib \ + $(DIST)\lib\libplc21.lib \ + $(LIBNSPR) +!if "$(MOZ_BITS)"=="32" && defined(MOZ_DEBUG) && defined(GLOWCODE) +LLIBS=$(LLIBS) $(GLOWDIR)\glowcode.lib +!endif + + +include <$(DEPTH)\config\rules.mak> + +libs:: $(DLL) + $(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin + $(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib + +clobber:: + rm -f $(DIST)\bin\$(DLLNAME).dll + rm -f $(DIST)\lib\$(DLLNAME).lib diff --git a/editor/base/nsEditorInterfaces.cpp b/editor/base/nsEditorInterfaces.cpp new file mode 100644 index 000000000000..aa10578cec58 --- /dev/null +++ b/editor/base/nsEditorInterfaces.cpp @@ -0,0 +1,240 @@ +/* -*- 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 "nsEditorInterfaces.h" +#include "nsEditorMode.h" +#include "nsString.h" + +/* + * nsEditorKeyListener implementation + */ + +nsEditorKeyListener::nsEditorKeyListener() +{ +} + +nsEditorKeyListener::~nsEditorKeyListener() +{ +} + +nsresult nsEditorKeyListener::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (NULL == 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; +} + +NS_IMPL_ADDREF(nsEditorKeyListener) + +NS_IMPL_RELEASE(nsEditorKeyListener) + +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. */ + 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; + } + return NS_ERROR_FAILURE; +} + +nsresult nsEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent) +{ + PRUint32 mKeyCode; + PRBool mIsShift; + char mChar; + + if (NS_OK == aKeyEvent->GetKeyCode(&mKeyCode) && + NS_OK == aKeyEvent->GetShiftKey(&mIsShift)) { + switch(mKeyCode) { + case nsIDOMEvent::VK_BACK: + nsDeleteLast(); + break; + case nsIDOMEvent::VK_RETURN: + // Need to implement creation of either

or
nodes. + break; + default: + // XXX Replace with x-platform NS-virtkeycode transform. + if (NS_OK == GetCharFromKeyCode(mKeyCode, mIsShift, &mChar)) { + nsString* key = new nsString(); + *key += mChar; + if (!mIsShift) { + key->ToLowerCase(); + } + nsAppendText(key); + } + break; + } + } + + return NS_ERROR_BASE; +} + +nsresult nsEditorKeyListener::KeyUp(nsIDOMEvent* aKeyEvent) +{ + return NS_OK; +} + +nsresult nsEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) +{ + return NS_OK; +} + +/* + * nsEditorMouseListener implementation + */ + +nsEditorMouseListener::nsEditorMouseListener() +{ +} + +nsEditorMouseListener::~nsEditorMouseListener() +{ +} + +nsresult nsEditorMouseListener::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (NULL == 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; +} + +NS_IMPL_ADDREF(nsEditorMouseListener) + +NS_IMPL_RELEASE(nsEditorMouseListener) + +nsresult nsEditorMouseListener::ProcessEvent(nsIDOMEvent* aEvent) +{ + return NS_OK; +} + +nsresult nsEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent) +{ + nsIDOMNode *aTarget; + if (NS_OK == aMouseEvent->GetTarget(&aTarget)) { + nsSetCurrentNode(aTarget); + NS_RELEASE(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) +{ + nsEditorKeyListener* it = new nsEditorKeyListener(); + if (NULL == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + + static NS_DEFINE_IID(kIDOMEventListenerIID, NS_IDOMEVENTLISTENER_IID); + + return it->QueryInterface(kIDOMEventListenerIID, (void **) aInstancePtrResult); +} + +nsresult NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult) +{ + nsEditorMouseListener* it = new nsEditorMouseListener(); + if (NULL == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + + static NS_DEFINE_IID(kIDOMEventListenerIID, NS_IDOMEVENTLISTENER_IID); + + return it->QueryInterface(kIDOMEventListenerIID, (void **) aInstancePtrResult); +} + diff --git a/editor/core/Makefile b/editor/core/Makefile new file mode 100644 index 000000000000..6f4385b1c1c4 --- /dev/null +++ b/editor/core/Makefile @@ -0,0 +1,39 @@ +#!gmake +# +# 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. + +DEPTH=../.. + + +LIBRARY_NAME = ender + +CPPSRCS = \ + editor.cpp \ + $(NULL) + + +MODULE = raptor + +REQUIRES = xpcom raptor + +include $(DEPTH)/config/config.mk + +TARGET = $(LIBARY) + +include $(DEPTH)/config/rules.mk + +test: + @echo OS_ARCH = $(OS_ARCH) \ No newline at end of file diff --git a/editor/core/Makefile.in b/editor/core/Makefile.in new file mode 100644 index 000000000000..3c4168bc4777 --- /dev/null +++ b/editor/core/Makefile.in @@ -0,0 +1,86 @@ +#!gmake +# +# 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. + +DEPTH=../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +DEFINES =-D_IMPL_NS_BASE + +ifeq ($(OS_TARGET),Rhapsody) +DIRS = rhapsody +else +DIRS = unix +endif + +LIBRARY_NAME = raptorbase + +CPPSRCS = \ + nsArena.cpp \ + nsAtomTable.cpp \ + nsBTree.cpp \ + nsByteBuffer.cpp \ + nsCRT.cpp \ + nsDeque.cpp \ + nsRBTree.cpp \ + nsSizeOfHandler.cpp \ + nsString.cpp \ + nsUnicharBuffer.cpp \ + nsUnicharInputStream.cpp \ + nsVoidArray.cpp \ + $(NULL) + +EXPORTS = \ + nscore.h \ + nsBTree.h \ + nsCRT.h \ + nsDeque.h \ + nsIArena.h \ + nsIAtom.h \ + nsIByteBuffer.h \ + nsIBaseStream.h \ + nsIInputStream.h \ + nsIOutputStream.h \ + nsITimer.h \ + nsITimerCallback.h \ + nsIUnicharBuffer.h \ + nsIUnicharInputStream.h \ + nsInt64.h \ + nsRBTree.h \ + nsString.h \ + nsTime.h \ + nsVoidArray.h \ + nsUnitConversion.h \ + $(NULL) + +EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) + +MODULE = raptor + +REQUIRES = xpcom netlib raptor + +include $(topsrcdir)/config/config.mk + +TARGET = $(LIBARY) + +include $(topsrcdir)/config/rules.mk + +test: + @echo OS_ARCH = $(OS_ARCH) diff --git a/editor/core/editor.cpp b/editor/core/editor.cpp new file mode 100644 index 000000000000..92144183e1d1 --- /dev/null +++ b/editor/core/editor.cpp @@ -0,0 +1,20 @@ +/* -*- 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" diff --git a/editor/core/editor.h b/editor/core/editor.h new file mode 100644 index 000000000000..8b03ed2eecbf --- /dev/null +++ b/editor/core/editor.h @@ -0,0 +1,64 @@ +/* -*- 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. + */ + +#include "nsIEditor.h" +#include "COM_auto_ptr.h" + + +/*implementation of an editor object. it ALSO supplies an nsIEditor Interface*/ + +class Editor : public nsIEditor +{ +private: + COM_auto_ptr mDomInterfaceP; +public: +/*nsIEditorInterfaces*/ + virtual nsresult Init(); + virtual nsresult Init() = 0; + +/*BEGIN interface manipulators and accessors*/ + + /*SetDomInterface accepts an interface to a nsIDOMDocument and it will add a reference to it + since it will keep it for some time*/ + virtual nsresult SetDomInterface(nsIDOMDocument *aDomInterface){mDomInterfaceP = aDomInterface} + + /*GetDomInterface returns a "look" at the dom interface. it will NOT ADD A REFERENCE!!!!!.*/ + virtual nsresult GetDomInterface(nsIDOMDocument **aDomInterface){*aDomInterface = mDomInterfaceP;} +/*END interface manipulators*/ + + virtual nsresult SetProperties(PROPERTIES aProperty){} + virtual nsresult GetProperties(PROPERTIES &){} + +/*EditorInterfaces*/ + Editor(); + ~Editor(); + +/*KeyListener Methods*/ + + /*KeyDown :accepts a keycode + :returns False if ignored*/ + PR_Bool KeyDown(int keycode); + +/*MouseListener Methods*/ + + /* Mouse Click accepts an x and + a y for location in the webshell*/ + PR_Bool MouseClick(int x,int y); //it should also tell us the dom element that was selected. +}; + + diff --git a/editor/core/makefile.win b/editor/core/makefile.win new file mode 100644 index 000000000000..797745294d68 --- /dev/null +++ b/editor/core/makefile.win @@ -0,0 +1,65 @@ +#!nmake +# +# 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. + +DEPTH=..\.. +IGNORE_MANIFEST=1 + +LIBRARY_NAME=ender + +CPPSRCS = \ + editor.cpp \ + $(NULL) + +CPP_OBJS = \ + .\$(OBJDIR)\editor.obj \ + $(NULL) + +MODULE=raptor + +REQUIRES=xpcom raptor + +LINCS=-I$(PUBLIC)\xpcom \ + -I$(PUBLIC)\raptor + +MAKE_OBJ_TYPE = DLL +DLLNAME = ender +DLL=.\$(OBJDIR)\$(DLLNAME).dll + +LCFLAGS = \ + $(LCFLAGS) \ + $(DEFINES) \ + $(NULL) + +# These are the libraries we need to link with to create the dll +LLIBS= \ + $(DIST)\lib\xpcom32.lib \ + $(DIST)\lib\libplc21.lib \ + $(LIBNSPR) +!if "$(MOZ_BITS)"=="32" && defined(MOZ_DEBUG) && defined(GLOWCODE) +LLIBS=$(LLIBS) $(GLOWDIR)\glowcode.lib +!endif + + +include <$(DEPTH)\config\rules.mak> + +libs:: $(DLL) + $(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin + $(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib + +clobber:: + rm -f $(DIST)\bin\$(DLLNAME).dll + rm -f $(DIST)\lib\$(DLLNAME).lib diff --git a/editor/core/nsEditorInterfaces.cpp b/editor/core/nsEditorInterfaces.cpp new file mode 100644 index 000000000000..aa10578cec58 --- /dev/null +++ b/editor/core/nsEditorInterfaces.cpp @@ -0,0 +1,240 @@ +/* -*- 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 "nsEditorInterfaces.h" +#include "nsEditorMode.h" +#include "nsString.h" + +/* + * nsEditorKeyListener implementation + */ + +nsEditorKeyListener::nsEditorKeyListener() +{ +} + +nsEditorKeyListener::~nsEditorKeyListener() +{ +} + +nsresult nsEditorKeyListener::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (NULL == 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; +} + +NS_IMPL_ADDREF(nsEditorKeyListener) + +NS_IMPL_RELEASE(nsEditorKeyListener) + +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. */ + 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; + } + return NS_ERROR_FAILURE; +} + +nsresult nsEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent) +{ + PRUint32 mKeyCode; + PRBool mIsShift; + char mChar; + + if (NS_OK == aKeyEvent->GetKeyCode(&mKeyCode) && + NS_OK == aKeyEvent->GetShiftKey(&mIsShift)) { + switch(mKeyCode) { + case nsIDOMEvent::VK_BACK: + nsDeleteLast(); + break; + case nsIDOMEvent::VK_RETURN: + // Need to implement creation of either

or
nodes. + break; + default: + // XXX Replace with x-platform NS-virtkeycode transform. + if (NS_OK == GetCharFromKeyCode(mKeyCode, mIsShift, &mChar)) { + nsString* key = new nsString(); + *key += mChar; + if (!mIsShift) { + key->ToLowerCase(); + } + nsAppendText(key); + } + break; + } + } + + return NS_ERROR_BASE; +} + +nsresult nsEditorKeyListener::KeyUp(nsIDOMEvent* aKeyEvent) +{ + return NS_OK; +} + +nsresult nsEditorKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) +{ + return NS_OK; +} + +/* + * nsEditorMouseListener implementation + */ + +nsEditorMouseListener::nsEditorMouseListener() +{ +} + +nsEditorMouseListener::~nsEditorMouseListener() +{ +} + +nsresult nsEditorMouseListener::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (NULL == 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; +} + +NS_IMPL_ADDREF(nsEditorMouseListener) + +NS_IMPL_RELEASE(nsEditorMouseListener) + +nsresult nsEditorMouseListener::ProcessEvent(nsIDOMEvent* aEvent) +{ + return NS_OK; +} + +nsresult nsEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent) +{ + nsIDOMNode *aTarget; + if (NS_OK == aMouseEvent->GetTarget(&aTarget)) { + nsSetCurrentNode(aTarget); + NS_RELEASE(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) +{ + nsEditorKeyListener* it = new nsEditorKeyListener(); + if (NULL == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + + static NS_DEFINE_IID(kIDOMEventListenerIID, NS_IDOMEVENTLISTENER_IID); + + return it->QueryInterface(kIDOMEventListenerIID, (void **) aInstancePtrResult); +} + +nsresult NS_NewEditorMouseListener(nsIDOMEventListener ** aInstancePtrResult) +{ + nsEditorMouseListener* it = new nsEditorMouseListener(); + if (NULL == it) { + return NS_ERROR_OUT_OF_MEMORY; + } + + static NS_DEFINE_IID(kIDOMEventListenerIID, NS_IDOMEVENTLISTENER_IID); + + return it->QueryInterface(kIDOMEventListenerIID, (void **) aInstancePtrResult); +} +