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

View file

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

View file

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

View file

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

View file

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