* NSScroller.m move backend code into frontend, polish code, remove ifdefs.

* TrackingRectangle.m/.h rename class to GS* prefix (GSTrackingRect).
	* NSView.m resizeWithOldSuperviewSize: floor possibly fractional results.
	displayIfNeededIgnoringOpacity: rewrite to fix obscure bugs in auto
	display.  Minor tweaks in other display methods for same reasons.
	* NSView.h rename invalidatedRectangle to invalidRect.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3421 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
far 1998-12-09 01:26:37 +00:00
parent 51cc732212
commit 04cfb58055
11 changed files with 361 additions and 326 deletions

View file

@ -1,3 +1,12 @@
Tue Dec 8 1998 Felipe A. Rodriguez <far@ix.netcom.com>
* NSScroller.m move backend code into frontend, polish code, remove ifdefs.
* TrackingRectangle.m/.h rename class to GS* prefix (GSTrackingRect).
* NSView.m resizeWithOldSuperviewSize: floor possibly fractional results.
displayIfNeededIgnoringOpacity: rewrite to fix obscure bugs in auto
display. Minor tweaks in other display methods for same reasons.
* NSView.h rename invalidatedRectangle to invalidRect.
Tue Dec 8 20:50:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk> Tue Dec 8 20:50:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Headers/gnustep/gui/NSWindow.h: fixed designated initialiser to * Headers/gnustep/gui/NSWindow.h: fixed designated initialiser to

View file

@ -1,5 +1,5 @@
/* /*
TrackingRectangle.h GSTrackingRect.h
Tracking rectangle class Tracking rectangle class
@ -26,12 +26,12 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _GNUstep_H_TrackingRectangle #ifndef _GNUstep_H_GSTrackingRect
#define _GNUstep_H_TrackingRectangle #define _GNUstep_H_GSTrackingRect
#include <AppKit/NSView.h> #include <AppKit/NSView.h>
@interface TrackingRectangle : NSObject <NSCoding> @interface GSTrackingRect : NSObject <NSCoding>
{ {
// Attributes // Attributes
NSRect rectangle; NSRect rectangle;
@ -62,4 +62,4 @@
@end @end
#endif // _GNUstep_H_TrackingRectangle #endif // _GNUstep_H_GSTrackingRect

View file

@ -81,7 +81,7 @@ enum { // resized when the view's superview is resized
id window; id window;
NSMutableArray *tracking_rects; NSMutableArray *tracking_rects;
NSMutableArray *cursor_rects; NSMutableArray *cursor_rects;
NSRect invalidatedRectangle; NSRect invalidRect;
unsigned int autoresizingMask; unsigned int autoresizingMask;
BOOL is_rotated_from_base; BOOL is_rotated_from_base;

View file

@ -1081,7 +1081,7 @@ NSSetShowsServicesMenuItem(NSString *name, BOOL enabled)
} }
BOOL BOOL
NSShowsServicesMenuItem(NSString * itemName) NSShowsServicesMenuItem(NSString * name)
{ {
return [[GNUServicesManager manager] showsServicesMenuItem: itemName]; return [[GNUServicesManager manager] showsServicesMenuItem: itemName];
} }

View file

@ -105,7 +105,7 @@ NSTextView.m \
NSView.m \ NSView.m \
NSWindow.m \ NSWindow.m \
NSWorkspace.m \ NSWorkspace.m \
TrackingRectangle.m \ GSTrackingRect.m \
GNUAlertPanel.m \ GNUAlertPanel.m \
GNUServicesManager.m \ GNUServicesManager.m \
PSMatrix.m \ PSMatrix.m \
@ -199,10 +199,10 @@ AppKit/NSTextView.h \
AppKit/NSView.h \ AppKit/NSView.h \
AppKit/NSWindow.h \ AppKit/NSWindow.h \
AppKit/NSWorkspace.h \ AppKit/NSWorkspace.h \
AppKit/TrackingRectangle.h \ AppKit/GSTrackingRect.h \
AppKit/PSMatrix.h \ AppKit/PSMatrix.h \
AppKit/GNUServicesManager.h \
AppKit/nsimage-tiff.h \ AppKit/nsimage-tiff.h \
AppKit/GNUServicesManager.h \
-include GNUmakefile.preamble -include GNUmakefile.preamble

View file

@ -1,5 +1,5 @@
/* /*
TrackingRectangle.m GSTrackingRect.m
Tracking rectangle class Tracking rectangle class
@ -27,16 +27,16 @@
*/ */
#include <gnustep/gui/config.h> #include <gnustep/gui/config.h>
#include <gnustep/gui/TrackingRectangle.h> #include <gnustep/gui/GSTrackingRect.h>
@implementation TrackingRectangle @implementation GSTrackingRect
// //
// Class methods // Class methods
// //
+ (void)initialize + (void)initialize
{ {
if (self == [TrackingRectangle class]) if (self == [GSTrackingRect class])
{ {
// Initial version // Initial version
[self setVersion:1]; [self setVersion:1];

View file

@ -92,7 +92,7 @@ static Class rulerViewClass = nil;
_pageScroll = 10; _pageScroll = 10;
_borderType = NSBezelBorder; _borderType = NSBezelBorder;
_scrollsDynamically = YES; _scrollsDynamically = YES;
autoresizingMask = NSViewMaxYMargin; // autoresizingMask = NSViewMaxYMargin;
[self tile]; [self tile];
return self; return self;

View file

@ -27,6 +27,8 @@
*/ */
#include <gnustep/gui/config.h> #include <gnustep/gui/config.h>
#include <math.h>
#include <Foundation/NSDate.h> #include <Foundation/NSDate.h>
#include <Foundation/NSRunLoop.h> #include <Foundation/NSRunLoop.h>
@ -85,141 +87,136 @@ static BOOL preCalcValues = NO;
- (SEL)action { return _action; } - (SEL)action { return _action; }
- (void)setTarget:(id)target { ASSIGN(_target, target); } - (void)setTarget:(id)target { ASSIGN(_target, target); }
- (id)target { return _target; } - (id)target { return _target; }
- (void)encodeWithCoder:aCoder { }
- initWithCoder:aDecoder { return self; }
- (BOOL)isOpaque { return YES; } - (BOOL)isOpaque { return YES; }
- initWithFrame:(NSRect)frameRect - initWithFrame:(NSRect)frameRect
{ {
/* Determine if its horizontal or vertical if (frameRect.size.width > frameRect.size.height) // determine the
then adjust the width to the standard */ { // orientation of
if (frameRect.size.width > frameRect.size.height) { _isHorizontal = YES; // the scroller and
_isHorizontal = YES; frameRect.size.height = [isa scrollerWidth]; // adjust it's size
frameRect.size.height = [isa scrollerWidth]; } // accordingly
} 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;
else else
_arrowsPosition = NSScrollerArrowsMaxEnd; _arrowsPosition = NSScrollerArrowsMaxEnd;
_hitPart = NSScrollerNoPart; _hitPart = NSScrollerNoPart;
[self drawParts]; [self drawParts];
[self setEnabled:NO]; [self setEnabled:NO];
[self checkSpaceForParts]; [self checkSpaceForParts];
return self; return self;
} }
- init - init
{ {
return [self initWithFrame:NSZeroRect]; return [self initWithFrame:NSZeroRect];
} }
- (void)drawParts - (void)drawParts
{ { // Create the class variable
/* Create the class variable button cells if they are not already created */ if (knobCell) // button cells if they do not
if (knobCell) return; // yet exist.
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 if (size > 2 * scrollerWidth + 1) else
_usableParts = NSOnlyScrollerArrows; if (size > 2 * scrollerWidth + 1)
else if (size > scrollerWidth) _usableParts = NSOnlyScrollerArrows;
_usableParts = NSNoScrollerParts; else
if (size > scrollerWidth)
_usableParts = NSNoScrollerParts;
} }
- (void)setEnabled:(BOOL)flag - (void)setEnabled:(BOOL)flag
{ {
if (_isEnabled == flag) if (_isEnabled == flag)
return; return;
_isEnabled = flag; _isEnabled = flag;
#if 1 [self setNeedsDisplay:YES];
[self setNeedsDisplay:YES];
#else
[self display];
#endif
} }
- (void)setArrowsPosition:(NSScrollArrowPosition)where - (void)setArrowsPosition:(NSScrollArrowPosition)where
{ {
if (_arrowsPosition == where) if (_arrowsPosition == where)
return; return;
_arrowsPosition = where; _arrowsPosition = where;
#if 1 [self setNeedsDisplay:YES];
[self setNeedsDisplay:YES];
#else
[self display];
#endif
} }
- (void)setFloatValue:(float)aFloat - (void)setFloatValue:(float)aFloat
@ -235,88 +232,83 @@ static BOOL preCalcValues = NO;
[self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]]; [self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]];
} }
- (void)setFloatValue:(float)aFloat - (void)setFloatValue:(float)aFloat knobProportion:(float)ratio
knobProportion:(float)ratio
{ {
if (ratio < 0) if (ratio < 0)
_knobProportion = 0; _knobProportion = 0;
else if (ratio > 1) else
_knobProportion = 1; if (ratio > 1)
else _knobProportion = 1;
_knobProportion = ratio; else
_knobProportion = ratio;
[self setFloatValue:aFloat]; [self setFloatValue:aFloat];
} }
- (void)setFrame:(NSRect)frameRect - (void)setFrame:(NSRect)frameRect
{ {
/* Determine if its horizontal or vertical if (frameRect.size.width > frameRect.size.height) // determine the
then adjust the width to the standard */ { // orientation of
if (frameRect.size.width > frameRect.size.height) { _isHorizontal = YES; // the scroller and
_isHorizontal = YES; frameRect.size.height = [isa scrollerWidth]; // adjust it's size
frameRect.size.height = [isa scrollerWidth]; } // accordingly
} 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;
else else
_arrowsPosition = NSScrollerArrowsMaxEnd; _arrowsPosition = NSScrollerArrowsMaxEnd;
_hitPart = NSScrollerNoPart; _hitPart = NSScrollerNoPart;
[self checkSpaceForParts]; [self checkSpaceForParts];
} }
- (void)setFrameSize:(NSSize)size - (void)setFrameSize:(NSSize)size
{ {
[super setFrameSize:size]; [super setFrameSize:size];
[self checkSpaceForParts]; [self checkSpaceForParts];
#if 1 [self setNeedsDisplay:YES];
[self setNeedsDisplay:YES];
#else
[self display];
[[self window] flushWindow];
#endif
} }
- (NSScrollerPart)testPart:(NSPoint)thePoint - (NSScrollerPart)testPart:(NSPoint)thePoint // return what part
{ { // of the scroller
NSRect rect; NSRect rect; // the mouse hit
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
@ -369,10 +361,10 @@ float position;
return floatValue; return floatValue;
} }
- (void)_preCalcParts - (void)_preCalcParts // pre calculate
{ { // values to lessen
NSRect knobRect = [self rectForPart:NSScrollerKnob]; NSRect knobRect = [self rectForPart:NSScrollerKnob]; // the burden while
// scrolling
slotRect = [self rectForPart:NSScrollerKnobSlot]; slotRect = [self rectForPart:NSScrollerKnobSlot];
halfKnobRectWidth = knobRect.size.width / 2; halfKnobRectWidth = knobRect.size.width / 2;
@ -389,8 +381,8 @@ NSRect knobRect = [self rectForPart:NSScrollerKnob];
} }
- (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) // Adjust point to lie
@ -484,6 +476,7 @@ 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
NSArray* path = [self _pathBetweenSubview:self NSArray* path = [self _pathBetweenSubview:self
toSuperview:[window contentView]]; toSuperview:[window contentView]];
@ -496,19 +489,26 @@ NSArray* path = [self _pathBetweenSubview:self
preCalcValues = YES; preCalcValues = YES;
_hitPart = NSScrollerKnob; // set periodic events rate _hitPart = NSScrollerKnob; // set periodic events rate
// to achieve max of 30fps // 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 { // user is moving scroller
if (eventType != NSPeriodic) // loop until left mouse up if (eventType != NSPeriodic) // loop until left mouse up
apoint = [theEvent locationInWindow]; {
else apoint = [theEvent locationInWindow]; // zero the periodic count
{ periodCount = 0; // whenever a real position
} // event is recieved
else
{ // if 6x periods have gone by w/o movement
if(periodCount == 6) // check mouse and update if necessary
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)
@ -523,28 +523,31 @@ NSArray* path = [self _pathBetweenSubview:self
_floatValue = floatValue; _floatValue = floatValue;
} }
[self drawKnobSlot]; // draw scroller slot [self drawKnobSlot]; // draw the scroller slot
[self drawKnob]; // draw scroller knob [self drawKnob]; // draw the scroller knob
[_target performSelector:_action withObject:self]; [_target performSelector:_action withObject:self];
[window flushWindow]; [window flushWindow];
oldFloatValue = floatValue; oldFloatValue = floatValue;
} } // avoid timing related scrolling
// hesitation by counting number of
knobRect.origin = point; 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
theEvent = [app nextEventMatchingMask:eventMask theEvent = [app nextEventMatchingMask:eventMask
untilDate:theDistantFuture untilDate:theDistantFuture
inMode:NSEventTrackingRunLoopMode inMode:NSEventTrackingRunLoopMode
dequeue:YES]; dequeue:YES];
} }
[NSEvent stopPeriodicEvents]; [NSEvent stopPeriodicEvents];
// scrolling has stopped
if([_target respondsToSelector:@selector(contentView)]) if([_target isKindOf:[NSScrollView class]]) // hack for XRAW FIX ME
{ {
if([_target respondsToSelector:@selector(_freeMatrix)]) NSObject *targetCV = (NSObject *)[_target contentView];
[[_target contentView] _freeMatrix];
if([targetCV respondsToSelector:@selector(_freeMatrix)])
[targetCV _freeMatrix];
} }
preCalcValues = NO; preCalcValues = NO;
@ -633,51 +636,42 @@ BOOL ret = [super sendAction:theAction to:theTarget]; // the target on
return ret; return ret;
} }
- (void)encodeWithCoder:aCoder
{
}
- initWithCoder:aDecoder
{
return self;
}
// //
// 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 ? NSScrollerIncrementLine : NSScrollerDecrementLine)];
: 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"),
rect.origin.x, rect.origin.y); rect.origin.x, rect.origin.y);
switch (whichButton) { switch (whichButton)
case NSScrollerDecrementArrow: {
theCell = (_isHorizontal ? leftCell : downCell); case NSScrollerDecrementArrow:
break; theCell = (_isHorizontal ? leftCell : downCell);
case NSScrollerIncrementArrow: break;
theCell = (_isHorizontal ? rightCell : upCell); case NSScrollerIncrementArrow:
break; theCell = (_isHorizontal ? rightCell : upCell);
} break;
}
[theCell drawWithFrame:rect inView:self];
[theCell drawWithFrame:rect inView:self];
} }
- (void)drawKnob - (void)drawKnob

View file

@ -31,6 +31,7 @@
*/ */
#include <gnustep/gui/config.h> #include <gnustep/gui/config.h>
#include <math.h>
#include <Foundation/NSString.h> #include <Foundation/NSString.h>
#include <Foundation/NSCoder.h> #include <Foundation/NSCoder.h>
@ -43,7 +44,7 @@
#include <AppKit/NSView.h> #include <AppKit/NSView.h>
#include <AppKit/NSWindow.h> #include <AppKit/NSWindow.h>
#include <AppKit/TrackingRectangle.h> #include <AppKit/GSTrackingRect.h>
#include <AppKit/PSMatrix.h> #include <AppKit/PSMatrix.h>
@ -638,20 +639,20 @@ int options = 0;
// do nothing if view // do nothing if view
if(autoresizingMask == NSViewNotSizable) // is not resizable if(autoresizingMask == NSViewNotSizable) // is not resizable
return; return;
// adjust the X axis // determine if X axis
if(autoresizingMask & NSViewWidthSizable) if(autoresizingMask & NSViewWidthSizable) // can be resized
options++; // width resizable? options++;
if(autoresizingMask & NSViewMinXMargin) if(autoresizingMask & NSViewMinXMargin)
options++; options++;
if(autoresizingMask & NSViewMaxXMargin) if(autoresizingMask & NSViewMaxXMargin)
options++; options++;
// adjust the X axis if
if(options >= 1) if(options >= 1) // any X options are
{ { // set in the mask
change = [super_view frame].size.width - oldSize.width; change = [super_view frame].size.width - oldSize.width;
changePerOption = change/options; // need to floor FIX ME changePerOption = floor(change/options);
if(autoresizingMask & NSViewWidthSizable) // width resizable? if(autoresizingMask & NSViewWidthSizable)
frame.size.width += changePerOption; frame.size.width += changePerOption;
if(autoresizingMask & NSViewMinXMargin) if(autoresizingMask & NSViewMinXMargin)
frame.origin.x += changePerOption; frame.origin.x += changePerOption;
@ -659,21 +660,21 @@ int options = 0;
frame.size.width += changePerOption; frame.size.width += changePerOption;
bounds.size.width = frame.size.width; bounds.size.width = frame.size.width;
} }
// adjust the Y axis // determine if Y axis
options = 0; options = 0; // can be resized
if(autoresizingMask & NSViewHeightSizable) if(autoresizingMask & NSViewHeightSizable)
options++; // height resizable? options++;
if(autoresizingMask & NSViewMinYMargin) if(autoresizingMask & NSViewMinYMargin)
options++; options++;
if(autoresizingMask & NSViewMaxYMargin) if(autoresizingMask & NSViewMaxYMargin)
options++; options++;
// adjust the Y axis if
if(options >= 1) if(options >= 1) // any Y options are
{ { // set in the mask
change = [super_view frame].size.height - oldSize.height; change = [super_view frame].size.height - oldSize.height;
changePerOption = change/options; // need to floor FIX ME changePerOption = floor(change/options);
if(autoresizingMask & NSViewHeightSizable) // height resizable? if(autoresizingMask & NSViewHeightSizable)
frame.size.height += changePerOption; frame.size.height += changePerOption;
if(autoresizingMask & NSViewMinYMargin) if(autoresizingMask & NSViewMinYMargin)
frame.origin.y += changePerOption; frame.origin.y += changePerOption;
@ -723,23 +724,22 @@ int options = 0;
{ {
if(needs_display) if(needs_display)
{ {
NSView *firstOpaque = [self opaqueAncestor]; if(invalidRect.size.width > 0 && invalidRect.size.height > 0)
NSRect rect; {
NSView *firstOpaque = [self opaqueAncestor];
if(invalidatedRectangle.size.width > 0 NSRect rect = invalidRect; // convert rect into
&& invalidatedRectangle.size.height > 0) // coordinates of the
rect = invalidatedRectangle;
else // convert rect into
rect = bounds; // coordinates of the
// first opaque view // first opaque view
rect = [firstOpaque convertRect:rect fromView:self]; rect = [firstOpaque convertRect:rect fromView:self];
[firstOpaque displayIfNeededInRectIgnoringOpacity:rect]; [firstOpaque displayIfNeededInRectIgnoringOpacity:rect];
}
needs_display = NO;
} }
} }
} }
- (void)displayIfNeededInRect:(NSRect)aRect - (void)displayIfNeededInRect:(NSRect)aRect
{ // of our sub views if {
} }
- (void)displayIfNeededInRectIgnoringOpacity:(NSRect)aRect - (void)displayIfNeededInRectIgnoringOpacity:(NSRect)aRect
@ -752,9 +752,9 @@ int i = 0, count; // of our sub views if
// stNeedsDisplayInRect // stNeedsDisplayInRect
if(subview->needs_display) if(subview->needs_display)
{ {
NSRect rect = subview->invalidatedRectangle; NSRect rect = subview->invalidRect;
if(rect.size.width > 0 && rect.size.height > 0) if(rect.size.width > 0 && rect.size.height > 0)
[subview displayRect:rect]; // display invalid rect [subview displayRect:rect]; // display invalid rect
else else
[subview displayIfNeededIgnoringOpacity]; [subview displayIfNeededIgnoringOpacity];
} // subview must contain } // subview must contain
@ -770,20 +770,54 @@ int i = 0, count; // display self and all
// need of display with // need of display with
if (needs_display) // setNeedsDisplay or if (needs_display) // setNeedsDisplay or
{ // stNeedsDisplayInRect { // stNeedsDisplayInRect
if(invalidatedRectangle.size.width > 0 if(invalidRect.size.width > 0 && invalidRect.size.height > 0)
&& invalidatedRectangle.size.height > 0) {
[self displayRect:invalidatedRectangle]; // display invalid rect [self lockFocus]; // self has an invalid
else [self drawRect:invalidRect]; // rect that needs to
needs_display = NO; [self unlockFocus]; // be displayed
}
for (count = [sub_views count]; i < count; ++i)
{
NSView* subview = [sub_views objectAtIndex:i];
if(subview->needs_display) for (count = [sub_views count]; i < count; ++i)
[subview displayIfNeededIgnoringOpacity]; // subview contains a { // cycle thru subviews displaying
} // view needing display NSRect intersection; // any that intersect invalidRect
NSView* subview = [sub_views objectAtIndex:i];
NSRect subviewFrame = subview->frame;
// If subview is rotated compute
// it's bounding rect and use this
// instead of the subview's frame.
if ([subview->frameMatrix isRotated])
[subview->frameMatrix boundingRectFor:subviewFrame
result:&subviewFrame];
// Display the subview if
// it intersects "rect".
intersection = NSIntersectionRect (invalidRect, subviewFrame);
if (intersection.origin.x || intersection.origin.y ||
intersection.size.width || intersection.size.height)
{ // Convert the intersection rectangle
// to the subview's coordinates
intersection = [subview convertRect:intersection
fromView:self];
[subview displayRect:intersection];
} // subview does not intersect
else // invalidRect but it may be
if(subview->needs_display) // marked as needing display
[subview displayIfNeededIgnoringOpacity];
}
invalidRect = NSZeroRect;
} // self does not need
else // display but a sub
{ // view might
for (count = [sub_views count]; i < count; ++i)
{
NSView* subview = [sub_views objectAtIndex:i];
// a subview contains a
if(subview->needs_display) // view needing display
[subview displayIfNeededIgnoringOpacity];
}
}
needs_display = NO;
}
} }
- (void)displayRect:(NSRect)rect // not per spec FIX ME - (void)displayRect:(NSRect)rect // not per spec FIX ME
@ -795,27 +829,25 @@ int i, count;
NSStringFromClass(isa), self); NSStringFromClass(isa), self);
needs_display = NO; needs_display = NO;
invalidatedRectangle = NSZeroRect; // Reset invalid rect invalidRect = NSZeroRect; // Reset invalid rect
[self lockFocus]; [self lockFocus];
[self drawRect:rect]; [self drawRect:rect];
[self unlockFocus]; [self unlockFocus]; // display any subviews
// Tell subviews to display // that intersect rect
for (i = 0, count = [sub_views count]; i < count; ++i) for (i = 0, count = [sub_views count]; i < count; ++i)
{ {
NSView* subview = [sub_views objectAtIndex:i]; NSView* subview = [sub_views objectAtIndex:i];
NSRect subviewFrame = subview->frame; NSRect subviewFrame = subview->frame;
NSRect intersection; NSRect intersection; // If the subview is rotated compute
// If the subview is rotated compute
// its bounding rectangle and use this // its bounding rectangle and use this
// one instead of the subview's frame. // one instead of the subview's frame.
if ([subview->frameMatrix isRotated]) if ([subview->frameMatrix isRotated])
[subview->frameMatrix boundingRectFor:subviewFrame [subview->frameMatrix boundingRectFor:subviewFrame
result:&subviewFrame]; result:&subviewFrame];
// Determine if the subview's frame // Display the subview if
// intersects "rect" so that we can // it intersects "rect".
// display the subview.
intersection = NSIntersectionRect (rect, subviewFrame); intersection = NSIntersectionRect (rect, subviewFrame);
if (intersection.origin.x || intersection.origin.y || if (intersection.origin.x || intersection.origin.y ||
intersection.size.width || intersection.size.height) intersection.size.width || intersection.size.height)
@ -863,7 +895,7 @@ int i, count;
rect = [firstOpaque convertRect:bounds fromView:self]; rect = [firstOpaque convertRect:bounds fromView:self];
[firstOpaque setNeedsDisplayInRect:rect]; [firstOpaque setNeedsDisplayInRect:rect];
invalidatedRectangle = bounds; invalidRect = bounds;
[window setViewsNeedDisplay:YES]; [window setViewsNeedDisplay:YES];
while (currentView) // set needs display while (currentView) // set needs display
@ -873,7 +905,7 @@ int i, count;
} }
} }
else else
invalidatedRectangle = NSZeroRect; invalidRect = NSZeroRect;
} }
- (void)setNeedsDisplayInRect:(NSRect)rect // not per spec FIX ME - (void)setNeedsDisplayInRect:(NSRect)rect // not per spec FIX ME
@ -881,7 +913,7 @@ int i, count;
NSView* currentView = super_view; NSView* currentView = super_view;
needs_display = YES; needs_display = YES;
invalidatedRectangle = NSUnionRect (invalidatedRectangle, rect); invalidRect = NSUnionRect (invalidRect, rect);
[window setViewsNeedDisplay:YES]; [window setViewsNeedDisplay:YES];
while (currentView) // set needs display while (currentView) // set needs display
@ -946,13 +978,13 @@ NSRect new;
// //
- (void)addCursorRect:(NSRect)aRect cursor:(NSCursor *)anObject - (void)addCursorRect:(NSRect)aRect cursor:(NSCursor *)anObject
{ {
TrackingRectangle *m; GSTrackingRect *m;
m = [[[TrackingRectangle alloc] initWithRect: aRect m = [[[GSTrackingRect alloc] initWithRect: aRect
tag: 0 tag: 0
owner: anObject owner: anObject
userData: NULL userData: NULL
inside: YES] autorelease]; inside: YES] autorelease];
[cursor_rects addObject:m]; [cursor_rects addObject:m];
} }
@ -964,7 +996,7 @@ TrackingRectangle *m;
- (void)removeCursorRect:(NSRect)aRect cursor:(NSCursor *)anObject - (void)removeCursorRect:(NSRect)aRect cursor:(NSCursor *)anObject
{ {
id e = [cursor_rects objectEnumerator]; id e = [cursor_rects objectEnumerator];
TrackingRectangle *o; GSTrackingRect *o;
NSCursor *c; NSCursor *c;
o = [e nextObject]; // Base remove test o = [e nextObject]; // Base remove test
@ -1056,12 +1088,12 @@ NSView *v = nil, *w;
- (void)removeTrackingRect:(NSTrackingRectTag)tag - (void)removeTrackingRect:(NSTrackingRectTag)tag
{ {
int i, j; int i, j;
TrackingRectangle *m; GSTrackingRect *m;
j = [tracking_rects count]; j = [tracking_rects count];
for (i = 0;i < j; ++i) for (i = 0;i < j; ++i)
{ {
m = (TrackingRectangle *)[tracking_rects objectAtIndex:i]; m = (GSTrackingRect *)[tracking_rects objectAtIndex:i];
if ([m tag] == tag) if ([m tag] == tag)
{ {
[tracking_rects removeObjectAtIndex:i]; [tracking_rects removeObjectAtIndex:i];
@ -1083,22 +1115,22 @@ TrackingRectangle *m;
{ {
NSTrackingRectTag t; NSTrackingRectTag t;
int i, j; int i, j;
TrackingRectangle *m; GSTrackingRect *m;
t = 0; t = 0;
j = [tracking_rects count]; j = [tracking_rects count];
for (i = 0;i < j; ++i) for (i = 0;i < j; ++i)
{ {
m = (TrackingRectangle *)[tracking_rects objectAtIndex:i]; m = (GSTrackingRect *)[tracking_rects objectAtIndex:i];
if ([m tag] > t) if ([m tag] > t)
t = [m tag]; t = [m tag];
} }
++t; ++t;
m = [[[TrackingRectangle alloc] initWithRect:aRect m = [[[GSTrackingRect alloc] initWithRect:aRect
tag:t owner:anObject tag:t owner:anObject
userData:data userData:data
inside:flag] autorelease]; inside:flag] autorelease];
[tracking_rects addObject:m]; [tracking_rects addObject:m];
return t; return t;

View file

@ -44,7 +44,7 @@
#include <AppKit/NSTextFieldCell.h> #include <AppKit/NSTextFieldCell.h>
#include <AppKit/NSTextField.h> #include <AppKit/NSTextField.h>
#include <AppKit/NSColor.h> #include <AppKit/NSColor.h>
#include <AppKit/TrackingRectangle.h> #include <AppKit/GSTrackingRect.h>
#include <AppKit/NSSliderCell.h> #include <AppKit/NSSliderCell.h>
#include <AppKit/NSScreen.h> #include <AppKit/NSScreen.h>
#include <AppKit/NSCursor.h> #include <AppKit/NSCursor.h>
@ -72,10 +72,10 @@
} }
} }
+ (NSView *)_windowViewWithFrame:(NSRect)frameRect // create the top view + (NSView *)_windowViewWithFrame:(NSRect)frameRect // create the view at
{ // view in the view's { // the root of window's
return nil; // heirarchy (backend) return nil; // view heirarchy.
} } // (backend)
+ (void)removeFrameUsingName:(NSString *)name + (void)removeFrameUsingName:(NSString *)name
{ // Saving and restoring { // Saving and restoring
@ -772,7 +772,7 @@ NSApplication *theApp = [NSApplication sharedApplication];
{ {
NSArray *tr = [theView trackingRectangles]; NSArray *tr = [theView trackingRectangles];
NSArray *sb = [theView subviews]; NSArray *sb = [theView subviews];
TrackingRectangle *r; GSTrackingRect *r;
int i, j; int i, j;
BOOL last, now; BOOL last, now;
NSEvent *e; NSEvent *e;
@ -780,7 +780,7 @@ NSEvent *e;
j = [tr count]; // Loop through the tracking j = [tr count]; // Loop through the tracking
for (i = 0;i < j; ++i) // rectangles for (i = 0;i < j; ++i) // rectangles
{ {
r = (TrackingRectangle *)[tr objectAtIndex:i]; r = (GSTrackingRect *)[tr objectAtIndex:i];
// Check mouse at last point // Check mouse at last point
last = [theView mouse:last_point inRect:[r rectangle]]; last = [theView mouse:last_point inRect:[r rectangle]];
// Check mouse at current point // Check mouse at current point
@ -829,7 +829,7 @@ NSEvent *e;
{ {
NSArray *tr = [theView cursorRectangles]; NSArray *tr = [theView cursorRectangles];
NSArray *sb = [theView subviews]; NSArray *sb = [theView subviews];
TrackingRectangle *r; GSTrackingRect *r;
int i, j; int i, j;
BOOL last, now; BOOL last, now;
NSEvent *e; NSEvent *e;
@ -841,7 +841,7 @@ NSRect rect;
j = [tr count]; j = [tr count];
for (i = 0;i < j; ++i) // Convert cursor rectangle for (i = 0;i < j; ++i) // Convert cursor rectangle
{ // to window coordinates { // to window coordinates
r = (TrackingRectangle *)[tr objectAtIndex:i]; r = (GSTrackingRect *)[tr objectAtIndex:i];
lastPointConverted = [theView convertPoint:last_point fromView:nil]; lastPointConverted = [theView convertPoint:last_point fromView:nil];
locationConverted = [theView convertPoint:loc fromView:nil]; locationConverted = [theView convertPoint:loc fromView:nil];
@ -966,7 +966,7 @@ NSView *v;
case NSCursorUpdate: // Cursor update case NSCursorUpdate: // Cursor update
if ([theEvent trackingNumber]) // if it's a mouse entered if ([theEvent trackingNumber]) // if it's a mouse entered
{ // push the cursor { // push the cursor
TrackingRectangle *r =(TrackingRectangle *)[theEvent userData]; GSTrackingRect *r =(GSTrackingRect *)[theEvent userData];
NSCursor *c = (NSCursor *)[r owner]; NSCursor *c = (NSCursor *)[r owner];
[c push]; [c push];
} // it is a mouse exited } // it is a mouse exited

View file

@ -117,7 +117,7 @@ __objc_class_name_NSView
__objc_category_name_NSWindow_GNUstepBackend __objc_category_name_NSWindow_GNUstepBackend
__objc_class_name_NSWindow __objc_class_name_NSWindow
__objc_class_name_NSWorkspace __objc_class_name_NSWorkspace
__objc_class_name_TrackingRectangle __objc_class_name_GSTrackingRect
NSTiffClose NSTiffClose
NSTiffGetColormap NSTiffGetColormap
NSTiffGetInfo NSTiffGetInfo