Misc tidying.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3698 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-02-12 21:43:18 +00:00
parent eddafd66d5
commit bd715ecc15
4 changed files with 805 additions and 645 deletions

View file

@ -1,3 +1,9 @@
Fri Feb 12 21:00:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSView.m: Tidied some more.
* Source/NSText.m: Don't use display - use setNeedsDisplay: instead
so that drawing gets done automatically.
Fri Feb 12 16:20:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSView.m: Improve window flushing

View file

@ -644,7 +644,7 @@ typedef enum
[lineLayoutInformation autorelease]; lineLayoutInformation=nil; // force complete re-layout
[self setRichText:NO];
//[self display];
//[self setNeedsDisplay: YES];
}
-(void) setText:(NSString *)string {[self setString:string];}
@ -697,7 +697,7 @@ typedef enum
[self updateDragTypeRegistration];
[self sizeToFit];
[self display];
[self setNeedsDisplay: YES];
}
- (void)setSelectable:(BOOL)flag
@ -779,7 +779,7 @@ typedef enum
- (void)setTextColor:(NSColor *)color
{ ASSIGN(text_color,color);
if(![self isRichText]) [self display];
if(![self isRichText]) [self setNeedsDisplay: YES];
}
- (void)setUsesFontPanel:(BOOL)flag
@ -1043,7 +1043,7 @@ typedef enum
[self updateDragTypeRegistration];
[self replaceRange:NSMakeRange(0,[self textLength]) withAttributedString:peek];
[self rebuildLineLayoutInformationStartingAtLine:0];
[self display];
[self setNeedsDisplay: YES];
return YES;
}
return NO;
@ -1430,7 +1430,7 @@ fprintf(stderr, " NSText keyDown \n");
[lineLayoutInformation autorelease]; lineLayoutInformation=nil;
[self rebuildLineLayoutInformationStartingAtLine:0];
[self display];
[self setNeedsDisplay: YES];
return;
#endif
#if 1
@ -1502,7 +1502,7 @@ fprintf(stderr, " NSText keyDown \n");
[lineLayoutInformation autorelease]; lineLayoutInformation=nil;
[self rebuildLineLayoutInformationStartingAtLine:0];
[self display];
[self setNeedsDisplay: YES];
return;
#endif
#if 1

View file

@ -201,12 +201,6 @@ id t;
- (SEL)errorAction { return error_action; }
- (void)setErrorAction:(SEL)aSelector { error_action = aSelector; }
- (void)displayRect:(NSRect)rect // not per OS spec FIX ME
{
[super displayRect:rect];
[window flushWindow];
}
//
// Handling Events
//

View file

@ -64,7 +64,7 @@ static NSString *viewThreadKey = @"NSViewThreadKey";
if (self == [NSView class])
{
NSDebugLog(@"Initialize NSView class\n");
[self setVersion:1]; // Initial version
[self setVersion: 1];
}
}
@ -142,7 +142,7 @@ static NSString *viewThreadKey = @"NSViewThreadKey";
//
// Instance methods
//
- init
- (id) init
{
return [self initWithFrame: NSZeroRect];
}
@ -158,10 +158,10 @@ static NSString *viewThreadKey = @"NSViewThreadKey";
frameMatrix = [PSMatrix new]; // init PS matrix for
boundsMatrix = [PSMatrix new]; // frame and bounds
[frameMatrix setFrameOrigin: frame.origin];
// initialize lists of:
sub_views = [NSMutableArray new]; // subviews
tracking_rects = [NSMutableArray new]; // tracking rectangles
cursor_rects = [NSMutableArray new]; // cursor rectangles
sub_views = [NSMutableArray new];
tracking_rects = [NSMutableArray new];
cursor_rects = [NSMutableArray new];
super_view = nil;
window = nil;
@ -242,34 +242,39 @@ static NSString *viewThreadKey = @"NSViewThreadKey";
[aView resetCursorRects];
[aView setNeedsDisplay: YES];
[aView release];
} // window it has moved to
}
- (NSView*) ancestorSharedWithView: (NSView*)aView
{
if (self == aView) // Are they the same view?
return self;
if ([self isDescendantOf: aView]) // Is self a descendant of
return aView; // view?
if ([self isDescendantOf: aView]) // Is self a descendant of view?
return aView;
if ([aView isDescendantOf: self]) // Is view a descendant of
return self; // self?
if ([aView isDescendantOf: self]) // Is view a descendant of self?
return self;
if (![self superview]) // If neither are descendants of each other
return nil; // and either does not have a superview
if (![aView superview]) // then they cannot have a common ancestor
// If neither are descendants of each other and either does not have a
// superview then they cannot have a common ancestor
if (![self superview])
return nil;
if (![aView superview])
return nil;
// Find the common ancestor of superviews
return [[self superview] ancestorSharedWithView: [aView superview]];
}
- (BOOL) isDescendantOf: (NSView*)aView
{
if (aView == self) // Quick check
if (aView == self)
return YES;
if (!super_view) // No superview then this
return NO; // is end of the line
if (!super_view)
return NO;
if (super_view == aView)
return YES;
@ -373,12 +378,12 @@ static NSString *viewThreadKey = @"NSViewThreadKey";
- (void) viewWillMoveToWindow: (NSWindow*)newWindow
{
int i, count;
unsigned i, count;
window = newWindow;
count = [sub_views count]; // Pass new window down
for (i = 0; i < count; ++i) // to subviews
count = [sub_views count];
for (i = 0; i < count; ++i)
[[sub_views objectAtIndex: i] viewWillMoveToWindow: newWindow];
}
@ -447,8 +452,7 @@ NSSize old_size = frame.size;
{
if (is_rotated_from_base)
return is_rotated_from_base;
else
if (super_view)
else if (super_view)
return [super_view isRotatedFromBase];
else
return NO;
@ -458,8 +462,7 @@ NSSize old_size = frame.size;
{
if (is_rotated_or_scaled_from_base)
return is_rotated_or_scaled_from_base;
else
if (super_view)
else if (super_view)
return [super_view isRotatedOrScaledFromBase];
else
return NO;
@ -494,8 +497,7 @@ float sx, sy;
[NSException raise: NSInvalidArgumentException
format: @"illegal bounds size supplied"];
bounds = aRect;
[boundsMatrix setFrameOrigin: NSMakePoint(-bounds.origin.x,
-bounds.origin.y)];
[boundsMatrix setFrameOrigin: NSMakePoint(-bounds.origin.x,-bounds.origin.y)];
sx = frame.size.width / bounds.size.width;
sy = frame.size.height / bounds.size.height;
[boundsMatrix scaleTo: sx : sy];
@ -509,10 +511,10 @@ float sx, sy;
object: self];
}
- (void)setBoundsOrigin:(NSPoint)newOrigin // translate bounds origin
{ // in opposite direction so
bounds.origin = newOrigin; // that newOrigin becomes
// the origin when viewed.
- (void) setBoundsOrigin: (NSPoint)newOrigin
{
bounds.origin = newOrigin;
[boundsMatrix setFrameOrigin: NSMakePoint(-newOrigin.x, -newOrigin.y)];
if (post_bounds_changes)
@ -698,12 +700,12 @@ float sx, sy;
- (PSMatrix*) _concatenateBoundsMatricesInReverseOrderFromPath: (NSArray*)viewsPath
{
int i, count = [viewsPath count];
unsigned count = [viewsPath count];
PSMatrix* matrix = [[PSMatrix new] autorelease];
for (i = count - 1; i >= 0; i--)
while (count > 0)
{
NSView* view = [viewsPath objectAtIndex:i];
NSView* view = [viewsPath objectAtIndex: --count];
[matrix concatenateWith: view->boundsMatrix];
}
@ -727,17 +729,15 @@ PSMatrix* matrix;
[matrix inverse];
new = [matrix sizeInMatrixSpace: aSize];
}
else
if ([aView isDescendantOf:self])
else if ([aView isDescendantOf: self])
{
NSArray* path = [self _pathBetweenSubview: aView toSuperview: self];
matrix = [self
_concatenateBoundsMatricesInReverseOrderFromPath:path];
matrix = [self _concatenateBoundsMatricesInReverseOrderFromPath: path];
new = [matrix sizeInMatrixSpace: aSize];
} // The views are not in the same hierarchy of views.
else // Convert the point to window from the other's view
{ // coordinates and then to our view coordinates.
}
else
{
new = [aView convertSize: aSize toView: nil];
new = [self convertSize: new fromView: nil];
}
@ -763,10 +763,11 @@ PSMatrix* matrix;
post_bounds_changes = flag;
}
- (void)resizeSubviewsWithOldSize:(NSSize)oldSize // resize subviews only
{ // if we are supposed
id e, o; // to and we have never
// been rotated
// resize subviews only if we are supposed to and we have never been rotated
- (void) resizeSubviewsWithOldSize: (NSSize)oldSize
{
id e, o;
if (![self autoresizesSubviews] && !is_rotated_from_base)
return;
@ -787,19 +788,22 @@ NSSize old_size = frame.size;
NSSize superViewFrameSize = [super_view frame].size;
BOOL changedOrigin = NO;
BOOL changedSize = NO;
// do nothing if view
if (autoresizingMask == NSViewNotSizable) // is not resizable
// do nothing if view is not resizable
if (autoresizingMask == NSViewNotSizable)
return;
// determine if and how
if (autoresizingMask & NSViewWidthSizable) // the X axis can be
options++; // resized
// determine if and how the X axis can be resized
if (autoresizingMask & NSViewWidthSizable)
options++;
if (autoresizingMask & NSViewMinXMargin)
options++;
if (autoresizingMask & NSViewMaxXMargin)
options++;
// adjust the X axis if
if (options >= 1) // any X options are
{ // set in the mask
// adjust the X axis if any X options are set in the mask
if (options >= 1)
{
change = superViewFrameSize.width - oldSize.width;
changePerOption = floor(change/options);
@ -823,17 +827,19 @@ BOOL changedSize = NO;
changedOrigin = YES;
}
}
// determine if and how
options = 0; // the Y axis can be
if (autoresizingMask & NSViewHeightSizable) // resized
// determine if and how the Y axis can be resized
options = 0;
if (autoresizingMask & NSViewHeightSizable)
options++;
if (autoresizingMask & NSViewMinYMargin)
options++;
if (autoresizingMask & NSViewMaxYMargin)
options++;
// adjust the Y axis if
if (options >= 1) // any Y options are
{ // set in the mask
// adjust the Y axis if any Y options are set in the mask
if (options >= 1)
{
change = superViewFrameSize.height - oldSize.height;
changePerOption = floor(change/options);
@ -873,17 +879,42 @@ BOOL changedSize = NO;
[self resizeSubviewsWithOldSize: old_size];
}
- (void)allocateGState {} // implemented by the
- (void)releaseGState {} // back end
- (int)gState { return 0; }
- (void)renewGState {}
- (void)setUpGState {}
- (void)lockFocus { [self subclassResponsibility:_cmd]; }
- (void)unlockFocus { [self subclassResponsibility:_cmd]; }
- (void) allocateGState
{
// implemented by the back end
}
- (void) releaseGState
{
// implemented by the back end
}
- (int) gState
{
return 0;
}
- (void) renewGState
{
}
- (void) setUpGState
{
}
- (void) lockFocus
{
[self subclassResponsibility: _cmd];
}
- (void) unlockFocus
{
[self subclassResponsibility: _cmd];
}
- (BOOL) canDraw
{ // not implemented per
if (window) // OS spec FIX ME
{ // not implemented per OS spec FIX ME
if (window)
return YES;
else
return NO;
@ -1272,7 +1303,7 @@ NSCursor *c;
- (id) viewWithTag: (int)aTag
{
int i, count;
unsigned i, count;
count = [sub_views count];
for (i = 0; i < count; ++i)
@ -1297,25 +1328,26 @@ int i, count;
- (NSView*) hitTest: (NSPoint)aPoint
{
NSPoint p;
int i, count;
unsigned count;
NSView *v = nil, *w;
// If not within our frame
if (![self mouse:aPoint inRect:frame]) // then immediately return
// If not within our frame then immediately return
if (![self mouse: aPoint inRect: frame])
return nil;
p = [self convertPoint: aPoint fromView: super_view];
count = [sub_views count]; // Check our sub_views
for (i = count - 1; i >= 0; i--)
while (count > 0)
{
w = [sub_views objectAtIndex:i];
w = [sub_views objectAtIndex: --count];
v = [w hitTest: p];
if (v)
break;
}
if (v) // mouse is either in the
return v; // subview or within self
if (v) // mouse is either in the subview or within self
return v;
else
return self;
}
@ -1341,7 +1373,7 @@ NSView *v = nil, *w;
- (void) removeTrackingRect: (NSTrackingRectTag)tag
{
int i, j;
unsigned i, j;
GSTrackingRect*m;
j = [tracking_rects count];
@ -1368,7 +1400,7 @@ GSTrackingRect *m;
assumeInside: (BOOL)flag
{
NSTrackingRectTag t;
int i, j;
unsigned i, j;
GSTrackingRect *m;
t = 0;
@ -1382,7 +1414,8 @@ GSTrackingRect *m;
++t;
m = [[[GSTrackingRect alloc] initWithRect: aRect
tag:t owner:anObject
tag: t
owner: anObject
userData: data
inside: flag] autorelease];
[tracking_rects addObject: m];
@ -1406,8 +1439,8 @@ GSTrackingRect *m;
return NO;
}
- (void)dragImage:(NSImage *)anImage // initiate a dragging
at:(NSPoint)viewLocation // session (backend)
- (void) dragImage: (NSImage*)anImage
at: (NSPoint)viewLocation
offset: (NSSize)initialOffset
event: (NSEvent*)event
pasteboard: (NSPasteboard*)pboard
@ -1429,10 +1462,18 @@ GSTrackingRect *m;
return nil;
}
- (void)fax:(id)sender {}
- (void)print:(id)sender {}
- (void)writeEPSInsideRect:(NSRect)rect toPasteboard:(NSPasteboard *)pasteboard
{}
- (void) fax: (id)sender
{
}
- (void) print: (id)sender
{
}
- (void) writeEPSInsideRect: (NSRect)rect
toPasteboard: (NSPasteboard*)pasteboard
{
}
//
// Pagination
@ -1441,13 +1482,15 @@ GSTrackingRect *m;
top: (float)oldTop
bottom: (float)oldBottom
limit: (float)bottomLimit
{}
{
}
- (void) adjustPageWidthNew: (float*)newRight
left: (float)oldLeft
right: (float)oldRight
limit: (float)rightLimit
{}
{
}
- (float) heightAdjustLimit
{
@ -1481,10 +1524,12 @@ GSTrackingRect *m;
label: (NSString*)aString
bBox: (NSRect)pageRect
fonts: (NSString*)fontNames
{}
{
}
- (void) beginPageSetupRect: (NSRect)aRect placement: (NSPoint)location
{}
{
}
- (void) beginPrologueBBox: (NSRect)boundingBox
creationDate: (NSString*)dateCreated
@ -1493,24 +1538,57 @@ GSTrackingRect *m;
forWhom: (NSString*)user
pages: (int)numPages
title: (NSString*)aTitle
{}
{
}
- (void)addToPageSetup {}
- (void)beginSetup {} // not implemented
- (void)beginTrailer {}
- (void)drawPageBorderWithSize:(NSSize)borderSize {}
- (void)drawSheetBorderWithSize:(NSSize)borderSize {}
- (void)endHeaderComments {}
- (void)endPrologue {}
- (void)endSetup {}
- (void)endPageSetup {}
- (void)endPage {}
- (void)endTrailer {}
- (void) addToPageSetup
{
}
- (void) beginSetup
{
} // not implemented
- (void) beginTrailer
{
}
- (void) drawPageBorderWithSize: (NSSize)borderSize
{
}
- (void) drawSheetBorderWithSize: (NSSize)borderSize
{
}
- (void) endHeaderComments
{
}
- (void) endPrologue
{
}
- (void) endSetup
{
}
- (void) endPageSetup
{
}
- (void) endPage
{
}
- (void) endTrailer
{
}
//
// NSCoding protocol
//
- (void)encodeWithCoder:aCoder
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[super encodeWithCoder: aCoder];
@ -1531,7 +1609,7 @@ GSTrackingRect *m;
NSDebugLog(@"NSView: finish encoding\n");
}
- initWithCoder:aDecoder
- (id) initWithCoder: (NSCoder*)aDecoder
{
[super initWithCoder: aDecoder];
@ -1557,27 +1635,109 @@ GSTrackingRect *m;
//
// Accessor methods
//
- (void)setAutoresizesSubviews:(BOOL)flag { autoresize_subviews = flag; }
- (void)setAutoresizingMask:(unsigned int)mask { autoresizingMask = mask; }
- (void) setAutoresizesSubviews: (BOOL)flag
{
autoresize_subviews = flag;
}
- (NSWindow *)window { return window; }
- (BOOL)autoresizesSubviews { return autoresize_subviews; }
- (unsigned int)autoresizingMask { return autoresizingMask; }
- (NSMutableArray *)subviews { return sub_views; }
- (NSView *)superview { return super_view; }
- (BOOL)shouldDrawColor { return YES; }
- (BOOL)isOpaque { return NO; }
- (BOOL)needsDisplay { return needs_display; }
- (int)tag { return -1; }
- (NSArray *)cursorRectangles { return cursor_rects; }
- (BOOL)isFlipped { return NO; }
- (NSRect)bounds { return bounds; }
- (NSRect)frame { return frame; }
- (float)boundsRotation { return [boundsMatrix rotationAngle]; }
- (float)frameRotation { return [frameMatrix rotationAngle]; }
- (PSMatrix*)_boundsMatrix { return boundsMatrix; }
- (PSMatrix*)_frameMatrix { return frameMatrix; }
- (BOOL)postsFrameChangedNotifications { return post_frame_changes; }
- (BOOL)postsBoundsChangedNotifications { return post_bounds_changes; }
- (void) setAutoresizingMask: (unsigned int)mask
{
autoresizingMask = mask;
}
- (NSWindow*) window
{
return window;
}
- (BOOL) autoresizesSubviews
{
return autoresize_subviews;
}
- (unsigned int) autoresizingMask
{
return autoresizingMask;
}
- (NSMutableArray*) subviews
{
return sub_views;
}
- (NSView*) superview
{
return super_view;
}
- (BOOL) shouldDrawColor
{
return YES;
}
- (BOOL) isOpaque
{
return NO;
}
- (BOOL) needsDisplay
{
return needs_display;
}
- (int) tag
{
return -1;
}
- (NSArray*) cursorRectangles
{
return cursor_rects;
}
- (BOOL) isFlipped
{
return NO;
}
- (NSRect) bounds
{
return bounds;
}
- (NSRect) frame
{
return frame;
}
- (float) boundsRotation
{
return [boundsMatrix rotationAngle];
}
- (float) frameRotation
{
return [frameMatrix rotationAngle];
}
- (PSMatrix*) _boundsMatrix
{
return boundsMatrix;
}
- (PSMatrix*) _frameMatrix
{
return frameMatrix;
}
- (BOOL) postsFrameChangedNotifications
{
return post_frame_changes;
}
- (BOOL) postsBoundsChangedNotifications
{
return post_bounds_changes;
}
@end