* 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:
Felipe A. Rodriguez 1998-12-09 01:26:37 +00:00
parent 427b47b20d
commit 3a0de0df6c
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>
* Headers/gnustep/gui/NSWindow.h: fixed designated initialiser to

View file

@ -1,5 +1,5 @@
/*
TrackingRectangle.h
GSTrackingRect.h
Tracking rectangle class
@ -26,12 +26,12 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _GNUstep_H_TrackingRectangle
#define _GNUstep_H_TrackingRectangle
#ifndef _GNUstep_H_GSTrackingRect
#define _GNUstep_H_GSTrackingRect
#include <AppKit/NSView.h>
@interface TrackingRectangle : NSObject <NSCoding>
@interface GSTrackingRect : NSObject <NSCoding>
{
// Attributes
NSRect rectangle;
@ -62,4 +62,4 @@
@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;
NSMutableArray *tracking_rects;
NSMutableArray *cursor_rects;
NSRect invalidatedRectangle;
NSRect invalidRect;
unsigned int autoresizingMask;
BOOL is_rotated_from_base;

View file

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

View file

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

View file

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

View file

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

View file

@ -27,6 +27,8 @@
*/
#include <gnustep/gui/config.h>
#include <math.h>
#include <Foundation/NSDate.h>
#include <Foundation/NSRunLoop.h>
@ -85,141 +87,136 @@ static BOOL preCalcValues = NO;
- (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
{
/* Determine if its horizontal or vertical
then adjust the width to the standard */
if (frameRect.size.width > frameRect.size.height) {
_isHorizontal = YES;
frameRect.size.height = [isa scrollerWidth];
}
else {
_isHorizontal = NO;
frameRect.size.width = [isa 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
else
{
_isHorizontal = NO;
frameRect.size.width = [isa scrollerWidth];
}
[super initWithFrame:frameRect];
if (_isHorizontal)
_arrowsPosition = NSScrollerArrowsMinEnd;
else
_arrowsPosition = NSScrollerArrowsMaxEnd;
_hitPart = NSScrollerNoPart;
[self drawParts];
[self setEnabled:NO];
[self checkSpaceForParts];
return self;
[super initWithFrame:frameRect];
if (_isHorizontal)
_arrowsPosition = NSScrollerArrowsMinEnd;
else
_arrowsPosition = NSScrollerArrowsMaxEnd;
_hitPart = NSScrollerNoPart;
[self drawParts];
[self setEnabled:NO];
[self checkSpaceForParts];
return self;
}
- init
{
return [self initWithFrame:NSZeroRect];
return [self initWithFrame:NSZeroRect];
}
- (void)drawParts
{
/* Create the class variable button cells if they are not already created */
if (knobCell)
return;
upCell = [NSButtonCell new];
[upCell setHighlightsBy:NSChangeBackgroundCellMask|NSContentsCellMask];
[upCell setImage:[NSImage imageNamed:@"common_ArrowUp"]];
[upCell setAlternateImage:[NSImage imageNamed:@"common_ArrowUpH"]];
[upCell setImagePosition:NSImageOnly];
[upCell setContinuous:YES];
[upCell setPeriodicDelay:0.05 interval:0.05];
downCell = [NSButtonCell new];
[downCell setHighlightsBy:NSChangeBackgroundCellMask|NSContentsCellMask];
[downCell setImage:[NSImage imageNamed:@"common_ArrowDown"]];
[downCell setAlternateImage:[NSImage imageNamed:@"common_ArrowDownH"]];
[downCell setImagePosition:NSImageOnly];
[downCell setContinuous:YES];
[downCell setPeriodicDelay:0.05 interval:0.05];
leftCell = [NSButtonCell new];
[leftCell setHighlightsBy:NSChangeBackgroundCellMask|NSContentsCellMask];
[leftCell setImage:[NSImage imageNamed:@"common_ArrowLeft"]];
[leftCell setAlternateImage:[NSImage imageNamed:@"common_ArrowLeftH"]];
[leftCell setImagePosition:NSImageOnly];
[leftCell setContinuous:YES];
[leftCell setPeriodicDelay:0.05 interval:0.05];
rightCell = [NSButtonCell new];
[rightCell setHighlightsBy:NSChangeBackgroundCellMask|NSContentsCellMask];
[rightCell setImage:[NSImage imageNamed:@"common_ArrowRight"]];
[rightCell setAlternateImage:[NSImage imageNamed:@"common_ArrowRightH"]];
[rightCell setImagePosition:NSImageOnly];
[rightCell setContinuous:YES];
[rightCell setPeriodicDelay:0.05 interval:0.05];
knobCell = [NSButtonCell new];
[knobCell setButtonType:NSMomentaryChangeButton];
[knobCell setImage:[NSImage imageNamed:@"common_Dimple"]];
[knobCell setImagePosition:NSImageOnly];
{ // Create the class variable
if (knobCell) // button cells if they do not
return; // yet exist.
upCell = [NSButtonCell new];
[upCell setHighlightsBy:NSChangeBackgroundCellMask|NSContentsCellMask];
[upCell setImage:[NSImage imageNamed:@"common_ArrowUp"]];
[upCell setAlternateImage:[NSImage imageNamed:@"common_ArrowUpH"]];
[upCell setImagePosition:NSImageOnly];
[upCell setContinuous:YES];
[upCell setPeriodicDelay:0.05 interval:0.05];
downCell = [NSButtonCell new];
[downCell setHighlightsBy:NSChangeBackgroundCellMask|NSContentsCellMask];
[downCell setImage:[NSImage imageNamed:@"common_ArrowDown"]];
[downCell setAlternateImage:[NSImage imageNamed:@"common_ArrowDownH"]];
[downCell setImagePosition:NSImageOnly];
[downCell setContinuous:YES];
[downCell setPeriodicDelay:0.05 interval:0.05];
leftCell = [NSButtonCell new];
[leftCell setHighlightsBy:NSChangeBackgroundCellMask|NSContentsCellMask];
[leftCell setImage:[NSImage imageNamed:@"common_ArrowLeft"]];
[leftCell setAlternateImage:[NSImage imageNamed:@"common_ArrowLeftH"]];
[leftCell setImagePosition:NSImageOnly];
[leftCell setContinuous:YES];
[leftCell setPeriodicDelay:0.05 interval:0.05];
rightCell = [NSButtonCell new];
[rightCell setHighlightsBy:NSChangeBackgroundCellMask|NSContentsCellMask];
[rightCell setImage:[NSImage imageNamed:@"common_ArrowRight"]];
[rightCell setAlternateImage:[NSImage imageNamed:@"common_ArrowRightH"]];
[rightCell setImagePosition:NSImageOnly];
[rightCell setContinuous:YES];
[rightCell setPeriodicDelay:0.05 interval:0.05];
knobCell = [NSButtonCell new];
[knobCell setButtonType:NSMomentaryChangeButton];
[knobCell setImage:[NSImage imageNamed:@"common_Dimple"]];
[knobCell setImagePosition:NSImageOnly];
}
- (void)_setTargetAndActionToCells
{
[upCell setTarget:_target];
[upCell setAction:_action];
[downCell setTarget:_target];
[downCell setAction:_action];
[leftCell setTarget:_target];
[leftCell setAction:_action];
[rightCell setTarget:_target];
[rightCell setAction:_action];
[knobCell setTarget:_target];
[knobCell setAction:_action];
[upCell setTarget:_target];
[upCell setAction:_action];
[downCell setTarget:_target];
[downCell setAction:_action];
[leftCell setTarget:_target];
[leftCell setAction:_action];
[rightCell setTarget:_target];
[rightCell setAction:_action];
[knobCell setTarget:_target];
[knobCell setAction:_action];
}
- (void)checkSpaceForParts
{
NSSize frameSize = [self frame].size;
float size = (_isHorizontal ? frameSize.width : frameSize.height);
float scrollerWidth = [isa scrollerWidth];
NSSize frameSize = [self frame].size;
float size = (_isHorizontal ? frameSize.width : frameSize.height);
float scrollerWidth = [isa scrollerWidth];
if (size > 3 * scrollerWidth + 2)
_usableParts = NSAllScrollerParts;
else if (size > 2 * scrollerWidth + 1)
_usableParts = NSOnlyScrollerArrows;
else if (size > scrollerWidth)
_usableParts = NSNoScrollerParts;
if (size > 3 * scrollerWidth + 2)
_usableParts = NSAllScrollerParts;
else
if (size > 2 * scrollerWidth + 1)
_usableParts = NSOnlyScrollerArrows;
else
if (size > scrollerWidth)
_usableParts = NSNoScrollerParts;
}
- (void)setEnabled:(BOOL)flag
{
if (_isEnabled == flag)
return;
_isEnabled = flag;
#if 1
[self setNeedsDisplay:YES];
#else
[self display];
#endif
if (_isEnabled == flag)
return;
_isEnabled = flag;
[self setNeedsDisplay:YES];
}
- (void)setArrowsPosition:(NSScrollArrowPosition)where
{
if (_arrowsPosition == where)
return;
if (_arrowsPosition == where)
return;
_arrowsPosition = where;
#if 1
[self setNeedsDisplay:YES];
#else
[self display];
#endif
_arrowsPosition = where;
[self setNeedsDisplay:YES];
}
- (void)setFloatValue:(float)aFloat
@ -235,88 +232,83 @@ static BOOL preCalcValues = NO;
[self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]];
}
- (void)setFloatValue:(float)aFloat
knobProportion:(float)ratio
- (void)setFloatValue:(float)aFloat knobProportion:(float)ratio
{
if (ratio < 0)
_knobProportion = 0;
else if (ratio > 1)
_knobProportion = 1;
else
_knobProportion = ratio;
if (ratio < 0)
_knobProportion = 0;
else
if (ratio > 1)
_knobProportion = 1;
else
_knobProportion = ratio;
[self setFloatValue:aFloat];
[self setFloatValue:aFloat];
}
- (void)setFrame:(NSRect)frameRect
{
/* Determine if its horizontal or vertical
then adjust the width to the standard */
if (frameRect.size.width > frameRect.size.height) {
_isHorizontal = YES;
frameRect.size.height = [isa scrollerWidth];
}
else {
_isHorizontal = NO;
frameRect.size.width = [isa 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
else
{
_isHorizontal = NO;
frameRect.size.width = [isa scrollerWidth];
}
[super setFrame:frameRect];
if (_isHorizontal)
_arrowsPosition = NSScrollerArrowsMinEnd;
else
_arrowsPosition = NSScrollerArrowsMaxEnd;
_hitPart = NSScrollerNoPart;
[self checkSpaceForParts];
[super setFrame:frameRect];
if (_isHorizontal)
_arrowsPosition = NSScrollerArrowsMinEnd;
else
_arrowsPosition = NSScrollerArrowsMaxEnd;
_hitPart = NSScrollerNoPart;
[self checkSpaceForParts];
}
- (void)setFrameSize:(NSSize)size
{
[super setFrameSize:size];
[self checkSpaceForParts];
#if 1
[self setNeedsDisplay:YES];
#else
[self display];
[[self window] flushWindow];
#endif
[super setFrameSize:size];
[self checkSpaceForParts];
[self setNeedsDisplay:YES];
}
- (NSScrollerPart)testPart:(NSPoint)thePoint
{
NSRect rect;
- (NSScrollerPart)testPart:(NSPoint)thePoint // return what part
{ // of the scroller
NSRect rect; // the mouse hit
if (thePoint.x < 0 || thePoint.x > frame.size.width
|| thePoint.y < 0 || thePoint.y > frame.size.height)
return NSScrollerNoPart;
rect = [self rectForPart:NSScrollerDecrementLine];
if ([self mouse:thePoint inRect:rect])
return NSScrollerDecrementLine;
rect = [self rectForPart:NSScrollerIncrementLine];
if ([self mouse:thePoint inRect:rect])
return NSScrollerIncrementLine;
rect = [self rectForPart:NSScrollerKnob];
if ([self mouse:thePoint inRect:rect])
return NSScrollerKnob;
rect = [self rectForPart:NSScrollerKnobSlot];
if ([self mouse:thePoint inRect:rect])
return NSScrollerKnobSlot;
rect = [self rectForPart:NSScrollerDecrementPage];
if ([self mouse:thePoint inRect:rect])
return NSScrollerDecrementPage;
rect = [self rectForPart:NSScrollerIncrementPage];
if ([self mouse:thePoint inRect:rect])
return NSScrollerIncrementPage;
return NSScrollerNoPart;
if (thePoint.x < 0 || thePoint.x > frame.size.width
|| thePoint.y < 0 || thePoint.y > frame.size.height)
return NSScrollerNoPart;
rect = [self rectForPart:NSScrollerDecrementLine];
if ([self mouse:thePoint inRect:rect])
return NSScrollerDecrementLine;
rect = [self rectForPart:NSScrollerIncrementLine];
if ([self mouse:thePoint inRect:rect])
return NSScrollerIncrementLine;
rect = [self rectForPart:NSScrollerKnob];
if ([self mouse:thePoint inRect:rect])
return NSScrollerKnob;
rect = [self rectForPart:NSScrollerKnobSlot];
if ([self mouse:thePoint inRect:rect])
return NSScrollerKnobSlot;
rect = [self rectForPart:NSScrollerDecrementPage];
if ([self mouse:thePoint inRect:rect])
return NSScrollerDecrementPage;
rect = [self rectForPart:NSScrollerIncrementPage];
if ([self mouse:thePoint inRect:rect])
return NSScrollerIncrementPage;
return NSScrollerNoPart;
}
- (float)_floatValueForMousePoint:(NSPoint)point
@ -369,10 +361,10 @@ float position;
return floatValue;
}
- (void)_preCalcParts
{
NSRect knobRect = [self rectForPart:NSScrollerKnob];
- (void)_preCalcParts // pre calculate
{ // values to lessen
NSRect knobRect = [self rectForPart:NSScrollerKnob]; // the burden while
// scrolling
slotRect = [self rectForPart:NSScrollerKnobSlot];
halfKnobRectWidth = knobRect.size.width / 2;
@ -389,8 +381,8 @@ NSRect knobRect = [self rectForPart:NSScrollerKnob];
}
- (float)_floatValueForMousePointFromPreCalc:(NSPoint)point
{
float floatValue = 0;
{
float floatValue = 0;
float position;
if (_isHorizontal) // Adjust point to lie
@ -484,6 +476,7 @@ NSDate *theDistantFuture = [NSDate distantFuture];
PSMatrix* matrix;
NSEventType eventType;
NSRect knobRect = {{0,0},{0,0}};
int periodCount = 0; // allows a forced update
NSArray* path = [self _pathBetweenSubview:self
toSuperview:[window contentView]];
@ -496,19 +489,26 @@ NSArray* path = [self _pathBetweenSubview:self
preCalcValues = YES;
_hitPart = NSScrollerKnob; // set periodic events rate
// to achieve max of 30fps
// 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];
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];
if (point.x != knobRect.origin.x || point.y != knobRect.origin.y)
{
{
floatValue = [self _floatValueForMousePointFromPreCalc:point];
if (floatValue != oldFloatValue)
@ -523,28 +523,31 @@ NSArray* path = [self _pathBetweenSubview:self
_floatValue = floatValue;
}
[self drawKnobSlot]; // draw scroller slot
[self drawKnob]; // draw scroller knob
[self drawKnobSlot]; // draw the scroller slot
[self drawKnob]; // draw the scroller knob
[_target performSelector:_action withObject:self];
[window flushWindow];
oldFloatValue = floatValue;
}
knobRect.origin = point;
}
}
} // 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
theEvent = [app nextEventMatchingMask:eventMask
untilDate:theDistantFuture
inMode:NSEventTrackingRunLoopMode
dequeue:YES];
}
[NSEvent stopPeriodicEvents];
// scrolling has stopped
if([_target respondsToSelector:@selector(contentView)])
{
if([_target respondsToSelector:@selector(_freeMatrix)])
[[_target contentView] _freeMatrix];
if([_target isKindOf:[NSScrollView class]]) // hack for XRAW FIX ME
{
NSObject *targetCV = (NSObject *)[_target contentView];
if([targetCV respondsToSelector:@selector(_freeMatrix)])
[targetCV _freeMatrix];
}
preCalcValues = NO;
@ -633,51 +636,42 @@ BOOL ret = [super sendAction:theAction to:theTarget]; // the target on
return ret;
}
- (void)encodeWithCoder:aCoder
{
}
- initWithCoder:aDecoder
{
return self;
}
//
// draw the scroller
//
- (void)drawRect:(NSRect)rect
{
NSDebugLog (@"NSScroller drawRect: ((%f, %f), (%f, %f))",
rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
[self drawArrow:NSScrollerDecrementArrow highlight:NO];
[self drawArrow:NSScrollerIncrementArrow highlight:NO];
[self drawKnobSlot];
[self drawKnob];
NSDebugLog (@"NSScroller drawRect: ((%f, %f), (%f, %f))",
rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
[self drawArrow:NSScrollerDecrementArrow highlight:NO];
[self drawArrow:NSScrollerIncrementArrow highlight:NO];
[self drawKnobSlot];
[self drawKnob];
}
- (void)drawArrow:(NSScrollerArrow)whichButton highlight:(BOOL)flag
{
NSRect rect = [self rectForPart:(whichButton == NSScrollerIncrementArrow
? NSScrollerIncrementLine
: NSScrollerDecrementLine)];
id theCell = nil;
NSRect rect = [self rectForPart:(whichButton == NSScrollerIncrementArrow
? NSScrollerIncrementLine : NSScrollerDecrementLine)];
id theCell = nil;
NSDebugLog (@"position of %s cell is (%f, %f)",
(whichButton == NSScrollerIncrementArrow ? "increment" : "decrement"),
rect.origin.x, rect.origin.y);
switch (whichButton) {
case NSScrollerDecrementArrow:
theCell = (_isHorizontal ? leftCell : downCell);
break;
case NSScrollerIncrementArrow:
theCell = (_isHorizontal ? rightCell : upCell);
break;
}
[theCell drawWithFrame:rect inView:self];
NSDebugLog (@"position of %s cell is (%f, %f)",
(whichButton == NSScrollerIncrementArrow ? "increment" : "decrement"),
rect.origin.x, rect.origin.y);
switch (whichButton)
{
case NSScrollerDecrementArrow:
theCell = (_isHorizontal ? leftCell : downCell);
break;
case NSScrollerIncrementArrow:
theCell = (_isHorizontal ? rightCell : upCell);
break;
}
[theCell drawWithFrame:rect inView:self];
}
- (void)drawKnob

View file

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

View file

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

View file

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