From 0420f51df248b1ad64183e2e9d5841548b5cbaa5 Mon Sep 17 00:00:00 2001 From: "dcone%netscape.com" Date: Mon, 22 Feb 1999 15:00:59 +0000 Subject: [PATCH] Added fixes to get it to compile under UNIX --- gfx/src/ps/nsDeviceContextPS.cpp | 7 ++++++ gfx/src/ps/nsDeviceContextPS.h | 19 ++++++++++++--- gfx/src/ps/nsPostScriptObj.h | 6 ++--- gfx/src/ps/nsRenderingContextPS.cpp | 36 +++++++++++++++++++---------- gfx/src/ps/nsRenderingContextPS.h | 2 +- 5 files changed, 51 insertions(+), 19 deletions(-) diff --git a/gfx/src/ps/nsDeviceContextPS.cpp b/gfx/src/ps/nsDeviceContextPS.cpp index b8d5e9cccacd..7a22252ee31c 100644 --- a/gfx/src/ps/nsDeviceContextPS.cpp +++ b/gfx/src/ps/nsDeviceContextPS.cpp @@ -54,9 +54,16 @@ PRInt32 i, n; NS_RELEASE(fm); } mFontMetrics.Clear(); + NS_IF_RELEASE(mSpec); } +void nsDeviceContextPS :: SetSpec(nsIDeviceContextSpec* aSpec) +{ + mSpec = aSpec; + NS_ADDREF(aSpec); +} + NS_IMPL_QUERY_INTERFACE(nsDeviceContextPS, kDeviceContextIID) NS_IMPL_ADDREF(nsDeviceContextPS) NS_IMPL_RELEASE(nsDeviceContextPS) diff --git a/gfx/src/ps/nsDeviceContextPS.h b/gfx/src/ps/nsDeviceContextPS.h index 0a4e72cb46b8..3455f95e7f93 100644 --- a/gfx/src/ps/nsDeviceContextPS.h +++ b/gfx/src/ps/nsDeviceContextPS.h @@ -19,7 +19,12 @@ #ifndef nsDeviceContextPS_h___ #define nsDeviceContextPS_h___ +#define WINTEST + +#ifdef WINTEST #include +#endif + #include "nsDeviceContext.h" #include "nsUnitConversion.h" #include "nsIWidget.h" @@ -42,7 +47,11 @@ public: * with a NativeWidget. * @update 12/21/98 dwc */ - NS_IMETHOD Init(nsIDeviceContext *aCreatingDeviceContext,nsIDeviceContext *aPrinterContext, HDC aTheDC); +#ifdef WINTEST + NS_IMETHOD Init(nsIDeviceContext *aCreatingDeviceContext,nsIDeviceContext *aPrinterContext, HDC aTheDC); +#else + NS_IMETHOD Init(nsIDeviceContext *aCreatingDeviceContext,nsIDeviceContext *aPrinterContext); +#endif NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext); NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets); @@ -54,7 +63,6 @@ public: NS_IMETHOD CheckFontExistence(const nsString& aFontName); - //NS_IMETHOD CreateILColorSpace(IL_ColorSpace*& aColorSpace); NS_IMETHODIMP GetILColorSpace(IL_ColorSpace*& aColorSpace); NS_IMETHOD GetDepth(PRUint32& aDepth); NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel); @@ -72,6 +80,8 @@ public: NS_IMETHOD BeginPage(void); NS_IMETHOD EndPage(void); + virtual void SetSpec(nsIDeviceContextSpec *aSpec); + protected: virtual ~nsDeviceContextPS(); @@ -86,10 +96,13 @@ public: //static bool GetMacFontNumber(const nsString& aFontName, short &fontNum); nsPostScriptObj* GetPrintContext() { return mPSObj; } +#ifdef WINTEST public: HDC mDC; // this is temporary!!! +#endif -friend nsDeviceContextWin; // need to be a friend of the class using us. + +//friend nsDeviceContextWin; // need to be a friend of the class using us. }; #endif /* nsDeviceContextPS_h___ */ diff --git a/gfx/src/ps/nsPostScriptObj.h b/gfx/src/ps/nsPostScriptObj.h index c94c67076e7d..3d99de935415 100644 --- a/gfx/src/ps/nsPostScriptObj.h +++ b/gfx/src/ps/nsPostScriptObj.h @@ -25,8 +25,8 @@ #include "xp_file.h" #include "ntypes.h" #include "net.h" -#include "nscolor.h" -#include "nscoord.h" +#include "nsColor.h" +#include "nsCoord.h" class nsIImage; @@ -388,4 +388,4 @@ private: -#endif \ No newline at end of file +#endif diff --git a/gfx/src/ps/nsRenderingContextPS.cpp b/gfx/src/ps/nsRenderingContextPS.cpp index 8e422ecae93e..0be5f499d615 100644 --- a/gfx/src/ps/nsRenderingContextPS.cpp +++ b/gfx/src/ps/nsRenderingContextPS.cpp @@ -69,7 +69,7 @@ PS_State :: PS_State() mLocalClip.x = mLocalClip.y = mLocalClip.width = mLocalClip.height = 0; mFontMetrics = nsnull; mCurrentColor = NS_RGB(0, 0, 0); - mTextColor = RGB(0, 0, 0); + mTextColor = NS_RGB(0, 0, 0); mLineStyle = nsLineStyle_kSolid; } @@ -347,7 +347,9 @@ NS_IMETHODIMP nsRenderingContextPS :: IsVisibleRect(const nsRect& aRect, PRBool NS_IMETHODIMP nsRenderingContextPS :: SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty) { nsRect trect = aRect; +#ifdef XP_PC int cliptype; +#endif mStates->mLocalClip = aRect; @@ -384,10 +386,12 @@ int cliptype; NS_ASSERTION(FALSE, "illegal clip combination"); } +#ifdef XP_PC if (cliptype == NULLREGION) aClipEmpty = PR_TRUE; else aClipEmpty = PR_FALSE; +#endif return NS_OK; } @@ -600,14 +604,14 @@ nsRenderingContextPS :: DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints { const nsPoint* np; -POINT pp; +nsPoint pp; // First transform nsPoint's into POINT's; perform coordinate space // transformation at the same time np = &aPoints[0]; - pp.x = np->x; - pp.y = np->y; + pp.x = np->x; + pp.y = np->y; mTMatrix->TransformCoord((int*)&pp.x,(int*)&pp.y); mPSObj->moveto_loc(NS_PIXELS_TO_POINTS(pp.x),NS_PIXELS_TO_POINTS(pp.y)); np++; @@ -709,7 +713,7 @@ NS_IMETHODIMP nsRenderingContextPS :: DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) { const nsPoint* np; -POINT pp; +nsPoint pp; mPSObj->newpath(); @@ -745,7 +749,7 @@ NS_IMETHODIMP nsRenderingContextPS :: FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) { const nsPoint* np; -POINT pp; +nsPoint pp; mPSObj->newpath(); @@ -942,6 +946,7 @@ nsRenderingContextPS :: GetWidth(const char* aString, nscoord& aWidth) NS_IMETHODIMP nsRenderingContextPS :: GetWidth(const char* aString,PRUint32 aLength,nscoord& aWidth) { +#if XP_PC if (nsnull != mFontMetrics){ SIZE size; @@ -956,6 +961,9 @@ nsRenderingContextPS :: GetWidth(const char* aString,PRUint32 aLength,nscoord& a } else return NS_ERROR_FAILURE; +#else + return NS_OK; +#endif } /** --------------------------------------------------- @@ -975,6 +983,7 @@ nsRenderingContextPS :: GetWidth(const nsString& aString, nscoord& aWidth, PRInt NS_IMETHODIMP nsRenderingContextPS :: GetWidth(const PRUnichar *aString,PRUint32 aLength,nscoord &aWidth, PRInt32 *aFontID) { +#ifdef XP_PC if (nsnull != mFontMetrics){ SIZE size; @@ -992,6 +1001,9 @@ nsRenderingContextPS :: GetWidth(const PRUnichar *aString,PRUint32 aLength,nscoo } else return NS_ERROR_FAILURE; +#else + return NS_OK; +#endif } /** --------------------------------------------------- @@ -1007,13 +1019,12 @@ PRInt32 x = aX; PRInt32 y = aY; SetupFontAndColor(); - - INT dxMem[500]; - INT* dx0; + PRInt32 dxMem[500]; + PRInt32* dx0 = 0; if (nsnull != aSpacing) { dx0 = dxMem; if (aLength > 500) { - dx0 = new INT[aLength]; + dx0 = new PRInt32[aLength]; } mTMatrix->ScaleXCoords(aSpacing, aLength, dx0); } @@ -1204,11 +1215,11 @@ NS_IMETHODIMP nsRenderingContextPS :: CopyOffScreenBits(nsDrawingSurface aSrcSur void nsRenderingContextPS :: SetupFontAndColor(void) { +#ifdef XP_PC nscoord fontHeight = 0; nsFont *font; nsFontHandle fontHandle; // WINDOWS ONLY - mFontMetrics->GetHeight(fontHeight); mFontMetrics->GetFont(font); @@ -1222,6 +1233,7 @@ nsFontHandle fontHandle; // WINDOWS ONLY mStates->mFontMetrics = mFontMetrics; mPSObj->setscriptfont(fontHeight,font->style,font->variant,font->weight,font->decorations); +#endif } @@ -1308,4 +1320,4 @@ nsRenderingContextPS::SetColor(const nsString& aColor) } return NS_OK; } -#endif \ No newline at end of file +#endif diff --git a/gfx/src/ps/nsRenderingContextPS.h b/gfx/src/ps/nsRenderingContextPS.h index 25a32cca4a1b..ae89fb47e783 100644 --- a/gfx/src/ps/nsRenderingContextPS.h +++ b/gfx/src/ps/nsRenderingContextPS.h @@ -42,7 +42,7 @@ class nsRenderingContextPS : public nsIRenderingContext { public: nsRenderingContextPS(); - ~nsRenderingContextPS(); + virtual ~nsRenderingContextPS(); void* operator new(size_t sz) { void* rv = new char[sz];