Vain attempt to make the xlib toolkit work. Switched nsRenderingContextXlib to use nsRenderingContextImpl. Filled in some missing functions.

This commit is contained in:
cls%seawood.org 2000-05-13 05:38:50 +00:00
Родитель 6a444d116d
Коммит 04db137aab
6 изменённых файлов: 88 добавлений и 5 удалений

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

@ -367,6 +367,18 @@ NS_IMETHODIMP nsDeviceContextXlib::GetDeviceSurfaceDimensions(PRInt32 &aWidth, P
return NS_OK; 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) NS_IMETHODIMP nsDeviceContextXlib::GetClientRect(nsRect &aRect)
{ {
PRInt32 width, height; PRInt32 width, height;

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

@ -24,6 +24,7 @@
#define nsDeviceContextXlib_h__ #define nsDeviceContextXlib_h__
#include "nsDeviceContext.h" #include "nsDeviceContext.h"
#include "nsIRenderingContext.h"
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -50,6 +51,7 @@ public:
NS_IMETHOD CheckFontExistence(const nsString& aFontName); NS_IMETHOD CheckFontExistence(const nsString& aFontName);
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight); NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
NS_IMETHOD GetRect(nsRect &aRect);
NS_IMETHOD GetClientRect(nsRect &aRect); NS_IMETHOD GetClientRect(nsRect &aRect);
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
@ -61,9 +63,6 @@ public:
NS_IMETHOD BeginPage(void); NS_IMETHOD BeginPage(void);
NS_IMETHOD EndPage(void); NS_IMETHOD EndPage(void);
// unimplemented
NS_IMETHOD GetRect(nsRect&);
Display * GetDisplay() { return mDisplay; } Display * GetDisplay() { return mDisplay; }
Screen * GetScreen() { return mScreen; } Screen * GetScreen() { return mScreen; }
Visual * GetVisual() { return mVisual; } Visual * GetVisual() { return mVisual; }

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

@ -2597,4 +2597,34 @@ nsFontMetricsXlib::GetSpaceWidth(nscoord &aSpaceWidth)
return NS_OK; 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 */ #endif /* FONT_SWITCHING */

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

@ -176,6 +176,10 @@ protected:
nscoord mAscent; nscoord mAscent;
nscoord mDescent; nscoord mDescent;
nscoord mLeading; nscoord mLeading;
nscoord mEmHeight;
nscoord mEmAscent;
nscoord mEmDescent;
nscoord mMaxHeight;
nscoord mMaxAscent; nscoord mMaxAscent;
nscoord mMaxDescent; nscoord mMaxDescent;
nscoord mMaxAdvance; nscoord mMaxAdvance;

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

@ -671,7 +671,33 @@ nsRenderingContextXlib::DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord
return NS_OK; 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 NS_IMETHODIMP
nsRenderingContextXlib::DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints) nsRenderingContextXlib::DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints)
@ -1368,6 +1394,8 @@ nsRenderingContextXlib::DrawImage(nsIImage *aImage, const nsRect& aSRect, const
return NS_OK; return NS_OK;
} }
#if 0
// in nsRenderingContextImpl
/** --------------------------------------------------- /** ---------------------------------------------------
* See documentation in nsIRenderingContext.h * See documentation in nsIRenderingContext.h
* @update 3/16/00 dwc * @update 3/16/00 dwc
@ -1379,6 +1407,7 @@ nsRenderingContextXlib::DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoor
return NS_OK; return NS_OK;
} }
#endif
NS_IMETHODIMP NS_IMETHODIMP
nsRenderingContextXlib::CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY, nsRenderingContextXlib::CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,

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

@ -23,7 +23,7 @@
#ifndef nsRenderingContextXlib_h___ #ifndef nsRenderingContextXlib_h___
#define nsRenderingContextXlib_h___ #define nsRenderingContextXlib_h___
#include "nsIRenderingContext.h" #include "nsRenderingContextImpl.h"
#include "nsUnitConversion.h" #include "nsUnitConversion.h"
#include "nsFont.h" #include "nsFont.h"
#include "nsIFontMetrics.h" #include "nsIFontMetrics.h"
@ -42,7 +42,7 @@
class GraphicsState; class GraphicsState;
class nsRenderingContextXlib : public nsIRenderingContext class nsRenderingContextXlib : public nsRenderingContextImpl
{ {
public: public:
nsRenderingContextXlib(); nsRenderingContextXlib();
@ -104,8 +104,11 @@ class nsRenderingContextXlib : public nsIRenderingContext
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1); NS_IMETHOD DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
#if 0
// in nsRenderingContextImpl
NS_IMETHOD DrawPath(nsPathPoint aPointArray[], PRInt32 aNumPts); NS_IMETHOD DrawPath(nsPathPoint aPointArray[], PRInt32 aNumPts);
NS_IMETHOD FillPath(nsPathPoint aPointArray[], PRInt32 aNumPts); NS_IMETHOD FillPath(nsPathPoint aPointArray[], PRInt32 aNumPts);
#endif
NS_IMETHOD FillRect(const nsRect& aRect); NS_IMETHOD FillRect(const nsRect& aRect);
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); 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 DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD FillPolygon(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 FillStdPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD RasterPolygon(const nsPoint aPoints[], PRInt32 aNumPoints); NS_IMETHOD RasterPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
#endif
NS_IMETHOD DrawEllipse(const nsRect& aRect); NS_IMETHOD DrawEllipse(const nsRect& aRect);
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight); NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
@ -158,9 +164,12 @@ class nsRenderingContextXlib : public nsIRenderingContext
nscoord aWidth, nscoord aHeight); nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect); NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect); 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, NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1,
nscoord aWidth,nscoord aHeight); nscoord aWidth,nscoord aHeight);
NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX, nscoord aY, const nsRect&); NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX, nscoord aY, const nsRect&);
#endif
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY, NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags); const nsRect &aDestBounds, PRUint32 aCopyFlags);