//
//  MSInkObject.h
//  MSInkFramework
//
//  Created by Raleigh Ledet on Tue Aug 19 2003.
//  Copyright (c) 2003-2007 Mage Software. All rights reserved.
//

#import <Foundation/Foundation.h>

// MSInkObject is a combination of MSAttributedInkData and possible recognized strings the InkData represents. An MSInkObject can either draw itself in the original attributed ink, or as text that fills the bounds of the original attributed ink.

extern NSString *kMSInkObject;
extern NSString *kMSInkObjectPossibleArray;
extern NSString *kMSInkObjectRecognizedIdx;
extern NSString *MSInkObjectPboardType;
extern NSString *kMSInkObjecDrawType;
extern NSString *kMSInkObjectStringAttributes;

// The type drawing the MSInkObject should perform.
enum {
  kMSInkObjecDrawTypeInk = 0,
  kMSInkObjecDrawTypeString
};

@class MSAttributedInkData, MSMutableAttributedInkData;

@interface MSInkObject : NSObject
{
@private
	MSMutableAttributedInkData *_inkData;
	NSMutableArray		*_recognizedText;
	UInt32				_recognizedIndex;
	UInt32				_drawType;
	
	NSDictionary		*_userElements;
}

// Set / Get the drawing type to perform
// Defautls to kMSInkObjecDrawTypeInk
- (int)drawType;
- (void)setDrawType:(int)drawType;

// Return the preferred recognized string from the list of all recognized possabilites.
- (NSString *)recognizedString;

// Same as -recognized string, only the color of the attributed ink data is applied as an attribute of the recognized string.
- (NSAttributedString *)recognizedAttributeString;

// An array of all recognized possabilites (as NSStrings)
- (NSArray *)recognizedStrings;

- (UInt32)numberOfRecognizedStringPossibilities;
- (NSString *)recognizedStringAtIndex:(UInt32)loc;

// Add another recognized string possibility to the list
- (void)addRecognizedStringPossibility:(NSString*)newString;

// Set the preferred recognized string. If the passed in string is not in the list of possibilities, it is added, then set at the preferred one.
- (void)setRecognizedString:(NSString*)recognizedString;

// The raw MSAttributedInkData
- (MSAttributedInkData*)inkData;

// A mutable (autoreleased) copy of the raw MSAttributedInkData
- (MSMutableAttributedInkData*)mutableInkData;

// Return the MSInkBoject in the form of serialzed binary data suitable for storage in a file, database, etc. Pass back to initWithData to recreate the inkObject.
- (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;
- (void) setUserElements:(NSDictionary*)userElements;

// Replace the current MSAttributedInkData with this MSAttributedInkData
- (void)setMSAttributedInkData:(MSAttributedInkData*)newInkData;

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

// 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;

// Convenience method to get paste board type when dealing with many ink objects without having to check thier class 
- (NSString*)pasteBoardType;
@end

// Convenience methods for MSInkObject creation
@interface MSInkObject (MSInkObjectCreation)
+ (id)inkObjectWithMSInkData:(MSAttributedInkData*)inkData recognizableStringArray:(NSArray*)strings;
- (id)init;
- (id)initWithMSInkData:(MSAttributedInkData*)inkData;
- (id)initWithMSInkData:(MSAttributedInkData*)inkData recognizableStringArray:(NSArray*)strings;

// initialize an MSInkObject with serialized binary data from an otherwise previous call to -data;
- (id)initWithData:(NSData*)data;
@end

@interface MSInkObject (MSAttributedInkDataDrawExtensions)
- (void)drawAtPoint:(NSPoint)loc;
- (void)drawInRect:(NSRect)rect;

// If possibe, cache drawing to speed up drawAtPoint latter
- (void)cacheDrawing;
@end
