From ca6bf4c1bdd9f7bee113860e014151f6f8cd146e Mon Sep 17 00:00:00 2001 From: "dcone%netscape.com" Date: Mon, 24 Aug 1998 20:10:57 +0000 Subject: [PATCH] Finished the first pass at implementation git-svn-id: svn://10.0.0.236/trunk@8368 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gfx/src/mac/nsDeviceContextMac.cpp | 25 +- mozilla/gfx/src/mac/nsRegionMac.cpp | 215 ++--- mozilla/gfx/src/mac/nsRegionMac.h | 9 +- mozilla/gfx/src/mac/nsRenderingContextMac.cpp | 742 +++++++++--------- mozilla/gfx/src/mac/nsRenderingContextMac.h | 19 +- mozilla/widget/src/mac/nsDeviceContextMac.cpp | 25 +- 6 files changed, 570 insertions(+), 465 deletions(-) diff --git a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp index 02f9eabf51f..44fa9ad8d15 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp +++ b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp @@ -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; } +//------------------------------------------------------------------------ + + diff --git a/mozilla/gfx/src/mac/nsRegionMac.cpp b/mozilla/gfx/src/mac/nsRegionMac.cpp index 220cd60a56e..cf93c282948 100644 --- a/mozilla/gfx/src/mac/nsRegionMac.cpp +++ b/mozilla/gfx/src/mac/nsRegionMac.cpp @@ -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); -}*/ +} diff --git a/mozilla/gfx/src/mac/nsRegionMac.h b/mozilla/gfx/src/mac/nsRegionMac.h index 9c4a3562d14..3c08adb32e0 100644 --- a/mozilla/gfx/src/mac/nsRegionMac.h +++ b/mozilla/gfx/src/mac/nsRegionMac.h @@ -20,6 +20,7 @@ #define nsRegionMac_h___ #include "nsIRegion.h" +#include 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); }; diff --git a/mozilla/gfx/src/mac/nsRenderingContextMac.cpp b/mozilla/gfx/src/mac/nsRenderingContextMac.cpp index 424d8db9182..2fba27412f0 100644 --- a/mozilla/gfx/src/mac/nsRenderingContextMac.cpp +++ b/mozilla/gfx/src/mac/nsRenderingContextMac.cpp @@ -15,6 +15,17 @@ * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ + +/* + String + +translated to a number via getfnum() + +TextFont(number) +TextSize +TextFace -- may not play well with new style +DrawString(); DrawText for cstrings +*/ #include "nsRenderingContextMac.h" #include "nsDeviceContextMac.h" @@ -44,36 +55,43 @@ public: GraphicsState(); ~GraphicsState(); - /*nsTransform2D *mMatrix; + GrafPtr *mCurPort; // port set up on the stack + nsTransform2D *mMatrix; nsRect mLocalClip; - Region mClipRegion; + RgnHandle mClipRegion; nscolor mColor; nsIFontMetrics *mFontMetrics; - Font mFont;*/ + PRInt32 mFont; }; +//------------------------------------------------------------------------ + GraphicsState :: GraphicsState() { - /* mMatrix = nsnull; + mMatrix = nsnull; mLocalClip.x = mLocalClip.y = mLocalClip.width = mLocalClip.height = 0; mClipRegion = nsnull; mColor = NS_RGB(0, 0, 0); mFontMetrics = nsnull; - mFont = nsnull;*/ + mFont = 0; } +//------------------------------------------------------------------------ + GraphicsState :: ~GraphicsState() { -// mFont = nsnull; + mFont = 0; } static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID); +//------------------------------------------------------------------------ + nsRenderingContextMac :: nsRenderingContextMac() { NS_INIT_REFCNT(); - /*mFontCache = nsnull ; + //mFontCache = nsnull ; mFontMetrics = nsnull ; mContext = nsnull ; mFrontBuffer = nsnull ; @@ -82,100 +100,96 @@ nsRenderingContextMac :: nsRenderingContextMac() mTMatrix = nsnull; mP2T = 1.0f; mStateCache = new nsVoidArray(); - mRegion = nsnull; - mCurrFontHandle = 0;*/ + mClipRegion = nsnull; + mCurrFontHandle = 0; PushState(); } +//------------------------------------------------------------------------ + nsRenderingContextMac :: ~nsRenderingContextMac() { -/* - if (mRegion) { - ::XDestroyRegion(mRegion); - mRegion = nsnull; - } + if (mClipRegion) + { + ::DisposeRgn(mClipRegion); + mClipRegion = nsnull; + } + mTMatrix = nsnull; // Destroy the State Machine if (nsnull != mStateCache) - { + { PRInt32 cnt = mStateCache->Count(); while (--cnt >= 0) - { + { GraphicsState *state = (GraphicsState *)mStateCache->ElementAt(cnt); mStateCache->RemoveElementAt(cnt); if (nsnull != state) delete state; - } - + } delete mStateCache; mStateCache = nsnull; - } + } // Destroy the front buffer and it's GC if one was allocated for it - if (nsnull != mFrontBuffer) { - if (mFrontBuffer != mRenderingSurface) { - ::XFreeGC(mFrontBuffer->display, - mFrontBuffer->gc); - } + if (nsnull != mFrontBuffer) + { + if (mFrontBuffer != mRenderingSurface) + { + //::XFreeGC(mFrontBuffer->display,mFrontBuffer->gc); + } delete mFrontBuffer; - } + } NS_IF_RELEASE(mFontMetrics); NS_IF_RELEASE(mFontCache); NS_IF_RELEASE(mContext); -*/ + } NS_IMPL_QUERY_INTERFACE(nsRenderingContextMac, kRenderingContextIID) NS_IMPL_ADDREF(nsRenderingContextMac) NS_IMPL_RELEASE(nsRenderingContextMac) -nsresult nsRenderingContextMac :: Init(nsIDeviceContext* aContext, - nsIWidget *aWindow) +//------------------------------------------------------------------------ + +nsresult nsRenderingContextMac :: Init(nsIDeviceContext* aContext,nsIWidget *aWindow) { -/* + if (nsnull == aWindow->GetNativeData(NS_NATIVE_WINDOW)) return NS_ERROR_NOT_INITIALIZED; mContext = aContext; NS_IF_ADDREF(mContext); - mRenderingSurface = new nsDrawingSurfaceMac(); - mRenderingSurface->display = (Display *)aWindow->GetNativeData(NS_NATIVE_DISPLAY); - mRenderingSurface->drawable = (Drawable)aWindow->GetNativeData(NS_NATIVE_WINDOW); - mRenderingSurface->gc = (GC)aWindow->GetNativeData(NS_NATIVE_GRAPHIC); + mRenderingSurface = (nsDrawingSurfaceMac)aWindow->GetNativeData(NS_NATIVE_DISPLAY); - XWindowAttributes wa; - - ::XGetWindowAttributes(mRenderingSurface->display, - mRenderingSurface->drawable, - &wa); - - mRenderingSurface->visual = wa.visual; - mRenderingSurface->depth = wa.depth; - mFrontBuffer = mRenderingSurface; -*/ + return (CommonInit()); } +//------------------------------------------------------------------------ + nsresult nsRenderingContextMac :: Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface) { -/* + mContext = aContext; NS_IF_ADDREF(mContext); - mRenderingSurface = (nsDrawingSurfaceMac *) aSurface; -*/ + mRenderingSurface = (nsDrawingSurfaceMac) aSurface; return (CommonInit()); } +//------------------------------------------------------------------------ + + nsresult nsRenderingContextMac :: CommonInit() { /* ((nsDeviceContextMac *)mContext)->SetDrawingSurface(mRenderingSurface); @@ -188,6 +202,8 @@ nsresult nsRenderingContextMac :: CommonInit() return NS_OK; } +//------------------------------------------------------------------------ + nsresult nsRenderingContextMac :: SelectOffScreenDrawingSurface(nsDrawingSurface aSurface) { @@ -202,21 +218,26 @@ nsresult nsRenderingContextMac :: SelectOffScreenDrawingSurface(nsDrawingSurface return NS_OK; } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: Reset() { } +//------------------------------------------------------------------------ + nsIDeviceContext * nsRenderingContextMac :: GetDeviceContext(void) { - //NS_IF_ADDREF(mContext); - //return mContext; - return nsnull; + NS_IF_ADDREF(mContext); + return mContext; } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: PushState(void) { -/* - nsRect rect; +nsRect rect; +Rect mac_rect; GraphicsState * state = new GraphicsState(); @@ -232,34 +253,35 @@ void nsRenderingContextMac :: PushState(void) GetClipRect(state->mLocalClip); - state->mClipRegion = mRegion; + state->mClipRegion = mClipRegion; - if (nsnull != state->mClipRegion) { - mRegion = ::XCreateRegion(); - - XRectangle xrect; + if (nsnull != state->mClipRegion) + { + mClipRegion = NewRgn(); - xrect.x = state->mLocalClip.x; - xrect.y = state->mLocalClip.y; - xrect.width = state->mLocalClip.width; - xrect.height = state->mLocalClip.height; + mac_rect.left = state->mLocalClip.x; + mac_rect.top = state->mLocalClip.y; + mac_rect.right = state->mLocalClip.x + state->mLocalClip.width; + mac_rect.bottom = state->mLocalClip.y + state->mLocalClip.height; - ::XUnionRectWithRegion(&xrect, mRegion, mRegion); - } + SetRectRgn(mClipRegion,state->mLocalClip.x,state->mLocalClip.y, + state->mLocalClip.x + state->mLocalClip.width,state->mLocalClip.y + state->mLocalClip.height); + } state->mColor = mCurrentColor; -*/ } +//------------------------------------------------------------------------ + PRBool nsRenderingContextMac :: PopState(void) { -/* - PRBool bEmpty = PR_FALSE; +PRBool bEmpty = PR_FALSE; PRUint32 cnt = mStateCache->Count(); GraphicsState * state; - if (cnt > 0) { + if (cnt > 0) + { state = (GraphicsState *)mStateCache->ElementAt(cnt - 1); mStateCache->RemoveElementAt(cnt - 1); @@ -268,242 +290,221 @@ PRBool nsRenderingContextMac :: PopState(void) delete mTMatrix; mTMatrix = state->mMatrix; - if (nsnull != mRegion) - ::XDestroyRegion(mRegion); + if (nsnull != mClipRegion) + ::DisposeRgn(mClipRegion); - mRegion = state->mClipRegion; + mClipRegion = state->mClipRegion; - if (nsnull != mRegion && ::XEmptyRegion(mRegion) == True){ + if (nsnull != mClipRegion && ::EmptyRgn(mClipRegion) == PR_TRUE) + { bEmpty = PR_TRUE; - }else{ - + } + else + { // Select in the old region. We probably want to set a dirty flag and only // do this IFF we need to draw before the next Pop. We'd need to check the // state flag on every draw operation. - if (nsnull != mRegion) - ::XSetRegion(mRenderingSurface->display, - mRenderingSurface->gc, - mRegion); - - } + if (nsnull != mClipRegion) + { + // set this region as the currentclippig region + ::SetClip(mClipRegion); + } + } if (state->mColor != mCurrentColor) SetColor(state->mColor); - // Delete this graphics state object delete state; - } + } - return bEmpty;*/ + return bEmpty; return PR_FALSE; } +//------------------------------------------------------------------------ + PRBool nsRenderingContextMac :: IsVisibleRect(const nsRect& aRect) { return PR_TRUE; } +//------------------------------------------------------------------------ + PRBool nsRenderingContextMac :: SetClipRectInPixels(const nsRect& aRect, nsClipCombine aCombine) { -/* PRBool bEmpty = PR_FALSE; +PRBool bEmpty = PR_FALSE; +nsRect trect = aRect; +RgnHandle theregion,tregion; - nsRect trect = aRect; - - XRectangle xrect; - - xrect.x = trect.x; - xrect.y = trect.y; - xrect.width = trect.width; - xrect.height = trect.height; - - Region a = ::XCreateRegion(); - ::XUnionRectWithRegion(&xrect, a, a); + theregion = ::NewRgn(); + SetRectRgn(theregion,trect.x,trect.y,trect.x+trect.width,trect.y+trect.height); if (aCombine == nsClipCombine_kIntersect) - { - Region tRegion = ::XCreateRegion(); + { + if (nsnull != mClipRegion) + { + tregion = ::NewRgn(); + ::SectRgn(theregion,mClipRegion,tregion); + ::DisposeRgn(theregion); + ::DisposeRgn(mClipRegion); + mClipRegion = tregion; + } + } + else + if (aCombine == nsClipCombine_kUnion) + { + if (nsnull != mClipRegion) + { + tregion = ::NewRgn(); + ::UnionRgn(theregion, mClipRegion, tregion); + ::DisposeRgn(mClipRegion); + ::DisposeRgn(theregion); + mClipRegion = tregion; + } + } + else + if (aCombine == nsClipCombine_kSubtract) + { + if (nsnull != mClipRegion) + { + tregion = ::NewRgn(); + ::DiffRgn(mClipRegion, theregion, tregion); + ::DisposeRgn(mClipRegion); + ::DisposeRgn(theregion); + mClipRegion = tregion; + } + } + else + if (aCombine == nsClipCombine_kReplace) + { + if (nsnull != mClipRegion) + ::DisposeRgn(mClipRegion); - if (nsnull != mRegion) { - ::XIntersectRegion(a, mRegion, tRegion); - ::XDestroyRegion(mRegion); - ::XDestroyRegion(a); - mRegion = tRegion; - } else { - ::XDestroyRegion(tRegion); - mRegion = a; - } - - } - else if (aCombine == nsClipCombine_kUnion) - { - if (nsnull != mRegion) { - Region tRegion = ::XCreateRegion(); - ::XUnionRegion(a, mRegion, tRegion); - ::XDestroyRegion(mRegion); - ::XDestroyRegion(a); - mRegion = tRegion; - } else { - mRegion = a; - } - - } - else if (aCombine == nsClipCombine_kSubtract) - { - - if (nsnull != mRegion) { - - Region tRegion = ::XCreateRegion(); - ::XSubtractRegion(mRegion, a, tRegion); - ::XDestroyRegion(mRegion); - ::XDestroyRegion(a); - mRegion = tRegion; - - } else { - mRegion = a; - } - - } - else if (aCombine == nsClipCombine_kReplace) - { - - if (nsnull != mRegion) - ::XDestroyRegion(mRegion); - - mRegion = a; - - } - else - NS_ASSERTION(PR_FALSE, "illegal clip combination"); - - if (::XEmptyRegion(mRegion) == True) { + mClipRegion = theregion; + } + else + NS_ASSERTION(PR_FALSE, "illegal clip combination"); + if (nsnull == mClipRegion) + { bEmpty = PR_TRUE; - ::XSetClipMask(mRenderingSurface->display, - mRenderingSurface->gc, - None); - - } else { - - ::XSetRegion(mRenderingSurface->display, - mRenderingSurface->gc, - mRegion); - - } + // clip to the size of the window + ::SetPort(mRenderingSurface); + ::ClipRect(&mRenderingSurface->portRect); + } + else + { + // set the clipping area of this windowptr + ::SetPort(mRenderingSurface); + ::SetClip(mClipRegion); + } return bEmpty; -*/ - return PR_FALSE; } +//------------------------------------------------------------------------ + PRBool nsRenderingContextMac :: SetClipRect(const nsRect& aRect, nsClipCombine aCombine) { -/* - nsRect trect = aRect; +nsRect trect = aRect; - mTMatrix->TransformCoord(&trect.x, &trect.y, - &trect.width, &trect.height); + mTMatrix->TransformCoord(&trect.x, &trect.y,&trect.width, &trect.height); return(SetClipRectInPixels(trect,aCombine)); -*/ - return PR_FALSE; } +//------------------------------------------------------------------------ + PRBool nsRenderingContextMac :: GetClipRect(nsRect &aRect) { -/* - if (mRegion != nsnull) { - XRectangle xrect; - ::XClipBox(mRegion, &xrect); - aRect.SetRect(xrect.x, xrect.y, xrect.width, xrect.height); - } else { +Rect cliprect; + + if (mClipRegion != nsnull) + { + cliprect = (**mClipRegion).rgnBBox; + aRect.SetRect(cliprect.left, cliprect.top, cliprect.right-cliprect.left, cliprect.bottom-cliprect.top); + return(PR_FALSE); + } + else + { aRect.SetRect(0,0,0,0); return (PR_TRUE); - } - if (::XEmptyRegion(mRegion) == True) - return PR_TRUE; - else - return PR_FALSE; -*/ - return PR_FALSE; + } } +//------------------------------------------------------------------------ + PRBool nsRenderingContextMac :: SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine) { -/* - nsRect rect; - XRectangle xrect; +nsRect rect; +Rect mrect; +RgnHandle mregion; nsRegionMac *pRegion = (nsRegionMac *)&aRegion; - Region xregion = pRegion->GetXRegion(); - ::XClipBox(xregion, &xrect); - - rect.x = xrect.x; - rect.y = xrect.y; - rect.width = xrect.width; - rect.height = xrect.height; + + mregion = pRegion->GetRegion(); + mrect = (**mClipRegion).rgnBBox; + + rect.x = mrect.left; + rect.y = mrect.right; + rect.width = mrect.right-mrect.left; + rect.height = mrect.bottom-mrect.top; SetClipRectInPixels(rect, aCombine); - if (::XEmptyRegion(mRegion) == True) + if (::EmptyRgn(mClipRegion) == PR_TRUE) return PR_TRUE; else return PR_FALSE; -*/ - return PR_FALSE; } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: GetClipRegion(nsIRegion **aRegion) { -/* - nsIRegion * pRegion ; +nsIRegion * pRegion ; static NS_DEFINE_IID(kCRegionCID, NS_REGION_CID); static NS_DEFINE_IID(kIRegionIID, NS_IREGION_IID); - nsresult rv = NSRepository::CreateInstance(kCRegionCID, - nsnull, - kIRegionIID, - (void **)aRegion); + nsresult rv = NSRepository::CreateInstance(kCRegionCID,nsnull, kIRegionIID, (void **)aRegion); - if (NS_OK == rv) { + if (NS_OK == rv) + { nsRect rect; pRegion = (nsIRegion *)&aRegion; pRegion->Init(); this->GetClipRect(rect); pRegion->Union(rect.x,rect.y,rect.width,rect.height); - } -*/ - return ; - + } } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: SetColor(nscolor aColor) { -/* - XGCValues values ; +RGBColor thecolor; + // mCurrentColor = ((nsDeviceContextMac *)mContext)->ConvertPixel(aColor); - mCurrentColor = ((nsDeviceContextMac *)mContext)->ConvertPixel(aColor); - - values.foreground = mCurrentColor; - values.background = mCurrentColor; - - ::XChangeGC(mRenderingSurface->display, - mRenderingSurface->gc, - GCForeground | GCBackground, - &values); + + thecolor.red = NS_GET_R(aColor); + thecolor.red = NS_GET_G(aColor); + thecolor.red = NS_GET_B(aColor); + ::RGBForeColor(&thecolor); mCurrentColor = aColor ; -*/ + } +//------------------------------------------------------------------------ + nscolor nsRenderingContextMac :: GetColor() const { -/* return mCurrentColor; -*/ - return nsnull; } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: SetFont(const nsFont& aFont) { /* @@ -525,45 +526,50 @@ void nsRenderingContextMac :: SetFont(const nsFont& aFont) */ } +//------------------------------------------------------------------------ + const nsFont& nsRenderingContextMac :: GetFont() { -/* return mFontMetrics->GetFont(); -*/ } +//------------------------------------------------------------------------ + nsIFontMetrics* nsRenderingContextMac :: GetFontMetrics() { -/* return mFontMetrics; -*/ - return nsnull; } +//------------------------------------------------------------------------ + // add the passed in translation to the current translation void nsRenderingContextMac :: Translate(nscoord aX, nscoord aY) { -/* + mTMatrix->AddTranslation((float)aX,(float)aY); -*/ + } +//------------------------------------------------------------------------ + // add the passed in scale to the current scale void nsRenderingContextMac :: Scale(float aSx, float aSy) { -/* + mTMatrix->AddScale(aSx, aSy); -*/ + } +//------------------------------------------------------------------------ + nsTransform2D * nsRenderingContextMac :: GetCurrentTransform() { -/* + return mTMatrix; -*/ - return nsnull; } +//------------------------------------------------------------------------ + nsDrawingSurface nsRenderingContextMac :: CreateDrawingSurface(nsRect *aBounds) { /* @@ -572,15 +578,18 @@ nsDrawingSurface nsRenderingContextMac :: CreateDrawingSurface(nsRect *aBounds) DefaultScreen(mRenderingSurface->display)); Pixmap p; - if (aBounds != nsnull) { + if (aBounds != nsnull) + { p = ::XCreatePixmap(mRenderingSurface->display, mRenderingSurface->drawable, aBounds->width, aBounds->height, depth); - } else { + } + else + { p = ::XCreatePixmap(mRenderingSurface->display, mRenderingSurface->drawable, 2, 2, depth); - } + } nsDrawingSurfaceMac * surface = new nsDrawingSurfaceMac(); @@ -595,6 +604,8 @@ nsDrawingSurface nsRenderingContextMac :: CreateDrawingSurface(nsRect *aBounds) return nsnull; } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DestroyDrawingSurface(nsDrawingSurface aDS) { /* @@ -611,32 +622,37 @@ void nsRenderingContextMac :: DestroyDrawingSurface(nsDrawingSurface aDS) */ } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1) { -/* mTMatrix->TransformCoord(&aX0,&aY0); mTMatrix->TransformCoord(&aX1,&aY1); - ::XDrawLine(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - aX0, aY0, aX1, aY1); -*/ + SetPort(mCurrentSurface); + ::MoveTo(aX0, aY0); + ::LineTo(aX1, aY1); } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints) { } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DrawRect(const nsRect& aRect) { DrawRect(aRect.x, aRect.y, aRect.width, aRect.height); } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) { -/* - nscoord x,y,w,h; +nscoord x,y,w,h; +Rect therect; x = aX; y = aY; @@ -645,22 +661,25 @@ void nsRenderingContextMac :: DrawRect(nscoord aX, nscoord aY, nscoord aWidth, n mTMatrix->TransformCoord(&x,&y,&w,&h); - ::XDrawRectangle(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x,y,w,h); -*/ + SetPort(mCurrentSurface); + ::SetRect(&therect,x,y,x+w,y+h); + ::FrameRect(&therect); + } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: FillRect(const nsRect& aRect) { FillRect(aRect.x, aRect.y, aRect.width, aRect.height); } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) { -/* - nscoord x,y,w,h; +nscoord x,y,w,h; +Rect therect; x = aX; y = aY; @@ -668,77 +687,79 @@ void nsRenderingContextMac :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, n h = aHeight; mTMatrix->TransformCoord(&x,&y,&w,&h); - ::XFillRectangle(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x,y,w,h); - -*/ + SetPort(mCurrentSurface); + ::SetRect(&therect,aX,aY,aX+aWidth,aY+aHeight); + ::PaintRect(&therect); + } +//------------------------------------------------------------------------ void nsRenderingContextMac::DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) { -/* - PRUint32 i ; - XPoint * xpoints; - XPoint * thispoint; - - xpoints = (XPoint *) PR_Malloc(sizeof(XPoint) * aNumPoints); +PRUint32 i ; +PolyHandle thepoly; +PRInt32 x,y; - for (i = 0; i < aNumPoints; i++){ - thispoint = (xpoints+i); - thispoint->x = aPoints[i].x; - thispoint->y = aPoints[i].y; - mTMatrix->TransformCoord((PRInt32*)&thispoint->x,(PRInt32*)&thispoint->y); - } - ::XDrawLines(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - xpoints, aNumPoints, CoordModeOrigin); - - PR_Free((void *)xpoints); -*/ + thepoly = ::OpenPoly(); + + x = aPoints[0].x; + y = aPoints[0].y; + mTMatrix->TransformCoord((PRInt32*)&x,(PRInt32*)&y); + ::MoveTo(x,y); + for (i = 1; i < aNumPoints; i++) + { + x = aPoints[i].x; + y = aPoints[i].y; + mTMatrix->TransformCoord((PRInt32*)&x,(PRInt32*)&y); + ::LineTo(x,y); + } + ClosePoly(); + + ::FramePoly(thepoly); } +//------------------------------------------------------------------------ + void nsRenderingContextMac::FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) { -/* - PRUint32 i ; - XPoint * xpoints; - XPoint * thispoint; - nscoord x,y; - - xpoints = (XPoint *) PR_Malloc(sizeof(XPoint) * aNumPoints); +PRUint32 i ; +PolyHandle thepoly; +PRInt32 x,y; - for (i = 0; i < aNumPoints; i++){ - thispoint = (xpoints+i); + + thepoly = ::OpenPoly(); + + x = aPoints[0].x; + y = aPoints[0].y; + mTMatrix->TransformCoord((PRInt32*)&x,(PRInt32*)&y); + ::MoveTo(x,y); + for (i = 1; i < aNumPoints; i++) + { x = aPoints[i].x; y = aPoints[i].y; - mTMatrix->TransformCoord(&x,&y); - thispoint->x = x; - thispoint->y = y; - } - - ::XFillPolygon(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - xpoints, aNumPoints, Convex, CoordModeOrigin); - - PR_Free((void *)xpoints); -*/ + mTMatrix->TransformCoord((PRInt32*)&x,(PRInt32*)&y); + ::LineTo(x,y); + } + ClosePoly(); + + ::PaintPoly(thepoly); } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DrawEllipse(const nsRect& aRect) { DrawEllipse(aRect.x, aRect.y, aRect.width, aRect.height); } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) { -/* - nscoord x,y,w,h; +nscoord x,y,w,h; +Rect therect; x = aX; y = aY; @@ -746,23 +767,23 @@ void nsRenderingContextMac :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth h = aHeight; mTMatrix->TransformCoord(&x,&y,&w,&h); - - ::XDrawArc(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x,y,w,h, 0, 360 * 64); -*/ + SetRect(&therect,x,y,x+w,x+h); + ::FrameOval(&therect); } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: FillEllipse(const nsRect& aRect) { FillEllipse(aRect.x, aRect.y, aRect.width, aRect.height); } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) { -/* - nscoord x,y,w,h; +nscoord x,y,w,h; +Rect therect; x = aX; y = aY; @@ -770,25 +791,25 @@ void nsRenderingContextMac :: FillEllipse(nscoord aX, nscoord aY, nscoord aWidth h = aHeight; mTMatrix->TransformCoord(&x,&y,&w,&h); - - ::XFillArc(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x,y,w,h, 0, 360 * 64); -*/ + SetRect(&therect,x,y,x+w,x+h); + ::PaintOval(&therect); } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DrawArc(const nsRect& aRect, float aStartAngle, float aEndAngle) { this->DrawArc(aRect.x,aRect.y,aRect.width,aRect.height,aStartAngle,aEndAngle); } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, float aStartAngle, float aEndAngle) { -/* - nscoord x,y,w,h; +nscoord x,y,w,h; +Rect therect; x = aX; y = aY; @@ -796,26 +817,26 @@ void nsRenderingContextMac :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, ns h = aHeight; mTMatrix->TransformCoord(&x,&y,&w,&h); + SetRect(&therect,x,y,x+w,x+h); + ::FrameArc(&therect,aStartAngle,aEndAngle); - ::XDrawArc(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x,y,w,h, NSToIntRound(aStartAngle * 64.0f), - NSToIntRound(aEndAngle * 64.0f)); -*/ } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: FillArc(const nsRect& aRect, float aStartAngle, float aEndAngle) { this->FillArc(aRect.x, aRect.y, aRect.width, aRect.height, aStartAngle, aEndAngle); } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, float aStartAngle, float aEndAngle) { -/* - nscoord x,y,w,h; +nscoord x,y,w,h; +Rect therect; x = aX; y = aY; @@ -823,33 +844,28 @@ void nsRenderingContextMac :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, ns h = aHeight; mTMatrix->TransformCoord(&x,&y,&w,&h); - - ::XFillArc(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x,y,w,h, NSToIntRound(aStartAngle * 64.0f), - NSToIntRound(aEndAngle * 64.0f)); -*/ + SetRect(&therect,x,y,x+w,x+h); + ::PaintArc(&therect,aStartAngle,aEndAngle); } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DrawString(const char *aString, PRUint32 aLength, nscoord aX, nscoord aY, nscoord aWidth) { -/* - PRInt32 x = aX; - PRInt32 y = aY; +PRInt32 x = aX; +PRInt32 y = aY; // Substract xFontStruct ascent since drawing specifies baseline if (mFontMetrics) y += mFontMetrics->GetMaxAscent(); mTMatrix->TransformCoord(&x,&y); + + ::MoveTo(x,y); + DrawText(aString,0,aLength); - ::XDrawString(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x, y, aString, aLength); if (mFontMetrics) { @@ -874,15 +890,17 @@ void nsRenderingContextMac :: DrawString(const char *aString, PRUint32 aLength, DrawLine(aX, aY + (height >> 1), aX + aWidth, aY + (height >> 1)); } } -*/ + } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DrawString(const PRUnichar *aString, PRUint32 aLength, nscoord aX, nscoord aY, nscoord aWidth) { -/* - PRInt32 x = aX; - PRInt32 y = aY; + +PRInt32 x = aX; +PRInt32 y = aY; // Substract xFontStruct ascent since drawing specifies baseline if (mFontMetrics) @@ -890,10 +908,8 @@ void nsRenderingContextMac :: DrawString(const PRUnichar *aString, PRUint32 aLen mTMatrix->TransformCoord(&x, &y); - ::XDrawString16(mRenderingSurface->display, - mRenderingSurface->drawable, - mRenderingSurface->gc, - x, y, (XChar2b *)aString, aLength); + ::MoveTo(x,y); + DrawText(aString,0,aLength); if (mFontMetrics) { @@ -918,41 +934,48 @@ void nsRenderingContextMac :: DrawString(const PRUnichar *aString, PRUint32 aLen DrawLine(aX, aY + (height >> 1), aX + aWidth, aY + (height >> 1)); } } -*/ + } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DrawString(const nsString& aString, nscoord aX, nscoord aY, nscoord aWidth) { DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aWidth); } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY) { -/* - nscoord width,height; +nscoord width,height; + width = NSToCoordRound(mP2T * aImage->GetWidth()); height = NSToCoordRound(mP2T * aImage->GetHeight()); - this->DrawImage(aImage,aX,aY,width,height);8? -*/ + this->DrawImage(aImage,aX,aY,width,height); } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) { - /* nsRect tr; +nsRect tr; tr.x = aX; tr.y = aY; tr.width = aWidth; tr.height = aHeight; - this->DrawImage(aImage,tr);*/ + this->DrawImage(aImage,tr); } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect) { -/* nsRect sr,dr; +nsRect sr,dr; sr = aSRect; mTMatrix ->TransformCoord(&sr.x,&sr.y,&sr.width,&sr.height); @@ -961,23 +984,30 @@ void nsRenderingContextMac :: DrawImage(nsIImage *aImage, const nsRect& aSRect, mTMatrix->TransformCoord(&dr.x,&dr.y,&dr.width,&dr.height); ((nsImageMac*)aImage)->Draw(*this,mRenderingSurface,sr.x,sr.y,sr.width,sr.height, - dr.x,dr.y,dr.width,dr.height);*/ + dr.x,dr.y,dr.width,dr.height); } +//------------------------------------------------------------------------ + void nsRenderingContextMac :: DrawImage(nsIImage *aImage, const nsRect& aRect) { -/* nsRect tr; +nsRect tr; tr = aRect; mTMatrix->TransformCoord(&tr.x,&tr.y,&tr.width,&tr.height); - if (aImage != nsnull) { + if (aImage != nsnull) + { ((nsImageMac*)aImage)->Draw(*this,mRenderingSurface,tr.x,tr.y,tr.width,tr.height); - } else { + } + else + { printf("Image is NULL!\n"); - }*/ + } } +//------------------------------------------------------------------------ + nsresult nsRenderingContextMac :: CopyOffScreenBits(nsRect &aBounds) { /* diff --git a/mozilla/gfx/src/mac/nsRenderingContextMac.h b/mozilla/gfx/src/mac/nsRenderingContextMac.h index db3dacc26a0..6d6e77920c4 100644 --- a/mozilla/gfx/src/mac/nsRenderingContextMac.h +++ b/mozilla/gfx/src/mac/nsRenderingContextMac.h @@ -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; diff --git a/mozilla/widget/src/mac/nsDeviceContextMac.cpp b/mozilla/widget/src/mac/nsDeviceContextMac.cpp index 02f9eabf51f..44fa9ad8d15 100644 --- a/mozilla/widget/src/mac/nsDeviceContextMac.cpp +++ b/mozilla/widget/src/mac/nsDeviceContextMac.cpp @@ -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; } +//------------------------------------------------------------------------ + +