diff options
author | fvogel <fvogelnew1@free.fr> | 2022-11-09 21:40:51 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2022-11-09 21:40:51 (GMT) |
commit | 16a63be615ba1ff0eddd22b777c041361eb7c0ef (patch) | |
tree | eefd6674a199a676740186e5e0f4f12770f2b424 /macosx/tkMacOSXDraw.c | |
parent | 3dbd737f1811d01dcff8791b15a8cf9dd1bc8735 (diff) | |
parent | 104947147225fa0d71faf4e8769567377370fb6f (diff) | |
download | tk-16a63be615ba1ff0eddd22b777c041361eb7c0ef.zip tk-16a63be615ba1ff0eddd22b777c041361eb7c0ef.tar.gz tk-16a63be615ba1ff0eddd22b777c041361eb7c0ef.tar.bz2 |
merge 8.6
Diffstat (limited to 'macosx/tkMacOSXDraw.c')
-rw-r--r-- | macosx/tkMacOSXDraw.c | 78 |
1 files changed, 30 insertions, 48 deletions
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index d5396eb..874d3cc 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -514,7 +514,7 @@ XDrawSegments( * * XFillPolygon -- * - * Draws a filled polygon using the even-odd fill algorithm, + * Draws a filled polygon. * * Results: * None. @@ -562,7 +562,9 @@ XFillPolygon( CGContextAddLineToPoint(dc.context, prevx, prevy); } } - CGContextEOFillPath(dc.context); + (gc->fill_rule == EvenOddRule) + ? CGContextEOFillPath(dc.context) + : CGContextFillPath(dc.context); } TkMacOSXRestoreDrawingContext(&dc); return Success; @@ -1142,72 +1144,52 @@ TkScrollWindow( Drawable drawable = Tk_WindowId(tkwin); MacDrawable *macDraw = (MacDrawable *)drawable; TKContentView *view = (TKContentView *)TkMacOSXGetNSViewForDrawable(macDraw); - CGRect srcRect, dstRect; - HIShapeRef dmgRgn = NULL, extraRgn = NULL; - NSRect bounds, visRect, scrollSrc, scrollDst; + HIShapeRef srcRgn, dstRgn; + HIMutableShapeRef dmgRgn = HIShapeCreateMutable(); + NSRect bounds, viewSrcRect, srcRect, dstRect; int result = 0; if (view) { + /* * Get the scroll area in NSView coordinates (origin at bottom left). */ bounds = [view bounds]; - scrollSrc = NSMakeRect(macDraw->xOff + x, + viewSrcRect = NSMakeRect(macDraw->xOff + x, bounds.size.height - height - (macDraw->yOff + y), width, height); - scrollDst = NSOffsetRect(scrollSrc, dx, -dy); - /* - * Limit scrolling to the window content area. + /* + * Scroll the rectangle. */ - visRect = [view visibleRect]; - scrollSrc = NSIntersectionRect(scrollSrc, visRect); - scrollDst = NSIntersectionRect(scrollDst, visRect); - if (!NSIsEmptyRect(scrollSrc) && !NSIsEmptyRect(scrollDst)) { - /* - * Mark the difference between source and destination as damaged. - * This region is described in NSView coordinates (y=0 at the - * bottom) and converted to Tk coordinates later. - */ - - srcRect = CGRectMake(x, y, width, height); - dstRect = CGRectOffset(srcRect, dx, dy); + [view scrollRect:viewSrcRect by:NSMakeSize(dx, -dy)]; - /* - * Compute the damage. - */ + /* + * Compute the damage region, using Tk coordinates (origin at top left). + */ - dmgRgn = HIShapeCreateMutableWithRect(&srcRect); - extraRgn = HIShapeCreateWithRect(&dstRect); - ChkErr(HIShapeDifference, dmgRgn, extraRgn, - (HIMutableShapeRef) dmgRgn); - result = HIShapeIsEmpty(dmgRgn) ? 0 : 1; + srcRect = CGRectMake(x, y, width, height); + dstRect = CGRectOffset(srcRect, dx, dy); + srcRgn = HIShapeCreateWithRect(&srcRect); + dstRgn = HIShapeCreateWithRect(&dstRect); + ChkErr(HIShapeDifference, srcRgn, dstRgn, dmgRgn); + result = HIShapeIsEmpty(dmgRgn) ? 0 : 1; - /* - * Convert to Tk coordinates, offset by the window origin. - */ + } - TkMacOSXSetWithNativeRegion(damageRgn, dmgRgn); - if (extraRgn) { - CFRelease(extraRgn); - } + /* + * Convert the HIShape dmgRgn into a TkRegion and store it. + */ - /* - * Scroll the rectangle. - */ + TkMacOSXSetWithNativeRegion(damageRgn, dmgRgn); - [view scrollRect:scrollSrc by:NSMakeSize(dx, -dy)]; - } - } else { - dmgRgn = HIShapeCreateEmpty(); - TkMacOSXSetWithNativeRegion(damageRgn, dmgRgn); - } + /* + * Mutable shapes are not reference counted, and must be released. + */ - if (dmgRgn) { - CFRelease(dmgRgn); - } + CFRelease(dmgRgn); return result; } |