ftp.nice.ch/pub/next/science/chemistry/BeakerBoy.0.31.s.tar.gz#/BeakerBoy.0.31.s/Inspector.subproj/RegionInspector.subproj/BBRegionAttributesController.m

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

/* BBRegionAttributesController.m				 
 *
 * This subclass of MiscInspector is in charge of a regions attribute
 * settings.
 *
 * For more interface-info see the header file. In depth information
 * can be found here in the source-code.
 *
 * Written by: 		Thomas Engel
 * Created:    		21.01.1994 (Copyleft)
 * Last modified: 	23.05.1994
 */

#import "BBRegionAttributesController.h"
#import "../../BBMolecule.h"
#import "../../BBBasicShapeHollowSticks.h"
#import "../../BBBasicShapeRoundSticks.h"
#import "../../BBBasicShapeBallsSticks.h"
#import "../../BBBasicShapeSpacefilling.h"

@implementation BBRegionAttributesController

- textDidChange:sender;
{
	[self touch:self];
	return self;
}

- styleDidChange:sender
{
	// Here we will show the type and shape names.

	[self touch:self];
	return self;
}

- ok:sender
{
	BBRegion * ourRegion;
	int	tag;
	
	ourRegion = [self selection];
	[ourRegion setName:[nameField stringValue]];

	// According to the selection inside the matrix we will use another
	// region style.
	
	tag = [[shapeMatrix selectedCell] tag];
	
	// Now if we are a real molecule the following setting has to apply to
	// the default region of that molecule!!
	
	if( [ourRegion respondsTo:@selector(defaultRegion)] )
		ourRegion = [(BBMolecule *)ourRegion defaultRegion];
		
	if( tag == 1 )
		[ourRegion setShapeClass:[BBBasicShapeHollowSticks class]];

	else if( tag == 2 )
		[ourRegion setShapeClass:[BBBasicShapeRoundSticks class]];

	else if( tag == 3 )
		[ourRegion setShapeClass:[BBBasicShapeBallsSticks class]];

	else if( tag == 4 )
		[ourRegion setShapeClass:[BBBasicShapeSpacefilling class]];
	
	else		
		[ourRegion setShapeClass:[BBBasicShapeBallsSticks class]];

	return [super ok:sender];
}

- revert:sender
{
	id		ourRegion;
	Class	shape;
	
	[super revert:sender];
	
	ourRegion = [self selection];
	[nameField setStringValue:[ourRegion name]];	

	// Lets find the real shapeMatrix if there is none right now.
	// We have to do this because we can only connect to the scrollview
	// Without big problems.
	
	if( [shapeMatrix isKindOf:[ScrollView class]] )
		shapeMatrix = [shapeMatrix docView];
	
	// Now if we are a real molecule the following query has to apply to
	// the default region of that molecule!!
	
	if( [ourRegion respondsTo:@selector(defaultRegion)] )
		shape = [[ourRegion defaultRegion] shapeClass];
	else
		shape = [ourRegion shapeClass];
	
	if( shape == [BBBasicShapeHollowSticks class] )
		[shapeMatrix selectCellWithTag:1];
	else if( shape == [BBBasicShapeRoundSticks class] )
		[shapeMatrix selectCellWithTag:2];
	else if( shape == [BBBasicShapeBallsSticks class] )
		[shapeMatrix selectCellWithTag:3];
	else if( shape == [BBBasicShapeSpacefilling class] )
		[shapeMatrix selectCellWithTag:4];
	else
		[shapeMatrix selectCellWithTag:5];
	
	return self;
}

@end

/*
 * History: 23.05.95 Supports the new style selection mode.
 *
 *			12.05.94 Converted to fit BB... naming
 *
 *			09.03.94 Made it a Region inspector.
 *
 *			21.01.94 First implementation.
 *
 *
 * Bugs: - Hmm sure...not really ready. But it works.
 */

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