diff --git a/gfx/src/motif/Makefile b/gfx/src/motif/Makefile new file mode 100644 index 00000000000..7469308bed8 --- /dev/null +++ b/gfx/src/motif/Makefile @@ -0,0 +1,37 @@ +#!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 = ../../.. + +include $(DEPTH)/config/config.mk + +LIBRARY_NAME = gfxunix + +MODULE=raptor + +REQUIRES=util img xpcom raptor netlib + +LCFLAGS+=-D_IMPL_NS_GFXONXP + +LLIBS+=$(DIST)/lib/libxpcom.a $(DIST)/lib/libraptorbase.a $(DIST)/lib/libraptorgfx.a + +CPPSRCS=nsDeviceContextUnix.cpp nsFontMetricsUnix.cpp nsGfxFactoryUnix.cpp \ + nsRenderingContextUnix.cpp nsImageUnix.cpp + +include $(DEPTH)/config/rules.mk + + diff --git a/gfx/src/motif/nsDeviceContextUnix.cpp b/gfx/src/motif/nsDeviceContextUnix.cpp new file mode 100644 index 00000000000..47f1cbc9e5b --- /dev/null +++ b/gfx/src/motif/nsDeviceContextUnix.cpp @@ -0,0 +1,152 @@ +/* -*- 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 "nsDeviceContextUnix.h" +#include "nsRenderingContextUnix.h" +#include "../nsGfxCIID.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID); + +nsDeviceContextUnix :: nsDeviceContextUnix() +{ + NS_INIT_REFCNT(); + + mFontCache = nsnull; +} + +nsDeviceContextUnix :: ~nsDeviceContextUnix() +{ + NS_IF_RELEASE(mFontCache); +} + +NS_IMPL_QUERY_INTERFACE(nsDeviceContextUnix, kDeviceContextIID) +NS_IMPL_ADDREF(nsDeviceContextUnix) +NS_IMPL_RELEASE(nsDeviceContextUnix) + +nsresult nsDeviceContextUnix :: Init() +{ + return NS_OK; +} + +float nsDeviceContextUnix :: GetTwipsToDevUnits() const +{ + return 0.0; +} + +float nsDeviceContextUnix :: GetDevUnitsToTwips() const +{ + return 0.0; +} + +void nsDeviceContextUnix :: SetAppUnitsToDevUnits(float aAppUnits) +{ +} + +void nsDeviceContextUnix :: SetDevUnitsToAppUnits(float aDevUnits) +{ +} + +float nsDeviceContextUnix :: GetAppUnitsToDevUnits() const +{ + return 0.0; +} + +float nsDeviceContextUnix :: GetDevUnitsToAppUnits() const +{ + return 0.0; +} + +float nsDeviceContextUnix :: GetScrollBarWidth() const +{ + return 0.0; +} + +float nsDeviceContextUnix :: GetScrollBarHeight() const +{ + return 0.0; +} + +nsIRenderingContext * nsDeviceContextUnix :: CreateRenderingContext(nsIView *aView) +{ + nsIRenderingContext *pContext = nsnull; + nsresult rv; + + static NS_DEFINE_IID(kRCCID, NS_RENDERING_CONTEXT_CID); + static NS_DEFINE_IID(kRCIID, NS_IRENDERING_CONTEXT_IID); + + rv = NSRepository::CreateInstance(kRCCID, nsnull, kRCIID, (void **)&pContext); + + if (NS_OK == rv) + InitRenderingContext(pContext, mWidget); + + return pContext; +} + +void nsDeviceContextUnix :: InitRenderingContext(nsIRenderingContext *aContext, nsIWidget *aWin) +{ + aContext->Init(this, aWin); + mWidget = aWin; +} + +nsIFontCache* nsDeviceContextUnix::GetFontCache() +{ + if (nsnull == mFontCache) { + if (NS_OK != CreateFontCache()) { + return nsnull; + } + } + NS_ADDREF(mFontCache); + return mFontCache; +} + +nsresult nsDeviceContextUnix::CreateFontCache() +{ +#if 0 + nsresult rv = NS_NewFontCache(&mFontCache); + if (NS_OK != rv) { + return rv; + } + mFontCache->Init(this); +#endif + return NS_OK; +} + +void nsDeviceContextUnix::FlushFontCache() +{ +} + + +nsIFontMetrics* nsDeviceContextUnix::GetMetricsFor(const nsFont& aFont) +{ + return nsnull; +} + +void nsDeviceContextUnix :: SetZoom(float aZoom) +{ +} + +float nsDeviceContextUnix :: GetZoom() const +{ + return 0.0; +} + +nsDrawingSurface nsDeviceContextUnix :: GetDrawingSurface(nsIRenderingContext &aContext) +{ + return ( aContext.CreateDrawingSurface(nsnull)); +} diff --git a/gfx/src/motif/nsDeviceContextUnix.h b/gfx/src/motif/nsDeviceContextUnix.h new file mode 100644 index 00000000000..1bf6ae05631 --- /dev/null +++ b/gfx/src/motif/nsDeviceContextUnix.h @@ -0,0 +1,72 @@ +/* -*- 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. + */ + +#ifndef nsDeviceContextUnix_h___ +#define nsDeviceContextUnix_h___ + +#include "nsIDeviceContext.h" +#include "nsUnitConversion.h" +#include "nsIFontCache.h" +#include "nsIWidget.h" +#include "nsIView.h" +#include "nsIRenderingContext.h" + +class nsDeviceContextUnix : public nsIDeviceContext +{ +public: + nsDeviceContextUnix(); + + NS_DECL_ISUPPORTS + + virtual nsresult Init(); + + virtual nsIRenderingContext * CreateRenderingContext(nsIView *aView); + virtual void InitRenderingContext(nsIRenderingContext *aContext, nsIWidget *aWidget); + + virtual float GetTwipsToDevUnits() const; + virtual float GetDevUnitsToTwips() const; + + virtual void SetAppUnitsToDevUnits(float aAppUnits); + virtual void SetDevUnitsToAppUnits(float aDevUnits); + + virtual float GetAppUnitsToDevUnits() const; + virtual float GetDevUnitsToAppUnits() const; + + virtual float GetScrollBarWidth() const; + virtual float GetScrollBarHeight() const; + + virtual nsIFontCache * GetFontCache(); + virtual void FlushFontCache(); + + virtual nsIFontMetrics* GetMetricsFor(const nsFont& aFont); + + virtual void SetZoom(float aZoom); + virtual float GetZoom() const; + + virtual nsDrawingSurface GetDrawingSurface(nsIRenderingContext &aContext); + +protected: + ~nsDeviceContextUnix(); + nsresult CreateFontCache(); + + nsIFontCache *mFontCache; + nsIWidget *mWidget; + +}; + +#endif /* nsDeviceContextUnix_h___ */ diff --git a/gfx/src/motif/nsFontMetricsUnix.cpp b/gfx/src/motif/nsFontMetricsUnix.cpp new file mode 100644 index 00000000000..2199584e778 --- /dev/null +++ b/gfx/src/motif/nsFontMetricsUnix.cpp @@ -0,0 +1,115 @@ +/* -*- 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 "nsFontMetricsUnix.h" + +static NS_DEFINE_IID(kIFontMetricsIID, NS_IFONT_METRICS_IID); + +nsFontMetricsUnix :: nsFontMetricsUnix() +{ + NS_INIT_REFCNT(); +} + +nsFontMetricsUnix :: ~nsFontMetricsUnix() +{ +} + +NS_IMPL_ISUPPORTS(nsFontMetricsUnix, kIFontMetricsIID) + +nsresult nsFontMetricsUnix :: Init(const nsFont& aFont, nsIDeviceContext* aCX) +{ + mFont = new nsFont(aFont); + mContext = aCX ; + + QueryFont(); + + return NS_OK; +} + +void nsFontMetricsUnix::QueryFont() +{ +} + +nscoord nsFontMetricsUnix :: GetWidth(char ch) +{ + return nsnull; +} + +nscoord nsFontMetricsUnix :: GetWidth(PRUnichar ch) +{ + return 0; +} + +nscoord nsFontMetricsUnix :: GetWidth(const nsString& aString) +{ + return nsnull; +} + +nscoord nsFontMetricsUnix :: GetWidth(const char *aString) +{ + return nsnull; +} + +nscoord nsFontMetricsUnix :: GetWidth(const PRUnichar *aString, PRUint32 aLength) +{ + return nsnull; +} + +nscoord nsFontMetricsUnix :: GetHeight() +{ + return 0; +} + +nscoord nsFontMetricsUnix :: GetLeading() +{ + return 0; +} + +nscoord nsFontMetricsUnix :: GetMaxAscent() +{ + return 0; +} + +nscoord nsFontMetricsUnix :: GetMaxDescent() +{ + return 0; +} + +nscoord nsFontMetricsUnix :: GetMaxAdvance() +{ + return 0; +} + +const nscoord * nsFontMetricsUnix :: GetWidths() +{ + return nsnull; +} + +const nsFont& nsFontMetricsUnix :: GetFont() +{ + return *mFont; +} + +nsFontHandle nsFontMetricsUnix :: GetFontHandle() +{ + return ((nsFontHandle)mFontHandle); +} + + + + diff --git a/gfx/src/motif/nsFontMetricsUnix.h b/gfx/src/motif/nsFontMetricsUnix.h new file mode 100644 index 00000000000..57c95413c8d --- /dev/null +++ b/gfx/src/motif/nsFontMetricsUnix.h @@ -0,0 +1,73 @@ +/* -*- 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. + */ + +#ifndef nsFontMetricsUnix_h__ +#define nsFontMetricsUnix_h__ + +#include "nsIFontMetrics.h" +#include "nsFont.h" +#include "nsString.h" +#include "nsUnitConversion.h" +#include "nsIDeviceContext.h" +#include "nsCRT.h" + +#include "Xm/Xm.h" + +class nsFontMetricsUnix : public nsIFontMetrics +{ +public: + nsFontMetricsUnix(); + ~nsFontMetricsUnix(); + + void* operator new(size_t sz) { + void* rv = new char[sz]; + nsCRT::zero(rv, sz); + return rv; + } + + NS_DECL_ISUPPORTS + + virtual nsresult Init(const nsFont& aFont, nsIDeviceContext* aContext); + virtual nscoord GetWidth(char aC); + virtual nscoord GetWidth(PRUnichar aC); + virtual nscoord GetWidth(const nsString& aString); + virtual nscoord GetWidth(const char *aString); + virtual nscoord GetWidth(const PRUnichar *aString, PRUint32 aLength); + virtual nscoord GetHeight(); + virtual nscoord GetLeading(); + virtual nscoord GetMaxAscent(); + virtual nscoord GetMaxDescent(); + virtual nscoord GetMaxAdvance(); + virtual const nscoord *GetWidths(); + virtual const nsFont& GetFont(); + virtual nsFontHandle GetFontHandle(); + +protected: + void QueryFont(); + + nsFont *mFont; + nsIDeviceContext *mContext; + XFontStruct *mFontInfo; + Font mFontHandle; +}; + +#endif + + + + diff --git a/gfx/src/motif/nsGfxFactoryUnix.cpp b/gfx/src/motif/nsGfxFactoryUnix.cpp new file mode 100644 index 00000000000..a0e6c06f8c7 --- /dev/null +++ b/gfx/src/motif/nsGfxFactoryUnix.cpp @@ -0,0 +1,171 @@ +/* -*- 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 "nscore.h" +#include "nsIFactory.h" +#include "nsISupports.h" +#include "../nsGfxCIID.h" +#include "nsFontMetricsUnix.h" +#include "nsRenderingContextUnix.h" +#include "nsImageUnix.h" +#include "nsDeviceContextUnix.h" + +static NS_DEFINE_IID(kCFontMetrics, NS_FONT_METRICS_CID); +static NS_DEFINE_IID(kCRenderingContext, NS_RENDERING_CONTEXT_CID); +static NS_DEFINE_IID(kCImage, NS_IMAGE_CID); +static NS_DEFINE_IID(kCDeviceContext, NS_DEVICE_CONTEXT_CID); + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); + +class nsGfxFactoryUnix : public nsIFactory +{ + public: + // nsISupports methods + NS_IMETHOD QueryInterface(const nsIID &aIID, + void **aResult); + NS_IMETHOD_(nsrefcnt) AddRef(void); + NS_IMETHOD_(nsrefcnt) Release(void); + + // nsIFactory methods + NS_IMETHOD CreateInstance(nsISupports *aOuter, + const nsIID &aIID, + void **aResult); + + NS_IMETHOD LockFactory(PRBool aLock); + + nsGfxFactoryUnix(const nsCID &aClass); + ~nsGfxFactoryUnix(); + + private: + nsrefcnt mRefCnt; + nsCID mClassID; +}; + +nsGfxFactoryUnix::nsGfxFactoryUnix(const nsCID &aClass) +{ + mRefCnt = 0; + mClassID = aClass; +} + +nsGfxFactoryUnix::~nsGfxFactoryUnix() +{ + NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction"); +} + +nsresult nsGfxFactoryUnix::QueryInterface(const nsIID &aIID, + void **aResult) +{ + if (aResult == NULL) { + return NS_ERROR_NULL_POINTER; + } + + // Always NULL result, in case of failure + *aResult = NULL; + + if (aIID.Equals(kISupportsIID)) { + *aResult = (void *)(nsISupports*)this; + } else if (aIID.Equals(kIFactoryIID)) { + *aResult = (void *)(nsIFactory*)this; + } + + if (*aResult == NULL) { + return NS_NOINTERFACE; + } + + AddRef(); // Increase reference count for caller + return NS_OK; +} + +nsrefcnt nsGfxFactoryUnix::AddRef() +{ + return ++mRefCnt; +} + +nsrefcnt nsGfxFactoryUnix::Release() +{ + if (--mRefCnt == 0) { + delete this; + return 0; // Don't access mRefCnt after deleting! + } + return mRefCnt; +} + +nsresult nsGfxFactoryUnix::CreateInstance(nsISupports *aOuter, + const nsIID &aIID, + void **aResult) +{ + if (aResult == NULL) { + return NS_ERROR_NULL_POINTER; + } + + *aResult = NULL; + + nsISupports *inst = nsnull; + + if (mClassID.Equals(kCFontMetrics)) { + inst = (nsISupports *)new nsFontMetricsUnix(); + } + else if (mClassID.Equals(kCDeviceContext)) { + inst = (nsISupports *)new nsDeviceContextUnix(); + } + else if (mClassID.Equals(kCRenderingContext)) { + inst = (nsISupports *)new nsRenderingContextUnix(); + } + else if (mClassID.Equals(kCImage)) { + inst = (nsISupports *)new nsImageUnix(); + } + + if (inst == NULL) { + return NS_ERROR_OUT_OF_MEMORY; + } + + nsresult res = inst->QueryInterface(aIID, aResult); + + if (res != NS_OK) { + // We didn't get the right interface, so clean up + delete inst; + } +// else { +// inst->Release(); +// } + + return res; +} + +nsresult nsGfxFactoryUnix::LockFactory(PRBool aLock) +{ + // Not implemented in simplest case. + return NS_OK; +} + +// return the proper factory to the caller +extern "C" NS_GFXNONXP nsresult NSGetFactory(const nsCID &aClass, nsIFactory **aFactory) +{ + if (nsnull == aFactory) { + return NS_ERROR_NULL_POINTER; + } + + *aFactory = new nsGfxFactoryUnix(aClass); + + if (nsnull == aFactory) { + return NS_ERROR_OUT_OF_MEMORY; + } + + return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory); +} diff --git a/gfx/src/motif/nsImageUnix.cpp b/gfx/src/motif/nsImageUnix.cpp new file mode 100644 index 00000000000..c7d094f1fd7 --- /dev/null +++ b/gfx/src/motif/nsImageUnix.cpp @@ -0,0 +1,85 @@ +/* -*- 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 "nsImageUnix.h" +#include "nsRenderingContextUnix.h" + +static NS_DEFINE_IID(kIImageIID, NS_IIMAGE_IID); + +//------------------------------------------------------------ + +nsImageUnix :: nsImageUnix() +{ + NS_INIT_REFCNT(); +} + +//------------------------------------------------------------ + +nsImageUnix :: ~nsImageUnix() +{ +} + +NS_IMPL_ISUPPORTS(nsImageUnix, kIImageIID); + +//------------------------------------------------------------ + +nsresult nsImageUnix :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMaskRequirements aMaskRequirements) +{ + return NS_OK; +} + +//------------------------------------------------------------ + +// set up the pallete to the passed in color array, RGB only in this array +void nsImageUnix :: ImageUpdated(PRUint8 aFlags, nsRect *aUpdateRect) +{ +} + +//------------------------------------------------------------ + +// Draw the bitmap, this method has a source and destination coordinates +PRBool nsImageUnix :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight, + PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) +{ + return PR_TRUE; +} + +//------------------------------------------------------------ + +// Draw the bitmap, this draw just has destination coordinates +PRBool nsImageUnix :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, + PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) +{ + return PR_TRUE; +} + +//------------------------------------------------------------ + +void nsImageUnix::CompositeImage(nsIImage *aTheImage, nsPoint *aULLocation) +{ + +} + +//------------------------------------------------------------ + +// lets build an alpha mask from this image +PRBool nsImageUnix::SetAlphaMask(nsIImage *aTheMask) +{ + return(PR_FALSE); +} + diff --git a/gfx/src/motif/nsImageUnix.h b/gfx/src/motif/nsImageUnix.h new file mode 100644 index 00000000000..b8f28d1ae33 --- /dev/null +++ b/gfx/src/motif/nsImageUnix.h @@ -0,0 +1,82 @@ +/* -*- 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. + */ + +#ifndef nsImageUnix_h___ +#define nsImageUnix_h___ + +#include "nsIImage.h" + +class nsImageUnix : public nsIImage +{ +public: + nsImageUnix(); + ~nsImageUnix(); + + NS_DECL_ISUPPORTS + + /** + @see nsIImage.h + */ + virtual PRInt32 GetHeight() { return 0; } + virtual PRInt32 GetWidth() { return 0; } + virtual PRUint8* GetBits() { return nsnull; } + virtual PRInt32 GetLineStride() {return 0; } + virtual PRBool Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight); + virtual PRBool Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight, + PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight); + virtual nsColorMap* GetColorMap() {return nsnull;} + virtual void ImageUpdated(PRUint8 aFlags, nsRect *aUpdateRect); + virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements); + virtual PRBool IsOptimized() { return PR_FALSE; } + virtual nsresult Optimize(nsDrawingSurface aSurface); + virtual PRUint8* GetAlphaBits() { return nsnull; } + virtual PRInt32 GetAlphaWidth() { return 0;} + virtual PRInt32 GetAlphaHeight() {return 0;} + virtual PRInt32 GetAlphaXLoc() {return 0;} + virtual PRInt32 GetAlphaYLoc() {return 0;} + virtual PRInt32 GetAlphaLineStride(){ return 0; } + virtual void CompositeImage(nsIImage *aTheImage,nsPoint *aULLocation); + + virtual nsIImage* DuplicateImage(); + + /** + * Return the image size of the Device Independent Bitmap(DIB). + * @return size of image in bytes + */ + PRIntn GetSizeImage(){ return 0; } + + /** + * Make a palette for the DIB. + * @return true or false if the palette was created + */ + PRBool MakePalette(); + + /** + * Calculate the number of bytes spaned for this image for a given width + * @param aWidth is the width to calculate the number of bytes for + * @return the number of bytes in this span + */ + PRInt32 CalcBytesSpan(PRUint32 aWidth); + + PRBool SetAlphaMask(nsIImage *aTheMask); + + void MoveAlphaMask(PRInt32 aX, PRInt32 aY){} + +}; + +#endif diff --git a/gfx/src/motif/nsRenderingContextUnix.cpp b/gfx/src/motif/nsRenderingContextUnix.cpp new file mode 100644 index 00000000000..c462a1d0977 --- /dev/null +++ b/gfx/src/motif/nsRenderingContextUnix.cpp @@ -0,0 +1,301 @@ +/* -*- 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 "nsRenderingContextUnix.h" +#include + +typedef unsigned char BYTE; + +#define RGB(r,g,b) ((unsigned long) (((BYTE) (r) | ((unsigned long) ((BYTE) (g)) <<8)) | (((unsigned long)(BYTE)(b)) << 16))) + +static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID); + +nsRenderingContextUnix :: nsRenderingContextUnix() +{ + NS_INIT_REFCNT(); + + mFontCache = nsnull ; + mFontMetrics = nsnull ; + mContext = nsnull ; +} + +nsRenderingContextUnix :: ~nsRenderingContextUnix() +{ + NS_IF_RELEASE(mContext); + NS_IF_RELEASE(mFontCache); + NS_IF_RELEASE(mFontMetrics); +} + +NS_IMPL_QUERY_INTERFACE(nsRenderingContextUnix, kRenderingContextIID) +NS_IMPL_ADDREF(nsRenderingContextUnix) +NS_IMPL_RELEASE(nsRenderingContextUnix) + +nsresult nsRenderingContextUnix :: Init(nsIDeviceContext* aContext, + nsIWidget *aWindow) +{ + + mContext = aContext; + NS_IF_ADDREF(mContext); + + mGC = (GC)aWindow->GetNativeData(NS_NATIVE_GRAPHIC); + mDrawable = (Drawable) aWindow->GetNativeData(NS_NATIVE_WIDGET); + +#if 0 + mFontCache = mContext->GetFontCache(); +#endif +} + +nsresult nsRenderingContextUnix :: Init(nsIDeviceContext* aContext, + nsDrawingSurface aSurface) +{ + // XXX We are doomed if this is the case .... need to remove this API. In X, you need both + // a drawable and gc for rendering + mContext = aContext; + NS_IF_ADDREF(mContext); + + mGC = (GC)aSurface; +} + +nsresult nsRenderingContextUnix :: SelectOffScreenDrawingSurface(nsDrawingSurface aSurface) +{ + return NS_OK; +} + +void nsRenderingContextUnix :: Reset() +{ +} + +nsIDeviceContext * nsRenderingContextUnix :: GetDeviceContext(void) +{ + return mContext; +} + +void nsRenderingContextUnix :: PushState() +{ +} + +void nsRenderingContextUnix :: PopState() +{ +} + +PRBool nsRenderingContextUnix :: IsVisibleRect(const nsRect& aRect) +{ + return PR_TRUE; +} + +void nsRenderingContextUnix :: SetClipRect(const nsRect& aRect, PRBool aIntersect) +{ +} + +const nsRect& nsRenderingContextUnix :: GetClipRect() +{ + nsRect r(0,0,0,0); + return r; +} + +void nsRenderingContextUnix :: SetColor(nscolor aColor) +{ + XGCValues values ; + + mCurrentColor = aColor ; + + values.foreground = mCurrentColor; + values.background = mCurrentColor; + + XChangeGC(XtDisplay((Widget)mDrawable), + mGC, + GCForeground | GCBackground, + &values); +} + +nscolor nsRenderingContextUnix :: GetColor() const +{ + return mCurrentColor; +} + +void nsRenderingContextUnix :: SetFont(const nsFont& aFont) +{ + Font id = ::XLoadFont(XtDisplay((Widget)mDrawable), "fixed"); + + XFontStruct * fs = ::XQueryFont(XtDisplay((Widget)mDrawable), id); + + ::XSetFont(XtDisplay((Widget)mDrawable), mGC, id); + + +#if 0 + NS_IF_RELEASE(mFontMetrics); + mFontMetrics = mFontCache->GetMetricsFor(aFont); +#endif + +} + +const nsFont& nsRenderingContextUnix :: GetFont() +{ + return mFontMetrics->GetFont(); +} + +nsIFontMetrics* nsRenderingContextUnix :: GetFontMetrics() +{ + return mFontMetrics; +} + +// add the passed in translation to the current translation +void nsRenderingContextUnix :: Translate(nscoord aX, nscoord aY) +{ +} + +// add the passed in scale to the current scale +void nsRenderingContextUnix :: Scale(float aSx, float aSy) +{ +} + +nsTransform2D * nsRenderingContextUnix :: GetCurrentTransform() +{ + return nsnull ; +} + +nsDrawingSurface nsRenderingContextUnix :: CreateDrawingSurface(nsRect *aBounds) +{ + return nsnull ; +} + +void nsRenderingContextUnix :: DestroyDrawingSurface(nsDrawingSurface aDS) +{ +} + +void nsRenderingContextUnix :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1) +{ +} + +void nsRenderingContextUnix :: DrawRect(const nsRect& aRect) +{ +} + +void nsRenderingContextUnix :: DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) +{ +} + +void nsRenderingContextUnix :: FillRect(const nsRect& aRect) +{ + FillRect(aRect.x, aRect.y, aRect.width, aRect.height); +} + +void nsRenderingContextUnix :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) +{ + ::XFillRectangle(XtDisplay((Widget)mDrawable), + XtWindow((Widget)mDrawable), + mGC, + aX, aY, + aWidth, aHeight); +} + + +void nsRenderingContextUnix::DrawPolygon(nsPoint aPoints[], PRInt32 aNumPoints) +{ +} + +void nsRenderingContextUnix::FillPolygon(nsPoint aPoints[], PRInt32 aNumPoints) +{ +} + +void nsRenderingContextUnix :: DrawEllipse(const nsRect& aRect) +{ + DrawEllipse(aRect.x, aRect.y, aRect.width, aRect.height); +} + +void nsRenderingContextUnix :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) +{ +} + +void nsRenderingContextUnix :: FillEllipse(const nsRect& aRect) +{ + FillEllipse(aRect.x, aRect.y, aRect.width, aRect.height); +} + +void nsRenderingContextUnix :: FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) +{ +} + +void nsRenderingContextUnix :: DrawArc(const nsRect& aRect, + float aStartAngle, float aEndAngle) +{ + this->DrawArc(aRect.x,aRect.y,aRect.width,aRect.height,aStartAngle,aEndAngle); +} + +void nsRenderingContextUnix :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, + float aStartAngle, float aEndAngle) +{ +} + +void nsRenderingContextUnix :: FillArc(const nsRect& aRect, + float aStartAngle, float aEndAngle) +{ + this->FillArc(aRect.x, aRect.y, aRect.width, aRect.height, aStartAngle, aEndAngle); +} + +void nsRenderingContextUnix :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, + float aStartAngle, float aEndAngle) +{ +} + +void nsRenderingContextUnix :: DrawString(const char *aString, PRUint32 aLength, + nscoord aX, nscoord aY, + nscoord aWidth) +{ + // XXX Hack + ::XLoadFont(XtDisplay((Widget)mDrawable), "fixed"); + + ::XDrawString(XtDisplay((Widget)mDrawable), + XtWindow((Widget)mDrawable), + mGC, + aX, aY, aString, aWidth); +} + +void nsRenderingContextUnix :: DrawString(const PRUnichar *aString, PRUint32 aLength, + nscoord aX, nscoord aY, nscoord aWidth) +{ +} + +void nsRenderingContextUnix :: DrawString(const nsString& aString, + nscoord aX, nscoord aY, nscoord aWidth) +{ + // XXX Leak - How to Print UniChar + DrawString(aString.ToNewCString(), aString.Length(), aX, aY, aWidth); +} + +void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY) +{ +} + +void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY, + nscoord aWidth, nscoord aHeight) +{ +} + +void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect) +{ +} + +void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, const nsRect& aRect) +{ +} + +nsresult nsRenderingContextUnix :: CopyOffScreenBits(nsRect &aBounds) +{ + return NS_OK; +} diff --git a/gfx/src/motif/nsRenderingContextUnix.h b/gfx/src/motif/nsRenderingContextUnix.h new file mode 100644 index 00000000000..4575ec89a80 --- /dev/null +++ b/gfx/src/motif/nsRenderingContextUnix.h @@ -0,0 +1,137 @@ +/* -*- 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. + */ + +#ifndef nsRenderingContextUnix_h___ +#define nsRenderingContextUnix_h___ + +#include "nsIRenderingContext.h" +#include "nsUnitConversion.h" +#include "nsFont.h" +#include "nsIFontMetrics.h" +#include "nsPoint.h" +#include "nsString.h" +#include "nsCRT.h" +#include "nsTransform2D.h" +#include "nsIViewManager.h" +#include "nsIWidget.h" +#include "nsRect.h" +#include "nsIFontCache.h" +#include "nsImageUnix.h" +#include "nsIDeviceContext.h" +#include "nsVoidArray.h" + +#include "Xm/Xm.h" + +class nsRenderingContextUnix : public nsIRenderingContext +{ +public: + nsRenderingContextUnix(); + ~nsRenderingContextUnix(); + + void* operator new(size_t sz) { + void* rv = new char[sz]; + nsCRT::zero(rv, sz); + return rv; + } + + NS_DECL_ISUPPORTS + + virtual nsresult Init(nsIDeviceContext* aContext, nsIWidget *aWindow); + virtual nsresult Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface); + + virtual void Reset(); + + virtual nsIDeviceContext * GetDeviceContext(void); + + virtual nsresult SelectOffScreenDrawingSurface(nsDrawingSurface aSurface); + + virtual void PushState(); + virtual void PopState(); + + virtual PRBool IsVisibleRect(const nsRect& aRect); + + virtual void SetClipRect(const nsRect& aRect, PRBool aIntersect); + virtual const nsRect& GetClipRect(); + + virtual void SetColor(nscolor aColor); + virtual nscolor GetColor() const; + + virtual void SetFont(const nsFont& aFont); + virtual const nsFont& GetFont(); + + virtual nsIFontMetrics * GetFontMetrics(); + + virtual void Translate(nscoord aX, nscoord aY); + virtual void Scale(float aSx, float aSy); + virtual nsTransform2D * GetCurrentTransform(); + + virtual nsDrawingSurface CreateDrawingSurface(nsRect *aBounds); + virtual void DestroyDrawingSurface(nsDrawingSurface aDS); + + virtual void DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1); + + virtual void DrawRect(const nsRect& aRect); + virtual void DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); + virtual void FillRect(const nsRect& aRect); + virtual void FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); + + virtual void DrawPolygon(nsPoint aPoints[], PRInt32 aNumPoints); + virtual void FillPolygon(nsPoint aPoints[], PRInt32 aNumPoints); + + virtual void DrawEllipse(const nsRect& aRect); + virtual void DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); + virtual void FillEllipse(const nsRect& aRect); + virtual void FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); + + virtual void DrawArc(const nsRect& aRect, + float aStartAngle, float aEndAngle); + virtual void DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, + float aStartAngle, float aEndAngle); + virtual void FillArc(const nsRect& aRect, + float aStartAngle, float aEndAngle); + virtual void FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, + float aStartAngle, float aEndAngle); + + virtual void DrawString(const char *aString, PRUint32 aLength, + nscoord aX, nscoord aY, + nscoord aWidth); + virtual void DrawString(const PRUnichar *aString, PRUint32 aLength, nscoord aX, nscoord aY, + nscoord aWidth); + virtual void DrawString(const nsString& aString, nscoord aX, nscoord aY, + nscoord aWidth); + + virtual void DrawImage(nsIImage *aImage, nscoord aX, nscoord aY); + virtual void DrawImage(nsIImage *aImage, nscoord aX, nscoord aY, + nscoord aWidth, nscoord aHeight); + virtual void DrawImage(nsIImage *aImage, const nsRect& aRect); + virtual void DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect); + + virtual nsresult CopyOffScreenBits(nsRect &aBounds); + +protected: + nscolor mCurrentColor ; + GC mGC; + Drawable mDrawable; + nsIDeviceContext *mContext; + nsIFontMetrics *mFontMetrics; + nsIFontCache *mFontCache; + + +}; + +#endif /* nsRenderingContextUnix_h___ */ diff --git a/widget/src/motif/Makefile b/widget/src/motif/Makefile new file mode 100644 index 00000000000..9e0de215c51 --- /dev/null +++ b/widget/src/motif/Makefile @@ -0,0 +1,55 @@ +#!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 = widgetunix + +MODULE=raptor + +REQUIRES=util img xpcom raptor netlib + +DEFINES = -D_IMPL_NS_WIDGET + +LLIBS+=$(DIST)/lib/libxpcom.a $(DIST)/lib/libraptorbase.a $(DIST)/lib/libraptorgfx.a -lXm -lXt -lX11 + +CPPSRCS=nsWidgetFactory.cpp \ + nsWindow.cpp \ + nsXtEventHandler.cpp \ + nsToolkit.cpp + +CPP_OBJS= \ + ./$(OBJDIR)/nsWidgetFactory.o \ + ./$(OBJDIR)/nsWindow.o \ + ./$(OBJDIR)/nsToolkit.o \ + ./$(OBJDIR)/nsXtEventHandler.o \ + $(NULL) + +include $(DEPTH)/config/config.mk + +TARGETS = $(LIBRARY) + +include $(DEPTH)/config/rules.mk + + + + + + + diff --git a/widget/src/motif/nsToolkit.cpp b/widget/src/motif/nsToolkit.cpp new file mode 100644 index 00000000000..7b6bb45eb8a --- /dev/null +++ b/widget/src/motif/nsToolkit.cpp @@ -0,0 +1,70 @@ +/* -*- 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 "nsToolkit.h" +#include "nsWindow.h" +#include "prmon.h" +#include "prtime.h" +#include "nsGUIEvent.h" + + + +void RunPump(void* arg) +{ +} + +//------------------------------------------------------------------------- +// +// constructor +// +//------------------------------------------------------------------------- +nsToolkit::nsToolkit() +{ + NS_INIT_REFCNT(); +} + + +//------------------------------------------------------------------------- +// +// destructor +// +//------------------------------------------------------------------------- +nsToolkit::~nsToolkit() +{ +} + + +//------------------------------------------------------------------------- +// +// nsISupports implementation macro +// +//------------------------------------------------------------------------- +NS_DEFINE_IID(kIToolkitIID, NS_ITOOLKIT_IID); +NS_IMPL_ISUPPORTS(nsToolkit,kIToolkitIID); + + + +//------------------------------------------------------------------------- +// +// +//------------------------------------------------------------------------- +void nsToolkit::Init(PRThread *aThread) +{ +} + + diff --git a/widget/src/motif/nsToolkit.h b/widget/src/motif/nsToolkit.h new file mode 100644 index 00000000000..282a134bde5 --- /dev/null +++ b/widget/src/motif/nsToolkit.h @@ -0,0 +1,50 @@ +/* -*- 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. + */ + +#ifndef TOOLKIT_H +#define TOOLKIT_H + +#include "nsIToolkit.h" + +struct MethodInfo; + +/** + * Wrapper around the thread running the message pump. + * The toolkit abstraction is necessary because the message pump must + * execute within the same thread that created the widget under Win32. + */ + +class nsToolkit : public nsIToolkit +{ + + public: + nsToolkit(); + + NS_DECL_ISUPPORTS + + virtual void Init(PRThread *aThread); + + +private: + ~nsToolkit(); + +}; + + + +#endif // TOOLKIT_H diff --git a/widget/src/motif/nsWidgetFactory.cpp b/widget/src/motif/nsWidgetFactory.cpp new file mode 100644 index 00000000000..4e63095aa2d --- /dev/null +++ b/widget/src/motif/nsWidgetFactory.cpp @@ -0,0 +1,151 @@ +/* -*- 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 "nsIFactory.h" +#include "nsISupports.h" +#include "nsWidgetsCID.h" + +#include "nsToolkit.h" +#include "nsWindow.h" + +static NS_DEFINE_IID(kCWindow, NS_WINDOW_CID); +static NS_DEFINE_IID(kIWidget, NS_IWIDGET_IID); +static NS_DEFINE_IID(kCChild, NS_CHILD_CID); + + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); + +class nsWidgetFactory : public nsIFactory +{ +public: + + NS_DECL_ISUPPORTS + + // nsIFactory methods + NS_IMETHOD CreateInstance(nsISupports *aOuter, + const nsIID &aIID, + void **aResult); + + NS_IMETHOD LockFactory(PRBool aLock); + + nsWidgetFactory(); + ~nsWidgetFactory(); + +}; + + + +nsWidgetFactory::nsWidgetFactory() +{ +} + +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) + +nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter, + const nsIID &aIID, + void **aResult) +{ + if (aResult == NULL) { + return NS_ERROR_NULL_POINTER; + } + + *aResult = NULL; + + if (nsnull != aOuter && !aIID.Equals(kISupportsIID)) { + // aggregation with IID != nsISupports + return NS_ERROR_ILLEGAL_VALUE; + } + + nsIWidget *inst = nsnull; + if (aIID.Equals(kCWindow)) { + inst = (nsIWidget*)new nsWindow(aOuter); + } + else if (aIID.Equals(kIWidget)) { + inst = (nsIWidget*)new nsWindow(aOuter); + } + else if (aIID.Equals(kCChild)) { + inst = (nsIWidget*)new ChildWindow(aOuter); + } + + if (inst == NULL) { + return NS_ERROR_OUT_OF_MEMORY; + } + + + nsresult res = inst->QueryInterface(aIID, aResult); + + if (res != NS_OK) { + delete inst ; + } + + return res; + + return NS_OK; +} + +nsresult nsWidgetFactory::LockFactory(PRBool aLock) +{ + // Not implemented in simplest case. + return NS_OK; +} + +// return the proper factory to the caller +extern "C" NS_WIDGET nsresult NSGetFactory(const nsCID &aClass, nsIFactory **aFactory) +{ + if (nsnull == aFactory) { + return NS_ERROR_NULL_POINTER; + } + + *aFactory = new nsWidgetFactory(); + + if (nsnull == aFactory) { + return NS_ERROR_OUT_OF_MEMORY; + } + + return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory); +} + + diff --git a/widget/src/motif/nsWindow.cpp b/widget/src/motif/nsWindow.cpp new file mode 100644 index 00000000000..c5092da207f --- /dev/null +++ b/widget/src/motif/nsWindow.cpp @@ -0,0 +1,675 @@ +/* -*- 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 "nsWindow.h" +#include "nsIFontMetrics.h" +#include "nsIFontCache.h" +#include "nsGUIEvent.h" +#include "nsIRenderingContext.h" +#include "nsIDeviceContext.h" +#include "nsRect.h" +#include "nsTransform2D.h" +#include "nsGfxCIID.h" + +#include "nsXtEventHandler.h" + +#include "Xm/Xm.h" +#include "Xm/MainW.h" +#include "Xm/Frame.h" +#include "Xm/XmStrDefs.h" +#include "Xm/DrawingA.h" + +#include "stdio.h" + +static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); + +NS_IMPL_QUERY_INTERFACE(nsWindow, kIWidgetIID) +NS_IMPL_ADDREF(nsWindow) +NS_IMPL_RELEASE(nsWindow) + +void nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) +{ +} + +void nsWindow::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect) +{ +} + +//------------------------------------------------------------------------- +// +// Setup initial tooltip rectangles +// +//------------------------------------------------------------------------- + +void nsWindow::SetTooltips(PRUint32 aNumberOfTips,const nsRect* aTooltipAreas) +{ +} + +//------------------------------------------------------------------------- +// +// Update all tooltip rectangles +// +//------------------------------------------------------------------------- + +void nsWindow::UpdateTooltips(const nsRect* aNewTips) +{ +} + +//------------------------------------------------------------------------- +// +// Remove all tooltip rectangles +// +//------------------------------------------------------------------------- + +void nsWindow::RemoveTooltips() +{ +} + + +//------------------------------------------------------------------------- +// +// nsWindow constructor +// +//------------------------------------------------------------------------- +nsWindow::nsWindow(nsISupports *aOuter) +{ + // XXX Til can deal with ColorMaps! + SetForegroundColor(1); + SetBackgroundColor(2); +} + + +//------------------------------------------------------------------------- +// +// nsWindow destructor +// +//------------------------------------------------------------------------- +nsWindow::~nsWindow() +{ +} + + + +//------------------------------------------------------------------------- +// +// Create the proper widget +// +//------------------------------------------------------------------------- +void nsWindow::Create(nsIWidget *aParent, + const nsRect &aRect, + EVENT_CALLBACK aHandleEventFunction, + nsIDeviceContext *aContext, + nsIToolkit *aToolkit, + void *aInitData) +{ + + Widget mainWindow, frame; + Widget parentWidget; + + if (nsnull == mToolkit) { + if (nsnull != aToolkit) { + mToolkit = (nsToolkit*)aToolkit; + mToolkit->AddRef(); + } + else { + if (nsnull != aParent) { + mToolkit = (nsToolkit*)(aParent->GetToolkit()); // the call AddRef's, we don't have to + } + // it's some top level window with no toolkit passed in. + // Create a default toolkit with the current thread + else { + mToolkit = new nsToolkit(); + mToolkit->AddRef(); + mToolkit->Init(PR_GetCurrentThread()); + } + } + + } + + // save the event callback function + mEventCallback = aHandleEventFunction; + + // keep a reference to the toolkit object + if (aContext) { + mContext = aContext; + mContext->AddRef(); + } + else { + nsresult res; + + static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID); + static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID); + + res = NSRepository::CreateInstance(kDeviceContextCID, + nsnull, + kDeviceContextIID, + (void **)&mContext); + + if (NS_OK == res) + mContext->Init(); + } + + if (aParent) + parentWidget = (Widget) aParent->GetNativeData(NS_NATIVE_WIDGET); + else + parentWidget = (Widget) aInitData ; + + if (!aParent) + mainWindow = ::XtVaCreateManagedWidget("mainWindow", + xmMainWindowWidgetClass, + parentWidget, + XmNwidth, aRect.width, + XmNheight, aRect.height, + nsnull); + + frame = ::XtVaCreateManagedWidget("frame", + xmDrawingAreaWidgetClass, + (aParent) ? parentWidget : mainWindow, + XmNwidth, aRect.width, + XmNheight, aRect.height, + nsnull); + + if (!aParent) + XmMainWindowSetAreas (mainWindow, nsnull, nsnull, nsnull, nsnull, frame); + + mWidget = frame ; + + if (aParent) { + aParent->AddChild(this); + } + + // setup the event Handlers + XtAddEventHandler(mWidget, + ExposureMask, + PR_FALSE, + nsXtWidget_ExposureMask_EventHandler, + this); + + XtAddEventHandler(mWidget, + ButtonPressMask, + PR_FALSE, + nsXtWidget_ButtonPressMask_EventHandler, + this); + + XtAddEventHandler(mWidget, + ButtonReleaseMask, + PR_FALSE, + nsXtWidget_ButtonReleaseMask_EventHandler, + this); + + XtAddEventHandler(mWidget, + ButtonMotionMask, + PR_FALSE, + nsXtWidget_ButtonMotionMask_EventHandler, + this); + + + // Force cursor to default setting + mCursor = eCursor_select; + SetCursor(eCursor_standard); + +} + + +//------------------------------------------------------------------------- +// +// create with a native parent +// +//------------------------------------------------------------------------- +void nsWindow::Create(nsNativeWindow aParent, + const nsRect &aRect, + EVENT_CALLBACK aHandleEventFunction, + nsIDeviceContext *aContext, + nsIToolkit *aToolkit, + void *aInitData) +{ +} + + +//------------------------------------------------------------------------- +// +// Close this nsWindow +// +//------------------------------------------------------------------------- +void nsWindow::Destroy() +{ +} + + +//------------------------------------------------------------------------- +// +// Get this nsWindow parent +// +//------------------------------------------------------------------------- +nsIWidget* nsWindow::GetParent(void) +{ + return nsnull; +} + + +//------------------------------------------------------------------------- +// +// Get this nsWindow's list of children +// +//------------------------------------------------------------------------- +nsIEnumerator* nsWindow::GetChildren() +{ + return nsnull; +} + + +//------------------------------------------------------------------------- +// +// Add a child to the list of children +// +//------------------------------------------------------------------------- +void nsWindow::AddChild(nsIWidget* aChild) +{ +} + + +//------------------------------------------------------------------------- +// +// Remove a child from the list of children +// +//------------------------------------------------------------------------- +void nsWindow::RemoveChild(nsIWidget* aChild) +{ +} + + +//------------------------------------------------------------------------- +// +// Hide or show this component +// +//------------------------------------------------------------------------- +void nsWindow::Show(PRBool bState) +{ +} + +//------------------------------------------------------------------------- +// +// Move this component +// +//------------------------------------------------------------------------- +void nsWindow::Move(PRUint32 aX, PRUint32 aY) +{ +} + +//------------------------------------------------------------------------- +// +// Resize this component +// +//------------------------------------------------------------------------- +void nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight) +{ +} + + +//------------------------------------------------------------------------- +// +// Resize this component +// +//------------------------------------------------------------------------- +void nsWindow::Resize(PRUint32 aX, PRUint32 aY, PRUint32 aWidth, PRUint32 aHeight) +{ +} + + +//------------------------------------------------------------------------- +// +// Enable/disable this component +// +//------------------------------------------------------------------------- +void nsWindow::Enable(PRBool bState) +{ +} + + +//------------------------------------------------------------------------- +// +// Give the focus to this component +// +//------------------------------------------------------------------------- +void nsWindow::SetFocus(void) +{ +} + + +//------------------------------------------------------------------------- +// +// Get this component dimension +// +//------------------------------------------------------------------------- +void nsWindow::GetBounds(nsRect &aRect) +{ + XWindowAttributes attrs ; + + Display * d = ::XtDisplay(mWidget); + Window w = ::XtWindow(mWidget); + + XGetWindowAttributes(d, w, &attrs); + + aRect.x = attrs.x ; + aRect.y = attrs.y ; + aRect.width = attrs.width ; + aRect.height = attrs.height; + +} + + +//------------------------------------------------------------------------- +// +// Get the foreground color +// +//------------------------------------------------------------------------- +nscolor nsWindow::GetForegroundColor(void) +{ + return (mForeground); +} + + +//------------------------------------------------------------------------- +// +// Set the foreground color +// +//------------------------------------------------------------------------- +void nsWindow::SetForegroundColor(const nscolor &aColor) +{ + mForeground = aColor; +} + + +//------------------------------------------------------------------------- +// +// Get the background color +// +//------------------------------------------------------------------------- +nscolor nsWindow::GetBackgroundColor(void) +{ + return (mBackground); +} + + +//------------------------------------------------------------------------- +// +// Set the background color +// +//------------------------------------------------------------------------- +void nsWindow::SetBackgroundColor(const nscolor &aColor) +{ + mBackground = aColor ; +} + + +//------------------------------------------------------------------------- +// +// Get this component font +// +//------------------------------------------------------------------------- +nsIFontMetrics* nsWindow::GetFont(void) +{ + NS_NOTYETIMPLEMENTED("GetFont not yet implemented"); // to be implemented + return nsnull; +} + + +//------------------------------------------------------------------------- +// +// Set this component font +// +//------------------------------------------------------------------------- +void nsWindow::SetFont(const nsFont &aFont) +{ +} + + +//------------------------------------------------------------------------- +// +// Get this component cursor +// +//------------------------------------------------------------------------- +nsCursor nsWindow::GetCursor() +{ +} + + +//------------------------------------------------------------------------- +// +// Set this component cursor +// +//------------------------------------------------------------------------- + +void nsWindow::SetCursor(nsCursor aCursor) +{ +} + +//------------------------------------------------------------------------- +// +// Invalidate this component visible area +// +//------------------------------------------------------------------------- +void nsWindow::Invalidate(PRBool aIsSynchronous) +{ +} + + +//------------------------------------------------------------------------- +// +// Return some native data according to aDataType +// +//------------------------------------------------------------------------- +void* nsWindow::GetNativeData(PRUint32 aDataType) +{ + switch(aDataType) { + + case NS_NATIVE_WINDOW: + { + return (void*)XtWindow(mWidget); + } + break; + case NS_NATIVE_WIDGET: + { + return (void*)(mWidget); + } + break; + case NS_NATIVE_DISPLAY: + { + return (void*)(XtDisplay(mWidget)); + } + break; + case NS_NATIVE_GRAPHIC: + { + XGCValues values; + GC aGC; + + aGC= ::XtGetGC(mWidget, + nsnull, + &values); + + return (void*)aGC; + } + break; + case NS_NATIVE_COLORMAP: + default: + break; + } + + return NULL; + +} + + +//------------------------------------------------------------------------- +// +// Create a rendering context from this nsWindow +// +//------------------------------------------------------------------------- +nsIRenderingContext* nsWindow::GetRenderingContext() +{ + return nsnull ; +} + +//------------------------------------------------------------------------- +// +// Return the toolkit this widget was created on +// +//------------------------------------------------------------------------- +nsIToolkit* nsWindow::GetToolkit() +{ +} + + +//------------------------------------------------------------------------- +// +// Set the colormap of the window +// +//------------------------------------------------------------------------- +void nsWindow::SetColorMap(nsColorMap *aColorMap) +{ +} + +//------------------------------------------------------------------------- +// +// Return the used device context +// +//------------------------------------------------------------------------- +nsIDeviceContext* nsWindow::GetDeviceContext() +{ +} + + +//------------------------------------------------------------------------- +// +// Scroll the bits of a window +// +//------------------------------------------------------------------------- +void nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) +{ +} + + + + + +void nsWindow::SetBorderStyle(nsBorderStyle aBorderStyle) +{ +} + +void nsWindow::SetTitle(const nsString& aTitle) +{ +} + + +/** + * Processes a mouse pressed event + * + **/ +void nsWindow::AddMouseListener(nsIMouseListener * aListener) +{ +} + +/** + * Processes a mouse pressed event + * + **/ +void nsWindow::AddEventListener(nsIEventListener * aListener) +{ +} + +PRBool nsWindow::ConvertStatus(nsEventStatus aStatus) +{ + switch(aStatus) { + case nsEventStatus_eIgnore: + return(PR_FALSE); + break; + case nsEventStatus_eConsumeNoDefault: + return(PR_TRUE); + break; + case nsEventStatus_eConsumeDoDefault: + return(PR_FALSE); + break; + default: + NS_ASSERTION(0, "Illegal nsEventStatus enumeration value"); + return(PR_FALSE); + break; + } +} + +//------------------------------------------------------------------------- +// +// Invokes callback and ProcessEvent method on Event Listener object +// +//------------------------------------------------------------------------- + +PRBool nsWindow::DispatchEvent(nsGUIEvent* event) +{ + PRBool result = PR_FALSE; + + if (nsnull != mEventCallback) { + result = ConvertStatus((*mEventCallback)(event)); + } + + // Dispatch to event listener if event was not consumed + if ((result != PR_TRUE) && (nsnull != mEventListener)) { + return ConvertStatus(mEventListener->ProcessEvent(*event)); + } + else { + return(result); + } +} + +/** + * Processes an Expose Event + * + **/ +void nsWindow::OnPaint(nsPaintEvent &event) +{ + nsresult result ; + + // call the event callback + if (mEventCallback) { + + nsRect rr ; + + GetBounds(rr); + + event.rect = &rr; + + static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID); + static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID); + + if (NS_OK == NSRepository::CreateInstance(kRenderingContextCID, + nsnull, + kRenderingContextIID, + (void **)&event.renderingContext)) + { + event.renderingContext->Init(mContext, this); + result = DispatchEvent(&event); + NS_RELEASE(event.renderingContext); + } + else + result = PR_FALSE; + } + +} + + + + + diff --git a/widget/src/motif/nsWindow.h b/widget/src/motif/nsWindow.h new file mode 100644 index 00000000000..977af4a07ae --- /dev/null +++ b/widget/src/motif/nsWindow.h @@ -0,0 +1,313 @@ +/* -*- 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. + */ +#ifndef Window_h__ +#define Window_h__ + +#include "nsToolkit.h" + +#include "nsIWidget.h" +#include "nsIEnumerator.h" + +#include "nsIMouseListener.h" +#include "nsIEventListener.h" +#include "nsString.h" + +#include "Xm/Xm.h" + +#define NSRGB_2_COLOREF(color) \ + RGB(NS_GET_R(color),NS_GET_G(color),NS_GET_B(color)) + + +/** + * Native WIN32 window wrapper. + */ + +class nsWindow : public nsIWidget +{ + +public: + nsWindow(nsISupports *aOuter); + virtual ~nsWindow(); + + NS_DECL_ISUPPORTS + + // nsIWidget interface + virtual void Create(nsIWidget *aParent, + const nsRect &aRect, + EVENT_CALLBACK aHandleEventFunction, + nsIDeviceContext *aContext, + nsIToolkit *aToolkit = nsnull, + void *aInitData = nsnull); + virtual void Create(nsNativeWindow aParent, + const nsRect &aRect, + EVENT_CALLBACK aHandleEventFunction, + nsIDeviceContext *aContext, + nsIToolkit *aToolkit = nsnull, + void *aInitData = nsnull); + virtual void Destroy(); + virtual nsIWidget* GetParent(void); + virtual nsIEnumerator* GetChildren(); + virtual void AddChild(nsIWidget* aChild); + virtual void RemoveChild(nsIWidget* aChild); + virtual void Show(PRBool bState); + virtual void Move(PRUint32 aX, PRUint32 aY); + virtual void Resize(PRUint32 aWidth, + PRUint32 aHeight); + virtual void Resize(PRUint32 aX, + PRUint32 aY, + PRUint32 aWidth, + PRUint32 aHeight); + virtual void Enable(PRBool bState); + virtual void SetFocus(void); + virtual void GetBounds(nsRect &aRect); + virtual nscolor GetForegroundColor(void); + virtual void SetForegroundColor(const nscolor &aColor); + virtual nscolor GetBackgroundColor(void); + virtual void SetBackgroundColor(const nscolor &aColor); + virtual nsIFontMetrics* GetFont(void); + virtual void SetFont(const nsFont &aFont); + virtual nsCursor GetCursor(); + virtual void SetCursor(nsCursor aCursor); + virtual void Invalidate(PRBool aIsSynchronous); + virtual void* GetNativeData(PRUint32 aDataType); + virtual nsIRenderingContext* GetRenderingContext(); + virtual void SetColorMap(nsColorMap *aColorMap); + virtual nsIDeviceContext* GetDeviceContext(); + virtual void Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect); + virtual nsIToolkit* GetToolkit(); + virtual void SetBorderStyle(nsBorderStyle aBorderStyle); + virtual void SetTitle(const nsString& aTitle); + virtual void SetTooltips(PRUint32 aNumberOfTips,const nsRect* aTooltipAreas); + virtual void RemoveTooltips(); + virtual void UpdateTooltips(const nsRect* aNewTips); + virtual void WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect); + virtual void ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect); + virtual void AddMouseListener(nsIMouseListener * aListener); + virtual void AddEventListener(nsIEventListener * aListener); + virtual void OnPaint(nsPaintEvent &event); + PRBool DispatchEvent(nsGUIEvent* event); + static PRBool ConvertStatus(nsEventStatus aStatus); + +private: + Widget mWidget; + GC mGC ; + EVENT_CALLBACK mEventCallback; + nsIDeviceContext *mContext; + nsIFontMetrics *mFontMetrics; + nsToolkit *mToolkit; + + nsIMouseListener * mMouseListener; + nsIEventListener * mEventListener; + + nscolor mBackground; + nscolor mForeground; + nsCursor mCursor; + nsBorderStyle mBorderStyle; + +}; + +// +// A child window is a window with different style +// +class ChildWindow : public nsWindow { + +public: + ChildWindow(nsISupports *aOuter) : nsWindow(aOuter) {} + +}; + +#define BASE_IWIDGET_IMPL BASE_INITIALIZE_IMPL BASE_WINDOWS_METHODS + + +#define BASE_INITIALIZE_IMPL \ + void Create(nsIWidget *aParent, \ + const nsRect &aRect, \ + EVENT_CALLBACK aHandleEventFunction, \ + nsIDeviceContext *aContext, \ + nsIToolkit *aToolkit = nsnull, \ + void *aInitData = nsnull) \ + { \ + nsWindow::Create(aParent, aRect, aHandleEventFunction, aContext, aToolkit, aInitData); \ + } \ + +#define BASE_WINDOWS_METHODS \ + void Create(nsNativeWindow aParent, \ + const nsRect &aRect, \ + EVENT_CALLBACK aHandleEventFunction, \ + nsIDeviceContext *aContext, \ + nsIToolkit *aToolkit = nsnull, \ + void *aInitData = nsnull) \ + { \ + nsWindow::Create(aParent, aRect, aHandleEventFunction, aContext, aToolkit, aInitData); \ + } \ + void Destroy(void) \ + { \ + nsWindow::Destroy(); \ + } \ + nsIWidget* GetParent(void) \ + { \ + return nsWindow::GetParent(); \ + } \ + nsIEnumerator* GetChildren(void) \ + { \ + return nsWindow::GetChildren(); \ + } \ + void AddChild(nsIWidget* aChild) \ + { \ + nsWindow::AddChild(aChild); \ + } \ + void RemoveChild(nsIWidget* aChild) \ + { \ + nsWindow::RemoveChild(aChild); \ + } \ + void Show(PRBool bState) \ + { \ + nsWindow::Show(bState); \ + } \ + void Move(PRUint32 aX, PRUint32 aY) \ + { \ + nsWindow::Move(aX, aY); \ + } \ + void Resize(PRUint32 aWidth, \ + PRUint32 aHeight) \ + { \ + nsWindow::Resize(aWidth, aHeight); \ + } \ + void Resize(PRUint32 aX, \ + PRUint32 aY, \ + PRUint32 aWidth, \ + PRUint32 aHeight) \ + { \ + nsWindow::Resize(aX, aY, aWidth, aHeight); \ + } \ + void Enable(PRBool bState) \ + { \ + nsWindow::Enable(bState); \ + } \ + void SetFocus(void) \ + { \ + nsWindow::SetFocus(); \ + } \ + void GetBounds(nsRect &aRect) \ + { \ + nsWindow::GetBounds(aRect); \ + } \ + nscolor GetForegroundColor(void) \ + { \ + return nsWindow::GetForegroundColor(); \ + } \ + void SetForegroundColor(const nscolor &aColor) \ + { \ + nsWindow::SetForegroundColor(aColor); \ + } \ + nscolor GetBackgroundColor(void) \ + { \ + return nsWindow::GetBackgroundColor(); \ + } \ + void SetBackgroundColor(const nscolor &aColor) \ + { \ + nsWindow::SetBackgroundColor(aColor); \ + } \ + nsIFontMetrics* GetFont(void) \ + { \ + return nsWindow::GetFont(); \ + } \ + void SetFont(const nsFont &aFont) \ + { \ + nsWindow::SetFont(aFont); \ + } \ + nsCursor GetCursor() \ + { \ + return nsWindow::GetCursor(); \ + } \ + void SetCursor(nsCursor aCursor) \ + { \ + nsWindow::SetCursor(aCursor); \ + } \ + void Invalidate(PRBool aIsSynchronous) \ + { \ + nsWindow::Invalidate(aIsSynchronous); \ + } \ + void* GetNativeData(PRUint32 aDataType) \ + { \ + return nsWindow::GetNativeData(aDataType); \ + } \ + nsIRenderingContext* GetRenderingContext() \ + { \ + return nsWindow::GetRenderingContext(); \ + } \ + nsIDeviceContext* GetDeviceContext() \ + { \ + return nsWindow::GetDeviceContext(); \ + } \ + void Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) \ + { \ + nsWindow::Scroll(aDx, aDy, aClipRect); \ + } \ + nsIToolkit* GetToolkit() \ + { \ + return nsWindow::GetToolkit(); \ + } \ + void SetColorMap(nsColorMap *aColorMap) \ + { \ + nsWindow::SetColorMap(aColorMap); \ + } \ + void AddMouseListener(nsIMouseListener * aListener) \ + { \ + nsWindow::AddMouseListener(aListener); \ + } \ + void AddEventListener(nsIEventListener * aListener) \ + { \ + nsWindow::AddEventListener(aListener); \ + } \ + PRBool OnKey(PRUint32 aEventType, PRUint32 aKeyCode) \ + { \ + return nsWindow::OnKey(aEventType, aKeyCode); \ + } \ + void SetBorderStyle(nsBorderStyle aBorderStyle) \ + { \ + nsWindow::SetBorderStyle(aBorderStyle); \ + } \ + void SetTitle(const nsString& aTitle) \ + { \ + nsWindow::SetTitle(aTitle); \ + } \ + void SetTooltips(PRUint32 aNumberOfTips,const nsRect* aTooltipAreas) \ + { \ + nsWindow::SetTooltips(aNumberOfTips, aTooltipAreas); \ + } \ + void UpdateTooltips(const nsRect* aNewTips) \ + { \ + nsWindow::UpdateTooltips(aNewTips); \ + } \ + void RemoveTooltips() \ + { \ + nsWindow::RemoveTooltips(); \ + } \ + void WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect) \ + { \ + nsWindow::WidgetToScreen(aOldRect, aNewRect); \ + } \ + void ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect) \ + { \ + nsWindow::ScreenToWidget(aOldRect, aNewRect); \ + } + + + +#endif // Window_h__ diff --git a/widget/src/motif/nsXtEventHandler.cpp b/widget/src/motif/nsXtEventHandler.cpp new file mode 100644 index 00000000000..37fc1f61024 --- /dev/null +++ b/widget/src/motif/nsXtEventHandler.cpp @@ -0,0 +1,62 @@ +/* -*- 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 "Xm/Xm.h" +#include "nsXtEventHandler.h" + +#include "nsWindow.h" + +#include "stdio.h" + +void nsXtWidget_ExposureMask_EventHandler(Widget w, caddr_t client_data, XEvent * event) +{ + nsPaintEvent pevent ; + nsWindow * widgetWindow = (nsWindow *) client_data ; + + if (event->xexpose.count != 0) + return ; + + pevent.widget = widgetWindow; + + pevent.point.x = event->xbutton.x; + pevent.point.y = event->xbutton.y; + + pevent.time = 0; // XXX TBD... + pevent.message = NS_PAINT ; + + widgetWindow->OnPaint(pevent); + +} + +void nsXtWidget_ButtonPressMask_EventHandler(Widget w, caddr_t client_data, XEvent * event) +{ + nsWindow * widgetWindow = (nsWindow *) client_data ; +} + +void nsXtWidget_ButtonReleaseMask_EventHandler(Widget w, caddr_t client_data, XEvent * event) +{ + nsWindow * widgetWindow = (nsWindow *) client_data ; +} + +void nsXtWidget_ButtonMotionMask_EventHandler(Widget w, caddr_t client_data, XEvent * event) +{ + nsWindow * widgetWindow = (nsWindow *) client_data ; +} + + + diff --git a/widget/src/motif/nsXtEventHandler.h b/widget/src/motif/nsXtEventHandler.h new file mode 100644 index 00000000000..e304fbafe1f --- /dev/null +++ b/widget/src/motif/nsXtEventHandler.h @@ -0,0 +1,34 @@ +/* -*- 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. + */ + +#ifndef __nsXtEventHandler_h +#define __nsXtEventHandler_h + +#include "Xm/Xm.h" + +void nsXtWidget_ExposureMask_EventHandler(Widget w, caddr_t client_data, XEvent * event); +void nsXtWidget_ButtonPressMask_EventHandler(Widget w, caddr_t client_data, XEvent * event); +void nsXtWidget_ButtonReleaseMask_EventHandler(Widget w, caddr_t client_data, XEvent * event); +void nsXtWidget_ButtonMotionMask_EventHandler(Widget w, caddr_t client_data, XEvent * event); + +#endif // __nsXtEventHandler.h + + + + +