ftp.nice.ch/Attic/openStep/developer/resources/MiscKit.2.0.5.s.gnutar.gz#/MiscKit2/Examples/Giger/GigerInfoView.m

This is GigerInfoView.m in view mode; [Download] [Up]

#import "GigerInfoView.h"

#import <math.h>

@implementation GigerInfoView

- initWithFrame:(NSRect)frameRect;
{
  	[super initWithFrame:frameRect];	
   	oldImage = frontImage = [NSImage imageNamed:@"QueenFront"];
	image = [NSImage imageNamed:@"QueenBack"];
   	imageSize = [image size];
   	buffer = [[NSImage alloc] initWithSize:imageSize];  	
	[self compositeWithDissolve:NO andDelta:0.0];
	animateTimer = nil;
	frontPage = YES;
   	return self;
}
   
- (void)dealloc;
{
	[self removeTimer];
   	[image release];
   	[oldImage release];
   	[buffer release];
   	return [super dealloc];
}

- (void)compositeWithDissolve:(BOOL)aBool andDelta:(float)aDelta
{
	NSPoint pt = {0.0,0.0};

   	[buffer lockFocus];
  	[oldImage compositeToPoint:pt operation:NSCompositeCopy];
   	if(aBool)
   		[image dissolveToPoint:pt fraction:aDelta];    
   	[buffer unlockFocus]; 
}

- (void)drawRect:(NSRect)rect;
{
   	NSPoint p = {0.0, 0.0};
	
   	PSsetgray(NSLightGray);
   	NSRectFill([self bounds]);
   	[buffer compositeToPoint:p operation:NSCompositeCopy];
}

- (void)mouseDown:(NSEvent *)thisEvent 
{
    	if(animateTimer)
            	return;
   	delta = 0.0;		
   	[self compositeWithDissolve:NO andDelta:delta];
    	[self display];
	animationStep = 0; 
	animateTimer = [[NSTimer scheduledTimerWithTimeInterval:.03 
			target:self selector:@selector(animationClick:) 
			userInfo:self repeats:YES] retain];
}

- (void)animationClick:(NSTimer *)timer
{
	[self animateDissolve];
	PSWait(); 
}


- (void)animateDissolve
{
	id dummy;

	delta = delta + 0.05;
	[self compositeWithDissolve:YES andDelta:delta];
	[self display];
	if(delta < 1.0)
		return;
	dummy = oldImage;
    	oldImage = image;
    	image = dummy;
	frontPage = !frontPage;
        if(!frontPage)
            	delta = 0;
        else
		[self removeTimer];
}

- (void)removeTimer
{
	if(animateTimer){
		[animateTimer invalidate]; 
		[animateTimer release];
		animateTimer = nil;
	} 
}


- (BOOL)windowShouldClose:(id)sender
{
    	if(animateTimer)
		return NO;
	return YES;
}


@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.