General tidyup - make updates work properly etc.

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

View file

@ -1225,6 +1225,8 @@ BOOL done = NO;
int i, count;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSArray *window_list = [self windows];
windows_need_update = NO;
// notify that an update is
// imminent
[nc postNotificationName:NSApplicationWillUpdateNotification object: self];

View file

@ -97,6 +97,9 @@
- (void) scrollToPoint: (NSPoint)point
{
NSRect originalBounds = [self bounds];
NSRect newBounds = originalBounds;
NSRect intersection;
#ifdef DEBUGLOG
NSPoint currentPoint = [self bounds].origin;
@ -105,17 +108,92 @@
point.x, point.y);
#endif
point = [self constrainScrollPoint: point];
[self setBoundsOrigin: NSMakePoint(point.x, point.y)];
newBounds.origin = [self constrainScrollPoint: point];
if (NSEqualPoints(originalBounds.origin, newBounds.origin))
return;
// [self setBoundsOrigin: newBounds.origin];
[self setNeedsDisplay: YES];
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
[_documentView setNeedsDisplayInRect: bounds];
// [_documentView setNeedsDisplay: YES];
[self display];
{
NSPoint destPoint = intersection.origin;
float dx = newBounds.origin.x - originalBounds.origin.x;
float dy = newBounds.origin.y - originalBounds.origin.y;
destPoint.x -= dx;
destPoint.y -= dy;
[self lockFocus];
NSCopyBits(0, intersection, destPoint);
[self unlockFocus];
[self setBoundsOrigin: newBounds.origin];
if (dx != 0)
{
// moved in x -- redraw a full-height rectangle at
// side of intersection
NSRect redrawRect;
redrawRect.origin.y = newBounds.origin.y;
redrawRect.size.height = newBounds.size.height;
redrawRect.size.width = newBounds.size.width
- intersection.size.width;
if (dx < 0)
{
// moved to the left -- redraw at left of intersection
redrawRect.origin.x = newBounds.origin.x;
}
else
{
// moved to the right -- redraw at right of intersection
redrawRect.origin.x = newBounds.origin.x
+ intersection.size.width;
}
[_documentView setNeedsDisplayInRect: redrawRect];
}
if (dy != 0)
{
// moved in y
// -- redraw rectangle with intersection's width over or under it
NSRect redrawRect;
redrawRect.origin.x = intersection.origin.x;
redrawRect.size.width = intersection.size.width;
redrawRect.size.height = newBounds.size.height
- intersection.size.height;
if (dy < 0)
{
// moved down -- redraw under intersection
redrawRect.origin.y = newBounds.origin.y;
}
else
{
// moved up -- redraw over intersection
redrawRect.origin.y = newBounds.origin.y
+ intersection.size.height;
}
[_documentView setNeedsDisplayInRect: redrawRect];
}
}
}
else
{
// dont copy anything -- docview draws it all
[self setBoundsOrigin: newBounds.origin];
[_documentView setNeedsDisplayInRect: newBounds];
}
}
- (NSPoint) constrainScrollPoint: (NSPoint)proposedNewOrigin
@ -124,7 +202,7 @@
NSPoint new = proposedNewOrigin;
if (documentFrame.size.width <= bounds.size.width)
new.x = 0.0;
new.x = documentFrame.origin.x;
else if (proposedNewOrigin.x <= documentFrame.origin.x)
new.x = documentFrame.origin.x;
else if (proposedNewOrigin.x
@ -145,7 +223,7 @@
else
{
if (documentFrame.size.height <= bounds.size.height)
new.y = 0.0;
new.y = documentFrame.origin.y;
else if (proposedNewOrigin.y <= documentFrame.origin.y)
new.y = documentFrame.origin.y;
else if (proposedNewOrigin.y
@ -247,15 +325,50 @@
[super_view reflectScrolledClipView:self];
}
- (BOOL)isOpaque { return YES; }
- (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; }
- (BOOL) isOpaque
{
return YES;
}
- (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
{

View file

@ -66,18 +66,28 @@ static Class rulerViewClass = nil;
}
}
+ (void)setRulerViewClass:(Class)aClass { rulerViewClass = aClass; }
+ (Class)rulerViewClass { return rulerViewClass; }
+ (void) setRulerViewClass: (Class)aClass
{
rulerViewClass = aClass;
}
+ (NSSize)contentSizeForFrameSize:(NSSize)frameSize // calc content size by
hasHorizontalScroller:(BOOL)hFlag // taking into account
hasVerticalScroller:(BOOL)vFlag // the border type
+ (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
if (hFlag) // the line that separates the horizontal
{ // and vertical scroller from the clip view
// the line that separates the horizontal
// and vertical scroller from the clip view
if (hFlag)
{
size.height -= [NSScroller scrollerWidth];
size.height -= 1;
}
@ -113,9 +123,12 @@ NSSize size = frameSize;
borderType: (NSBorderType)borderType
{
NSSize size = contentSize;
// Add 1 to the width and height for the
if (hFlag) // line that separates the horizontal and
{ // vertical scroller from the clip view.
// line that separates the horizontal and
// vertical scroller from the clip view.
if (hFlag)
{
size.height += [NSScroller scrollerWidth];
size.height += 1;
}
@ -265,16 +278,22 @@ NSRect clipViewBounds = [_contentView bounds];
NSScrollerPart hitPart = [scroller hitPart];
NSRect documentRect = [_contentView documentRect];
float amount = 0;
NSPoint point;
NSPoint point = clipViewBounds.origin;
NSDebugLog (@"_doScroll: float value = %f", floatValue);
// do nothing if scroller is unknown
if (scroller != _horizScroller && scroller != _vertScroller)
return;
_knobMoved = NO;
if(hitPart == NSScrollerKnob)
if (hitPart == NSScrollerKnob || hitPart == NSScrollerKnobSlot)
_knobMoved = YES;
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)
amount = _lineScroll;
else if (hitPart == NSScrollerIncrementPage)
@ -284,7 +303,7 @@ NSPoint point;
else if (hitPart == NSScrollerDecrementPage)
amount = -_pageScroll;
else
_knobMoved = YES;
return;
}
if (!_knobMoved) // button scrolling
@ -292,23 +311,18 @@ NSPoint point;
if (scroller == _horizScroller)
{
point.x = clipViewBounds.origin.x + amount;
point.y = clipViewBounds.origin.y;
}
else
{
if (scroller == _vertScroller)
if ([_contentView isFlipped])
{
point.x = clipViewBounds.origin.x;
// If view is flipped
if ([_contentView isFlipped]) // reverse the scroll
amount = -amount; // direction
// reverse the scroll direction
amount = -amount;
}
NSDebugLog (@"increment/decrement: amount = %f, flipped = %d",
amount, [_contentView isFlipped]);
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
@ -317,33 +331,23 @@ NSPoint point;
{
point.x = floatValue * (documentRect.size.width
- clipViewBounds.size.width);
point.y = clipViewBounds.origin.y;
}
else
{
if (scroller == _vertScroller)
{
point.x = clipViewBounds.origin.x;
if (![_contentView isFlipped])
floatValue = 1 - floatValue;
point.y = floatValue * (documentRect.size.height
- clipViewBounds.size.height);
}
else
return; // do nothing
}
}
[_contentView scrollToPoint:point]; // scroll clipview
if (!_knobMoved)
{ // if scrolling via
[self reflectScrolledClipView:_contentView]; // buttons update
// if (scroller == _vertScroller) // scroller pos to
// [_vertScroller displayIfNeeded]; // reflect clipview
// else
// [_horizScroller displayIfNeeded];
// [window flushWindow];
}
[_contentView scrollToPoint: point];
// scroll clipview
// reflectScrolledClipView has been called by the clipView.
//FIXME: should this be here?
// NSWindow's doc says update is called for each event
[window update];
}
- (void) reflectScrolledClipView: (NSClipView*)aClipView
@ -353,12 +357,9 @@ NSRect clipViewBounds = NSZeroRect;
float floatValue;
float knobProportion;
id documentView;
// do nothing if
if(aClipView != _contentView) // aClipView is not
return; // our content view
// if (_knobMoved) // is this really needed?
// return; // FAR FIX ME ?
if (aClipView != _contentView)
return;
NSDebugLog (@"reflectScrolledClipView:");
@ -381,7 +382,6 @@ id documentView;
floatValue = 1 - floatValue;
[_vertScroller setFloatValue: floatValue
knobProportion: knobProportion];
[_vertScroller displayIfNeededIgnoringOpacity];
}
}
@ -398,11 +398,8 @@ id documentView;
clipViewBounds.size.width);
[_horizScroller setFloatValue: floatValue
knobProportion: knobProportion];
[_horizScroller displayIfNeededIgnoringOpacity];
}
}
[window flushWindow];
}
- (void) setHorizontalRulerView: (NSRulerView*)aRulerView // FIX ME
@ -498,9 +495,10 @@ float borderThickness = 0;
contentRect.origin.y += scrollerWidth + 1;
}
// If the document view is not
if (![_contentView isFlipped]) // flipped reverse the meaning
[_vertScroller setFloatValue:1]; // of the vertical scroller's
// If the document view is not flipped reverse the meaning
// of the vertical scroller's
if (![_contentView isFlipped])
[_vertScroller setFloatValue: 1];
[_horizScroller setFrame: horizScrollerRect];
[_vertScroller setFrame: vertScrollerRect];
[_contentView setFrame: contentRect];
@ -606,32 +604,109 @@ float borderThickness = 0;
}
#endif
- (id)documentView { return [_contentView documentView]; }
- (NSCursor*)documentCursor { return [_contentView documentCursor]; }
- (id) documentView
{
return [_contentView documentView];
}
- (NSCursor*) documentCursor
{
return [_contentView documentCursor];
}
- (void) setDocumentCursor: (NSCursor*)aCursor
{
[_contentView setDocumentCursor: aCursor];
}
- (BOOL)isOpaque { return YES; }
- (NSBorderType)borderType { return _borderType; }
- (NSScroller*)verticalScroller { return _vertScroller; }
- (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; }
- (BOOL) isOpaque
{
return YES;
}
- (NSBorderType) borderType
{
return _borderType;
}
- (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

View file

@ -77,27 +77,78 @@ static BOOL preCalcValues = NO;
[self setVersion: 1];
}
+ (float)scrollerWidth { return 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
+ (float) scrollerWidth
{
if (frameRect.size.width > frameRect.size.height) // determine the
{ // orientation of
_isHorizontal = YES; // the scroller and
frameRect.size.height = [isa scrollerWidth]; // adjust it's size
} // accordingly
return 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: (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
{
_isHorizontal = NO;
@ -119,15 +170,16 @@ static BOOL preCalcValues = NO;
return self;
}
- init
- (id) init
{
return [self initWithFrame: NSZeroRect];
}
- (void) drawParts
{ // Create the class variable
if (knobCell) // button cells if they do not
return; // yet exist.
{
// Create the class variable button cells if they do not yet exist.
if (knobCell)
return;
upCell = [NSButtonCell new];
[upCell setHighlightsBy: NSChangeBackgroundCellMask|NSContentsCellMask];
@ -193,11 +245,9 @@ float scrollerWidth = [isa scrollerWidth];
if (size > 3 * scrollerWidth + 2)
_usableParts = NSAllScrollerParts;
else
if (size > 2 * scrollerWidth + 1)
else if (size > 2 * scrollerWidth + 1)
_usableParts = NSOnlyScrollerArrows;
else
if (size > scrollerWidth)
_usableParts = NSNoScrollerParts;
}
@ -221,10 +271,12 @@ float scrollerWidth = [isa scrollerWidth];
- (void) setFloatValue: (float)aFloat
{
if (aFloat == _floatValue)
return;
if (aFloat < 0)
_floatValue = 0;
else
if (aFloat > 1)
else if (aFloat > 1)
_floatValue = 1;
else
_floatValue = aFloat;
@ -236,8 +288,7 @@ float scrollerWidth = [isa scrollerWidth];
{
if (ratio < 0)
_knobProportion = 0;
else
if (ratio > 1)
else if (ratio > 1)
_knobProportion = 1;
else
_knobProportion = ratio;
@ -247,11 +298,12 @@ float scrollerWidth = [isa scrollerWidth];
- (void) setFrame: (NSRect)frameRect
{
if (frameRect.size.width > frameRect.size.height) // determine the
{ // orientation of
_isHorizontal = YES; // the scroller and
frameRect.size.height = [isa scrollerWidth]; // adjust it's size
} // accordingly
// 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
{
_isHorizontal = NO;
@ -276,9 +328,10 @@ float scrollerWidth = [isa scrollerWidth];
[self setNeedsDisplay: YES];
}
- (NSScrollerPart)testPart:(NSPoint)thePoint // return what part
{ // of the scroller
NSRect rect; // the mouse hit
- (NSScrollerPart)testPart: (NSPoint)thePoint
{
// return what part of the scroller the mouse hit
NSRect rect;
if (thePoint.x < 0 || thePoint.x > frame.size.width
|| thePoint.y < 0 || thePoint.y > frame.size.height)
@ -318,8 +371,9 @@ NSRect slotRect = [self rectForPart:NSScrollerKnobSlot];
float floatValue = 0;
float position;
if (_isHorizontal) // Adjust point to lie
{ // within the knob slot
// Adjust point to lie within the knob slot
if (_isHorizontal)
{
float halfKnobRectWidth = knobRect.size.width / 2;
if (point.x < slotRect.origin.x + halfKnobRectWidth)
@ -332,13 +386,13 @@ float position;
halfKnobRectWidth;
else
position = point.x;
} // Compute float value
// given the knob size
}
// Compute float value given the knob size
floatValue = (position - (slotRect.origin.x + halfKnobRectWidth))
/ (slotRect.size.width - knobRect.size.width);
}
else // Adjust point to lie
{ // within the knob slot
else
{
float halfKnobRectHeight = knobRect.size.height / 2;
if (point.y < slotRect.origin.y + halfKnobRectHeight)
@ -352,7 +406,7 @@ float position;
else
position = point.y;
}
// Compute float value
// Compute float value given the knob size
floatValue = (position - (slotRect.origin.y + halfKnobRectHeight)) /
(slotRect.size.height - knobRect.size.height);
floatValue = 1 - floatValue;
@ -361,12 +415,11 @@ float position;
return floatValue;
}
- (void)_preCalcParts // pre calculate
{ // values to lessen
NSRect knobRect = [self rectForPart:NSScrollerKnob]; // the burden while
// scrolling
slotRect = [self rectForPart:NSScrollerKnobSlot];
- (void) _preCalcParts
{
NSRect knobRect = [self rectForPart: NSScrollerKnob];
slotRect = [self rectForPart: NSScrollerKnobSlot];
halfKnobRectWidth = knobRect.size.width / 2;
slotOriginPlusKnobWidth = slotRect.origin.x + halfKnobRectWidth;
slotOriginPlusSlotWidthMinusHalfKnobWidth = slotRect.origin.x +
@ -385,8 +438,8 @@ NSRect knobRect = [self rectForPart:NSScrollerKnob]; // the burden while
float floatValue = 0;
float position;
if (_isHorizontal) // Adjust point to lie
{ // within the knob slot
if (_isHorizontal)
{
if (point.x < slotOriginPlusKnobWidth)
position = slotOriginPlusKnobWidth;
else
@ -395,13 +448,12 @@ float position;
position = slotOriginPlusSlotWidthMinusHalfKnobWidth;
else
position = point.x;
} // Compute float value
// given the knob size
}
floatValue = (position - slotOriginPlusKnobWidth) /
slotWidthMinusKnobWidth;
}
else // Adjust point to lie
{ // within the knob slot
else
{
if (point.y < slotOriginPlusKnobHeight)
position = slotOriginPlusKnobHeight;
else
@ -411,7 +463,7 @@ float position;
else
position = point.y;
}
// Compute float value
floatValue = (position - slotOriginPlusKnobHeight) /
slotHeightMinusKnobHeight;
floatValue = 1 - floatValue;
@ -425,7 +477,6 @@ float position;
NSPoint location = [self convertPoint: [theEvent locationInWindow]
fromView: nil];
[self lockFocus];
_hitPart = [self testPart: location];
[self _setTargetAndActionToCells];
@ -448,9 +499,6 @@ NSPoint location = [self convertPoint:[theEvent locationInWindow]
[self setFloatValue: floatValue];
[self sendAction: _action to: _target];
[self drawKnobSlot];
[self drawKnob];
[window flushWindow];
[self trackKnob: theEvent];
break;
}
@ -460,7 +508,6 @@ NSPoint location = [self convertPoint:[theEvent locationInWindow]
}
_hitPart = NSScrollerNoPart;
[self unlockFocus];
}
- (void)trackKnob: (NSEvent*)theEvent
@ -489,21 +536,24 @@ NSMutableArray* path = [self _pathBetweenSubview:self
[self _preCalcParts]; // pre calc scroller parts
preCalcValues = YES;
_hitPart = NSScrollerKnob; // set periodic events rate
// to achieve max of ~30fps
_hitPart = NSScrollerKnob;
// set periodic events rate to achieve max of ~30fps
[NSEvent startPeriodicEventsAfterDelay: 0.02 withPeriod: 0.03];
[[NSRunLoop currentRunLoop] limitDateForMode: NSEventTrackingRunLoopMode];
while ((eventType = [theEvent type]) != NSLeftMouseUp)
{ // user is moving scroller
if (eventType != NSPeriodic) // loop until left mouse up
{
apoint = [theEvent locationInWindow]; // zero the periodic count
periodCount = 0; // whenever a real position
} // event is recieved
if (eventType != NSPeriodic)
{
apoint = [theEvent locationInWindow];
// zero the periodic count whenever a real position event is recieved
periodCount = 0;
}
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];
point = [matrix pointInMatrixSpace: apoint];
@ -514,28 +564,20 @@ NSMutableArray* path = [self _pathBetweenSubview:self
if (floatValue != oldFloatValue)
{
if (floatValue < 0)
_floatValue = 0;
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];
[self setFloatValue: floatValue];
[self sendAction: _action to: _target];
oldFloatValue = floatValue;
} // avoid timing related scrolling
// hesitation by counting number of
knobRect.origin = point; // periodic events since scroll pos
} // was updated, when this reaches
periodCount++; // 6x periodic rate an update is
} // forced on next periodic event
[window update];
}
knobRect.origin = point;
}
// avoid timing related scrolling hesitation by counting number of
// periodic events since scroll pos was updated, when this reaches
// 6x periodic rate an update is forced on next periodic event
periodCount++;
}
theEvent = [app nextEventMatchingMask: eventMask
untilDate: theDistantFuture
inMode: NSEventTrackingRunLoopMode
@ -543,14 +585,6 @@ NSMutableArray* path = [self _pathBetweenSubview:self
}
[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;
}
@ -565,13 +599,14 @@ id theCell = nil;
NSRect rect;
NSDebugLog (@"trackScrollButtons");
do {
do
{
location = [self convertPoint: [theEvent locationInWindow]fromView: nil];
_hitPart = [self testPart: location];
rect = [self rectForPart: _hitPart];
switch (_hitPart) // determine which
{ // cell was hit
switch (_hitPart)
{
case NSScrollerIncrementLine:
case NSScrollerIncrementPage:
theCell = (_isHorizontal ? rightCell : upCell);
@ -589,25 +624,21 @@ NSRect rect;
if (theCell)
{
[self lockFocus];
[theCell highlight: YES withFrame: rect inView: self];
[self unlockFocus];
[window flushWindow];
NSLog (@"tracking cell %x", theCell);
shouldReturn = [theCell trackMouse:theEvent // Track the mouse
inRect:rect // until left mouse
ofView:self // goes up
shouldReturn = [theCell trackMouse: theEvent
inRect: rect
ofView: self
untilMouseUp: YES];
if([_target isKindOf:[NSScrollView class]]) // a hack for XRAW
{ // FIX ME
NSObject *targetCV = (NSObject *)[_target contentView];
if([targetCV respondsToSelector:@selector(_freeMatrix)])
[targetCV _freeMatrix];
}
[self lockFocus];
[theCell highlight: NO withFrame: rect inView: self];
[self unlockFocus];
[window flushWindow];
}
@ -624,17 +655,6 @@ NSRect rect;
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
//
@ -682,13 +702,14 @@ id theCell = nil;
{
NSRect rect;
if(preCalcValues) // in a modal loop we
rect = slotRect; // have already pre
else // calc'd our parts
// in a modal loop we have already pre calc'd our parts
if (preCalcValues)
rect = slotRect;
else
rect = [self rectForPart: NSScrollerKnobSlot];
[[NSColor darkGrayColor] set];
NSRectFill(rect); // draw the bar slot
NSRectFill(rect);
}
- (NSRect)rectForPart: (NSScrollerPart)partCode
@ -697,15 +718,18 @@ NSRect scrollerFrame = frame;
float x = 1, y = 1, width = 0, height = 0, floatValue;
NSScrollArrowPosition arrowsPosition;
NSUsableScrollerParts usableParts;
// If the scroller is disabled then
if (!_isEnabled) // the scroller buttons and the
usableParts = NSNoScrollerParts; // knob are not displayed at all.
// If the scroller is disabled then the scroller buttons and the
// knob are not displayed at all.
if (!_isEnabled)
usableParts = NSNoScrollerParts;
else
usableParts = _usableParts;
// Since we haven't yet flipped views we have
if (!_isHorizontal) // to swap the meaning of the arrows position
{ // if the scroller's orientation is vertical.
// to swap the meaning of the arrows position
// if the scroller's orientation is vertical.
if (!_isHorizontal)
{
if (_arrowsPosition == NSScrollerArrowsMaxEnd)
arrowsPosition = NSScrollerArrowsMinEnd;
else
@ -722,8 +746,10 @@ NSUsableScrollerParts usableParts;
// Assign to `width' and `height' values describing
// the width and height of the scroller regardless
// of its orientation. Also compute the `floatValue'
if (_isHorizontal) // which is essentially the same width as _floatValue
{ // but keeps track of the scroller's orientation.
// which is essentially the same width as _floatValue
// but keeps track of the scroller's orientation.
if (_isHorizontal)
{
width = scrollerFrame.size.height;
height = scrollerFrame.size.width;
floatValue = _floatValue;
@ -733,15 +759,16 @@ NSUsableScrollerParts usableParts;
width = scrollerFrame.size.width;
height = scrollerFrame.size.height;
floatValue = 1 - _floatValue;
} // The x, y, width and height values
// are computed below for the vertical
switch (partCode) // scroller. The height of the scroll
{ // buttons is assumed to be equal to
case NSScrollerKnob: // the width.
}
// The x, y, width and height values are computed below for the vertical
// scroller. The height of the scroll buttons is assumed to be equal to
// the width.
switch (partCode)
{
case NSScrollerKnob:
{
float knobHeight, knobPosition, slotHeight;
// If the scroller does not have parts
// or a knob return a zero rect.
// If the scroller does not have parts or a knob return a zero rect.
if (usableParts == NSNoScrollerParts ||
usableParts == NSOnlyScrollerArrows)
return NSZeroRect;
@ -762,16 +789,17 @@ NSUsableScrollerParts usableParts;
0 : 2 * (buttonsWidth + buttonsDistance));
height = knobHeight;
width = buttonsWidth;
if (_isHorizontal) // keeps horiz knob off
y++; // of the buttons
if (_isHorizontal) // keeps horiz knob off of the buttons
y++;
break;
}
case NSScrollerKnobSlot:
x = 0; // if the scroller does
width = scrollerWidth; // not have buttons the
// slot completely
if (usableParts == NSNoScrollerParts) // fills the scroller.
// if the scroller does not have buttons the slot completely
// fills the scroller.
x = 0;
width = scrollerWidth;
if (usableParts == NSNoScrollerParts)
{
y = 0; // `height' unchanged
break;
@ -795,9 +823,9 @@ NSUsableScrollerParts usableParts;
case NSScrollerDecrementLine:
case NSScrollerDecrementPage:
if (usableParts == NSNoScrollerParts) // if scroller has no
return NSZeroRect; // parts or knob then
// return a zero rect
// if scroller has no parts or knob then return a zero rect
if (usableParts == NSNoScrollerParts)
return NSZeroRect;
width = buttonsWidth;
if (arrowsPosition == NSScrollerArrowsMaxEnd)
y = height - 2 * (buttonsWidth + buttonsDistance);
@ -813,9 +841,8 @@ NSUsableScrollerParts usableParts;
case NSScrollerIncrementLine:
case NSScrollerIncrementPage:
if (usableParts == NSNoScrollerParts) // if scroller has no
return NSZeroRect; // parts or knob then
// return a zero rect
if (usableParts == NSNoScrollerParts)
return NSZeroRect;
width = buttonsWidth;
if (arrowsPosition == NSScrollerArrowsMaxEnd)
y = height - (buttonsWidth + buttonsDistance);

View file

@ -561,7 +561,13 @@ NSPoint basePoint;
- (BOOL)isAutodisplay { return is_autodisplay; }
- (BOOL)isFlushWindowDisabled { return disable_flush_window; }
- (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; }
- (void)useOptimizedDrawing:(BOOL)flag { optimize_drawing = flag; }