//
//  MSAttributedInkData.h
//  MSInkFramework
//
//  Created by Raleigh Ledet on Sun Aug 10 2003.
//  Copyright (c) 2003-2007 Mage Software. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Carbon/Carbon.h>

extern NSString *kMSAttributedInkDataObject;
extern NSString *kMSAttributedInkDataAttributes;
extern NSString *MSAttributedInkDataPboardType;

@class MSInkData, MSMutableInkData;

// InkData with Attributes such as color and brush. An MSInkObject contains one of these.
// MSAttributedInkData also adds a new concept to InkData. Stroke.
// A stroke is all the Ink Data points from mouse down to mouse up. Or, to be more technical, all the data points between points with zero pressure.
@interface MSAttributedInkData : NSObject <NSCopying, NSMutableCopying>{
	MSMutableInkData	*_inkData;
	NSMutableArray		*_strokes;
	NSMutableArray		*_attributes;
	NSImage				*_imageCache;
	
	NSDictionary		*_userElements;
}

// The raw inkData without attributes.
- (MSInkData *)inkData;

// return an NSDictionaty describing the attributes of a particular stroke. Attributes are applied at a granularity of a stroke. Generally, an MSAttributedInkData object only hase one set of Attributes.
// If a pointer to an NSRange structure is supplied, the effective range of the attribues at that index is returned.
- (NSDictionary *)attributesAtIndex:(unsigned)location effectiveRange:(NSRangePointer)range;

// Paste board type to use when putting this object on the paste board.
- (NSString*)pasteBoardType;
@end

extern NSString *MSAttributedInkDataPboardType;

@interface MSAttributedInkData (MSExtendedAttributedInkData)

// returns the number of strokes
- (unsigned)length;

// The range of raw data points that make up a particular stroke.
- (NSRange)rangeOfStrokeAtIndex:(unsigned)loc;

- (id)initWithMSInkData:(MSInkData *)ink;
- (id)initWithMSInkData:(MSInkData *)ink attributes:(NSDictionary *)attrs;
- (id)initWithMSAttributedInkData:(MSAttributedInkData *)attrInk;

// initialize a newly allocated MSAttributedInkData object with data obtained from a previous call to -data; This is typically used when recreating data from a file or pasteboard.
- (id)initWithData:(NSData*)data;

// return serialzed binary data that can be stored on disk or pasteboards. Pass this data back to -initWithData: to recreate this object.
- (NSData*)data;

// userElements are whatever you set them to be. Though, you would do well to stick to serializable Dictionary elements if you want -data to serialize them for you. (See NSPropertyListSerialization class overview.)
- (NSDictionary*)userElements;

// The natural size of the InkObject if drawn
- (NSSize)size;

- (MSAttributedInkData*)subMSAttributedInkDataWithRange:(NSRange)range;

// convience method to create an MSAttributedInkData object that is auto released.
+ (id)attributedInkDataWithInkData:(MSInkData *)ink attributes:(NSDictionary *)attrs;
@end

@interface MSAttributedInkData (MSAttributedInkDataDrawExtensions)
- (void)drawAtPoint:(NSPoint)loc;
- (void)drawInRect:(NSRect)rect;
- (void)cacheDrawing;
@end

// The mutable version of MSAttributedInkData - Used internally, you should need to use these.
@interface MSMutableAttributedInkData : MSAttributedInkData{
}

- (void)replaceMSInkDataInRange:(NSRange)range withMSInkData:(MSInkData *)ink;
- (void)setAttributes:(NSDictionary *)attrs range:(NSRange)range;

@end

@interface MSMutableAttributedInkData (MSExtendedMutableAttributedInkData)

- (MSMutableInkData *)mutableInkData;

- (void)addAttributes:(NSDictionary *)attrs range:(NSRange)range;

- (void)replaceMSInkDataInRange:(NSRange)range withAttributedInkData:(MSAttributedInkData *)attrInk;
- (void)insertMSAttributedInkData:(MSAttributedInkData *)attrInk atIndex:(unsigned)loc;
- (void)appendMSAttributedInkData:(MSAttributedInkData *)attrInk;
- (void)deleteMSInkDataInRange:(NSRange)range;

// userElements are whatever you set them to be. Though, you would do well to stick to serializable Dictionary elements if you want -data to serialize them for you. (See NSPropertyListSerialization class overview.)
- (void) setUserElements:(NSDictionary*)userElements;

// Scales the ink data points such that the natural size matches the input.
// Note: While this scales ink data, this does not scale brush attributes.
- (void) setSize:(NSSize)size;

- (void)translateInkPointsBy:(NSPoint)translatePoint;
- (void)scaleInkPointsByX:(float)x y:(float)y;
- (void)rotInkPointsCWByRadAngle:(double)cwAngle;
@end
