//
//  MSGraphicsEngine.h
//  MSGraphicsEngineFramework
//
//  Created by Raleigh Ledet on Sat Oct 25 2003.
//  Copyright (c) 2003 MageSW. All rights reserved.
//

/**************************************************************************************************
********************************************************
******************* MSGraphicsEngine *******************

The MSGraphicsEngine is responsible for managing the collection of brushes. You can do the mangement
manually, or you can wire up an NSTable and NSView to the graphics engine and forget about it.

NIB WIRING
1) Brush List:
	Create an NSTableView.
	Set the NSTableView to have 2 columns. 
	Set the identifier of one column to "brushLabel" (sans quotes). The name of the brush goes there.
	Set the identifier of one column to "brushImage" (sans quotes). The brush's icon goes there.
	(Actually, the columns are optional, if you only want the icons, don't include the label column.)
	Wire the NSTableView to the MSGraphicsEngine's brushListView.
	Wire the MSGraphicsEngine to the NSTableView's dataSource.
	Wire the NSTableView to the MSGraphicsEngine's brushListClicked Action.

2) Brush Attributes:
	Create a custom NSView with a width of 174 pixels. The height is variable depending on the
	  attributes of the brush, but if it's not in a scroll view, this biggest brush currently uses
	  240 pixels.
	Wire the NSView to the MSGraphicsEngine's brushAttributesView.
*/

#import <Foundation/Foundation.h>
#import "MSBrush.h";

@interface MSGraphicsEngine : NSObject {
	IBOutlet NSTableView *_brushListView;
	IBOutlet NSView *_brushAttributesView;
	
	MSBrush *_currentBrush;
	MSBrush *_defaultBrush;
	MSBrush *_tipBrush;
	MSBrush *_eraserBrush;
	NSArray *_brushesList;
	
	NSMutableDictionary *transducerBrushDict;
}

// You do not have to use a global graphics engine, but if you do, you can get one here.
+(MSGraphicsEngine*)defaultGraphicsEngine;

// This routine causes the settings for all brushes and the graphics engine to be saved in the standardUserDefaults. These setting are automatically read in when MSGraphicsEngine is inited.
// This method is automatically called when MSGraphicsEngine is deallocated.
// If you are using the +defaultGraphicsEngine then MSGraphicsEngine will not be deallocated for you, and thus this method may come in handy.
-(void)sychWithUserDefaults;

///////// Auto NIB WIring //////////////
// The table view for automatic brush selection. See notes at top of this file.
-(NSTableView*)brushListView;
-(void)setBrushListView:(NSTableView*)brushListView;

// The table view for automatic brush attribute modification. See notes at top of this file.
-(NSView*)brushAttributesView;
-(void)setBrushAttributesView:(NSView*)brushAttributesView;

// The click action of the brushListView should be wired to this method.
-(IBAction)brushListClicked:(id)sender;


//////// Manual brush manipulation API //////////
// If you do not want to use the auto NIB API above, the following API may be useful. You can also mix and match this API with the auto NIB API.

// The brush currently in use.
-(MSBrush*)currentBrush;

// Sets the current brush.
// Note: There is really a tip brush and an eraser brush.
// When the eraser end of the pen is in proximity, the current brush automatically switches to the eraser
// When the tip of the pen in in proximity, the current brush switches back to the brush set here.
// In other words, this call sets the tip brush and does not override the eraser brush if the eraser of the pen is in proximity.
-(void)setCurrentBrush:(MSBrush*)brush;

// The number of brushes MSGraphicsEngine knows about.
-(UInt32)brushCount;

// Returns the brush from the known list at the supplied index. idx < -brushCount.
-(MSBrush*)brushAtIndex:(int)idx;

// Shortcut method to get the identifier of a brush from the known brush list.
-(NSString*)identifierOfBrushAtIndex:(int)idx;

// Shortcut method to get a brush via it's identifier
-(MSBrush*)brushWithIdentifier:(NSString*)identifier;

// Deprecated: The initial brush to use on startup. Typically this is the Pencil Brush.
-(MSBrush*)defaultBrush;
@end
