mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
Coordinate conversion code plus bugfix in redisplay stuff.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3768 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6936cc40ab
commit
55564033f8
5 changed files with 97 additions and 21 deletions
|
@ -1,3 +1,10 @@
|
|||
Sun Feb 21 20:36:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* 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 <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSClipView.m: coordinate fixes.
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue