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

@ -237,24 +237,36 @@
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; new.x = documentFrame.origin.x;
else if (proposedNewOrigin.x }
>= NSMaxX(documentFrame) - _bounds.size.width) else if (proposedNewOrigin.x + _bounds.size.width >= NSMaxX(documentFrame))
{
new.x = NSMaxX(documentFrame) - _bounds.size.width; 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; new.y = documentFrame.origin.y;
else if (proposedNewOrigin.y }
>= NSMaxY(documentFrame) - _bounds.size.height) else if (proposedNewOrigin.y + _bounds.size.height >= NSMaxY(documentFrame))
{
new.y = NSMaxY(documentFrame) - _bounds.size.height; 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

View file

@ -430,23 +430,34 @@ 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; floatValue = 1 - floatValue;
}
[_vertScroller setFloatValue: floatValue [_vertScroller setFloatValue: floatValue
knobProportion: knobProportion]; knobProportion: knobProportion];
} }
@ -455,14 +466,19 @@ static Class rulerViewClass = nil;
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,8 +618,10 @@ 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,10 +670,12 @@ GSSetDragTypes(NSView* obj, NSArray *types)
} }
[self resizeSubviewsWithOldSize: old_size]; [self resizeSubviewsWithOldSize: old_size];
if (_post_frame_changes) if (_post_frame_changes)
{
[nc postNotificationName: NSViewFrameDidChangeNotification [nc postNotificationName: NSViewFrameDidChangeNotification
object: self]; object: self];
} }
} }
}
- (void) setFrameOrigin: (NSPoint)newOrigin - (void) setFrameOrigin: (NSPoint)newOrigin
{ {
@ -683,9 +687,11 @@ GSSetDragTypes(NSView* obj, NSArray *types)
[_frameMatrix setFrameOrigin: _frame.origin]; [_frameMatrix setFrameOrigin: _frame.origin];
if (_post_frame_changes) if (_post_frame_changes)
{
[nc postNotificationName: NSViewFrameDidChangeNotification [nc postNotificationName: NSViewFrameDidChangeNotification
object: self]; object: self];
} }
}
- (void) setFrameSize: (NSSize)newSize - (void) setFrameSize: (NSSize)newSize
{ {
@ -716,7 +722,9 @@ 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,29 +744,43 @@ 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 [nc postNotificationName: NSViewFrameDidChangeNotification
object: self]; 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,9 +806,11 @@ GSSetDragTypes(NSView* obj, NSArray *types)
[self _updateBoundsMatrix]; [self _updateBoundsMatrix];
if (_post_bounds_changes) if (_post_bounds_changes)
{
[nc postNotificationName: NSViewBoundsDidChangeNotification [nc postNotificationName: NSViewBoundsDidChangeNotification
object: self]; object: self];
} }
}
- (void) setBounds: (NSRect)aRect - (void) setBounds: (NSRect)aRect
{ {
@ -810,9 +834,11 @@ GSSetDragTypes(NSView* obj, NSArray *types)
[self _updateBoundsMatrix]; [self _updateBoundsMatrix];
if (_post_bounds_changes) if (_post_bounds_changes)
{
[nc postNotificationName: NSViewBoundsDidChangeNotification [nc postNotificationName: NSViewBoundsDidChangeNotification
object: self]; object: self];
} }
}
- (void) setBoundsOrigin: (NSPoint)newOrigin - (void) setBoundsOrigin: (NSPoint)newOrigin
{ {
@ -852,9 +878,11 @@ GSSetDragTypes(NSView* obj, NSArray *types)
[self _updateBoundsMatrix]; [self _updateBoundsMatrix];
if (_post_bounds_changes) if (_post_bounds_changes)
{
[nc postNotificationName: NSViewBoundsDidChangeNotification [nc postNotificationName: NSViewBoundsDidChangeNotification
object: self]; object: self];
} }
}
- (void) setBoundsRotation: (float)angle - (void) setBoundsRotation: (float)angle
{ {
@ -881,9 +909,11 @@ GSSetDragTypes(NSView* obj, NSArray *types)
[_boundsMatrix translateToPoint: point]; [_boundsMatrix translateToPoint: point];
if (_post_bounds_changes) if (_post_bounds_changes)
{
[nc postNotificationName: NSViewBoundsDidChangeNotification [nc postNotificationName: NSViewBoundsDidChangeNotification
object: self]; object: self];
} }
}
- (NSRect) centerScanRect: (NSRect)aRect - (NSRect) centerScanRect: (NSRect)aRect
{ {