mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 06:10:59 +00:00
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:
parent
e7072cb446
commit
951c165938
5 changed files with 1402 additions and 1179 deletions
|
@ -1220,18 +1220,20 @@ 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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,7 +81,7 @@
|
||||||
[[self superview] reflectScrolledClipView:self];
|
[[self superview] reflectScrolledClipView:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)resetCursorRects
|
- (void) resetCursorRects
|
||||||
{
|
{
|
||||||
[self addCursorRect:[self bounds] cursor:_cursor];
|
[self addCursorRect:[self bounds] cursor:_cursor];
|
||||||
}
|
}
|
||||||
|
@ -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
|
else
|
||||||
[_documentView setNeedsDisplayInRect: bounds];
|
{
|
||||||
// [_documentView setNeedsDisplay: YES];
|
NSPoint destPoint = intersection.origin;
|
||||||
[self display];
|
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
|
||||||
|
{
|
||||||
|
// dont copy anything -- docview draws it all
|
||||||
|
[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];
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,27 +57,37 @@ static Class rulerViewClass = nil;
|
||||||
//
|
//
|
||||||
// Class methods
|
// Class methods
|
||||||
//
|
//
|
||||||
+ (void)initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
if (self == [NSScrollView class])
|
if (self == [NSScrollView class])
|
||||||
{
|
{
|
||||||
NSDebugLog(@"Initialize NSScrollView class\n");
|
NSDebugLog(@"Initialize NSScrollView class\n");
|
||||||
[self setVersion:1];
|
[self setVersion: 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void)setRulerViewClass:(Class)aClass { rulerViewClass = aClass; }
|
+ (void) setRulerViewClass: (Class)aClass
|
||||||
+ (Class)rulerViewClass { return rulerViewClass; }
|
|
||||||
|
|
||||||
+ (NSSize)contentSizeForFrameSize:(NSSize)frameSize // calc content size by
|
|
||||||
hasHorizontalScroller:(BOOL)hFlag // taking into account
|
|
||||||
hasVerticalScroller:(BOOL)vFlag // the border type
|
|
||||||
borderType:(NSBorderType)borderType
|
|
||||||
{
|
{
|
||||||
NSSize size = frameSize;
|
rulerViewClass = aClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (Class) rulerViewClass
|
||||||
|
{
|
||||||
|
return rulerViewClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSSize) contentSizeForFrameSize: (NSSize)frameSize
|
||||||
|
hasHorizontalScroller: (BOOL)hFlag
|
||||||
|
hasVerticalScroller: (BOOL)vFlag
|
||||||
|
borderType: (NSBorderType)borderType
|
||||||
|
{
|
||||||
|
NSSize size = frameSize;
|
||||||
|
|
||||||
// Substract 1 from the width and height of
|
// Substract 1 from the width and height of
|
||||||
if (hFlag) // the line that separates the horizontal
|
// the line that separates the horizontal
|
||||||
{ // and vertical scroller from the clip view
|
// and vertical scroller from the clip view
|
||||||
|
if (hFlag)
|
||||||
|
{
|
||||||
size.height -= [NSScroller scrollerWidth];
|
size.height -= [NSScroller scrollerWidth];
|
||||||
size.height -= 1;
|
size.height -= 1;
|
||||||
}
|
}
|
||||||
|
@ -107,15 +117,18 @@ NSSize size = frameSize;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSSize)frameSizeForContentSize:(NSSize)contentSize
|
+ (NSSize) frameSizeForContentSize: (NSSize)contentSize
|
||||||
hasHorizontalScroller:(BOOL)hFlag
|
hasHorizontalScroller: (BOOL)hFlag
|
||||||
hasVerticalScroller:(BOOL)vFlag
|
hasVerticalScroller: (BOOL)vFlag
|
||||||
borderType:(NSBorderType)borderType
|
borderType: (NSBorderType)borderType
|
||||||
{
|
{
|
||||||
NSSize size = contentSize;
|
NSSize size = contentSize;
|
||||||
|
|
||||||
// Add 1 to the width and height for the
|
// Add 1 to the width and height for the
|
||||||
if (hFlag) // line that separates the horizontal and
|
// line that separates the horizontal and
|
||||||
{ // vertical scroller from the clip view.
|
// vertical scroller from the clip view.
|
||||||
|
if (hFlag)
|
||||||
|
{
|
||||||
size.height += [NSScroller scrollerWidth];
|
size.height += [NSScroller scrollerWidth];
|
||||||
size.height += 1;
|
size.height += 1;
|
||||||
}
|
}
|
||||||
|
@ -148,10 +161,10 @@ NSSize size = contentSize;
|
||||||
//
|
//
|
||||||
// Instance methods
|
// Instance methods
|
||||||
//
|
//
|
||||||
- initWithFrame:(NSRect)rect
|
- initWithFrame: (NSRect)rect
|
||||||
{
|
{
|
||||||
[super initWithFrame:rect];
|
[super initWithFrame: rect];
|
||||||
[self setContentView:[[NSClipView new] autorelease]];
|
[self setContentView: [[NSClipView new] autorelease]];
|
||||||
_lineScroll = 10;
|
_lineScroll = 10;
|
||||||
_pageScroll = 10;
|
_pageScroll = 10;
|
||||||
_borderType = NSBezelBorder;
|
_borderType = NSBezelBorder;
|
||||||
|
@ -163,10 +176,10 @@ NSSize size = contentSize;
|
||||||
|
|
||||||
- init
|
- init
|
||||||
{
|
{
|
||||||
return [self initWithFrame:NSZeroRect];
|
return [self initWithFrame: NSZeroRect];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[_contentView release];
|
[_contentView release];
|
||||||
|
|
||||||
|
@ -196,12 +209,12 @@ NSSize size = contentSize;
|
||||||
if (_horizScroller)
|
if (_horizScroller)
|
||||||
{
|
{
|
||||||
[_horizScroller setAutoresizingMask: NSViewWidthSizable];
|
[_horizScroller setAutoresizingMask: NSViewWidthSizable];
|
||||||
[_horizScroller setTarget:self];
|
[_horizScroller setTarget: self];
|
||||||
[_horizScroller setAction:@selector(_doScroll:)];
|
[_horizScroller setAction: @selector(_doScroll:)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setHasHorizontalScroller:(BOOL)flag
|
- (void) setHasHorizontalScroller: (BOOL)flag
|
||||||
{
|
{
|
||||||
if (_hasHorizScroller == flag)
|
if (_hasHorizScroller == flag)
|
||||||
return;
|
return;
|
||||||
|
@ -211,8 +224,8 @@ NSSize size = contentSize;
|
||||||
if (_hasHorizScroller)
|
if (_hasHorizScroller)
|
||||||
{
|
{
|
||||||
if (!_horizScroller)
|
if (!_horizScroller)
|
||||||
[self setHorizontalScroller:[[NSScroller new] autorelease]];
|
[self setHorizontalScroller: [[NSScroller new] autorelease]];
|
||||||
[self addSubview:_horizScroller];
|
[self addSubview: _horizScroller];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
[_horizScroller removeFromSuperview];
|
[_horizScroller removeFromSuperview];
|
||||||
|
@ -230,12 +243,12 @@ NSSize size = contentSize;
|
||||||
if (_vertScroller)
|
if (_vertScroller)
|
||||||
{
|
{
|
||||||
[_vertScroller setAutoresizingMask: NSViewHeightSizable];
|
[_vertScroller setAutoresizingMask: NSViewHeightSizable];
|
||||||
[_vertScroller setTarget:self];
|
[_vertScroller setTarget: self];
|
||||||
[_vertScroller setAction:@selector(_doScroll:)];
|
[_vertScroller setAction: @selector(_doScroll:)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setHasVerticalScroller:(BOOL)flag
|
- (void) setHasVerticalScroller: (BOOL)flag
|
||||||
{
|
{
|
||||||
if (_hasVertScroller == flag)
|
if (_hasVertScroller == flag)
|
||||||
return;
|
return;
|
||||||
|
@ -246,11 +259,11 @@ NSSize size = contentSize;
|
||||||
{
|
{
|
||||||
if (!_vertScroller)
|
if (!_vertScroller)
|
||||||
{
|
{
|
||||||
[self setVerticalScroller:[[NSScroller new] autorelease]];
|
[self setVerticalScroller: [[NSScroller new] autorelease]];
|
||||||
if (_contentView && ![_contentView isFlipped])
|
if (_contentView && ![_contentView isFlipped])
|
||||||
[_vertScroller setFloatValue:1];
|
[_vertScroller setFloatValue: 1];
|
||||||
}
|
}
|
||||||
[self addSubview:_vertScroller];
|
[self addSubview: _vertScroller];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
[_vertScroller removeFromSuperview];
|
[_vertScroller removeFromSuperview];
|
||||||
|
@ -258,23 +271,29 @@ NSSize size = contentSize;
|
||||||
[self tile];
|
[self tile];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_doScroll:(NSScroller*)scroller
|
- (void)_doScroll: (NSScroller*)scroller
|
||||||
{
|
{
|
||||||
float floatValue = [scroller floatValue];
|
float floatValue = [scroller floatValue];
|
||||||
NSRect clipViewBounds = [_contentView bounds];
|
NSRect clipViewBounds = [_contentView bounds];
|
||||||
NSScrollerPart hitPart = [scroller hitPart];
|
NSScrollerPart hitPart = [scroller hitPart];
|
||||||
NSRect documentRect = [_contentView documentRect];
|
NSRect documentRect = [_contentView documentRect];
|
||||||
float amount = 0;
|
float amount = 0;
|
||||||
NSPoint point;
|
NSPoint point = clipViewBounds.origin;
|
||||||
|
|
||||||
NSDebugLog (@"_doScroll: float value = %f", floatValue);
|
NSDebugLog (@"_doScroll: float value = %f", floatValue);
|
||||||
|
|
||||||
|
// do nothing if scroller is unknown
|
||||||
|
if (scroller != _horizScroller && scroller != _vertScroller)
|
||||||
|
return;
|
||||||
|
|
||||||
_knobMoved = NO;
|
_knobMoved = NO;
|
||||||
|
|
||||||
if(hitPart == NSScrollerKnob)
|
if (hitPart == NSScrollerKnob || hitPart == NSScrollerKnobSlot)
|
||||||
_knobMoved = YES;
|
_knobMoved = YES;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//FIXME in a page scroll, amount should be the portion of the view that
|
||||||
|
// stays visible, not the one that disapears
|
||||||
if (hitPart == NSScrollerIncrementLine)
|
if (hitPart == NSScrollerIncrementLine)
|
||||||
amount = _lineScroll;
|
amount = _lineScroll;
|
||||||
else if (hitPart == NSScrollerIncrementPage)
|
else if (hitPart == NSScrollerIncrementPage)
|
||||||
|
@ -284,7 +303,7 @@ NSPoint point;
|
||||||
else if (hitPart == NSScrollerDecrementPage)
|
else if (hitPart == NSScrollerDecrementPage)
|
||||||
amount = -_pageScroll;
|
amount = -_pageScroll;
|
||||||
else
|
else
|
||||||
_knobMoved = YES;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_knobMoved) // button scrolling
|
if (!_knobMoved) // button scrolling
|
||||||
|
@ -292,23 +311,18 @@ NSPoint point;
|
||||||
if (scroller == _horizScroller)
|
if (scroller == _horizScroller)
|
||||||
{
|
{
|
||||||
point.x = clipViewBounds.origin.x + amount;
|
point.x = clipViewBounds.origin.x + amount;
|
||||||
point.y = clipViewBounds.origin.y;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (scroller == _vertScroller)
|
if ([_contentView isFlipped])
|
||||||
{
|
{
|
||||||
point.x = clipViewBounds.origin.x;
|
|
||||||
// If view is flipped
|
// If view is flipped
|
||||||
if ([_contentView isFlipped]) // reverse the scroll
|
// reverse the scroll direction
|
||||||
amount = -amount; // direction
|
amount = -amount;
|
||||||
|
}
|
||||||
NSDebugLog (@"increment/decrement: amount = %f, flipped = %d",
|
NSDebugLog (@"increment/decrement: amount = %f, flipped = %d",
|
||||||
amount, [_contentView isFlipped]);
|
amount, [_contentView isFlipped]);
|
||||||
point.y = clipViewBounds.origin.y + amount;
|
point.y = clipViewBounds.origin.y + amount;
|
||||||
point.y = point.y < 0 ? 0 : point.y; // FIX ME s/b in
|
|
||||||
} // clipview
|
|
||||||
else
|
|
||||||
return; // do nothing
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // knob scolling
|
else // knob scolling
|
||||||
|
@ -317,48 +331,35 @@ NSPoint point;
|
||||||
{
|
{
|
||||||
point.x = floatValue * (documentRect.size.width
|
point.x = floatValue * (documentRect.size.width
|
||||||
- clipViewBounds.size.width);
|
- clipViewBounds.size.width);
|
||||||
point.y = clipViewBounds.origin.y;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (scroller == _vertScroller)
|
|
||||||
{
|
|
||||||
point.x = clipViewBounds.origin.x;
|
|
||||||
if (![_contentView isFlipped])
|
if (![_contentView isFlipped])
|
||||||
floatValue = 1 - floatValue;
|
floatValue = 1 - floatValue;
|
||||||
point.y = floatValue * (documentRect.size.height
|
point.y = floatValue * (documentRect.size.height
|
||||||
- clipViewBounds.size.height);
|
- clipViewBounds.size.height);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return; // do nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[_contentView scrollToPoint:point]; // scroll clipview
|
[_contentView scrollToPoint: point];
|
||||||
if (!_knobMoved)
|
// scroll clipview
|
||||||
{ // if scrolling via
|
// reflectScrolledClipView has been called by the clipView.
|
||||||
[self reflectScrolledClipView:_contentView]; // buttons update
|
|
||||||
// if (scroller == _vertScroller) // scroller pos to
|
//FIXME: should this be here?
|
||||||
// [_vertScroller displayIfNeeded]; // reflect clipview
|
// NSWindow's doc says update is called for each event
|
||||||
// else
|
[window update];
|
||||||
// [_horizScroller displayIfNeeded];
|
|
||||||
// [window flushWindow];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)reflectScrolledClipView:(NSClipView*)aClipView
|
- (void) reflectScrolledClipView: (NSClipView*)aClipView
|
||||||
{
|
{
|
||||||
NSRect documentFrame = NSZeroRect;
|
NSRect documentFrame = NSZeroRect;
|
||||||
NSRect clipViewBounds = NSZeroRect;
|
NSRect clipViewBounds = NSZeroRect;
|
||||||
float floatValue;
|
float floatValue;
|
||||||
float knobProportion;
|
float knobProportion;
|
||||||
id documentView;
|
id documentView;
|
||||||
// do nothing if
|
|
||||||
if(aClipView != _contentView) // aClipView is not
|
|
||||||
return; // our content view
|
|
||||||
|
|
||||||
// if (_knobMoved) // is this really needed?
|
if (aClipView != _contentView)
|
||||||
// return; // FAR FIX ME ?
|
return;
|
||||||
|
|
||||||
NSDebugLog (@"reflectScrolledClipView:");
|
NSDebugLog (@"reflectScrolledClipView:");
|
||||||
|
|
||||||
|
@ -369,48 +370,44 @@ id documentView;
|
||||||
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.size.height
|
floatValue = clipViewBounds.origin.y / (documentFrame.size.height
|
||||||
- clipViewBounds.size.height);
|
- clipViewBounds.size.height);
|
||||||
if (![_contentView isFlipped])
|
if (![_contentView isFlipped])
|
||||||
floatValue = 1 - floatValue;
|
floatValue = 1 - floatValue;
|
||||||
[_vertScroller setFloatValue:floatValue
|
[_vertScroller setFloatValue: floatValue
|
||||||
knobProportion:knobProportion];
|
knobProportion: knobProportion];
|
||||||
[_vertScroller displayIfNeededIgnoringOpacity];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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.size.width -
|
floatValue = clipViewBounds.origin.x / (documentFrame.size.width -
|
||||||
clipViewBounds.size.width);
|
clipViewBounds.size.width);
|
||||||
[_horizScroller setFloatValue:floatValue
|
[_horizScroller setFloatValue: floatValue
|
||||||
knobProportion:knobProportion];
|
knobProportion: knobProportion];
|
||||||
[_horizScroller displayIfNeededIgnoringOpacity];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[window flushWindow];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setHorizontalRulerView:(NSRulerView*)aRulerView // FIX ME
|
- (void) setHorizontalRulerView: (NSRulerView*)aRulerView // FIX ME
|
||||||
{
|
{
|
||||||
ASSIGN(_horizRuler, aRulerView);
|
ASSIGN(_horizRuler, aRulerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setHasHorizontalRuler:(BOOL)flag // FIX ME
|
- (void) setHasHorizontalRuler: (BOOL)flag // FIX ME
|
||||||
{
|
{
|
||||||
if (_hasHorizRuler == flag)
|
if (_hasHorizRuler == flag)
|
||||||
return;
|
return;
|
||||||
|
@ -418,12 +415,12 @@ id documentView;
|
||||||
_hasHorizRuler = flag;
|
_hasHorizRuler = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setVerticalRulerView:(NSRulerView*)ruler // FIX ME
|
- (void) setVerticalRulerView: (NSRulerView*)ruler // FIX ME
|
||||||
{
|
{
|
||||||
ASSIGN(_vertRuler, ruler);
|
ASSIGN(_vertRuler, ruler);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setHasVerticalRuler:(BOOL)flag // FIX ME
|
- (void) setHasVerticalRuler: (BOOL)flag // FIX ME
|
||||||
{
|
{
|
||||||
if (_hasVertRuler == flag)
|
if (_hasVertRuler == flag)
|
||||||
return;
|
return;
|
||||||
|
@ -431,34 +428,34 @@ id documentView;
|
||||||
_hasVertRuler = flag;
|
_hasVertRuler = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setRulersVisible:(BOOL)flag
|
- (void) setRulersVisible: (BOOL)flag
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFrame:(NSRect)rect
|
- (void) setFrame: (NSRect)rect
|
||||||
{
|
{
|
||||||
[super setFrame:rect];
|
[super setFrame: rect];
|
||||||
[self tile];
|
[self tile];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFrameSize:(NSSize)size
|
- (void) setFrameSize: (NSSize)size
|
||||||
{
|
{
|
||||||
[super setFrameSize:size];
|
[super setFrameSize: size];
|
||||||
[self tile];
|
[self tile];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)tile
|
- (void) tile
|
||||||
{
|
{
|
||||||
NSRect boundsRect = [self bounds];
|
NSRect boundsRect = [self bounds];
|
||||||
NSSize contentSize = [isa contentSizeForFrameSize:boundsRect.size
|
NSSize contentSize = [isa contentSizeForFrameSize: boundsRect.size
|
||||||
hasHorizontalScroller:_hasHorizScroller
|
hasHorizontalScroller: _hasHorizScroller
|
||||||
hasVerticalScroller:_hasVertScroller
|
hasVerticalScroller: _hasVertScroller
|
||||||
borderType:_borderType];
|
borderType: _borderType];
|
||||||
float scrollerWidth = [NSScroller scrollerWidth];
|
float scrollerWidth = [NSScroller scrollerWidth];
|
||||||
NSRect contentRect = { NSZeroPoint, contentSize };
|
NSRect contentRect = { NSZeroPoint, contentSize };
|
||||||
NSRect vertScrollerRect = NSZeroRect;
|
NSRect vertScrollerRect = NSZeroRect;
|
||||||
NSRect horizScrollerRect = NSZeroRect;
|
NSRect horizScrollerRect = NSZeroRect;
|
||||||
float borderThickness = 0;
|
float borderThickness = 0;
|
||||||
|
|
||||||
switch ([self borderType])
|
switch ([self borderType])
|
||||||
{
|
{
|
||||||
|
@ -498,19 +495,20 @@ float borderThickness = 0;
|
||||||
contentRect.origin.y += scrollerWidth + 1;
|
contentRect.origin.y += scrollerWidth + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the document view is not
|
// If the document view is not flipped reverse the meaning
|
||||||
if (![_contentView isFlipped]) // flipped reverse the meaning
|
// of the vertical scroller's
|
||||||
[_vertScroller setFloatValue:1]; // of the vertical scroller's
|
if (![_contentView isFlipped])
|
||||||
[_horizScroller setFrame:horizScrollerRect];
|
[_vertScroller setFloatValue: 1];
|
||||||
[_vertScroller setFrame:vertScrollerRect];
|
[_horizScroller setFrame: horizScrollerRect];
|
||||||
[_contentView setFrame:contentRect];
|
[_vertScroller setFrame: vertScrollerRect];
|
||||||
|
[_contentView setFrame: contentRect];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawRect:(NSRect)rect
|
- (void) drawRect: (NSRect)rect
|
||||||
{
|
{
|
||||||
float scrollerWidth = [NSScroller scrollerWidth];
|
float scrollerWidth = [NSScroller scrollerWidth];
|
||||||
float horizLinePosition, horizLineLength = [self bounds].size.width;
|
float horizLinePosition, horizLineLength = [self bounds].size.width;
|
||||||
float borderThickness = 0;
|
float borderThickness = 0;
|
||||||
|
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"NSScrollView drawRect: origin (%1.2f, %1.2f), size (%1.2f, %1.2f)\n",
|
"NSScrollView drawRect: origin (%1.2f, %1.2f), size (%1.2f, %1.2f)\n",
|
||||||
|
@ -562,76 +560,153 @@ float borderThickness = 0;
|
||||||
PSgrestore ();
|
PSgrestore ();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRect)documentVisibleRect
|
- (NSRect) documentVisibleRect
|
||||||
{
|
{
|
||||||
return [_contentView documentVisibleRect];
|
return [_contentView documentVisibleRect];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setBackgroundColor:(NSColor*)aColor
|
- (void) setBackgroundColor: (NSColor*)aColor
|
||||||
{
|
{
|
||||||
[_contentView setBackgroundColor:aColor];
|
[_contentView setBackgroundColor: aColor];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSColor*)backgroundColor
|
- (NSColor*) backgroundColor
|
||||||
{
|
{
|
||||||
return [_contentView backgroundColor];
|
return [_contentView backgroundColor];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setBorderType:(NSBorderType)borderType
|
- (void) setBorderType: (NSBorderType)borderType
|
||||||
{
|
{
|
||||||
_borderType = borderType;
|
_borderType = borderType;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setDocumentView:(NSView*)aView
|
- (void) setDocumentView: (NSView*)aView
|
||||||
{
|
{
|
||||||
[_contentView setDocumentView:aView];
|
[_contentView setDocumentView: aView];
|
||||||
if (_contentView && ![_contentView isFlipped])
|
if (_contentView && ![_contentView isFlipped])
|
||||||
[_vertScroller setFloatValue:1];
|
[_vertScroller setFloatValue: 1];
|
||||||
[self tile];
|
[self tile];
|
||||||
#if 0
|
#if 0
|
||||||
/* Redundant stuff - done in -tile */
|
/* Redundant stuff - done in -tile */
|
||||||
[_contentView viewFrameChanged:nil];
|
[_contentView viewFrameChanged: nil];
|
||||||
// update scroller
|
// update scroller
|
||||||
[self reflectScrolledClipView:(NSClipView*)_contentView];
|
[self reflectScrolledClipView: (NSClipView*)_contentView];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Don't need to override if we can trust the default autoresizing */
|
/* Don't need to override if we can trust the default autoresizing */
|
||||||
- (void)resizeSubviewsWithOldSize:(NSSize)oldSize
|
- (void) resizeSubviewsWithOldSize: (NSSize)oldSize
|
||||||
{
|
{
|
||||||
fprintf (stderr, "NSScrollView resizeSubviewsWithOldSize \n");
|
fprintf (stderr, "NSScrollView resizeSubviewsWithOldSize \n");
|
||||||
[super resizeSubviewsWithOldSize:oldSize];
|
[super resizeSubviewsWithOldSize: oldSize];
|
||||||
[self tile];
|
[self tile];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
- (id)documentView { return [_contentView documentView]; }
|
- (id) documentView
|
||||||
- (NSCursor*)documentCursor { return [_contentView documentCursor]; }
|
|
||||||
|
|
||||||
- (void)setDocumentCursor:(NSCursor*)aCursor
|
|
||||||
{
|
{
|
||||||
[_contentView setDocumentCursor:aCursor];
|
return [_contentView documentView];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isOpaque { return YES; }
|
- (NSCursor*) documentCursor
|
||||||
- (NSBorderType)borderType { return _borderType; }
|
{
|
||||||
- (NSScroller*)verticalScroller { return _vertScroller; }
|
return [_contentView documentCursor];
|
||||||
- (BOOL)hasVerticalScroller { return _hasVertScroller; }
|
}
|
||||||
- (BOOL)hasHorizontalRuler { return _hasHorizRuler; }
|
|
||||||
- (NSSize)contentSize { return [_contentView bounds].size; }
|
- (void) setDocumentCursor: (NSCursor*)aCursor
|
||||||
- (NSView*)contentView { return _contentView; }
|
{
|
||||||
- (NSRulerView*)horizontalRulerView { return _horizRuler; }
|
[_contentView setDocumentCursor: aCursor];
|
||||||
- (BOOL)hasVerticalRuler { return _hasVertRuler; }
|
}
|
||||||
- (NSRulerView*)verticalRulerView { return _vertRuler; }
|
|
||||||
- (BOOL)rulersVisible { return _rulersVisible; }
|
- (BOOL) isOpaque
|
||||||
- (void)setLineScroll:(float)aFloat { _lineScroll = aFloat; }
|
{
|
||||||
- (float)lineScroll { return _lineScroll; }
|
return YES;
|
||||||
- (void)setPageScroll:(float)aFloat { _pageScroll = aFloat; }
|
}
|
||||||
- (float)pageScroll { return _pageScroll; }
|
|
||||||
- (void)setScrollsDynamically:(BOOL)flag { _scrollsDynamically = flag; }
|
- (NSBorderType) borderType
|
||||||
- (BOOL)scrollsDynamically { return _scrollsDynamically; }
|
{
|
||||||
- (NSScroller*)horizontalScroller { return _horizScroller; }
|
return _borderType;
|
||||||
- (BOOL)hasHorizontalScroller { return _hasHorizScroller; }
|
}
|
||||||
|
|
||||||
|
- (BOOL) hasVerticalScroller
|
||||||
|
{
|
||||||
|
return _hasVertScroller;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) hasHorizontalRuler
|
||||||
|
{
|
||||||
|
return _hasHorizRuler;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSSize) contentSize
|
||||||
|
{
|
||||||
|
return [_contentView bounds].size;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSView*) contentView
|
||||||
|
{
|
||||||
|
return _contentView;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSRulerView*) horizontalRulerView
|
||||||
|
{
|
||||||
|
return _horizRuler;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) hasVerticalRuler
|
||||||
|
{
|
||||||
|
return _hasVertRuler;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSRulerView*) verticalRulerView
|
||||||
|
{
|
||||||
|
return _vertRuler;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) rulersVisible
|
||||||
|
{
|
||||||
|
return _rulersVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setLineScroll: (float)aFloat
|
||||||
|
{
|
||||||
|
_lineScroll = aFloat;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (float) lineScroll
|
||||||
|
{
|
||||||
|
return _lineScroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setPageScroll: (float)aFloat
|
||||||
|
{
|
||||||
|
_pageScroll = aFloat;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (float) pageScroll
|
||||||
|
{
|
||||||
|
return _pageScroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setScrollsDynamically: (BOOL)flag
|
||||||
|
{
|
||||||
|
_scrollsDynamically = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) scrollsDynamically
|
||||||
|
{
|
||||||
|
return _scrollsDynamically;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSScroller*) horizontalScroller
|
||||||
|
{
|
||||||
|
return _horizScroller;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) hasHorizontalScroller
|
||||||
|
{
|
||||||
|
return _hasHorizScroller;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -71,40 +71,91 @@ static BOOL preCalcValues = NO;
|
||||||
//
|
//
|
||||||
// Class methods
|
// Class methods
|
||||||
//
|
//
|
||||||
+ (void)initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
if (self == [NSScroller class])
|
if (self == [NSScroller class])
|
||||||
[self setVersion:1];
|
[self setVersion: 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (float)scrollerWidth { return scrollerWidth; }
|
+ (float) scrollerWidth
|
||||||
- (NSScrollArrowPosition)arrowsPosition { return _arrowsPosition; }
|
|
||||||
- (NSUsableScrollerParts)usableParts { return _usableParts; }
|
|
||||||
- (float)knobProportion { return _knobProportion; }
|
|
||||||
- (NSScrollerPart)hitPart { return _hitPart; }
|
|
||||||
- (float)floatValue { return _floatValue; }
|
|
||||||
- (void)setAction:(SEL)action { _action = action; }
|
|
||||||
- (SEL)action { return _action; }
|
|
||||||
- (void)setTarget:(id)target { ASSIGN(_target, target); }
|
|
||||||
- (id)target { return _target; }
|
|
||||||
- (void)encodeWithCoder:aCoder { }
|
|
||||||
- initWithCoder:aDecoder { return self; }
|
|
||||||
- (BOOL)isOpaque { return YES; }
|
|
||||||
|
|
||||||
- initWithFrame:(NSRect)frameRect
|
|
||||||
{
|
{
|
||||||
if (frameRect.size.width > frameRect.size.height) // determine the
|
return scrollerWidth;
|
||||||
{ // orientation of
|
}
|
||||||
_isHorizontal = YES; // the scroller and
|
|
||||||
frameRect.size.height = [isa scrollerWidth]; // adjust it's size
|
- (NSScrollArrowPosition) arrowsPosition
|
||||||
} // accordingly
|
{
|
||||||
|
return _arrowsPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSUsableScrollerParts) usableParts
|
||||||
|
{
|
||||||
|
return _usableParts;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (float) knobProportion
|
||||||
|
{
|
||||||
|
return _knobProportion;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSScrollerPart) hitPart
|
||||||
|
{
|
||||||
|
return _hitPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (float) floatValue
|
||||||
|
{
|
||||||
|
return _floatValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setAction: (SEL)action
|
||||||
|
{
|
||||||
|
_action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (SEL) action
|
||||||
|
{
|
||||||
|
return _action;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setTarget: (id)target
|
||||||
|
{
|
||||||
|
ASSIGN(_target, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) target
|
||||||
|
{
|
||||||
|
return _target;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||||
|
{
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) isOpaque
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithFrame: (NSRect)frameRect
|
||||||
|
{
|
||||||
|
// determine the orientation of the scroller and adjust it's size accordingly
|
||||||
|
if (frameRect.size.width > frameRect.size.height)
|
||||||
|
{
|
||||||
|
_isHorizontal = YES;
|
||||||
|
frameRect.size.height = [isa scrollerWidth];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_isHorizontal = NO;
|
_isHorizontal = NO;
|
||||||
frameRect.size.width = [isa scrollerWidth];
|
frameRect.size.width = [isa scrollerWidth];
|
||||||
}
|
}
|
||||||
|
|
||||||
[super initWithFrame:frameRect];
|
[super initWithFrame: frameRect];
|
||||||
|
|
||||||
if (_isHorizontal)
|
if (_isHorizontal)
|
||||||
_arrowsPosition = NSScrollerArrowsMinEnd;
|
_arrowsPosition = NSScrollerArrowsMinEnd;
|
||||||
|
@ -113,152 +164,153 @@ static BOOL preCalcValues = NO;
|
||||||
|
|
||||||
_hitPart = NSScrollerNoPart;
|
_hitPart = NSScrollerNoPart;
|
||||||
[self drawParts];
|
[self drawParts];
|
||||||
[self setEnabled:NO];
|
[self setEnabled: NO];
|
||||||
[self checkSpaceForParts];
|
[self checkSpaceForParts];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- init
|
- (id) init
|
||||||
{
|
{
|
||||||
return [self initWithFrame:NSZeroRect];
|
return [self initWithFrame: NSZeroRect];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawParts
|
- (void) drawParts
|
||||||
{ // Create the class variable
|
{
|
||||||
if (knobCell) // button cells if they do not
|
// Create the class variable button cells if they do not yet exist.
|
||||||
return; // yet exist.
|
if (knobCell)
|
||||||
|
return;
|
||||||
|
|
||||||
upCell = [NSButtonCell new];
|
upCell = [NSButtonCell new];
|
||||||
[upCell setHighlightsBy:NSChangeBackgroundCellMask|NSContentsCellMask];
|
[upCell setHighlightsBy: NSChangeBackgroundCellMask|NSContentsCellMask];
|
||||||
[upCell setImage:[NSImage imageNamed:@"common_ArrowUp"]];
|
[upCell setImage: [NSImage imageNamed: @"common_ArrowUp"]];
|
||||||
[upCell setAlternateImage:[NSImage imageNamed:@"common_ArrowUpH"]];
|
[upCell setAlternateImage: [NSImage imageNamed: @"common_ArrowUpH"]];
|
||||||
[upCell setImagePosition:NSImageOnly];
|
[upCell setImagePosition: NSImageOnly];
|
||||||
[upCell setContinuous:YES];
|
[upCell setContinuous: YES];
|
||||||
[upCell setPeriodicDelay:0.05 interval:0.05];
|
[upCell setPeriodicDelay: 0.05 interval: 0.05];
|
||||||
|
|
||||||
downCell = [NSButtonCell new];
|
downCell = [NSButtonCell new];
|
||||||
[downCell setHighlightsBy:NSChangeBackgroundCellMask|NSContentsCellMask];
|
[downCell setHighlightsBy: NSChangeBackgroundCellMask|NSContentsCellMask];
|
||||||
[downCell setImage:[NSImage imageNamed:@"common_ArrowDown"]];
|
[downCell setImage: [NSImage imageNamed: @"common_ArrowDown"]];
|
||||||
[downCell setAlternateImage:[NSImage imageNamed:@"common_ArrowDownH"]];
|
[downCell setAlternateImage: [NSImage imageNamed: @"common_ArrowDownH"]];
|
||||||
[downCell setImagePosition:NSImageOnly];
|
[downCell setImagePosition: NSImageOnly];
|
||||||
[downCell setContinuous:YES];
|
[downCell setContinuous: YES];
|
||||||
[downCell setPeriodicDelay:0.05 interval:0.05];
|
[downCell setPeriodicDelay: 0.05 interval: 0.05];
|
||||||
|
|
||||||
leftCell = [NSButtonCell new];
|
leftCell = [NSButtonCell new];
|
||||||
[leftCell setHighlightsBy:NSChangeBackgroundCellMask|NSContentsCellMask];
|
[leftCell setHighlightsBy: NSChangeBackgroundCellMask|NSContentsCellMask];
|
||||||
[leftCell setImage:[NSImage imageNamed:@"common_ArrowLeft"]];
|
[leftCell setImage: [NSImage imageNamed: @"common_ArrowLeft"]];
|
||||||
[leftCell setAlternateImage:[NSImage imageNamed:@"common_ArrowLeftH"]];
|
[leftCell setAlternateImage: [NSImage imageNamed: @"common_ArrowLeftH"]];
|
||||||
[leftCell setImagePosition:NSImageOnly];
|
[leftCell setImagePosition: NSImageOnly];
|
||||||
[leftCell setContinuous:YES];
|
[leftCell setContinuous: YES];
|
||||||
[leftCell setPeriodicDelay:0.05 interval:0.05];
|
[leftCell setPeriodicDelay: 0.05 interval: 0.05];
|
||||||
|
|
||||||
rightCell = [NSButtonCell new];
|
rightCell = [NSButtonCell new];
|
||||||
[rightCell setHighlightsBy:NSChangeBackgroundCellMask|NSContentsCellMask];
|
[rightCell setHighlightsBy: NSChangeBackgroundCellMask|NSContentsCellMask];
|
||||||
[rightCell setImage:[NSImage imageNamed:@"common_ArrowRight"]];
|
[rightCell setImage: [NSImage imageNamed: @"common_ArrowRight"]];
|
||||||
[rightCell setAlternateImage:[NSImage imageNamed:@"common_ArrowRightH"]];
|
[rightCell setAlternateImage: [NSImage imageNamed: @"common_ArrowRightH"]];
|
||||||
[rightCell setImagePosition:NSImageOnly];
|
[rightCell setImagePosition: NSImageOnly];
|
||||||
[rightCell setContinuous:YES];
|
[rightCell setContinuous: YES];
|
||||||
[rightCell setPeriodicDelay:0.05 interval:0.05];
|
[rightCell setPeriodicDelay: 0.05 interval: 0.05];
|
||||||
|
|
||||||
knobCell = [NSButtonCell new];
|
knobCell = [NSButtonCell new];
|
||||||
[knobCell setButtonType:NSMomentaryChangeButton];
|
[knobCell setButtonType: NSMomentaryChangeButton];
|
||||||
[knobCell setImage:[NSImage imageNamed:@"common_Dimple"]];
|
[knobCell setImage: [NSImage imageNamed: @"common_Dimple"]];
|
||||||
[knobCell setImagePosition:NSImageOnly];
|
[knobCell setImagePosition: NSImageOnly];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_setTargetAndActionToCells
|
- (void) _setTargetAndActionToCells
|
||||||
{
|
{
|
||||||
[upCell setTarget:_target];
|
[upCell setTarget: _target];
|
||||||
[upCell setAction:_action];
|
[upCell setAction: _action];
|
||||||
|
|
||||||
[downCell setTarget:_target];
|
[downCell setTarget: _target];
|
||||||
[downCell setAction:_action];
|
[downCell setAction: _action];
|
||||||
|
|
||||||
[leftCell setTarget:_target];
|
[leftCell setTarget: _target];
|
||||||
[leftCell setAction:_action];
|
[leftCell setAction: _action];
|
||||||
|
|
||||||
[rightCell setTarget:_target];
|
[rightCell setTarget: _target];
|
||||||
[rightCell setAction:_action];
|
[rightCell setAction: _action];
|
||||||
|
|
||||||
[knobCell setTarget:_target];
|
[knobCell setTarget: _target];
|
||||||
[knobCell setAction:_action];
|
[knobCell setAction: _action];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)checkSpaceForParts
|
- (void) checkSpaceForParts
|
||||||
{
|
{
|
||||||
NSSize frameSize = [self frame].size;
|
NSSize frameSize = [self frame].size;
|
||||||
float size = (_isHorizontal ? frameSize.width : frameSize.height);
|
float size = (_isHorizontal ? frameSize.width : frameSize.height);
|
||||||
float scrollerWidth = [isa scrollerWidth];
|
float scrollerWidth = [isa scrollerWidth];
|
||||||
|
|
||||||
if (size > 3 * scrollerWidth + 2)
|
if (size > 3 * scrollerWidth + 2)
|
||||||
_usableParts = NSAllScrollerParts;
|
_usableParts = NSAllScrollerParts;
|
||||||
else
|
else if (size > 2 * scrollerWidth + 1)
|
||||||
if (size > 2 * scrollerWidth + 1)
|
|
||||||
_usableParts = NSOnlyScrollerArrows;
|
_usableParts = NSOnlyScrollerArrows;
|
||||||
else
|
else
|
||||||
if (size > scrollerWidth)
|
|
||||||
_usableParts = NSNoScrollerParts;
|
_usableParts = NSNoScrollerParts;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setEnabled:(BOOL)flag
|
- (void) setEnabled: (BOOL)flag
|
||||||
{
|
{
|
||||||
if (_isEnabled == flag)
|
if (_isEnabled == flag)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_isEnabled = flag;
|
_isEnabled = flag;
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setArrowsPosition:(NSScrollArrowPosition)where
|
- (void) setArrowsPosition: (NSScrollArrowPosition)where
|
||||||
{
|
{
|
||||||
if (_arrowsPosition == where)
|
if (_arrowsPosition == where)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_arrowsPosition = where;
|
_arrowsPosition = where;
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFloatValue:(float)aFloat
|
- (void) setFloatValue: (float)aFloat
|
||||||
{
|
{
|
||||||
|
if (aFloat == _floatValue)
|
||||||
|
return;
|
||||||
|
|
||||||
if (aFloat < 0)
|
if (aFloat < 0)
|
||||||
_floatValue = 0;
|
_floatValue = 0;
|
||||||
else
|
else if (aFloat > 1)
|
||||||
if (aFloat > 1)
|
|
||||||
_floatValue = 1;
|
_floatValue = 1;
|
||||||
else
|
else
|
||||||
_floatValue = aFloat;
|
_floatValue = aFloat;
|
||||||
|
|
||||||
[self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]];
|
[self setNeedsDisplayInRect: [self rectForPart: NSScrollerKnobSlot]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (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
|
else if (ratio > 1)
|
||||||
if (ratio > 1)
|
|
||||||
_knobProportion = 1;
|
_knobProportion = 1;
|
||||||
else
|
else
|
||||||
_knobProportion = ratio;
|
_knobProportion = ratio;
|
||||||
|
|
||||||
[self setFloatValue:aFloat];
|
[self setFloatValue: aFloat];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFrame:(NSRect)frameRect
|
- (void) setFrame: (NSRect)frameRect
|
||||||
{
|
{
|
||||||
if (frameRect.size.width > frameRect.size.height) // determine the
|
// determine the orientation of the scroller and adjust it's size accordingly
|
||||||
{ // orientation of
|
if (frameRect.size.width > frameRect.size.height)
|
||||||
_isHorizontal = YES; // the scroller and
|
{
|
||||||
frameRect.size.height = [isa scrollerWidth]; // adjust it's size
|
_isHorizontal = YES;
|
||||||
} // accordingly
|
frameRect.size.height = [isa scrollerWidth];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_isHorizontal = NO;
|
_isHorizontal = NO;
|
||||||
frameRect.size.width = [isa scrollerWidth];
|
frameRect.size.width = [isa scrollerWidth];
|
||||||
}
|
}
|
||||||
|
|
||||||
[super setFrame:frameRect];
|
[super setFrame: frameRect];
|
||||||
|
|
||||||
if (_isHorizontal)
|
if (_isHorizontal)
|
||||||
_arrowsPosition = NSScrollerArrowsMinEnd;
|
_arrowsPosition = NSScrollerArrowsMinEnd;
|
||||||
|
@ -269,57 +321,59 @@ float scrollerWidth = [isa scrollerWidth];
|
||||||
[self checkSpaceForParts];
|
[self checkSpaceForParts];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFrameSize:(NSSize)size
|
- (void) setFrameSize: (NSSize)size
|
||||||
{
|
{
|
||||||
[super setFrameSize:size];
|
[super setFrameSize: size];
|
||||||
[self checkSpaceForParts];
|
[self checkSpaceForParts];
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSScrollerPart)testPart:(NSPoint)thePoint // return what part
|
- (NSScrollerPart)testPart: (NSPoint)thePoint
|
||||||
{ // of the scroller
|
{
|
||||||
NSRect rect; // the mouse hit
|
// return what part of the scroller the mouse hit
|
||||||
|
NSRect rect;
|
||||||
|
|
||||||
if (thePoint.x < 0 || thePoint.x > frame.size.width
|
if (thePoint.x < 0 || thePoint.x > frame.size.width
|
||||||
|| thePoint.y < 0 || thePoint.y > frame.size.height)
|
|| thePoint.y < 0 || thePoint.y > frame.size.height)
|
||||||
return NSScrollerNoPart;
|
return NSScrollerNoPart;
|
||||||
|
|
||||||
rect = [self rectForPart:NSScrollerDecrementLine];
|
rect = [self rectForPart: NSScrollerDecrementLine];
|
||||||
if ([self mouse:thePoint inRect:rect])
|
if ([self mouse: thePoint inRect: rect])
|
||||||
return NSScrollerDecrementLine;
|
return NSScrollerDecrementLine;
|
||||||
|
|
||||||
rect = [self rectForPart:NSScrollerIncrementLine];
|
rect = [self rectForPart: NSScrollerIncrementLine];
|
||||||
if ([self mouse:thePoint inRect:rect])
|
if ([self mouse: thePoint inRect: rect])
|
||||||
return NSScrollerIncrementLine;
|
return NSScrollerIncrementLine;
|
||||||
|
|
||||||
rect = [self rectForPart:NSScrollerKnob];
|
rect = [self rectForPart: NSScrollerKnob];
|
||||||
if ([self mouse:thePoint inRect:rect])
|
if ([self mouse: thePoint inRect: rect])
|
||||||
return NSScrollerKnob;
|
return NSScrollerKnob;
|
||||||
|
|
||||||
rect = [self rectForPart:NSScrollerKnobSlot];
|
rect = [self rectForPart: NSScrollerKnobSlot];
|
||||||
if ([self mouse:thePoint inRect:rect])
|
if ([self mouse: thePoint inRect: rect])
|
||||||
return NSScrollerKnobSlot;
|
return NSScrollerKnobSlot;
|
||||||
|
|
||||||
rect = [self rectForPart:NSScrollerDecrementPage];
|
rect = [self rectForPart: NSScrollerDecrementPage];
|
||||||
if ([self mouse:thePoint inRect:rect])
|
if ([self mouse: thePoint inRect: rect])
|
||||||
return NSScrollerDecrementPage;
|
return NSScrollerDecrementPage;
|
||||||
|
|
||||||
rect = [self rectForPart:NSScrollerIncrementPage];
|
rect = [self rectForPart: NSScrollerIncrementPage];
|
||||||
if ([self mouse:thePoint inRect:rect])
|
if ([self mouse: thePoint inRect: rect])
|
||||||
return NSScrollerIncrementPage;
|
return NSScrollerIncrementPage;
|
||||||
|
|
||||||
return NSScrollerNoPart;
|
return NSScrollerNoPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float)_floatValueForMousePoint:(NSPoint)point
|
- (float) _floatValueForMousePoint: (NSPoint)point
|
||||||
{
|
{
|
||||||
NSRect knobRect = [self rectForPart:NSScrollerKnob];
|
NSRect knobRect = [self rectForPart: NSScrollerKnob];
|
||||||
NSRect slotRect = [self rectForPart:NSScrollerKnobSlot];
|
NSRect slotRect = [self rectForPart: NSScrollerKnobSlot];
|
||||||
float floatValue = 0;
|
float floatValue = 0;
|
||||||
float position;
|
float position;
|
||||||
|
|
||||||
if (_isHorizontal) // Adjust point to lie
|
// Adjust point to lie within the knob slot
|
||||||
{ // within the knob slot
|
if (_isHorizontal)
|
||||||
|
{
|
||||||
float halfKnobRectWidth = knobRect.size.width / 2;
|
float halfKnobRectWidth = knobRect.size.width / 2;
|
||||||
|
|
||||||
if (point.x < slotRect.origin.x + halfKnobRectWidth)
|
if (point.x < slotRect.origin.x + halfKnobRectWidth)
|
||||||
|
@ -332,13 +386,13 @@ float position;
|
||||||
halfKnobRectWidth;
|
halfKnobRectWidth;
|
||||||
else
|
else
|
||||||
position = point.x;
|
position = point.x;
|
||||||
} // Compute float value
|
}
|
||||||
// given the knob size
|
// Compute float value given the knob size
|
||||||
floatValue = (position - (slotRect.origin.x + halfKnobRectWidth))
|
floatValue = (position - (slotRect.origin.x + halfKnobRectWidth))
|
||||||
/ (slotRect.size.width - knobRect.size.width);
|
/ (slotRect.size.width - knobRect.size.width);
|
||||||
}
|
}
|
||||||
else // Adjust point to lie
|
else
|
||||||
{ // within the knob slot
|
{
|
||||||
float halfKnobRectHeight = knobRect.size.height / 2;
|
float halfKnobRectHeight = knobRect.size.height / 2;
|
||||||
|
|
||||||
if (point.y < slotRect.origin.y + halfKnobRectHeight)
|
if (point.y < slotRect.origin.y + halfKnobRectHeight)
|
||||||
|
@ -352,7 +406,7 @@ float position;
|
||||||
else
|
else
|
||||||
position = point.y;
|
position = point.y;
|
||||||
}
|
}
|
||||||
// Compute float value
|
// Compute float value given the knob size
|
||||||
floatValue = (position - (slotRect.origin.y + halfKnobRectHeight)) /
|
floatValue = (position - (slotRect.origin.y + halfKnobRectHeight)) /
|
||||||
(slotRect.size.height - knobRect.size.height);
|
(slotRect.size.height - knobRect.size.height);
|
||||||
floatValue = 1 - floatValue;
|
floatValue = 1 - floatValue;
|
||||||
|
@ -361,12 +415,11 @@ float position;
|
||||||
return floatValue;
|
return floatValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_preCalcParts // pre calculate
|
- (void) _preCalcParts
|
||||||
{ // values to lessen
|
{
|
||||||
NSRect knobRect = [self rectForPart:NSScrollerKnob]; // the burden while
|
NSRect knobRect = [self rectForPart: NSScrollerKnob];
|
||||||
// scrolling
|
|
||||||
slotRect = [self rectForPart:NSScrollerKnobSlot];
|
|
||||||
|
|
||||||
|
slotRect = [self rectForPart: NSScrollerKnobSlot];
|
||||||
halfKnobRectWidth = knobRect.size.width / 2;
|
halfKnobRectWidth = knobRect.size.width / 2;
|
||||||
slotOriginPlusKnobWidth = slotRect.origin.x + halfKnobRectWidth;
|
slotOriginPlusKnobWidth = slotRect.origin.x + halfKnobRectWidth;
|
||||||
slotOriginPlusSlotWidthMinusHalfKnobWidth = slotRect.origin.x +
|
slotOriginPlusSlotWidthMinusHalfKnobWidth = slotRect.origin.x +
|
||||||
|
@ -380,13 +433,13 @@ NSRect knobRect = [self rectForPart:NSScrollerKnob]; // the burden while
|
||||||
slotHeightMinusKnobHeight = slotRect.size.height - knobRect.size.height;
|
slotHeightMinusKnobHeight = slotRect.size.height - knobRect.size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float)_floatValueForMousePointFromPreCalc:(NSPoint)point
|
- (float) _floatValueForMousePointFromPreCalc: (NSPoint)point
|
||||||
{
|
{
|
||||||
float floatValue = 0;
|
float floatValue = 0;
|
||||||
float position;
|
float position;
|
||||||
|
|
||||||
if (_isHorizontal) // Adjust point to lie
|
if (_isHorizontal)
|
||||||
{ // within the knob slot
|
{
|
||||||
if (point.x < slotOriginPlusKnobWidth)
|
if (point.x < slotOriginPlusKnobWidth)
|
||||||
position = slotOriginPlusKnobWidth;
|
position = slotOriginPlusKnobWidth;
|
||||||
else
|
else
|
||||||
|
@ -395,13 +448,12 @@ float position;
|
||||||
position = slotOriginPlusSlotWidthMinusHalfKnobWidth;
|
position = slotOriginPlusSlotWidthMinusHalfKnobWidth;
|
||||||
else
|
else
|
||||||
position = point.x;
|
position = point.x;
|
||||||
} // Compute float value
|
}
|
||||||
// given the knob size
|
|
||||||
floatValue = (position - slotOriginPlusKnobWidth) /
|
floatValue = (position - slotOriginPlusKnobWidth) /
|
||||||
slotWidthMinusKnobWidth;
|
slotWidthMinusKnobWidth;
|
||||||
}
|
}
|
||||||
else // Adjust point to lie
|
else
|
||||||
{ // within the knob slot
|
{
|
||||||
if (point.y < slotOriginPlusKnobHeight)
|
if (point.y < slotOriginPlusKnobHeight)
|
||||||
position = slotOriginPlusKnobHeight;
|
position = slotOriginPlusKnobHeight;
|
||||||
else
|
else
|
||||||
|
@ -411,7 +463,7 @@ float position;
|
||||||
else
|
else
|
||||||
position = point.y;
|
position = point.y;
|
||||||
}
|
}
|
||||||
// Compute float value
|
|
||||||
floatValue = (position - slotOriginPlusKnobHeight) /
|
floatValue = (position - slotOriginPlusKnobHeight) /
|
||||||
slotHeightMinusKnobHeight;
|
slotHeightMinusKnobHeight;
|
||||||
floatValue = 1 - floatValue;
|
floatValue = 1 - floatValue;
|
||||||
|
@ -420,13 +472,12 @@ float position;
|
||||||
return floatValue;
|
return floatValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseDown:(NSEvent*)theEvent
|
- (void) mouseDown: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
NSPoint location = [self convertPoint:[theEvent locationInWindow]
|
NSPoint location = [self convertPoint: [theEvent locationInWindow]
|
||||||
fromView:nil];
|
fromView: nil];
|
||||||
|
|
||||||
[self lockFocus];
|
_hitPart = [self testPart: location];
|
||||||
_hitPart = [self testPart:location];
|
|
||||||
[self _setTargetAndActionToCells];
|
[self _setTargetAndActionToCells];
|
||||||
|
|
||||||
switch (_hitPart)
|
switch (_hitPart)
|
||||||
|
@ -435,23 +486,20 @@ NSPoint location = [self convertPoint:[theEvent locationInWindow]
|
||||||
case NSScrollerDecrementLine:
|
case NSScrollerDecrementLine:
|
||||||
case NSScrollerIncrementPage:
|
case NSScrollerIncrementPage:
|
||||||
case NSScrollerDecrementPage:
|
case NSScrollerDecrementPage:
|
||||||
[self trackScrollButtons:theEvent];
|
[self trackScrollButtons: theEvent];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSScrollerKnob:
|
case NSScrollerKnob:
|
||||||
[self trackKnob:theEvent];
|
[self trackKnob: theEvent];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSScrollerKnobSlot:
|
case NSScrollerKnobSlot:
|
||||||
{
|
{
|
||||||
float floatValue = [self _floatValueForMousePoint:location];
|
float floatValue = [self _floatValueForMousePoint: location];
|
||||||
|
|
||||||
[self setFloatValue:floatValue];
|
[self setFloatValue: floatValue];
|
||||||
[self sendAction:_action to:_target];
|
[self sendAction: _action to: _target];
|
||||||
[self drawKnobSlot];
|
[self trackKnob: theEvent];
|
||||||
[self drawKnob];
|
|
||||||
[window flushWindow];
|
|
||||||
[self trackKnob:theEvent];
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,118 +508,105 @@ NSPoint location = [self convertPoint:[theEvent locationInWindow]
|
||||||
}
|
}
|
||||||
|
|
||||||
_hitPart = NSScrollerNoPart;
|
_hitPart = NSScrollerNoPart;
|
||||||
[self unlockFocus];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)trackKnob:(NSEvent*)theEvent
|
- (void)trackKnob: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
||||||
| NSLeftMouseDraggedMask | NSMouseMovedMask
|
| NSLeftMouseDraggedMask | NSMouseMovedMask
|
||||||
| NSPeriodicMask;
|
| NSPeriodicMask;
|
||||||
NSApplication *app = [NSApplication sharedApplication];
|
NSApplication *app = [NSApplication sharedApplication];
|
||||||
NSPoint point, apoint;
|
NSPoint point, apoint;
|
||||||
float oldFloatValue = _floatValue;
|
float oldFloatValue = _floatValue;
|
||||||
float floatValue;
|
float floatValue;
|
||||||
NSDate *theDistantFuture = [NSDate distantFuture];
|
NSDate *theDistantFuture = [NSDate distantFuture];
|
||||||
PSMatrix* matrix;
|
PSMatrix* matrix;
|
||||||
NSEventType eventType;
|
NSEventType eventType;
|
||||||
NSRect knobRect = {{0,0},{0,0}};
|
NSRect knobRect = {{0,0},{0,0}};
|
||||||
int periodCount = 0; // allows a forced update
|
int periodCount = 0; // allows a forced update
|
||||||
NSMutableArray* path = [self _pathBetweenSubview:self
|
NSMutableArray* path = [self _pathBetweenSubview: self
|
||||||
toSuperview:[window contentView]];
|
toSuperview: [window contentView]];
|
||||||
|
|
||||||
[path addObject: [window contentView]];
|
[path addObject: [window contentView]];
|
||||||
matrix = [self _concatenateMatricesInReverseOrderFromPath:path];
|
matrix = [self _concatenateMatricesInReverseOrderFromPath: path];
|
||||||
[matrix inverse];
|
[matrix inverse];
|
||||||
|
|
||||||
//fprintf(stderr, " trackKnob \n");
|
//fprintf(stderr, " trackKnob \n");
|
||||||
|
|
||||||
[self _preCalcParts]; // pre calc scroller parts
|
[self _preCalcParts]; // pre calc scroller parts
|
||||||
preCalcValues = YES;
|
preCalcValues = YES;
|
||||||
|
|
||||||
_hitPart = NSScrollerKnob; // set periodic events rate
|
_hitPart = NSScrollerKnob;
|
||||||
// to achieve max of ~30fps
|
// set periodic events rate to achieve max of ~30fps
|
||||||
[NSEvent startPeriodicEventsAfterDelay:0.02 withPeriod:0.03];
|
[NSEvent startPeriodicEventsAfterDelay: 0.02 withPeriod: 0.03];
|
||||||
[[NSRunLoop currentRunLoop] limitDateForMode:NSEventTrackingRunLoopMode];
|
[[NSRunLoop currentRunLoop] limitDateForMode: NSEventTrackingRunLoopMode];
|
||||||
|
|
||||||
while ((eventType = [theEvent type]) != NSLeftMouseUp)
|
while ((eventType = [theEvent type]) != NSLeftMouseUp)
|
||||||
{ // user is moving scroller
|
|
||||||
if (eventType != NSPeriodic) // loop until left mouse up
|
|
||||||
{
|
{
|
||||||
apoint = [theEvent locationInWindow]; // zero the periodic count
|
if (eventType != NSPeriodic)
|
||||||
periodCount = 0; // whenever a real position
|
{
|
||||||
} // event is recieved
|
apoint = [theEvent locationInWindow];
|
||||||
|
// zero the periodic count whenever a real position event is recieved
|
||||||
|
periodCount = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{ // if 6x periods have gone by w/o movement
|
{
|
||||||
if(periodCount == 6) // check mouse and update if necessary
|
// if 6x periods have gone by w/o movement
|
||||||
|
// check mouse and update if necessary
|
||||||
|
if (periodCount == 6)
|
||||||
apoint = [window mouseLocationOutsideOfEventStream];
|
apoint = [window mouseLocationOutsideOfEventStream];
|
||||||
|
|
||||||
point = [matrix pointInMatrixSpace:apoint];
|
point = [matrix pointInMatrixSpace: apoint];
|
||||||
|
|
||||||
if (point.x != knobRect.origin.x || point.y != knobRect.origin.y)
|
if (point.x != knobRect.origin.x || point.y != knobRect.origin.y)
|
||||||
{
|
{
|
||||||
floatValue = [self _floatValueForMousePointFromPreCalc:point];
|
floatValue = [self _floatValueForMousePointFromPreCalc: point];
|
||||||
|
|
||||||
if (floatValue != oldFloatValue)
|
if (floatValue != oldFloatValue)
|
||||||
{
|
{
|
||||||
if (floatValue < 0)
|
[self setFloatValue: floatValue];
|
||||||
_floatValue = 0;
|
[self sendAction: _action to: _target];
|
||||||
else
|
|
||||||
{
|
|
||||||
if (floatValue > 1)
|
|
||||||
_floatValue = 1;
|
|
||||||
else
|
|
||||||
_floatValue = floatValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
[self drawKnobSlot]; // draw the scroller slot
|
|
||||||
[self drawKnob]; // draw the scroller knob
|
|
||||||
[_target performSelector:_action withObject:self];
|
|
||||||
[window flushWindow];
|
|
||||||
|
|
||||||
oldFloatValue = floatValue;
|
oldFloatValue = floatValue;
|
||||||
} // avoid timing related scrolling
|
[window update];
|
||||||
// hesitation by counting number of
|
}
|
||||||
knobRect.origin = point; // periodic events since scroll pos
|
knobRect.origin = point;
|
||||||
} // was updated, when this reaches
|
}
|
||||||
periodCount++; // 6x periodic rate an update is
|
// avoid timing related scrolling hesitation by counting number of
|
||||||
} // forced on next periodic event
|
// periodic events since scroll pos was updated, when this reaches
|
||||||
theEvent = [app nextEventMatchingMask:eventMask
|
// 6x periodic rate an update is forced on next periodic event
|
||||||
untilDate:theDistantFuture
|
periodCount++;
|
||||||
inMode:NSEventTrackingRunLoopMode
|
}
|
||||||
dequeue:YES];
|
|
||||||
|
theEvent = [app nextEventMatchingMask: eventMask
|
||||||
|
untilDate: theDistantFuture
|
||||||
|
inMode: NSEventTrackingRunLoopMode
|
||||||
|
dequeue: YES];
|
||||||
}
|
}
|
||||||
[NSEvent stopPeriodicEvents];
|
[NSEvent stopPeriodicEvents];
|
||||||
|
|
||||||
if([_target isKindOf:[NSScrollView class]]) // hack for XRAW FIX ME
|
|
||||||
{
|
|
||||||
NSObject *targetCV = (NSObject *)[_target contentView];
|
|
||||||
|
|
||||||
if([targetCV respondsToSelector:@selector(_freeMatrix)])
|
|
||||||
[targetCV _freeMatrix];
|
|
||||||
}
|
|
||||||
|
|
||||||
preCalcValues = NO;
|
preCalcValues = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)trackScrollButtons:(NSEvent*)theEvent
|
- (void) trackScrollButtons: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
NSApplication *theApp = [NSApplication sharedApplication];
|
NSApplication *theApp = [NSApplication sharedApplication];
|
||||||
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask |
|
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask |
|
||||||
NSLeftMouseDraggedMask | NSMouseMovedMask;
|
NSLeftMouseDraggedMask | NSMouseMovedMask;
|
||||||
NSPoint location;
|
NSPoint location;
|
||||||
BOOL shouldReturn = NO;
|
BOOL shouldReturn = NO;
|
||||||
id theCell = nil;
|
id theCell = nil;
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
|
|
||||||
NSDebugLog (@"trackScrollButtons");
|
NSDebugLog (@"trackScrollButtons");
|
||||||
do {
|
do
|
||||||
location = [self convertPoint:[theEvent locationInWindow]fromView:nil];
|
{
|
||||||
_hitPart = [self testPart:location];
|
location = [self convertPoint: [theEvent locationInWindow]fromView: nil];
|
||||||
rect = [self rectForPart:_hitPart];
|
_hitPart = [self testPart: location];
|
||||||
|
rect = [self rectForPart: _hitPart];
|
||||||
|
|
||||||
switch (_hitPart) // determine which
|
switch (_hitPart)
|
||||||
{ // cell was hit
|
{
|
||||||
case NSScrollerIncrementLine:
|
case NSScrollerIncrementLine:
|
||||||
case NSScrollerIncrementPage:
|
case NSScrollerIncrementPage:
|
||||||
theCell = (_isHorizontal ? rightCell : upCell);
|
theCell = (_isHorizontal ? rightCell : upCell);
|
||||||
|
@ -589,72 +624,57 @@ NSRect rect;
|
||||||
|
|
||||||
if (theCell)
|
if (theCell)
|
||||||
{
|
{
|
||||||
[theCell highlight:YES withFrame:rect inView:self];
|
[self lockFocus];
|
||||||
|
[theCell highlight: YES withFrame: rect inView: self];
|
||||||
|
[self unlockFocus];
|
||||||
[window flushWindow];
|
[window flushWindow];
|
||||||
|
|
||||||
NSLog (@"tracking cell %x", theCell);
|
NSLog (@"tracking cell %x", theCell);
|
||||||
|
|
||||||
shouldReturn = [theCell trackMouse:theEvent // Track the mouse
|
shouldReturn = [theCell trackMouse: theEvent
|
||||||
inRect:rect // until left mouse
|
inRect: rect
|
||||||
ofView:self // goes up
|
ofView: self
|
||||||
untilMouseUp:YES];
|
untilMouseUp: YES];
|
||||||
|
|
||||||
if([_target isKindOf:[NSScrollView class]]) // a hack for XRAW
|
[self lockFocus];
|
||||||
{ // FIX ME
|
[theCell highlight: NO withFrame: rect inView: self];
|
||||||
NSObject *targetCV = (NSObject *)[_target contentView];
|
[self unlockFocus];
|
||||||
|
|
||||||
if([targetCV respondsToSelector:@selector(_freeMatrix)])
|
|
||||||
[targetCV _freeMatrix];
|
|
||||||
}
|
|
||||||
|
|
||||||
[theCell highlight:NO withFrame:rect inView:self];
|
|
||||||
[window flushWindow];
|
[window flushWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldReturn)
|
if (shouldReturn)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
theEvent = [theApp nextEventMatchingMask:eventMask
|
theEvent = [theApp nextEventMatchingMask: eventMask
|
||||||
untilDate:[NSDate distantFuture]
|
untilDate: [NSDate distantFuture]
|
||||||
inMode:NSEventTrackingRunLoopMode
|
inMode: NSEventTrackingRunLoopMode
|
||||||
dequeue:YES];
|
dequeue: YES];
|
||||||
}
|
}
|
||||||
while ([theEvent type] != NSLeftMouseUp);
|
while ([theEvent type] != NSLeftMouseUp);
|
||||||
|
|
||||||
NSDebugLog (@"return from trackScrollButtons");
|
NSDebugLog (@"return from trackScrollButtons");
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)sendActionO:(SEL)theAction to:(id)theTarget
|
|
||||||
{ // send action to
|
|
||||||
BOOL ret = [super sendAction:theAction to:theTarget]; // the target on
|
|
||||||
// behalf of cell
|
|
||||||
[self drawKnobSlot]; // lockFocus set in mouseDown method is
|
|
||||||
[self drawKnob]; // active so we simply redraw the knob and
|
|
||||||
[window flushWindow]; // slot to reflect the hit scroll button
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// draw the scroller
|
// draw the scroller
|
||||||
//
|
//
|
||||||
- (void)drawRect:(NSRect)rect
|
- (void) drawRect: (NSRect)rect
|
||||||
{
|
{
|
||||||
NSDebugLog (@"NSScroller drawRect: ((%f, %f), (%f, %f))",
|
NSDebugLog (@"NSScroller drawRect: ((%f, %f), (%f, %f))",
|
||||||
rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
|
rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
|
||||||
|
|
||||||
[self drawArrow:NSScrollerDecrementArrow highlight:NO];
|
[self drawArrow: NSScrollerDecrementArrow highlight: NO];
|
||||||
[self drawArrow:NSScrollerIncrementArrow highlight:NO];
|
[self drawArrow: NSScrollerIncrementArrow highlight: NO];
|
||||||
|
|
||||||
[self drawKnobSlot];
|
[self drawKnobSlot];
|
||||||
[self drawKnob];
|
[self drawKnob];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawArrow:(NSScrollerArrow)whichButton highlight:(BOOL)flag
|
- (void) drawArrow: (NSScrollerArrow)whichButton highlight: (BOOL)flag
|
||||||
{
|
{
|
||||||
NSRect rect = [self rectForPart:(whichButton == NSScrollerIncrementArrow
|
NSRect rect = [self rectForPart: (whichButton == NSScrollerIncrementArrow
|
||||||
? NSScrollerIncrementLine : NSScrollerDecrementLine)];
|
? NSScrollerIncrementLine : NSScrollerDecrementLine)];
|
||||||
id theCell = nil;
|
id theCell = nil;
|
||||||
|
|
||||||
NSDebugLog (@"position of %s cell is (%f, %f)",
|
NSDebugLog (@"position of %s cell is (%f, %f)",
|
||||||
(whichButton == NSScrollerIncrementArrow ? "increment" : "decrement"),
|
(whichButton == NSScrollerIncrementArrow ? "increment" : "decrement"),
|
||||||
|
@ -670,42 +690,46 @@ id theCell = nil;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
[theCell drawWithFrame:rect inView:self];
|
[theCell drawWithFrame: rect inView: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawKnob
|
- (void) drawKnob
|
||||||
{
|
{
|
||||||
[knobCell drawWithFrame:[self rectForPart:NSScrollerKnob] inView:self];
|
[knobCell drawWithFrame: [self rectForPart: NSScrollerKnob] inView: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawKnobSlot
|
- (void) drawKnobSlot
|
||||||
{
|
{
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
|
|
||||||
if(preCalcValues) // in a modal loop we
|
// in a modal loop we have already pre calc'd our parts
|
||||||
rect = slotRect; // have already pre
|
if (preCalcValues)
|
||||||
else // calc'd our parts
|
rect = slotRect;
|
||||||
rect = [self rectForPart:NSScrollerKnobSlot];
|
else
|
||||||
|
rect = [self rectForPart: NSScrollerKnobSlot];
|
||||||
|
|
||||||
[[NSColor darkGrayColor] set];
|
[[NSColor darkGrayColor] set];
|
||||||
NSRectFill(rect); // draw the bar slot
|
NSRectFill(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRect)rectForPart:(NSScrollerPart)partCode
|
- (NSRect)rectForPart: (NSScrollerPart)partCode
|
||||||
{
|
{
|
||||||
NSRect scrollerFrame = frame;
|
NSRect scrollerFrame = frame;
|
||||||
float x = 1, y = 1, width = 0, height = 0, floatValue;
|
float x = 1, y = 1, width = 0, height = 0, floatValue;
|
||||||
NSScrollArrowPosition arrowsPosition;
|
NSScrollArrowPosition arrowsPosition;
|
||||||
NSUsableScrollerParts usableParts;
|
NSUsableScrollerParts usableParts;
|
||||||
// If the scroller is disabled then
|
// If the scroller is disabled then the scroller buttons and the
|
||||||
if (!_isEnabled) // the scroller buttons and the
|
// knob are not displayed at all.
|
||||||
usableParts = NSNoScrollerParts; // knob are not displayed at all.
|
if (!_isEnabled)
|
||||||
|
usableParts = NSNoScrollerParts;
|
||||||
else
|
else
|
||||||
usableParts = _usableParts;
|
usableParts = _usableParts;
|
||||||
|
|
||||||
// Since we haven't yet flipped views we have
|
// Since we haven't yet flipped views we have
|
||||||
if (!_isHorizontal) // to swap the meaning of the arrows position
|
// to swap the meaning of the arrows position
|
||||||
{ // if the scroller's orientation is vertical.
|
// if the scroller's orientation is vertical.
|
||||||
|
if (!_isHorizontal)
|
||||||
|
{
|
||||||
if (_arrowsPosition == NSScrollerArrowsMaxEnd)
|
if (_arrowsPosition == NSScrollerArrowsMaxEnd)
|
||||||
arrowsPosition = NSScrollerArrowsMinEnd;
|
arrowsPosition = NSScrollerArrowsMinEnd;
|
||||||
else
|
else
|
||||||
|
@ -722,8 +746,10 @@ NSUsableScrollerParts usableParts;
|
||||||
// Assign to `width' and `height' values describing
|
// Assign to `width' and `height' values describing
|
||||||
// the width and height of the scroller regardless
|
// the width and height of the scroller regardless
|
||||||
// of its orientation. Also compute the `floatValue'
|
// of its orientation. Also compute the `floatValue'
|
||||||
if (_isHorizontal) // which is essentially the same width as _floatValue
|
// which is essentially the same width as _floatValue
|
||||||
{ // but keeps track of the scroller's orientation.
|
// but keeps track of the scroller's orientation.
|
||||||
|
if (_isHorizontal)
|
||||||
|
{
|
||||||
width = scrollerFrame.size.height;
|
width = scrollerFrame.size.height;
|
||||||
height = scrollerFrame.size.width;
|
height = scrollerFrame.size.width;
|
||||||
floatValue = _floatValue;
|
floatValue = _floatValue;
|
||||||
|
@ -733,15 +759,16 @@ NSUsableScrollerParts usableParts;
|
||||||
width = scrollerFrame.size.width;
|
width = scrollerFrame.size.width;
|
||||||
height = scrollerFrame.size.height;
|
height = scrollerFrame.size.height;
|
||||||
floatValue = 1 - _floatValue;
|
floatValue = 1 - _floatValue;
|
||||||
} // The x, y, width and height values
|
}
|
||||||
// are computed below for the vertical
|
// The x, y, width and height values are computed below for the vertical
|
||||||
switch (partCode) // scroller. The height of the scroll
|
// scroller. The height of the scroll buttons is assumed to be equal to
|
||||||
{ // buttons is assumed to be equal to
|
// the width.
|
||||||
case NSScrollerKnob: // the width.
|
switch (partCode)
|
||||||
|
{
|
||||||
|
case NSScrollerKnob:
|
||||||
{
|
{
|
||||||
float knobHeight, knobPosition, slotHeight;
|
float knobHeight, knobPosition, slotHeight;
|
||||||
// If the scroller does not have parts
|
// If the scroller does not have parts or a knob return a zero rect.
|
||||||
// or a knob return a zero rect.
|
|
||||||
if (usableParts == NSNoScrollerParts ||
|
if (usableParts == NSNoScrollerParts ||
|
||||||
usableParts == NSOnlyScrollerArrows)
|
usableParts == NSOnlyScrollerArrows)
|
||||||
return NSZeroRect;
|
return NSZeroRect;
|
||||||
|
@ -762,16 +789,17 @@ NSUsableScrollerParts usableParts;
|
||||||
0 : 2 * (buttonsWidth + buttonsDistance));
|
0 : 2 * (buttonsWidth + buttonsDistance));
|
||||||
height = knobHeight;
|
height = knobHeight;
|
||||||
width = buttonsWidth;
|
width = buttonsWidth;
|
||||||
if (_isHorizontal) // keeps horiz knob off
|
if (_isHorizontal) // keeps horiz knob off of the buttons
|
||||||
y++; // of the buttons
|
y++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case NSScrollerKnobSlot:
|
case NSScrollerKnobSlot:
|
||||||
x = 0; // if the scroller does
|
// if the scroller does not have buttons the slot completely
|
||||||
width = scrollerWidth; // not have buttons the
|
// fills the scroller.
|
||||||
// slot completely
|
x = 0;
|
||||||
if (usableParts == NSNoScrollerParts) // fills the scroller.
|
width = scrollerWidth;
|
||||||
|
if (usableParts == NSNoScrollerParts)
|
||||||
{
|
{
|
||||||
y = 0; // `height' unchanged
|
y = 0; // `height' unchanged
|
||||||
break;
|
break;
|
||||||
|
@ -795,9 +823,9 @@ NSUsableScrollerParts usableParts;
|
||||||
|
|
||||||
case NSScrollerDecrementLine:
|
case NSScrollerDecrementLine:
|
||||||
case NSScrollerDecrementPage:
|
case NSScrollerDecrementPage:
|
||||||
if (usableParts == NSNoScrollerParts) // if scroller has no
|
// if scroller has no parts or knob then return a zero rect
|
||||||
return NSZeroRect; // parts or knob then
|
if (usableParts == NSNoScrollerParts)
|
||||||
// return a zero rect
|
return NSZeroRect;
|
||||||
width = buttonsWidth;
|
width = buttonsWidth;
|
||||||
if (arrowsPosition == NSScrollerArrowsMaxEnd)
|
if (arrowsPosition == NSScrollerArrowsMaxEnd)
|
||||||
y = height - 2 * (buttonsWidth + buttonsDistance);
|
y = height - 2 * (buttonsWidth + buttonsDistance);
|
||||||
|
@ -813,9 +841,8 @@ NSUsableScrollerParts usableParts;
|
||||||
|
|
||||||
case NSScrollerIncrementLine:
|
case NSScrollerIncrementLine:
|
||||||
case NSScrollerIncrementPage:
|
case NSScrollerIncrementPage:
|
||||||
if (usableParts == NSNoScrollerParts) // if scroller has no
|
if (usableParts == NSNoScrollerParts)
|
||||||
return NSZeroRect; // parts or knob then
|
return NSZeroRect;
|
||||||
// return a zero rect
|
|
||||||
width = buttonsWidth;
|
width = buttonsWidth;
|
||||||
if (arrowsPosition == NSScrollerArrowsMaxEnd)
|
if (arrowsPosition == NSScrollerArrowsMaxEnd)
|
||||||
y = height - (buttonsWidth + buttonsDistance);
|
y = height - (buttonsWidth + buttonsDistance);
|
||||||
|
|
|
@ -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; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue