diff --git a/ChangeLog b/ChangeLog index a917989e4..61eaf91cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sun Feb 21 20:36:00 1999 Richard Frith-Macdonald + + * Headers/gnustep/gui/NSCell.h: tidyup + * Headers/gnustep/gui/NSView.h: Added matrix for coordinate conversion + * Source/NSView.m: Bugfix in update, plus partial code for improved + coordinate handling. + Fri Feb 19 20:00:00 1999 Richard Frith-Macdonald * Source/NSClipView.m: coordinate fixes. diff --git a/Headers/gnustep/gui/NSCell.h b/Headers/gnustep/gui/NSCell.h index d4ed044f8..3b1afc386 100644 --- a/Headers/gnustep/gui/NSCell.h +++ b/Headers/gnustep/gui/NSCell.h @@ -343,5 +343,15 @@ enum { @end +// +// Methods that are private GNUstep extensions +// +@interface NSCell (PrivateMethods) + +- (void) _drawImage: (NSImage*)anImage inFrame: (NSRect)aRect; +- (void) _drawText: (NSString*)aString inFrame: (NSRect)aRect; + +@end + #endif // _GNUstep_H_NSCell diff --git a/Headers/gnustep/gui/NSView.h b/Headers/gnustep/gui/NSView.h index 759f15d40..1ecb46d05 100644 --- a/Headers/gnustep/gui/NSView.h +++ b/Headers/gnustep/gui/NSView.h @@ -76,6 +76,7 @@ enum { NSRect bounds; id frameMatrix; id boundsMatrix; + id windowMatrix; NSView* super_view; NSMutableArray *sub_views; @@ -371,10 +372,11 @@ enum { * forcing recalculation of cached values next time they are needed. */ - (void) _invalidateCoordinates; - +- (void) _rebuildCoordinates; - (PSMatrix*)_frameMatrix; - (PSMatrix*)_boundsMatrix; +- (PSMatrix*)_windowMatrix; - (PSMatrix*) _concatenateBoundsMatricesInReverseOrderFromPath: (NSArray*)p; - (PSMatrix*) _concatenateMatricesInReverseOrderFromPath: (NSArray*)p; - (NSMutableArray*) _pathBetweenSubview: (NSView*)subview diff --git a/Source/NSView.m b/Source/NSView.m index 6856bab7d..396e18389 100644 --- a/Source/NSView.m +++ b/Source/NSView.m @@ -176,6 +176,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates); frameMatrix = [PSMatrix new]; // init PS matrix for boundsMatrix = [PSMatrix new]; // frame and bounds + windowMatrix = [PSMatrix new]; // map to window coordinates [frameMatrix setFrameOrigin: frame.origin]; sub_views = [NSMutableArray new]; @@ -191,12 +192,14 @@ static SEL invalidateSel = @selector(_invalidateCoordinates); post_frame_changes = NO; autoresize_subviews = YES; autoresizingMask = NSViewNotSizable; + coordinates_valid = NO; return self; } - (void) dealloc { + [windowMatrix release]; [frameMatrix release]; [boundsMatrix release]; [sub_views release]; @@ -626,10 +629,17 @@ static SEL invalidateSel = @selector(_invalidateCoordinates); { NSPoint new; PSMatrix *matrix; + NSPoint yyy; + PSMatrix *xxx; if (!aView) aView = [window contentView]; + xxx = [[aView _windowMatrix] copy]; + [xxx inverse]; + (*concatImp)(xxx, concatSel, [self _windowMatrix]); + yyy = [xxx pointInMatrixSpace: aPoint]; + if ([self isDescendantOf: aView]) { NSMutableArray *path; @@ -655,6 +665,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates); new = [self convertPoint: new fromView: nil]; } +// NSAssert(NSEqualPoints(new, yyy), NSInternalInconsistencyException); return new; } @@ -1004,7 +1015,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates); * Having drawn ourself into the rect, we must unconditionally * draw any subviews that are also in that rectangle. */ - isect = NSIntersectionRect(rect, subviewFrame); + isect = NSIntersectionRect(aRect, subviewFrame); if (NSIsEmptyRect(isect) == NO) { isect = [subview convertRect: isect @@ -1170,24 +1181,10 @@ static SEL invalidateSel = @selector(_invalidateCoordinates); - (NSRect) visibleRect { - if (coordinates_valid) - return visibleRect; - if (!window) - visibleRect = NSZeroRect; - else if (!super_view) - visibleRect = bounds; - else - { - NSRect superviewsVisibleRect; - - superviewsVisibleRect = [self convertRect: [super_view visibleRect] - fromView: super_view]; - - visibleRect = NSIntersectionRect(superviewsVisibleRect, bounds); - if (needs_display) - invalidRect = NSIntersectionRect(invalidRect, visibleRect); - } - coordinates_valid = YES; + if (coordinates_valid == NO) + [self _rebuildCoordinates]; + if (needs_display) + invalidRect = NSIntersectionRect(invalidRect, visibleRect); return visibleRect; } @@ -1865,11 +1862,58 @@ static SEL invalidateSel = @selector(_invalidateCoordinates); while (view && view != _superview) { [array addObject: view]; - view = view->super_view; + view = view->super_view; } return array; } +- (void) _rebuildCoordinates +{ + if (coordinates_valid == NO) + { + coordinates_valid = YES; + if (!window) + { + visibleRect = NSZeroRect; + [windowMatrix makeIdentityMatrix]; + } + if (!super_view) + { + visibleRect = bounds; + [windowMatrix makeIdentityMatrix]; + } + else + { + NSRect superviewsVisibleRect; + BOOL wasFlipped = [super_view isFlipped]; + float vals[6]; + PSMatrix *pMatrix = [super_view _windowMatrix]; + + [pMatrix getMatrix: vals]; + [windowMatrix setMatrix: vals]; + (*concatImp)(windowMatrix, concatSel, frameMatrix); + if ([self isFlipped] != wasFlipped) + { + flip->matrix[5] = bounds.size.height; + (*concatImp)(windowMatrix, concatSel, flip); + } + (*concatImp)(windowMatrix, concatSel, boundsMatrix); + + superviewsVisibleRect = [self convertRect: [super_view visibleRect] + fromView: super_view]; + + visibleRect = NSIntersectionRect(superviewsVisibleRect, bounds); + } + } +} + +- (PSMatrix*) _windowMatrix +{ + if (coordinates_valid == NO) + [self _rebuildCoordinates]; + return windowMatrix; +} + @end diff --git a/Source/PSMatrix.m b/Source/PSMatrix.m index d43156e76..62b135038 100644 --- a/Source/PSMatrix.m +++ b/Source/PSMatrix.m @@ -69,6 +69,19 @@ static const float pi = 3.1415926535897932384626433; return new; } +- (BOOL) isEqual: (id)anObject +{ + if ([anObject class] == [PSMatrix class]) + { + PSMatrix *o = anObject; + + if (A == o->A && B == o->B && C == o->C + && D == o->D && TX == o->TX && TY == o->TY) + return YES; + } + return NO; +} + - (void)scaleBy:(float)sx :(float)sy { A *= sx; B *= sx;