git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@8723 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
nico 2001-01-21 14:55:07 +00:00
parent 1350905dc8
commit b768800c21
4 changed files with 130 additions and 56 deletions

View file

@ -145,8 +145,8 @@
// and after scrolling. // and after scrolling.
// then tell docview to draw the exposed parts. // then tell docview to draw the exposed parts.
// intersection is the common rectangle // intersection is the common rectangle
intersection = NSIntersectionRect(originalBounds, newBounds); intersection = NSIntersectionRect (originalBounds, newBounds);
if (NSEqualRects(intersection, NSZeroRect)) if (NSEqualRects (intersection, NSZeroRect))
{ {
// no intersection -- docview should draw everything // no intersection -- docview should draw everything
[super setBoundsOrigin: newBounds.origin]; [super setBoundsOrigin: newBounds.origin];
@ -162,7 +162,7 @@
destPoint.x -= dx; destPoint.x -= dx;
destPoint.y -= dy; destPoint.y -= dy;
[self lockFocus]; [self lockFocus];
NSCopyBits(0, intersection, destPoint); NSCopyBits (0, intersection, destPoint);
[self unlockFocus]; [self unlockFocus];
[super setBoundsOrigin: newBounds.origin]; [super setBoundsOrigin: newBounds.origin];
@ -237,31 +237,43 @@
NSPoint new = proposedNewOrigin; NSPoint new = proposedNewOrigin;
if (_documentView == nil) if (_documentView == nil)
return _bounds.origin; {
return _bounds.origin;
}
documentFrame = [_documentView frame]; documentFrame = [_documentView frame];
if (documentFrame.size.width <= _bounds.size.width) if (documentFrame.size.width <= _bounds.size.width)
new.x = documentFrame.origin.x; {
new.x = documentFrame.origin.x;
}
else if (proposedNewOrigin.x <= documentFrame.origin.x) else if (proposedNewOrigin.x <= documentFrame.origin.x)
new.x = documentFrame.origin.x; {
else if (proposedNewOrigin.x new.x = documentFrame.origin.x;
>= NSMaxX(documentFrame) - _bounds.size.width) }
new.x = NSMaxX(documentFrame) - _bounds.size.width; else if (proposedNewOrigin.x + _bounds.size.width >= NSMaxX(documentFrame))
{
new.x = NSMaxX(documentFrame) - _bounds.size.width;
}
if (documentFrame.size.height <= _bounds.size.height) if (documentFrame.size.height <= _bounds.size.height)
new.y = documentFrame.origin.y; {
new.y = documentFrame.origin.y;
}
else if (proposedNewOrigin.y <= documentFrame.origin.y) else if (proposedNewOrigin.y <= documentFrame.origin.y)
new.y = documentFrame.origin.y; {
else if (proposedNewOrigin.y new.y = documentFrame.origin.y;
>= NSMaxY(documentFrame) - _bounds.size.height) }
new.y = NSMaxY(documentFrame) - _bounds.size.height; else if (proposedNewOrigin.y + _bounds.size.height >= NSMaxY(documentFrame))
{
new.y = NSMaxY(documentFrame) - _bounds.size.height;
}
// make it an integer coordinate in device space // make it an integer coordinate in device space
// to avoid some nice effects when scrolling // to avoid some nice effects when scrolling
new = [self convertPoint: new toView: nil]; new = [self convertPoint: new toView: nil];
new.x = (int)new.x; new.x = (int)new.x;
new.y = (int)new.y; new.y = (int)new.y;
new = [self convertPoint: new fromView: nil]; new = [self convertPoint: new fromView: nil];
return new; return new;
} }

View file

@ -430,39 +430,55 @@ static Class rulerViewClass = nil;
NSDebugLog (@"reflectScrolledClipView:"); NSDebugLog (@"reflectScrolledClipView:");
if (_contentView) if (_contentView)
clipViewBounds = [_contentView bounds]; {
clipViewBounds = [_contentView bounds];
}
if ((documentView = [_contentView documentView])) if ((documentView = [_contentView documentView]))
documentFrame = [documentView frame]; {
documentFrame = [documentView frame];
}
if (_hasVertScroller) if (_hasVertScroller)
{ {
if (documentFrame.size.height <= clipViewBounds.size.height) if (documentFrame.size.height <= clipViewBounds.size.height)
[_vertScroller setEnabled: NO]; {
[_vertScroller setEnabled: NO];
}
else else
{ {
[_vertScroller setEnabled: YES]; [_vertScroller setEnabled: YES];
knobProportion = clipViewBounds.size.height knobProportion = clipViewBounds.size.height
/ documentFrame.size.height; / documentFrame.size.height;
floatValue = (clipViewBounds.origin.y - documentFrame.origin.y) floatValue = (clipViewBounds.origin.y - documentFrame.origin.y)
/ (documentFrame.size.height - clipViewBounds.size.height); / (documentFrame.size.height - clipViewBounds.size.height);
if (!_contentView->_rFlags.flipped_view) if (!_contentView->_rFlags.flipped_view)
floatValue = 1 - floatValue; {
[_vertScroller setFloatValue: floatValue floatValue = 1 - floatValue;
knobProportion: knobProportion]; }
[_vertScroller setFloatValue: floatValue
knobProportion: knobProportion];
} }
} }
if (_hasHorizScroller) if (_hasHorizScroller)
{ {
if (documentFrame.size.width <= clipViewBounds.size.width) if (documentFrame.size.width <= clipViewBounds.size.width)
[_horizScroller setEnabled: NO]; {
[_horizScroller setEnabled: NO];
}
else else
{ {
[_horizScroller setEnabled: YES]; [_horizScroller setEnabled: YES];
knobProportion = clipViewBounds.size.width knobProportion = clipViewBounds.size.width
/ documentFrame.size.width; / documentFrame.size.width;
floatValue = (clipViewBounds.origin.x - documentFrame.origin.x) floatValue = (clipViewBounds.origin.x - documentFrame.origin.x)
/ (documentFrame.size.width - clipViewBounds.size.width); / (documentFrame.size.width - clipViewBounds.size.width);
[_horizScroller setFloatValue: floatValue [_horizScroller setFloatValue: floatValue
knobProportion: knobProportion]; knobProportion: knobProportion];
} }

View file

@ -340,11 +340,17 @@ static NSColor *scrollBarColor = nil;
- (void) setFloatValue: (float)aFloat - (void) setFloatValue: (float)aFloat
{ {
if (aFloat < 0) if (aFloat < 0)
_floatValue = 0; {
_floatValue = 0;
}
else if (aFloat > 1) else if (aFloat > 1)
_floatValue = 1; {
_floatValue = 1;
}
else else
_floatValue = aFloat; {
_floatValue = aFloat;
}
[self setNeedsDisplayInRect: [self rectForPart: NSScrollerKnobSlot]]; [self setNeedsDisplayInRect: [self rectForPart: NSScrollerKnobSlot]];
} }
@ -352,11 +358,17 @@ static NSColor *scrollBarColor = nil;
- (void) setFloatValue: (float)aFloat knobProportion: (float)ratio - (void) setFloatValue: (float)aFloat knobProportion: (float)ratio
{ {
if (ratio < 0) if (ratio < 0)
_knobProportion = 0; {
_knobProportion = 0;
}
else if (ratio > 1) else if (ratio > 1)
_knobProportion = 1; {
_knobProportion = 1;
}
else else
_knobProportion = ratio; {
_knobProportion = ratio;
}
[self setFloatValue: aFloat]; [self setFloatValue: aFloat];
} }
@ -794,9 +806,13 @@ static NSColor *scrollBarColor = nil;
* knob are not displayed at all. * knob are not displayed at all.
*/ */
if (!_isEnabled) if (!_isEnabled)
usableParts = NSNoScrollerParts; {
usableParts = NSNoScrollerParts;
}
else else
usableParts = _usableParts; {
usableParts = _usableParts;
}
/* /*
* Assign to `width' and `height' values describing * Assign to `width' and `height' values describing

View file

@ -618,7 +618,9 @@ GSSetDragTypes(NSView* obj, NSArray *types)
[_boundsMatrix scaleTo: sx : sy]; [_boundsMatrix scaleTo: sx : sy];
if (sx != 1 || sy != 1) if (sx != 1 || sy != 1)
_is_rotated_or_scaled_from_base = YES; {
_is_rotated_or_scaled_from_base = YES;
}
} }
- (void) setFrame: (NSRect)frameRect - (void) setFrame: (NSRect)frameRect
@ -668,8 +670,10 @@ GSSetDragTypes(NSView* obj, NSArray *types)
} }
[self resizeSubviewsWithOldSize: old_size]; [self resizeSubviewsWithOldSize: old_size];
if (_post_frame_changes) if (_post_frame_changes)
[nc postNotificationName: NSViewFrameDidChangeNotification {
object: self]; [nc postNotificationName: NSViewFrameDidChangeNotification
object: self];
}
} }
} }
@ -683,8 +687,10 @@ GSSetDragTypes(NSView* obj, NSArray *types)
[_frameMatrix setFrameOrigin: _frame.origin]; [_frameMatrix setFrameOrigin: _frame.origin];
if (_post_frame_changes) if (_post_frame_changes)
[nc postNotificationName: NSViewFrameDidChangeNotification {
object: self]; [nc postNotificationName: NSViewFrameDidChangeNotification
object: self];
}
} }
- (void) setFrameSize: (NSSize)newSize - (void) setFrameSize: (NSSize)newSize
@ -716,8 +722,10 @@ GSSetDragTypes(NSView* obj, NSArray *types)
_bounds.size.height = _frame.size.height * sy; _bounds.size.height = _frame.size.height * sy;
} }
else else
_frame.size = _bounds.size = newSize; {
_frame.size = _bounds.size = newSize;
}
[self resizeSubviewsWithOldSize: old_size]; [self resizeSubviewsWithOldSize: old_size];
if (_post_frame_changes) if (_post_frame_changes)
{ {
@ -736,28 +744,42 @@ GSSetDragTypes(NSView* obj, NSArray *types)
_is_rotated_from_base = _is_rotated_or_scaled_from_base = YES; _is_rotated_from_base = _is_rotated_or_scaled_from_base = YES;
if (_post_frame_changes) if (_post_frame_changes)
[nc postNotificationName: NSViewFrameDidChangeNotification {
object: self]; [nc postNotificationName: NSViewFrameDidChangeNotification
object: self];
}
} }
- (BOOL) isRotatedFromBase - (BOOL) isRotatedFromBase
{ {
if (_is_rotated_from_base) if (_is_rotated_from_base)
return _is_rotated_from_base; {
return YES;
}
else if (_super_view) else if (_super_view)
return [_super_view isRotatedFromBase]; {
return [_super_view isRotatedFromBase];
}
else else
return NO; {
return NO;
}
} }
- (BOOL) isRotatedOrScaledFromBase - (BOOL) isRotatedOrScaledFromBase
{ {
if (_is_rotated_or_scaled_from_base) if (_is_rotated_or_scaled_from_base)
return _is_rotated_or_scaled_from_base; {
return YES;
}
else if (_super_view) else if (_super_view)
return [_super_view isRotatedOrScaledFromBase]; {
return [_super_view isRotatedOrScaledFromBase];
}
else else
return NO; {
return NO;
}
} }
- (void) scaleUnitSquareToSize: (NSSize)newSize - (void) scaleUnitSquareToSize: (NSSize)newSize
@ -784,8 +806,10 @@ GSSetDragTypes(NSView* obj, NSArray *types)
[self _updateBoundsMatrix]; [self _updateBoundsMatrix];
if (_post_bounds_changes) if (_post_bounds_changes)
[nc postNotificationName: NSViewBoundsDidChangeNotification {
object: self]; [nc postNotificationName: NSViewBoundsDidChangeNotification
object: self];
}
} }
- (void) setBounds: (NSRect)aRect - (void) setBounds: (NSRect)aRect
@ -806,12 +830,14 @@ GSSetDragTypes(NSView* obj, NSArray *types)
} }
_bounds = aRect; _bounds = aRect;
[_boundsMatrix [_boundsMatrix
setFrameOrigin: NSMakePoint(-_bounds.origin.x,-_bounds.origin.y)]; setFrameOrigin: NSMakePoint(-_bounds.origin.x, -_bounds.origin.y)];
[self _updateBoundsMatrix]; [self _updateBoundsMatrix];
if (_post_bounds_changes) if (_post_bounds_changes)
[nc postNotificationName: NSViewBoundsDidChangeNotification {
object: self]; [nc postNotificationName: NSViewBoundsDidChangeNotification
object: self];
}
} }
- (void) setBoundsOrigin: (NSPoint)newOrigin - (void) setBoundsOrigin: (NSPoint)newOrigin
@ -852,8 +878,10 @@ GSSetDragTypes(NSView* obj, NSArray *types)
[self _updateBoundsMatrix]; [self _updateBoundsMatrix];
if (_post_bounds_changes) if (_post_bounds_changes)
[nc postNotificationName: NSViewBoundsDidChangeNotification {
object: self]; [nc postNotificationName: NSViewBoundsDidChangeNotification
object: self];
}
} }
- (void) setBoundsRotation: (float)angle - (void) setBoundsRotation: (float)angle
@ -881,8 +909,10 @@ GSSetDragTypes(NSView* obj, NSArray *types)
[_boundsMatrix translateToPoint: point]; [_boundsMatrix translateToPoint: point];
if (_post_bounds_changes) if (_post_bounds_changes)
[nc postNotificationName: NSViewBoundsDidChangeNotification {
object: self]; [nc postNotificationName: NSViewBoundsDidChangeNotification
object: self];
}
} }
- (NSRect) centerScanRect: (NSRect)aRect - (NSRect) centerScanRect: (NSRect)aRect