From 04db137aab39fb53a3adcb4e1cea0eec10f2f9a6 Mon Sep 17 00:00:00 2001 From: "cls%seawood.org" Date: Sat, 13 May 2000 05:38:50 +0000 Subject: [PATCH] Vain attempt to make the xlib toolkit work. Switched nsRenderingContextXlib to use nsRenderingContextImpl. Filled in some missing functions. --- gfx/src/xlib/nsDeviceContextXlib.cpp | 12 ++++++++++ gfx/src/xlib/nsDeviceContextXlib.h | 5 ++--- gfx/src/xlib/nsFontMetricsXlib.cpp | 30 +++++++++++++++++++++++++ gfx/src/xlib/nsFontMetricsXlib.h | 4 ++++ gfx/src/xlib/nsRenderingContextXlib.cpp | 29 ++++++++++++++++++++++++ gfx/src/xlib/nsRenderingContextXlib.h | 13 +++++++++-- 6 files changed, 88 insertions(+), 5 deletions(-) diff --git a/gfx/src/xlib/nsDeviceContextXlib.cpp b/gfx/src/xlib/nsDeviceContextXlib.cpp index b7b5fb456a8..b586df3d1ee 100644 --- a/gfx/src/xlib/nsDeviceContextXlib.cpp +++ b/gfx/src/xlib/nsDeviceContextXlib.cpp @@ -367,6 +367,18 @@ NS_IMETHODIMP nsDeviceContextXlib::GetDeviceSurfaceDimensions(PRInt32 &aWidth, P return NS_OK; } +NS_IMETHODIMP nsDeviceContextXlib::GetRect(nsRect &aRect) +{ + PRInt32 width, height; + nsresult rv; + rv = GetDeviceSurfaceDimensions(width, height); + aRect.x = 0; + aRect.y = 0; + aRect.width = width; + aRect.height = height; + return rv; +} + NS_IMETHODIMP nsDeviceContextXlib::GetClientRect(nsRect &aRect) { PRInt32 width, height; diff --git a/gfx/src/xlib/nsDeviceContextXlib.h b/gfx/src/xlib/nsDeviceContextXlib.h index accfbd53fbf..558836a0c20 100644 --- a/gfx/src/xlib/nsDeviceContextXlib.h +++ b/gfx/src/xlib/nsDeviceContextXlib.h @@ -24,6 +24,7 @@ #define nsDeviceContextXlib_h__ #include "nsDeviceContext.h" +#include "nsIRenderingContext.h" #include @@ -50,6 +51,7 @@ public: NS_IMETHOD CheckFontExistence(const nsString& aFontName); NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight); + NS_IMETHOD GetRect(nsRect &aRect); NS_IMETHOD GetClientRect(nsRect &aRect); NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, @@ -61,9 +63,6 @@ public: NS_IMETHOD BeginPage(void); NS_IMETHOD EndPage(void); - // unimplemented - NS_IMETHOD GetRect(nsRect&); - Display * GetDisplay() { return mDisplay; } Screen * GetScreen() { return mScreen; } Visual * GetVisual() { return mVisual; } diff --git a/gfx/src/xlib/nsFontMetricsXlib.cpp b/gfx/src/xlib/nsFontMetricsXlib.cpp index d8ce68258b9..7e3e7bb65c4 100644 --- a/gfx/src/xlib/nsFontMetricsXlib.cpp +++ b/gfx/src/xlib/nsFontMetricsXlib.cpp @@ -2597,4 +2597,34 @@ nsFontMetricsXlib::GetSpaceWidth(nscoord &aSpaceWidth) return NS_OK; } +NS_IMETHODIMP nsFontMetricsXlib::GetNormalLineHeight(nscoord &aHeight) +{ + aHeight = mEmHeight + mLeading; + return NS_OK; +} + +NS_IMETHODIMP nsFontMetricsXlib::GetEmHeight(nscoord &aHeight) +{ + aHeight = mEmHeight; + return NS_OK; +} + +NS_IMETHODIMP nsFontMetricsXlib::GetEmAscent(nscoord &aAscent) +{ + aAscent = mEmAscent; + return NS_OK; +} + +NS_IMETHODIMP nsFontMetricsXlib::GetEmDescent(nscoord &aDescent) +{ + aDescent = mEmDescent; + return NS_OK; +} + +NS_IMETHODIMP nsFontMetricsXlib::GetMaxHeight(nscoord &aHeight) +{ + aHeight = mMaxHeight; + return NS_OK; +} + #endif /* FONT_SWITCHING */ diff --git a/gfx/src/xlib/nsFontMetricsXlib.h b/gfx/src/xlib/nsFontMetricsXlib.h index f6641b54c48..5582ef35445 100644 --- a/gfx/src/xlib/nsFontMetricsXlib.h +++ b/gfx/src/xlib/nsFontMetricsXlib.h @@ -176,6 +176,10 @@ protected: nscoord mAscent; nscoord mDescent; nscoord mLeading; + nscoord mEmHeight; + nscoord mEmAscent; + nscoord mEmDescent; + nscoord mMaxHeight; nscoord mMaxAscent; nscoord mMaxDescent; nscoord mMaxAdvance; diff --git a/gfx/src/xlib/nsRenderingContextXlib.cpp b/gfx/src/xlib/nsRenderingContextXlib.cpp index d31f73d48d5..2fd68439887 100644 --- a/gfx/src/xlib/nsRenderingContextXlib.cpp +++ b/gfx/src/xlib/nsRenderingContextXlib.cpp @@ -671,7 +671,33 @@ nsRenderingContextXlib::DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord return NS_OK; } +NS_IMETHODIMP +nsRenderingContextXlib::DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1) +{ + nscoord diffX, diffY; + PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawStdLine()\n")); + if (nsnull == mTMatrix || nsnull == mRenderingSurface) + return NS_ERROR_FAILURE; + + mTMatrix->TransformCoord(&aX0,&aY0); + mTMatrix->TransformCoord(&aX1,&aY1); + + diffX = aX1-aX0; + diffY = aY1-aY0; + + if (0!=diffX) { + diffX = (diffX>0?1:-1); + } + if (0!=diffY) { + diffY = (diffY>0?1:-1); + } + + ::XDrawLine(mDisplay, mRenderingSurface->GetDrawable(), + mRenderingSurface->GetGC(), aX0, aY0, aX1 - diffX, aY1 - diffY); + + return NS_OK; +} NS_IMETHODIMP nsRenderingContextXlib::DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints) @@ -1368,6 +1394,8 @@ nsRenderingContextXlib::DrawImage(nsIImage *aImage, const nsRect& aSRect, const return NS_OK; } +#if 0 +// in nsRenderingContextImpl /** --------------------------------------------------- * See documentation in nsIRenderingContext.h * @update 3/16/00 dwc @@ -1379,6 +1407,7 @@ nsRenderingContextXlib::DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoor return NS_OK; } +#endif NS_IMETHODIMP nsRenderingContextXlib::CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY, diff --git a/gfx/src/xlib/nsRenderingContextXlib.h b/gfx/src/xlib/nsRenderingContextXlib.h index 7bd4f9e6d33..f1772d7038e 100644 --- a/gfx/src/xlib/nsRenderingContextXlib.h +++ b/gfx/src/xlib/nsRenderingContextXlib.h @@ -23,7 +23,7 @@ #ifndef nsRenderingContextXlib_h___ #define nsRenderingContextXlib_h___ -#include "nsIRenderingContext.h" +#include "nsRenderingContextImpl.h" #include "nsUnitConversion.h" #include "nsFont.h" #include "nsIFontMetrics.h" @@ -42,7 +42,7 @@ class GraphicsState; -class nsRenderingContextXlib : public nsIRenderingContext +class nsRenderingContextXlib : public nsRenderingContextImpl { public: nsRenderingContextXlib(); @@ -104,8 +104,11 @@ class nsRenderingContextXlib : public nsIRenderingContext NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); NS_IMETHOD DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1); +#if 0 + // in nsRenderingContextImpl NS_IMETHOD DrawPath(nsPathPoint aPointArray[], PRInt32 aNumPts); NS_IMETHOD FillPath(nsPathPoint aPointArray[], PRInt32 aNumPts); +#endif NS_IMETHOD FillRect(const nsRect& aRect); NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); @@ -115,8 +118,11 @@ class nsRenderingContextXlib : public nsIRenderingContext NS_IMETHOD DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints); NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints); +#if 0 + // in nsRenderingContextImpl NS_IMETHOD FillStdPolygon(const nsPoint aPoints[], PRInt32 aNumPoints); NS_IMETHOD RasterPolygon(const nsPoint aPoints[], PRInt32 aNumPoints); +#endif NS_IMETHOD DrawEllipse(const nsRect& aRect); NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); @@ -158,9 +164,12 @@ class nsRenderingContextXlib : public nsIRenderingContext nscoord aWidth, nscoord aHeight); NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect); NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect); +#if 0 + // in nsRenderingContextImpl NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1, nscoord aWidth,nscoord aHeight); NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX, nscoord aY, const nsRect&); +#endif NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY, const nsRect &aDestBounds, PRUint32 aCopyFlags);