rot13'd all the files to make them appear much prettier, and in the process fixed some bugs i believe.

This commit is contained in:
pavlov%pavlov.net 1999-04-07 04:02:44 +00:00
parent 616c553b24
commit ed3de3ccfe
4 changed files with 99 additions and 38 deletions

View File

@ -117,7 +117,52 @@ NS_IMETHODIMP nsDeviceContextGTK::Init(nsNativeWidget aNativeWidget)
NS_IMETHODIMP nsDeviceContextGTK::CreateRenderingContext(nsIRenderingContext *&aContext)
{
return NS_ERROR_FAILURE;
nsIRenderingContext *pContext;
nsresult rv;
nsDrawingSurfaceGTK *surf;
// to call init for this, we need to have a valid nsDrawingSurfaceGTK created
pContext = new nsRenderingContextGTK();
if (nsnull != pContext)
{
NS_ADDREF(pContext);
// create the nsDrawingSurfaceGTK
surf = new nsDrawingSurfaceGTK();
if (nsnull != surf)
{
GdkDrawable *win = nsnull;
// FIXME
if (GTK_IS_LAYOUT((GtkWidget*)mWidget))
win = (GdkDrawable*)gdk_window_ref(GTK_LAYOUT((GtkWidget*)mWidget)->bin_window);
else
win = (GdkDrawable*)gdk_window_ref(((GtkWidget*)mWidget)->window);
GdkGC *gc = gdk_gc_new(win);
// init the nsDrawingSurfaceGTK
rv = surf->Init(win,gc);
if (NS_OK == rv)
// Init the nsRenderingContextGTK
rv = pContext->Init(this, surf);
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
if (NS_OK != rv)
{
NS_IF_RELEASE(pContext);
}
aContext = pContext;
return rv;
}
NS_IMETHODIMP nsDeviceContextGTK::SupportsNativeWidgets(PRBool &aSupportsWidgets)
@ -188,7 +233,7 @@ NS_IMETHODIMP nsDeviceContextGTK::GetSystemAttribute(nsSystemAttrID anID, System
case eSystemAttr_Size_ScrollbarHeight:
aInfo->mSize = mScrollbarHeight;
break;
case eSystemAttr_Size_ScrollbarWidth :
case eSystemAttr_Size_ScrollbarWidth:
aInfo->mSize = mScrollbarWidth;
break;
case eSystemAttr_Size_WindowTitleHeight:

View File

@ -147,7 +147,8 @@ NS_IMETHODIMP nsDrawingSurfaceGTK :: Lock(PRInt32 aX, PRInt32 aY,
mLockHeight = aHeight;
mLockFlags = aFlags;
// Obtain an ximage from the pixmap.
// Obtain an ximage from the pixmap.
g_print("gdk_get_use_xshm() = %i\n", gdk_get_use_xshm());
mImage = ::gdk_image_get(mPixmap, mLockX, mLockY, mLockWidth, mLockHeight);
// The bits will be in the ximage.
@ -169,7 +170,7 @@ NS_IMETHODIMP nsDrawingSurfaceGTK :: Lock(PRInt32 aX, PRInt32 aY,
// int width_in_pixels = *aWidthBytes << 8;
// int bitmap_pad = ((GdkImagePrivate*)mImage)->ximage->bitmap_pad;
// int bitmap_pad = ((GdkImagePrivate*)mImage)->ximage->bitmap_pad;
// int depth = ((GdkImagePrivate*)mImage)->ximage->depth;
// #define RASWIDTH8(width, bpp) (width)
@ -199,7 +200,7 @@ NS_IMETHODIMP nsDrawingSurfaceGTK :: Lock(PRInt32 aX, PRInt32 aY,
// }
// *aStride = (*aWidthBytes) + ((bitmap_pad >> 3) - 1);
// *aStride = (*aWidthBytes) + ((bitmap_pad >> 3) - 1);
// ((GdkImagePrivate*)mImage)->ximage->bitmap_pad;

View File

@ -78,8 +78,7 @@ nsRenderingContextGTK::nsRenderingContextGTK()
mTMatrix = nsnull;
mP2T = 1.0f;
mStateCache = new nsVoidArray();
mRegion = new nsRegionGTK();
mRegion->Init();
mClipRegion = nsnull;
mDrawStringBuf = nsnull;
PushState();
@ -104,7 +103,7 @@ nsRenderingContextGTK::~nsRenderingContextGTK()
if (mTMatrix)
delete mTMatrix;
NS_IF_RELEASE(mRegion);
NS_IF_RELEASE(mClipRegion);
NS_IF_RELEASE(mOffscreenSurface);
NS_IF_RELEASE(mFontMetrics);
NS_IF_RELEASE(mContext);
@ -131,13 +130,16 @@ NS_IMETHODIMP nsRenderingContextGTK::Init(nsIDeviceContext* aContext,
if (mSurface)
{
#ifndef NS_GTK_REF
// we want to ref the window here so that we can unref in the drawing surface.
// otherwise, we can not unref and that causes windows that are created in the
// drawing surface not to be freed.
GdkDrawable *win = (GdkDrawable*)gdk_window_ref((GdkWindow *)aWindow->GetNativeData(NS_NATIVE_WINDOW));
#else
GdkDrawable *win = (GdkDrawable *)aWindow->GetNativeData(NS_NATIVE_WINDOW);
#endif
GdkGC *gc = (GdkGC *)aWindow->GetNativeData(NS_NATIVE_GRAPHIC);
mSurface->Init(win,gc);
mOffscreenSurface = mSurface;
NS_ADDREF(mSurface);
@ -159,6 +161,13 @@ NS_IMETHODIMP nsRenderingContextGTK::Init(nsIDeviceContext* aContext,
NS_IMETHODIMP nsRenderingContextGTK::CommonInit()
{
gint x, y, w, h, d;
gdk_window_get_geometry(mSurface->GetDrawable(), &x, &y, &w, &h, &d);
mClipRegion = new nsRegionGTK();
mClipRegion->Init();
mClipRegion->SetTo(0, 0, w, h);
mContext->GetDevUnitsToAppUnits(mP2T);
float app2dev;
mContext->GetAppUnitsToDevUnits(app2dev);
@ -245,14 +254,15 @@ NS_IMETHODIMP nsRenderingContextGTK::PushState(void)
else
mTMatrix = new nsTransform2D(mTMatrix);
NS_ADDREF(mRegion);
state->mClipRegion = mRegion;
if (state->mClipRegion) {
mRegion = new nsRegionGTK();
mRegion->Init();
mRegion->SetTo(state->mClipRegion);
}
if (mClipRegion)
{
NS_IF_ADDREF(mClipRegion);
state->mClipRegion = mClipRegion;
mClipRegion = new nsRegionGTK();
mClipRegion->Init();
mClipRegion->SetTo(state->mClipRegion);
}
NS_IF_ADDREF(mFontMetrics);
state->mFontMetrics = mFontMetrics;
@ -279,16 +289,16 @@ NS_IMETHODIMP nsRenderingContextGTK::PopState(PRBool &aClipEmpty)
delete mTMatrix;
mTMatrix = state->mMatrix;
NS_RELEASE(mRegion);
NS_RELEASE(mClipRegion);
// restore everything
mRegion = state->mClipRegion;
mClipRegion = state->mClipRegion;
mFontMetrics = state->mFontMetrics;
if (mSurface)
if (mSurface && mClipRegion)
{
GdkRegion *rgn;
mRegion->GetNativeRegion((void*&)rgn);
mClipRegion->GetNativeRegion((void*&)rgn);
::gdk_gc_set_clip_region (mSurface->GetGC(), rgn);
}
@ -302,7 +312,10 @@ NS_IMETHODIMP nsRenderingContextGTK::PopState(PRBool &aClipEmpty)
delete state;
}
aClipEmpty = mRegion->IsEmpty();
if (mClipRegion)
aClipEmpty = mClipRegion->IsEmpty();
else
aClipEmpty = PR_TRUE;
return NS_OK;
}
@ -317,9 +330,9 @@ NS_IMETHODIMP nsRenderingContextGTK::IsVisibleRect(const nsRect& aRect,
NS_IMETHODIMP nsRenderingContextGTK::GetClipRect(nsRect &aRect, PRBool &aClipValid)
{
PRInt32 x, y, w, h;
if (!mRegion->IsEmpty())
if (!mClipRegion->IsEmpty())
{
mRegion->GetBoundingBox(&x,&y,&w,&h);
mClipRegion->GetBoundingBox(&x,&y,&w,&h);
aRect.SetRect(x,y,w,h);
aClipValid = PR_TRUE;
} else {
@ -388,22 +401,22 @@ NS_IMETHODIMP nsRenderingContextGTK::SetClipRect(const nsRect& aRect,
switch(aCombine)
{
case nsClipCombine_kIntersect:
mRegion->Intersect(trect.x,trect.y,trect.width,trect.height);
mClipRegion->Intersect(trect.x,trect.y,trect.width,trect.height);
break;
case nsClipCombine_kUnion:
mRegion->Union(trect.x,trect.y,trect.width,trect.height);
mClipRegion->Union(trect.x,trect.y,trect.width,trect.height);
break;
case nsClipCombine_kSubtract:
mRegion->Subtract(trect.x,trect.y,trect.width,trect.height);
mClipRegion->Subtract(trect.x,trect.y,trect.width,trect.height);
break;
case nsClipCombine_kReplace:
mRegion->SetTo(trect.x,trect.y,trect.width,trect.height);
mClipRegion->SetTo(trect.x,trect.y,trect.width,trect.height);
break;
}
aClipEmpty = mRegion->IsEmpty();
aClipEmpty = mClipRegion->IsEmpty();
mRegion->GetNativeRegion((void*&)rgn);
mClipRegion->GetNativeRegion((void*&)rgn);
gdk_gc_set_clip_region(mSurface->GetGC(),rgn);
return NS_OK;
@ -418,21 +431,21 @@ NS_IMETHODIMP nsRenderingContextGTK::SetClipRegion(const nsIRegion& aRegion,
switch(aCombine)
{
case nsClipCombine_kIntersect:
mRegion->Intersect(aRegion);
mClipRegion->Intersect(aRegion);
break;
case nsClipCombine_kUnion:
mRegion->Union(aRegion);
mClipRegion->Union(aRegion);
break;
case nsClipCombine_kSubtract:
mRegion->Subtract(aRegion);
mClipRegion->Subtract(aRegion);
break;
case nsClipCombine_kReplace:
mRegion->SetTo(aRegion);
mClipRegion->SetTo(aRegion);
break;
}
aClipEmpty = mRegion->IsEmpty();
mRegion->GetNativeRegion((void*&)rgn);
aClipEmpty = mClipRegion->IsEmpty();
mClipRegion->GetNativeRegion((void*&)rgn);
gdk_gc_set_clip_region(mSurface->GetGC(),rgn);
return NS_OK;
@ -464,7 +477,7 @@ NS_IMETHODIMP nsRenderingContextGTK::GetClipRegion(nsIRegion **aRegion)
}
if (rv == NS_OK)
(*aRegion)->SetTo(*mRegion);
(*aRegion)->SetTo(*mClipRegion);
return rv;
}
@ -715,6 +728,8 @@ NS_IMETHODIMP nsRenderingContextGTK::FillRect(nscoord aX, nscoord aY, nscoord aW
mTMatrix->TransformCoord(&x,&y,&w,&h);
// gdk_gc_set_clip_region(mSurface->GetGC(), nsnull);
::gdk_draw_rectangle(mSurface->GetDrawable(), mSurface->GetGC(),
TRUE,
x, y, w, h);

View File

@ -156,7 +156,7 @@ protected:
nsDrawingSurfaceGTK *mSurface;
nsIDeviceContext *mContext;
nsIFontMetrics *mFontMetrics;
nsRegionGTK *mRegion;
nsRegionGTK *mClipRegion;
nsTransform2D *mTMatrix;
float mP2T;
GdkWChar* mDrawStringBuf;