//
//  EXPComponent.h
//  Expression
//
//  Created by ashley on 15/11/2008.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>

enum linestyle_enum {
	solid, dashed
};
typedef enum linestyle_enum linestyle;

NSPoint EXPNearestPointOnUnitSquareToPoint(float x, float y);

@interface EXPComponent : NSObject {
	NSString *_name;
	NSPoint _pos;
	NSSize _size;
	id _modelObject;
	NSBezierPath *_path;
	
	int _controlPointSelected;
	NSPoint _pos2;
	NSPoint _controlVector;
	NSPoint _controlVector2;
	
	NSString *_namePosition;
		
	NSString *_document;
	NSMutableArray *_definition;
	NSMutableArray *_inputs;
	NSMutableArray *_outputs;
	NSMutableArray *_connectedComponents;
}

- (id) getElementChild:(NSString *)name forElement:(NSXMLElement *)element;
- (NSSize) getSizeFromElement:(NSXMLElement *)element;
- (NSPoint) getPointFromElement:(NSXMLElement *)element;
- (void) setFromElement:(NSXMLElement *)element;

- (void) putString:(NSString *)string toElement:(NSXMLElement *)element named:(NSString *)name;
- (void) putPoint:(NSPoint)point toElement:(NSXMLElement *)element named:(NSString *)name;
- (void) putToElement:(NSXMLElement *)element;

- (id) componentType;

- (void) setName:(id)name;
- (id) name;
- (id) displayName;
- (void) setPosition:(NSPoint)pos;
- (NSPoint) pos;
- (void) setSize:(NSSize)size;
- (NSSize) size;

- (void) setControlPointSelected:(int)controlPointSelected;
- (int) controlPointSelected;
- (BOOL) controlAreaContainsPoint:(NSPoint)point;

- (BOOL) acceptsInputs;
- (BOOL) acceptsOutputs;
- (BOOL) acceptsInFlows;
- (BOOL) acceptsOutFlows;

//- (void) moveComponentsBy:(NSPoint)change;
- (void) moveComponentTo:(NSPoint)point inView:(id)view;
- (void) moveConnectedComponentsBy:(NSPoint)change;

- (void) setPosition2:(NSPoint)pos2;
- (NSPoint) pos2;

- (void) setControlvector:(NSPoint)vec;
- (NSPoint) controlVector;
- (void) setControlvector2:(NSPoint)vec;
- (NSPoint) controlVector2;

- (void) setNamePosition:(id)namePosition;
- (id) namePosition;
//- (void) drawName;

- (NSPoint) normalVectorForPoint:(NSPoint)point length:(float)length;
- (NSPoint) closestSurfacePointToPoint:(NSPoint)point;

- (void) setDocument:(id)document;
- (id) document;
- (void) setDefinition:(id)definition;
- (id) definition;
- (void) setDefinitionFromString:(NSString *)definitionString;
- (id) definitionAsString;
- (BOOL) process:(id) symbolTable;

- (void) setInputs:(id)inputs;
- (id) inputs;
- (id) inputComponents;
- (void) setOutputs:(id)outputs;
- (id) outputs;

- (void) setConnectedComponents:(id)connectedComponents;
- (id) connectedComponents;

- (void) addObjectsForDeletionTo:(id)array;
- (void) removeOutput:(id)component;
- (void) removeInput:(id)component;

- (void) dump;

- (NSRect) drawingBounds;
- (BOOL) containsPoint:(NSPoint)point;
- (id) path;
- (void) setPath:(id)path;
- (void) computePath;
- (void) addCurveFrom:(NSPoint)pos to:(NSPoint)pos2 normal1:(NSPoint)cv1 normal2:(NSPoint)cv2 toPath:(NSBezierPath *)path;	// lineDash:(float *)lineDash count:(int)n
- (id) arrowHeadAt:(NSPoint)pos inDirection:(NSPoint)cv size:(NSSize)size;
- (void) drawArrowheadAt:(NSPoint)pos inDirection:(NSPoint)cv size:(NSSize)size;
- (void) drawName;
- (void) drawInView:(id)view isSelected:(BOOL)flag;

- (void) setModelObject:(id)model;
- (id) modelObject;

@end