/* BBAtomAttributesController.h				 
 *
 * This subclass of MiscInspector is in charge of the Atom attributes
 * 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:    		12.01.1994 (Copyleft)
 * Last modified: 	07.11.1994
 */

#import "BBAtomAttributesController.h"
#import "../../BBAtom.h"

@implementation BBAtomAttributesController

- resetName:sender
{
	id	anAtom;
	
	anAtom = [[self selection] motherAtom];
	[nameField setStringValue:[anAtom name]];
	[symbolField setStringValue:[anAtom symbol]];
	[symbolAdditionsField setStringValue:[anAtom symbolExtention]];
	
	[self touch:self];
	return self;
}

- resetData:sender
{
	id	anAtom;
	
	anAtom = [[self selection] motherAtom];
	[neutronsField setIntValue:[anAtom neutrons]];
	[massField setFloatValue:[anAtom mass]];
	[radiusField setFloatValue:[anAtom radius]];
	[vanDerWaalsField setFloatValue:[anAtom vanDerWaalsRadius]];
	
	return self;
}

- ok:sender
{
	id	anAtom;
	
	anAtom = [self selection];
	[anAtom setMotherAtom:[dragWell delegate]];
	[(BBBasicAtom *)anAtom setName:[nameField stringValue]];

	[anAtom setSymbolExtention:[symbolAdditionsField stringValue]];
	[anAtom setNeutrons:(short)[neutronsField intValue]];
	[anAtom setMass:[massField floatValue]];
	[anAtom setRadius:[radiusField floatValue]];
	[anAtom setVanDerWaalsRadius:[vanDerWaalsField floatValue]];

	return [super ok:sender];
}

- revert:sender
{
	id	anAtom;
	
	[super revert:sender];
	
	anAtom = [self selection];
	[nameField setStringValue:[anAtom name]];
	[symbolField setStringValue:[anAtom symbol]];
	[symbolAdditionsField setStringValue:[anAtom symbolExtention]];

	[protonsField setIntValue:[anAtom protons]];
	[neutronsField setIntValue:[anAtom neutrons]];
	[massField setFloatValue:[anAtom mass]];
	[radiusField setFloatValue:[anAtom radius]];
	[vanDerWaalsField setFloatValue:[anAtom vanDerWaalsRadius]];

	[dragWell setDelegate:[anAtom motherAtom]];
	
	return self;
}

@end

/*
 * History: 07.11.94 Added symbolExtention support
 *
 *			12.05.94 Converted to fit BB... naming
 *
 *			08.02.94 MiscInspector changes made.
 *
 *			12.01.94 First implementation.
 *
 *
 * Bugs: - Not a problem. I know I could have cached the selection but it
 *		   is not necessary...so I saved the memory.
 */