Finished the first pass at implementation
git-svn-id: svn://10.0.0.236/trunk@8368 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
nsDeviceContextMac :: nsDeviceContextMac()
|
||||
{
|
||||
@@ -44,17 +44,26 @@ double pix_inch;
|
||||
|
||||
mTwipsToPixels = pix_inch/(float)NSIntPointsToTwips(72);
|
||||
mPixelsToTwips = 1.0f/mTwipsToPixels;
|
||||
|
||||
|
||||
mDepth = (**thepix).pixelSize;
|
||||
|
||||
HUnlock((Handle)thegd);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
nsDeviceContextMac :: ~nsDeviceContextMac()
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsDeviceContextMac, kDeviceContextIID)
|
||||
NS_IMPL_ADDREF(nsDeviceContextMac)
|
||||
NS_IMPL_RELEASE(nsDeviceContextMac)
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
nsresult nsDeviceContextMac :: Init(nsNativeWidget aNativeWidget)
|
||||
{
|
||||
NS_ASSERTION(!(aNativeWidget == nsnull), "attempt to init devicecontext with null widget");
|
||||
@@ -66,6 +75,7 @@ nsresult nsDeviceContextMac :: Init(nsNativeWidget aNativeWidget)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
float nsDeviceContextMac :: GetScrollBarWidth() const
|
||||
{
|
||||
@@ -73,19 +83,22 @@ float nsDeviceContextMac :: GetScrollBarWidth() const
|
||||
return 240.0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
float nsDeviceContextMac :: GetScrollBarHeight() const
|
||||
{
|
||||
// XXX Should we push this to widget library
|
||||
return 240.0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
nsDrawingSurface nsDeviceContextMac :: GetDrawingSurface(nsIRenderingContext &aContext)
|
||||
{
|
||||
return aContext.CreateDrawingSurface(nsnull);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextMac::GetDepth(PRUint32& aDepth)
|
||||
{
|
||||
@@ -93,6 +106,8 @@ NS_IMETHODIMP nsDeviceContextMac::GetDepth(PRUint32& aDepth)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextMac::CreateILColorSpace(IL_ColorSpace*& aColorSpace)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
@@ -101,9 +116,13 @@ NS_IMETHODIMP nsDeviceContextMac::CreateILColorSpace(IL_ColorSpace*& aColorSpace
|
||||
return result;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextMac :: CheckFontExistence(const nsString& aFontName)
|
||||
{
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@@ -20,215 +20,248 @@
|
||||
|
||||
static NS_DEFINE_IID(kRegionIID, NS_IREGION_IID);
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
nsRegionMac :: nsRegionMac()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
/* mRegion = nsnull;
|
||||
mRegionType = eRegionType_empty;*/
|
||||
mRegion = nsnull;
|
||||
mRegionType = eRegionType_empty;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
nsRegionMac :: ~nsRegionMac()
|
||||
{
|
||||
/* if (mRegion)
|
||||
::XDestroyRegion(mRegion);
|
||||
mRegion = nsnull;*/
|
||||
if (mRegion)
|
||||
::DisposeRgn(mRegion);
|
||||
mRegion = nsnull;
|
||||
}
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsRegionMac, kRegionIID)
|
||||
NS_IMPL_ADDREF(nsRegionMac)
|
||||
NS_IMPL_RELEASE(nsRegionMac)
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
nsresult nsRegionMac :: Init(void)
|
||||
{
|
||||
/* mRegion = ::XCreateRegion();
|
||||
mRegionType = eRegionType_empty;*/
|
||||
mRegion = ::NewRgn();
|
||||
mRegionType = eRegionType_empty;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void nsRegionMac :: SetTo(const nsIRegion &aRegion)
|
||||
{
|
||||
/* nsRegionMac * pRegion = (nsRegionMac *)&aRegion;
|
||||
|
||||
nsRegionMac * pRegion = (nsRegionMac *)&aRegion;
|
||||
SetRegionEmpty();
|
||||
|
||||
::XUnionRegion(mRegion, pRegion->mRegion, mRegion);
|
||||
|
||||
SetRegionType();*/
|
||||
::UnionRgn(mRegion,pRegion->mRegion,mRegion);
|
||||
SetRegionType();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void nsRegionMac :: SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
/*
|
||||
RgnHandle thergn;
|
||||
|
||||
SetRegionEmpty();
|
||||
|
||||
|
||||
thergn = ::NewRgn();
|
||||
::SetRectRgn(thergn,aX,aY,aX+aWidth,aY+aHeight);
|
||||
|
||||
::UnionRgn(mRegion,thergn,mRegion);
|
||||
::DisposeRgn(thergn);
|
||||
|
||||
XRectangle xrect;
|
||||
|
||||
xrect.x = aX;
|
||||
xrect.y = aY;
|
||||
xrect.width = aWidth;
|
||||
xrect.height = aHeight;
|
||||
|
||||
::XUnionRectWithRegion(&xrect, mRegion, mRegion);
|
||||
|
||||
SetRegionType();*/
|
||||
SetRegionType();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void nsRegionMac :: Intersect(const nsIRegion &aRegion)
|
||||
{
|
||||
/* nsRegionMac * pRegion = (nsRegionMac *)&aRegion;
|
||||
|
||||
::XIntersectRegion(mRegion, pRegion->mRegion, mRegion);
|
||||
|
||||
SetRegionType();*/
|
||||
nsRegionMac * pRegion = (nsRegionMac *)&aRegion;
|
||||
::SectRgn(mRegion, pRegion->mRegion, mRegion);
|
||||
SetRegionType();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void nsRegionMac :: Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
/* Region tRegion = CreateRectRegion(aX, aY, aWidth, aHeight);
|
||||
RgnHandle thergn;
|
||||
|
||||
::XIntersectRegion(mRegion, tRegion, mRegion);
|
||||
|
||||
::XDestroyRegion(tRegion);
|
||||
|
||||
SetRegionType();*/
|
||||
thergn = NewRgn();
|
||||
::SetRectRgn(thergn,aX,aY,aX+aWidth,aY+aHeight);
|
||||
::SectRgn(mRegion, thergn, mRegion);
|
||||
::DisposeRgn(thergn);
|
||||
SetRegionType();
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void nsRegionMac :: Union(const nsIRegion &aRegion)
|
||||
{
|
||||
/* nsRegionMac * pRegion = (nsRegionMac *)&aRegion;
|
||||
|
||||
::XUnionRegion(mRegion, pRegion->mRegion, mRegion);
|
||||
nsRegionMac * pRegion = (nsRegionMac *)&aRegion;
|
||||
|
||||
SetRegionType();*/
|
||||
::UnionRgn(mRegion, pRegion->mRegion, mRegion);
|
||||
|
||||
SetRegionType();
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void nsRegionMac :: Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
RgnHandle thergn;
|
||||
|
||||
/* Region tRegion = CreateRectRegion(aX, aY, aWidth, aHeight);
|
||||
thergn = ::NewRgn();
|
||||
::SetRectRgn(thergn,aX,aY,aX+aWidth,aY+aHeight);
|
||||
|
||||
::XUnionRegion(mRegion, tRegion, mRegion);
|
||||
::UnionRgn(mRegion, thergn, mRegion);
|
||||
|
||||
::XDestroyRegion(tRegion);
|
||||
::DisposeRgn(thergn);
|
||||
|
||||
SetRegionType();*/
|
||||
SetRegionType();
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void nsRegionMac :: Subtract(const nsIRegion &aRegion)
|
||||
{
|
||||
/* nsRegionMac * pRegion = (nsRegionMac *)&aRegion;
|
||||
nsRegionMac * pRegion = (nsRegionMac *)&aRegion;
|
||||
|
||||
::XSubtractRegion(mRegion, pRegion->mRegion, mRegion);
|
||||
DiffRgn(mRegion, pRegion->mRegion, mRegion);
|
||||
|
||||
SetRegionType();*/
|
||||
SetRegionType();
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void nsRegionMac :: Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
/* Region tRegion = CreateRectRegion(aX, aY, aWidth, aHeight);
|
||||
RgnHandle thergn;
|
||||
|
||||
thergn = ::NewRgn();
|
||||
::SetRectRgn(thergn,aX,aY,aX+aWidth,aY+aHeight);
|
||||
|
||||
::XSubtractRegion(mRegion, tRegion, mRegion);
|
||||
::DiffRgn(mRegion, thergn, mRegion);
|
||||
|
||||
::XDestroyRegion(tRegion);
|
||||
::DisposeRgn(thergn);
|
||||
|
||||
SetRegionType();*/
|
||||
SetRegionType();
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
PRBool nsRegionMac :: IsEmpty(void)
|
||||
{
|
||||
/* if (mRegionType == eRegionType_empty)
|
||||
return PR_TRUE;*/
|
||||
|
||||
return PR_FALSE;
|
||||
if (mRegionType == eRegionType_empty)
|
||||
return PR_TRUE;
|
||||
else
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
PRBool nsRegionMac :: IsEqual(const nsIRegion &aRegion)
|
||||
{
|
||||
/* nsRegionMac * pRegion = (nsRegionMac *)&aRegion;
|
||||
nsRegionMac * pRegion = (nsRegionMac *)&aRegion;
|
||||
|
||||
return(::XEqualRegion(mRegion, pRegion->mRegion));*/
|
||||
return PR_FALSE;
|
||||
return(::EqualRgn(mRegion, pRegion->mRegion));
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void nsRegionMac :: GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight)
|
||||
{
|
||||
/* XRectangle rect;
|
||||
Rect rect;
|
||||
|
||||
::XClipBox(mRegion, &rect);
|
||||
rect = (**mRegion).rgnBBox;
|
||||
|
||||
*aX = rect.x;
|
||||
*aY = rect.y;
|
||||
*aWidth = rect.width;
|
||||
*aHeight = rect.height;*/
|
||||
*aX = rect.left;
|
||||
*aY = rect.top;
|
||||
*aWidth = rect.right - rect.left;
|
||||
*aHeight = rect.bottom-rect.top;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void nsRegionMac :: Offset(PRInt32 aXOffset, PRInt32 aYOffset)
|
||||
{
|
||||
//::XOffsetRegion(mRegion, aXOffset, aYOffset);
|
||||
::OffsetRgn(mRegion, aXOffset, aYOffset);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
PRBool nsRegionMac :: ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
/*PRInt32 containment;
|
||||
|
||||
containment = ::XRectInRegion(mRegion, aX, aY, aWidth, aHeight);
|
||||
|
||||
if (containment == RectangleIn)
|
||||
return PR_TRUE;
|
||||
else*/
|
||||
return PR_FALSE;
|
||||
PRBool containment;
|
||||
Rect therect;
|
||||
|
||||
::SetRect(&therect,aX,aY,aX+aWidth,aY+aHeight);
|
||||
containment = ::RectInRgn(&therect,mRegion);
|
||||
return(containment);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
PRBool nsRegionMac :: ForEachRect(nsRectInRegionFunc *func, void *closure)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
/*Region nsRegionMac :: GetXRegion(void)
|
||||
RgnHandle nsRegionMac :: GetRegion(void)
|
||||
{
|
||||
return (mRegion);
|
||||
}*/
|
||||
}
|
||||
|
||||
/*void nsRegionMac :: SetRegionType()
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
|
||||
void nsRegionMac :: SetRegionType()
|
||||
{
|
||||
if (::XEmptyRegion(mRegion) == True)
|
||||
if (::EmptyRgn(mRegion) == PR_TRUE)
|
||||
mRegionType = eRegionType_empty;
|
||||
else
|
||||
mRegionType = eRegionType_rect ;
|
||||
}
|
||||
*/
|
||||
|
||||
/*void nsRegionMac :: SetRegionEmpty()
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
|
||||
void nsRegionMac :: SetRegionEmpty()
|
||||
{
|
||||
::XDestroyRegion(mRegion);
|
||||
mRegion = ::XCreateRegion();
|
||||
}*/
|
||||
::DisposeRgn(mRegion);
|
||||
mRegion = ::NewRgn();
|
||||
}
|
||||
|
||||
/*Region nsRegionMac :: CreateRectRegion(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
|
||||
RgnHandle nsRegionMac :: CreateRectRegion(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
Region r = ::XCreateRegion();
|
||||
|
||||
XRectangle xrect;
|
||||
|
||||
xrect.x = aX;
|
||||
xrect.y = aY;
|
||||
xrect.width = aWidth;
|
||||
xrect.height = aHeight;
|
||||
|
||||
::XUnionRectWithRegion(&xrect, r, r);
|
||||
RgnHandle r = ::NewRgn();
|
||||
|
||||
SetRectRgn(r,aX,aY,aX+aWidth,aY+aHeight);
|
||||
return (r);
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define nsRegionMac_h___
|
||||
|
||||
#include "nsIRegion.h"
|
||||
#include <quickdraw.h>
|
||||
|
||||
enum nsRegionType {
|
||||
eRegionType_empty,
|
||||
@@ -54,16 +55,16 @@ public:
|
||||
virtual PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
|
||||
virtual PRBool ForEachRect(nsRectInRegionFunc *func, void *closure);
|
||||
|
||||
//Region GetXRegion(void);
|
||||
RgnHandle GetRegion(void);
|
||||
|
||||
private:
|
||||
//Region mRegion;
|
||||
RgnHandle mRegion;
|
||||
nsRegionType mRegionType;
|
||||
|
||||
/*private:
|
||||
private:
|
||||
virtual void SetRegionType();
|
||||
virtual void SetRegionEmpty();
|
||||
virtual Region CreateRectRegion(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);*/
|
||||
virtual RgnHandle CreateRectRegion(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
|
||||
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -39,6 +39,8 @@
|
||||
|
||||
class GraphicsState;
|
||||
|
||||
typedef GrafPtr nsDrawingSurfaceMac;
|
||||
|
||||
class nsRenderingContextMac : public nsIRenderingContext
|
||||
{
|
||||
public:
|
||||
@@ -132,17 +134,18 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
/*nscolor mCurrentColor ;
|
||||
nscolor mCurrentColor ;
|
||||
nsTransform2D *mTMatrix; // transform that all the graphics drawn here will obey
|
||||
float mP2T;
|
||||
|
||||
nsDrawingSurfaceMac *mRenderingSurface; // Can be a BackBuffer if Selected in
|
||||
nsDrawingSurfaceMac *mFrontBuffer;
|
||||
nsIDeviceContext *mContext;
|
||||
nsIFontMetrics *mFontMetrics;
|
||||
nsIFontCache *mFontCache;
|
||||
Region mRegion;
|
||||
Font mCurrFontHandle;*/
|
||||
nsDrawingSurfaceMac mRenderingSurface; // Can be a BackBuffer if Selected in
|
||||
nsDrawingSurfaceMac mFrontBuffer;
|
||||
nsDrawingSurfaceMac mCurrentSurface;
|
||||
nsIDeviceContext *mContext;
|
||||
nsIFontMetrics *mFontMetrics;
|
||||
nsIFontCache *mFontCache;
|
||||
RgnHandle mClipRegion;
|
||||
PRInt32 mCurrFontHandle;
|
||||
|
||||
//state management
|
||||
nsVoidArray *mStateCache;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
nsDeviceContextMac :: nsDeviceContextMac()
|
||||
{
|
||||
@@ -44,17 +44,26 @@ double pix_inch;
|
||||
|
||||
mTwipsToPixels = pix_inch/(float)NSIntPointsToTwips(72);
|
||||
mPixelsToTwips = 1.0f/mTwipsToPixels;
|
||||
|
||||
|
||||
mDepth = (**thepix).pixelSize;
|
||||
|
||||
HUnlock((Handle)thegd);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
nsDeviceContextMac :: ~nsDeviceContextMac()
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsDeviceContextMac, kDeviceContextIID)
|
||||
NS_IMPL_ADDREF(nsDeviceContextMac)
|
||||
NS_IMPL_RELEASE(nsDeviceContextMac)
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
nsresult nsDeviceContextMac :: Init(nsNativeWidget aNativeWidget)
|
||||
{
|
||||
NS_ASSERTION(!(aNativeWidget == nsnull), "attempt to init devicecontext with null widget");
|
||||
@@ -66,6 +75,7 @@ nsresult nsDeviceContextMac :: Init(nsNativeWidget aNativeWidget)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
float nsDeviceContextMac :: GetScrollBarWidth() const
|
||||
{
|
||||
@@ -73,19 +83,22 @@ float nsDeviceContextMac :: GetScrollBarWidth() const
|
||||
return 240.0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
float nsDeviceContextMac :: GetScrollBarHeight() const
|
||||
{
|
||||
// XXX Should we push this to widget library
|
||||
return 240.0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
nsDrawingSurface nsDeviceContextMac :: GetDrawingSurface(nsIRenderingContext &aContext)
|
||||
{
|
||||
return aContext.CreateDrawingSurface(nsnull);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextMac::GetDepth(PRUint32& aDepth)
|
||||
{
|
||||
@@ -93,6 +106,8 @@ NS_IMETHODIMP nsDeviceContextMac::GetDepth(PRUint32& aDepth)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextMac::CreateILColorSpace(IL_ColorSpace*& aColorSpace)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
@@ -101,9 +116,13 @@ NS_IMETHODIMP nsDeviceContextMac::CreateILColorSpace(IL_ColorSpace*& aColorSpace
|
||||
return result;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextMac :: CheckFontExistence(const nsString& aFontName)
|
||||
{
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user