ftp.nice.ch/pub/next/science/chemistry/BeakerBoy.0.31.s.tar.gz#/BeakerBoy.0.31.s/Info.subproj/BBInfo.m

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

/* BBInfo.m				 
 *
 * Handles the Icon switching in the Info panel. Just basic actions.
 *
 * For interface-info see the header file. The comments in this file mostly
 * cover only the real implementation details.
 *
 * Written by: 		Thomas Engel
 * Created:    		25.10.1993 (Copyleft)
 * Last modified: 	07.05.1994
 */

#import "BBInfo.h"
#import "BBImageAnimator.h"

#define INFOSHOWINGICONBEAKER	1		// please use enum..
#define INFOSHOWINGICONTOMI		2
#define INFOSHOWINGICONWOLFY	3
#define INFOSHOWINGANIMATION	4

#define INFOANIMATEEYECLOSE		1		// let make it a enum..

@implementation BBInfo

- init
{
	self = [super init];
	if( !self ) return self;

	// OK. We really are an object...here we go with our init.

	currentIcon = INFOSHOWINGICONBEAKER;
	animationRunning = NO;
	
	return self;
}

- makeKeyAndOrderFront:sender;
{
	if( !panel )
	{
		if( [NXApp loadNibSection:"Info.nib" owner:self] == nil )
			NXRunAlertPanel( NULL, "Couldn't load Info.nib",
							 "OK", NULL, NULL );
	}
	[panel makeKeyAndOrderFront: self];
	
	return self;
}

- switchToBeakerIcon:sender;
{
	if( !animationRunning &&
		currentIcon != INFOSHOWINGICONBEAKER )
	{
		[imageButton setImage:[beakerImage image]];
		[textField setStringValue:[beakerText stringValue]];
		currentIcon = INFOSHOWINGICONBEAKER;
	}
	return self;
}

- switchToTomiIcon:sender;
{
	if( !animationRunning &&
		currentIcon != INFOSHOWINGICONTOMI )
	{
		[imageButton setImage:[tomiImage image]];
		[textField setStringValue:[tomiText stringValue]];
		currentIcon = INFOSHOWINGICONTOMI;
	}
	return self;
}

- switchToWolfyIcon:sender;
{
	if( !animationRunning &&
		currentIcon != INFOSHOWINGICONWOLFY )
	{
		[imageButton setImage:[wolfyImage image]];
		[textField setStringValue:[wolfyText stringValue]];
		currentIcon = INFOSHOWINGICONWOLFY;
	}
	return self;
}

- switchToNextIcon:sender;
{
	switch( currentIcon )
	{
		case INFOSHOWINGICONBEAKER:
			return [self switchToTomiIcon:self];
		case INFOSHOWINGICONTOMI:
			return [self switchToWolfyIcon:self];
		case INFOSHOWINGICONWOLFY:
			return [self switchToBeakerIcon:self];
	}
	return self;
}

- startRandomAnimation:sender;
{
	// if there is no animation running right now...
	
	if( animationRunning ) return self;
	
	// register that a animation will run and choose a random animator-obj
	// To be able to switch to a original Image we have to tell this object
	// that if is now shoning the AnimationImages
	
	[self switchToBeakerIcon:self];
	animationRunning = YES;
	currentIcon = INFOSHOWINGANIMATION;

	currentAnimator = eyeCloseAnimator;
		
	[currentAnimator setDelegate:self];
	[currentAnimator startAnimation:self];
	return self;
}

- animationDidStop:sender
{
	// After the animation we have to switch to the original BeakerIcon
	// we are also registered as the animators delegate.

	animationRunning = NO;
	[self switchToBeakerIcon:self];
	return self;

}

- windowWillClose:sender
{
	// WeÂre the InfoPanels delegate. So we can stop a animation even if it
	// has not finished yet.

	if( animationRunning ) [currentAnimator stopAnimation];

	return self;
}

@end

/*
 * History: 07.05.94 Switched to BBInfo.
 *
 *			19.01.94 Added the textFields.
 *
 *
 * Bugs: - No
 */

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