Index: gr_CocoaGraphics.mm =================================================================== RCS file: /cvsroot/abi/src/af/gr/cocoa/gr_CocoaGraphics.mm,v retrieving revision 1.74 diff --unified=3 -r1.74 gr_CocoaGraphics.mm --- gr_CocoaGraphics.mm 3 Oct 2004 12:36:14 -0000 1.74 +++ gr_CocoaGraphics.mm 5 Oct 2004 19:54:11 -0000 @@ -63,8 +63,8 @@ #define CG_CONTEXT__ (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort] -#define TDUX(x) (_tduX(x)+1.0) - +//#define TDUX(x) (_tduX(x)+1.0) +#define TDUX(x) (_tduX(x)) // create a stack object like that to lock a NSView, then it will be unlocked on scope exit. // never do a new class StNSViewLocker { @@ -777,108 +777,27 @@ * there can be a sizeable discrepancy (in local units) between the scroll that was requested and the * reported exposed area. I am therefore marking an extra 1-pixel border around the exposed display area. */ - if (offset.width > 0) - { - if (offset.width < bounds.size.width) - { - if (offset.height > 0) - { - if (offset.height < bounds.size.height) - { - NSRect tmp; - tmp.origin.x = -1.0 + bounds.origin.x + offset.width; - tmp.origin.y = -1.0 + bounds.origin.y; - tmp.size.width = 2.0 + bounds.size.width - offset.width; - tmp.size.height = 2.0 + offset.height; - [m_pWin setNeedsDisplayInRect:tmp]; - - bounds.size.width = offset.width; - } - } - else if (offset.height < 0) - { - if ((-offset.height) < bounds.size.height) - { - NSRect tmp; - tmp.origin.x = -1.0 + bounds.origin.x + offset.width; - tmp.origin.y = -1.0 + bounds.origin.y + bounds.size.height + offset.height; - tmp.size.width = 2.0 + bounds.size.width - offset.width; - tmp.size.height = 2.0 - offset.height; - [m_pWin setNeedsDisplayInRect:tmp]; - - bounds.size.width = offset.width; - } - } - else - { - bounds.size.width = offset.width; - } - } - } - else if (offset.width < 0) - { - if ((-offset.width) < bounds.size.width) - { - if (offset.height > 0) - { - if (offset.height < bounds.size.height) - { - NSRect tmp; - tmp.origin.x = -1.0 + bounds.origin.x; - tmp.origin.y = -1.0 + bounds.origin.y; - tmp.size.width = 2.0 + bounds.size.width - offset.width; - tmp.size.height = 2.0 + offset.height; - [m_pWin setNeedsDisplayInRect:tmp]; - bounds.origin.x += bounds.size.width + offset.width; - bounds.size.width = -offset.width; - } - } - else if (offset.height < 0) - { - if ((-offset.height) < bounds.size.height) - { - NSRect tmp; - tmp.origin.x = -1.0 + bounds.origin.x; - tmp.origin.y = -1.0 + bounds.origin.y + bounds.size.height + offset.height; - tmp.size.width = 2.0 + bounds.size.width + offset.width; - tmp.size.height = 2.0 - offset.height; - [m_pWin setNeedsDisplayInRect:tmp]; +/* This is a temporary special case to handle the fact that FV_View::setYScrollOffset doesn't call draw unlike it's horizontal counterpart and +the scroll functions of the rulers.*/ - bounds.origin.x += bounds.size.width + offset.width; - bounds.size.width = -offset.width; - } - } - else - { - bounds.origin.x += bounds.size.width + offset.width; - bounds.size.width = -offset.width; - } - } - } - else - { - if (offset.height > 0) - { - if (offset.height < bounds.size.height) - { - bounds.size.height = offset.height; - } - } - else if (offset.height < 0) - { - if ((-offset.height) < bounds.size.height) - { - bounds.origin.y += bounds.size.height + offset.height; - bounds.size.height = -offset.height; - } - } - } - bounds.origin.x += -1.0; - bounds.origin.y += -1.0; - bounds.size.width += 2.0; - bounds.size.height += 2.0; - [m_pWin setNeedsDisplayInRect:bounds]; + if ( bounds.size.width != 32 ) //if not the ruler ( poor check but temporary ) + { + NSRect tmp; + tmp.origin.x = -1.0 + bounds.origin.x; + tmp.size.width = 2.0 + bounds.size.width; + if (ddy > 0 ) + { + tmp.size.height = 2.0 + offset.height; + tmp.origin.y = -1.0 + bounds.origin.y; + } + else + { + tmp.size.height = 2.0 - offset.height; + tmp.origin.y = -1.0 + bounds.origin.y + bounds.size.height + offset.height; + } + [m_pWin setNeedsDisplayInRect:tmp]; + } if (pC) pC->enable (); } @@ -887,13 +806,22 @@ UT_sint32 x_src, UT_sint32 y_src, UT_sint32 width, UT_sint32 height) { - UT_sint32 dx, dy; - dx = tdu(x_src - x_dest); - dy = tdu(y_src - y_dest); - printf ("scrollrect: %f %f %f %f -> %d %d\n", (float)tdu(x_src), (float)tdu(y_src), - (float)tdu(width), (float)tdu(height), -dx, dy); - [m_pWin scrollRect:NSMakeRect(tduD(x_src), tduD(y_src), tduD(width), tduD(height)) - by:NSMakeSize(-dx,dy)]; + + UT_sint32 dx, dy; + dx = x_src - x_dest; + dy = y_src - y_dest; + + UT_sint32 oldDY = tdu(getPrevYOffset()); + UT_sint32 oldDX = tdu(getPrevXOffset()); + UT_sint32 newY = getPrevYOffset() + dy; + UT_sint32 newX = getPrevXOffset() + dx; + UT_sint32 ddx = -(tdu(newX) - oldDX); + UT_sint32 ddy = -(tdu(newY) - oldDY); + + [m_pWin scrollRect:NSMakeRect(_tduX(x_src), tdu(y_src), tdu(width), tdu(height)) + by:NSMakeSize(ddx,ddy)]; + setPrevYOffset(newY); + setPrevXOffset(newX); } void GR_CocoaGraphics::clearArea(UT_sint32 x, UT_sint32 y, @@ -930,7 +858,6 @@ return true; } - GR_Image* GR_CocoaGraphics::createNewImage(const char* pszName, const UT_ByteBuf* pBB, UT_sint32 iDisplayWidth, UT_sint32 iDisplayHeight, GR_Image::GRType iType) { GR_Image* pImg = NULL; @@ -1252,9 +1179,11 @@ NSImage* cache = m_cacheArray.getNthItem(iIndx); NSPoint pt = cacheRect->origin; pt.x -= 1; /* I don't know why this offset, but it is nicer no more pixeldirt */ - pt.y += cacheRect->size.height; + pt.y += cacheRect->size.height -1; { - LOCK_CONTEXT__; + LOCK_CONTEXT__; + ::CGContextTranslateCTM (m_CGContext, 0.5, 0.5); + [cache compositeToPoint:pt operation:NSCompositeCopy]; } }