diff --git a/ChangeLog b/ChangeLog index 2b107e000..3647da4d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2001-09-02 Adam Fedor + + * Source/NSView.m (-lockFocusInRect:) Properly mark the save object. + Do a rectviewclip in (sortof) the right place. + +2001-08-31 Georg Fleischmann + + * Source/NSView.m + [NSView lockFocusInRect:]: DPSsave(ctxt) added + [NSView unlockFocusWithFlush:]: DPSrestore(ctxt) added + + * Headers/gnustep/gui/DPSOperators.h + DPSrestore() and DPSsave(): new + + * Headers/gnustep/gui/GSMethodTable.h + DPSrestore and DPSsave added + + * Headers/gnustep/gui/NSGraphicsContext.h + -DPSrestore and -DPSsave added + + * Source/NSGraphicsContext.m + [NSGraphicContext _inittializeMethodTable]: + DPSrestore and DPSsave added + [NSGraphicsContext DPSrestore]: new + [NSGraphicsContext DPSsave]: new + 2001-09-01 Adam Fedor * Source/NSImage.m ([NSImage -initWithCoder:]): Create _reps array diff --git a/Headers/gnustep/gui/DPSOperators.h b/Headers/gnustep/gui/DPSOperators.h index f1798ae30..7b6997568 100644 --- a/Headers/gnustep/gui/DPSOperators.h +++ b/Headers/gnustep/gui/DPSOperators.h @@ -667,6 +667,17 @@ static inline void DPSviewclippath(GSCTXT *ctxt) __attribute__((unused)); +/* ----------------------------------------------------------------------- */ +/* System ops */ +/* ----------------------------------------------------------------------- */ +static inline void +DPSrestore(GSCTXT *ctxt) +__attribute__((unused)); + +static inline void +DPSsave(GSCTXT *ctxt) +__attribute__((unused)); + /* ----------------------------------------------------------------------- */ /* Window system ops */ /* ----------------------------------------------------------------------- */ @@ -2179,6 +2190,23 @@ DPScurrentalpha(GSCTXT *ctxt, float *a) (ctxt, @selector(DPScurrentalpha:), a); } +/* ----------------------------------------------------------------------- */ +/* System ops */ +/* ----------------------------------------------------------------------- */ +static inline void +DPSrestore(GSCTXT *ctxt) +{ + (ctxt->methods->DPSrestore) + (ctxt, @selector(DPSrestore)); +} + +static inline void +DPSsave(GSCTXT *ctxt) +{ + (ctxt->methods->DPSsave) + (ctxt, @selector(DPSsave)); +} + /* ----------------------------------------------------------------------- */ /* Window ops extensions */ /* ----------------------------------------------------------------------- */ diff --git a/Headers/gnustep/gui/GSMethodTable.h b/Headers/gnustep/gui/GSMethodTable.h index 49eedbf1c..4f91704b1 100644 --- a/Headers/gnustep/gui/GSMethodTable.h +++ b/Headers/gnustep/gui/GSMethodTable.h @@ -369,6 +369,14 @@ typedef struct { void (*DPSviewclippath) (NSGraphicsContext*, SEL); /* ----------------------------------------------------------------------- */ +/* System ops */ +/* ----------------------------------------------------------------------- */ + void (*DPSrestore) + (NSGraphicsContext*, SEL); + void (*DPSsave) + (NSGraphicsContext*, SEL); + +/* ----------------------------------------------------------------------- */ /* Window system ops */ /* ----------------------------------------------------------------------- */ void (*DPScurrentdrawingfunction_) diff --git a/Headers/gnustep/gui/NSGraphicsContext.h b/Headers/gnustep/gui/NSGraphicsContext.h index f5e8ad659..d761b0ff0 100644 --- a/Headers/gnustep/gui/NSGraphicsContext.h +++ b/Headers/gnustep/gui/NSGraphicsContext.h @@ -366,6 +366,13 @@ NSGraphicsContext *GSCurrentContext(); - (void) DPSsetbbox: (float)llx : (float)lly : (float)urx : (float)ury ; - (void) DPSviewclip; - (void) DPSviewclippath; + +/* ----------------------------------------------------------------------- */ +/* System system ops */ +/* ----------------------------------------------------------------------- */ +- (void) DPSrestore ; +- (void) DPSsave ; + /* ----------------------------------------------------------------------- */ /* Window system ops */ /* ----------------------------------------------------------------------- */ diff --git a/Headers/gnustep/gui/NSNibLoading.h b/Headers/gnustep/gui/NSNibLoading.h index e64fed530..d08244986 100644 --- a/Headers/gnustep/gui/NSNibLoading.h +++ b/Headers/gnustep/gui/NSNibLoading.h @@ -30,6 +30,8 @@ #include #include +#include +#include @class NSString; @class NSDictionary; diff --git a/Source/NSGraphicsContext.m b/Source/NSGraphicsContext.m index dc76bbdaf..6987f1d44 100644 --- a/Source/NSGraphicsContext.m +++ b/Source/NSGraphicsContext.m @@ -731,6 +731,13 @@ NSGraphicsContext *GSCurrentContext() methodTable.DPSviewclippath = GET_IMP(@selector(DPSviewclippath)); /* ----------------------------------------------------------------------- */ +/* System system ops */ +/* ----------------------------------------------------------------------- */ + methodTable.DPSrestore = + GET_IMP(@selector(DPSrestore)); + methodTable.DPSsave = + GET_IMP(@selector(DPSsave)); +/* ----------------------------------------------------------------------- */ /* Window system ops */ /* ----------------------------------------------------------------------- */ methodTable.DPScurrentdrawingfunction_ = @@ -1798,6 +1805,20 @@ NSGraphicsContext *GSCurrentContext() [self subclassResponsibility: _cmd]; } +/* ----------------------------------------------------------------------- */ +/* System ops */ +/* ----------------------------------------------------------------------- */ + +- (void) DPSrestore +{ + [self subclassResponsibility: _cmd]; +} + +- (void) DPSsave +{ + [self subclassResponsibility: _cmd]; +} + /* ----------------------------------------------------------------------- */ /* Window system ops */ /* ----------------------------------------------------------------------- */ diff --git a/Source/NSView.m b/Source/NSView.m index 33368a465..93a0c54aa 100644 --- a/Source/NSView.m +++ b/Source/NSView.m @@ -1317,6 +1317,7 @@ GSSetDragTypes(NSView* obj, NSArray *types) - (void) lockFocusInRect: (NSRect)rect { NSGraphicsContext *ctxt = GSCurrentContext(); + NSAffineTransform *matrix; struct NSWindow_struct *window_t; NSRect wrect; int window_gstate; @@ -1330,12 +1331,26 @@ GSSetDragTypes(NSView* obj, NSArray *types) [ctxt lockFocusView: self inRect: rect]; wrect = [self convertRect: rect toView: nil]; - NSDebugLLog(@"NSView", @"Displaying rect \n\t%@\n\t window %p", - NSStringFromRect(wrect), _window); + NSDebugLLog(@"NSView", @"Displaying rect \n\t%@\n\t window %p, flip %d", + NSStringFromRect(wrect), _window, _rFlags.flipped_view); window_t = (struct NSWindow_struct *)_window; [window_t->_rectsBeingDrawn addObject: [NSValue valueWithRect: wrect]]; - DPSgsave(ctxt); + /* + * Clipping - set viewclip to the visible rectangle - which will never be + * greater than the bounds of the view. This prevents drawing outside + * our bounds (FIXME: Perhaps IntersectRect with bounds, just to make sure?) + */ + DPSsave(ctxt); + DPSmark(ctxt); /* Rather than keep the save object, just mark it to make + sure we can find it when we unlock. We really should + keep an ivar for it, though... */ + matrix = [self _matrixToWindow]; + if ([matrix isRotated]) + { + [matrix boundingRectFor: rect result: &rect]; + } + if (_gstate) { DPSsetgstate(ctxt, _gstate); @@ -1345,32 +1360,16 @@ GSSetDragTypes(NSView* obj, NSArray *types) } _renew_gstate = 0; DPSgsave(ctxt); + DPSrectviewclip(ctxt, NSMinX(rect), NSMinY(rect), + NSWidth(rect), NSHeight(rect)); } else { - NSAffineTransform *matrix; - float x, y, w, h; - DPSsetgstate(ctxt, window_gstate); DPSgsave(ctxt); - matrix = [self _matrixToWindow]; [matrix concat]; - - /* - * Clipping - set viewclip to the visible rectangle - which will never be - * greater than the bounds of the view. - * Set the standard clippath to an empty path. - */ - if ([matrix isRotated]) - { - [matrix boundingRectFor: rect result: &rect]; - } - - x = NSMinX(rect); - y = NSMinY(rect); - w = NSWidth(rect); - h = NSHeight(rect); - DPSrectviewclip(ctxt, x, y, w, h); + DPSrectviewclip(ctxt, NSMinX(rect), NSMinY(rect), + NSWidth(rect), NSHeight(rect)); /* Allow subclases to make other modifications */ [self setUpGState]; @@ -1401,8 +1400,9 @@ GSSetDragTypes(NSView* obj, NSArray *types) /* Restore our original gstate */ DPSgrestore(ctxt); - /* Restore gstate of nesting lockFocus (if any) */ - DPSgrestore(ctxt); + /* Restore state (including viewclip) of nesting lockFocus */ + DPScleartomark(ctxt); + DPSrestore(ctxt); if (!_allocate_gstate) _gstate = 0;