General tidyup - make updates work properly etc.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3647 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-02-03 21:53:29 +00:00
parent e7072cb446
commit 951c165938
5 changed files with 1402 additions and 1179 deletions

View file

@ -1220,23 +1220,25 @@ BOOL done = NO;
windows_need_update = flag; windows_need_update = flag;
} }
- (void)updateWindows // send an update message - (void) updateWindows // send an update message
{ // to all visible windows { // to all visible windows
int i, count; int i, count;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSArray *window_list = [self windows]; NSArray *window_list = [self windows];
windows_need_update = NO;
// notify that an update is // notify that an update is
// imminent // imminent
[nc postNotificationName:NSApplicationWillUpdateNotification object:self]; [nc postNotificationName:NSApplicationWillUpdateNotification object: self];
for (i = 0, count = [window_list count]; i < count; i++) for (i = 0, count = [window_list count]; i < count; i++)
{ {
NSWindow *win = [window_list objectAtIndex:i]; NSWindow *win = [window_list objectAtIndex: i];
if ([win isVisible]) // send update only if the if ([win isVisible]) // send update only if the
[win update]; // window is visible [win update]; // window is visible
} }
// notify update did occur // notify update did occur
[nc postNotificationName:NSApplicationDidUpdateNotification object:self]; [nc postNotificationName:NSApplicationDidUpdateNotification object:self];
} }
- (NSArray*) windows - (NSArray*) windows

View file

@ -5,14 +5,14 @@
Author: Ovidiu Predescu <ovidiu@net-community.com> Author: Ovidiu Predescu <ovidiu@net-community.com>
Date: July 1997 Date: July 1997
This file is part of the GNUstep GUI Library. This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version. version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@ -42,7 +42,7 @@
return self; return self;
} }
- (void)setDocumentView:(NSView*)aView - (void) setDocumentView: (NSView*)aView
{ {
if (_documentView == aView) if (_documentView == aView)
return; return;
@ -81,11 +81,11 @@
[[self superview] reflectScrolledClipView:self]; [[self superview] reflectScrolledClipView:self];
} }
- (void)resetCursorRects - (void) resetCursorRects
{ {
[self addCursorRect:[self bounds] cursor:_cursor]; [self addCursorRect:[self bounds] cursor:_cursor];
} }
- (void) resizeSubviewsWithOldSize: (NSSize)old_size - (void) resizeSubviewsWithOldSize: (NSSize)old_size
{ {
[super resizeSubviewsWithOldSize: old_size]; [super resizeSubviewsWithOldSize: old_size];
@ -95,8 +95,11 @@
} }
} }
- (void)scrollToPoint:(NSPoint)point - (void) scrollToPoint: (NSPoint)point
{ {
NSRect originalBounds = [self bounds];
NSRect newBounds = originalBounds;
NSRect intersection;
#ifdef DEBUGLOG #ifdef DEBUGLOG
NSPoint currentPoint = [self bounds].origin; NSPoint currentPoint = [self bounds].origin;
@ -105,26 +108,101 @@
point.x, point.y); point.x, point.y);
#endif #endif
point = [self constrainScrollPoint: point]; newBounds.origin = [self constrainScrollPoint: point];
[self setBoundsOrigin: NSMakePoint(point.x, point.y)];
if (NSEqualPoints(originalBounds.origin, newBounds.origin))
return;
// [self setBoundsOrigin: newBounds.origin];
[self setNeedsDisplay: YES];
if (_copiesOnScroll) if (_copiesOnScroll)
/* TODO: move the visible portion of the document */ {
[_documentView displayRect: bounds]; // copy the portion of the view that is common before and after scrolling.
// then tell docview to draw the exposed parts.
// intersection is the common rectangle
intersection = NSIntersectionRect(originalBounds, newBounds);
if (NSEqualRects(intersection, NSZeroRect))
{
// no intersection -- docview should draw everyting
[self setBoundsOrigin: newBounds.origin];
[_documentView setNeedsDisplayInRect: newBounds];
}
else
{
NSPoint destPoint = intersection.origin;
float dx = newBounds.origin.x - originalBounds.origin.x;
float dy = newBounds.origin.y - originalBounds.origin.y;
destPoint.x -= dx;
destPoint.y -= dy;
[self lockFocus];
NSCopyBits(0, intersection, destPoint);
[self unlockFocus];
[self setBoundsOrigin: newBounds.origin];
if (dx != 0)
{
// moved in x -- redraw a full-height rectangle at
// side of intersection
NSRect redrawRect;
redrawRect.origin.y = newBounds.origin.y;
redrawRect.size.height = newBounds.size.height;
redrawRect.size.width = newBounds.size.width
- intersection.size.width;
if (dx < 0)
{
// moved to the left -- redraw at left of intersection
redrawRect.origin.x = newBounds.origin.x;
}
else
{
// moved to the right -- redraw at right of intersection
redrawRect.origin.x = newBounds.origin.x
+ intersection.size.width;
}
[_documentView setNeedsDisplayInRect: redrawRect];
}
if (dy != 0)
{
// moved in y
// -- redraw rectangle with intersection's width over or under it
NSRect redrawRect;
redrawRect.origin.x = intersection.origin.x;
redrawRect.size.width = intersection.size.width;
redrawRect.size.height = newBounds.size.height
- intersection.size.height;
if (dy < 0)
{
// moved down -- redraw under intersection
redrawRect.origin.y = newBounds.origin.y;
}
else
{
// moved up -- redraw over intersection
redrawRect.origin.y = newBounds.origin.y
+ intersection.size.height;
}
[_documentView setNeedsDisplayInRect: redrawRect];
}
}
}
else else
[_documentView setNeedsDisplayInRect: bounds]; {
// [_documentView setNeedsDisplay: YES]; // dont copy anything -- docview draws it all
[self display]; [self setBoundsOrigin: newBounds.origin];
[_documentView setNeedsDisplayInRect: newBounds];
}
} }
- (NSPoint)constrainScrollPoint:(NSPoint)proposedNewOrigin - (NSPoint) constrainScrollPoint: (NSPoint)proposedNewOrigin
{ {
NSRect documentFrame = [_documentView frame]; NSRect documentFrame = [_documentView frame];
NSPoint new = proposedNewOrigin; NSPoint new = proposedNewOrigin;
if (documentFrame.size.width <= bounds.size.width) if (documentFrame.size.width <= bounds.size.width)
new.x = 0.0; new.x = documentFrame.origin.x;
else if (proposedNewOrigin.x <= documentFrame.origin.x) else if (proposedNewOrigin.x <= documentFrame.origin.x)
new.x = documentFrame.origin.x; new.x = documentFrame.origin.x;
else if (proposedNewOrigin.x else if (proposedNewOrigin.x
@ -145,7 +223,7 @@
else else
{ {
if (documentFrame.size.height <= bounds.size.height) if (documentFrame.size.height <= bounds.size.height)
new.y = 0.0; new.y = documentFrame.origin.y;
else if (proposedNewOrigin.y <= documentFrame.origin.y) else if (proposedNewOrigin.y <= documentFrame.origin.y)
new.y = documentFrame.origin.y; new.y = documentFrame.origin.y;
else if (proposedNewOrigin.y else if (proposedNewOrigin.y
@ -156,7 +234,7 @@
return new; return new;
} }
- (NSRect)documentRect - (NSRect) documentRect
{ {
NSRect documentFrame = [_documentView frame]; NSRect documentFrame = [_documentView frame];
NSRect clipViewBounds = bounds; NSRect clipViewBounds = bounds;
@ -169,7 +247,7 @@
return rect; return rect;
} }
- (NSRect)documentVisibleRect - (NSRect) documentVisibleRect
{ {
NSRect documentBounds = [_documentView bounds]; NSRect documentBounds = [_documentView bounds];
NSRect clipViewBounds = bounds; NSRect clipViewBounds = bounds;
@ -183,97 +261,132 @@
return rect; return rect;
} }
- (void) drawRect:(NSRect)rect - (void) drawRect: (NSRect)rect
{ {
[[self backgroundColor] set]; [[self backgroundColor] set];
NSRectFill(rect); NSRectFill(rect);
} }
- (BOOL)autoscroll:(NSEvent*)theEvent - (BOOL) autoscroll: (NSEvent*)theEvent
{ {
return 0; return 0;
} }
- (void)viewBoundsChanged:(NSNotification*)aNotification - (void) viewBoundsChanged: (NSNotification*)aNotification
{ {
[super_view reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)viewFrameChanged:(NSNotification*)aNotification - (void) viewFrameChanged: (NSNotification*)aNotification
{ {
[self setBoundsOrigin: [self constrainScrollPoint: bounds.origin]]; [self setBoundsOrigin: [self constrainScrollPoint: bounds.origin]];
[super_view reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)scaleUnitSquareToSize:(NSSize)newUnitSize - (void) scaleUnitSquareToSize: (NSSize)newUnitSize
{ {
[super scaleUnitSquareToSize:newUnitSize]; [super scaleUnitSquareToSize:newUnitSize];
[super_view reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)setBoundsOrigin:(NSPoint)aPoint - (void) setBoundsOrigin: (NSPoint)aPoint
{ {
[super setBoundsOrigin:aPoint]; [super setBoundsOrigin:aPoint];
[super_view reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)setBoundsSize:(NSSize)aSize - (void) setBoundsSize: (NSSize)aSize
{ {
[super setBoundsSize:aSize]; [super setBoundsSize:aSize];
[super_view reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)setFrameSize:(NSSize)aSize - (void) setFrameSize: (NSSize)aSize
{ {
[super setFrameSize:aSize]; [super setFrameSize:aSize];
[super_view reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)setFrameOrigin:(NSPoint)aPoint - (void) setFrameOrigin: (NSPoint)aPoint
{ {
[super setFrameOrigin:aPoint]; [super setFrameOrigin:aPoint];
[super_view reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)setFrame:(NSRect)rect - (void) setFrame: (NSRect)rect
{ {
[super setFrame:rect]; [super setFrame:rect];
[super_view reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)translateOriginToPoint:(NSPoint)aPoint - (void) translateOriginToPoint: (NSPoint)aPoint
{ {
[super translateOriginToPoint:aPoint]; [super translateOriginToPoint:aPoint];
[super_view reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (BOOL)isOpaque { return YES; } - (BOOL) isOpaque
- (id)documentView { return _documentView; } {
- (void)setCopiesOnScroll:(BOOL)flag { _copiesOnScroll = flag; } return YES;
- (BOOL)copiesOnScroll { return _copiesOnScroll; } }
- (void)setDocumentCursor:(NSCursor*)aCursor { ASSIGN(_cursor, aCursor); }
- (NSCursor*)documentCursor { return _cursor; }
- (NSColor*)backgroundColor { return _backgroundColor; }
- (BOOL)isFlipped { return [_documentView isFlipped]; }
- (BOOL)acceptsFirstResponder { return _documentView != nil; }
- (void)setBackgroundColor:(NSColor*)aColor - (id) documentView
{
return _documentView;
}
- (void) setCopiesOnScroll: (BOOL)flag
{
_copiesOnScroll = flag;
}
- (BOOL) copiesOnScroll
{
return _copiesOnScroll;
}
- (void) setDocumentCursor: (NSCursor*)aCursor
{
ASSIGN(_cursor, aCursor);
}
- (NSCursor*) documentCursor
{
return _cursor;
}
- (NSColor*) backgroundColor
{
return _backgroundColor;
}
- (BOOL) isFlipped
{
return [_documentView isFlipped];
}
- (BOOL) acceptsFirstResponder
{
return _documentView != nil;
}
- (void) setBackgroundColor: (NSColor*)aColor
{ {
ASSIGN(_backgroundColor, aColor); ASSIGN(_backgroundColor, aColor);
} }
/* Disable rotation of clip view */ /* Disable rotation of clip view */
- (void)rotateByAngle:(float)angle - (void) rotateByAngle: (float)angle
{} {}
- (void)setBoundsRotation:(float)angle - (void) setBoundsRotation: (float)angle
{} {}
- (void)setFrameRotation:(float)angle - (void) setFrameRotation: (float)angle
{} {}
/* Managing responder chain */ /* Managing responder chain */
- (BOOL)becomeFirstResponder - (BOOL) becomeFirstResponder
{ {
return [_documentView becomeFirstResponder]; return [_documentView becomeFirstResponder];
} }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -561,7 +561,13 @@ NSPoint basePoint;
- (BOOL)isAutodisplay { return is_autodisplay; } - (BOOL)isAutodisplay { return is_autodisplay; }
- (BOOL)isFlushWindowDisabled { return disable_flush_window; } - (BOOL)isFlushWindowDisabled { return disable_flush_window; }
- (void)setAutodisplay:(BOOL)flag { is_autodisplay = flag; } - (void)setAutodisplay:(BOOL)flag { is_autodisplay = flag; }
- (void)setViewsNeedDisplay:(BOOL)flag { needs_display = flag; }
- (void) setViewsNeedDisplay: (BOOL)flag
{
needs_display = flag;
[[NSApplication sharedApplication] setWindowsNeedUpdate: YES];
}
- (BOOL)viewsNeedDisplay { return needs_display; } - (BOOL)viewsNeedDisplay { return needs_display; }
- (void)useOptimizedDrawing:(BOOL)flag { optimize_drawing = flag; } - (void)useOptimizedDrawing:(BOOL)flag { optimize_drawing = flag; }