//
//  MHSpriteTrack.h
//  wired
//
//  Created by Noah Sorscher on Sun May 18 2003.
//  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import "Movies.h"
#import "WiredSpriteUtilities.h"
#import "MHSpriteConstants.h"
#import "oSprite.h"

typedef enum {
    gotoTime, // by TimeValue
    gotoTimeAndPlay,
    gotoTimeByName, // also plays
    setAudioTrack, // by track number, not the number of audio tracks
    setAudioTrackByName, // applies to all tracks by that name
    setTextTrack, // ditto audio track stuff, -1 for the value to turn off all text tracks
    setTextTrackByName,
    gotoBeginning,
    gotoEnd,
    stepForward,
    stepBackward
} MHSpriteAction;

typedef struct {
    NSPoint point;
    BOOL visible;
    short layer;
    QTAtomID cursor;
    PicHandle picImage;
    NSString *fileImage; // choose a file or PicHandle for each of Main, Rollover and Clicked.  Files must be in PICT format
    PicHandle picRollImage;
    NSString *fileRollImage;
    PicHandle picClickImage;
    NSString *fileClickImage;
    MHSpriteAction action; // -1 for no action
    long longValue; // track index or TimeValue when relevant, ignored otherwise
    NSString *stringValue; // track/chapter name when relevant, ignored otherwise
} MHSpriteSpec;


@interface MHSpriteTrack : NSObject {

    NSMovie *theMovie;
    Track theTrack;
    NSColor *bgColor;
    BOOL first;
    QTAtomID picIndex, spriteIndex;
    QTAtomContainer theKeyFrameSample;
    TimeValue theDuration;
    QTAtomContainer aSprite, aKeyFrameSample;
    NSMutableArray *sprites;
    
    NSString *background;
    NSImage *bgImage;
}

- (MHSpriteSpec)newSpec;

- (MHSpriteTrack *)initWithMovie:(NSMovie *)movie;
- (NSDictionary *)defsEntry;
- (MHSpriteTrack *)initWithDefsEntry:(NSDictionary *)entry movie:(NSMovie *)movie;

- (id)newSprite;
- (void)removeSprite:(oSprite *)sprite;
- (void)removeAllSprites;

- (OSErr)addWiredSprite:(MHSpriteSpec)spec;


- (OSErr)setBackgroundColor:(NSColor *)color;
- (void)setBackgroundImage:(NSImage *)image source:(NSString *)input;
- (NSImage *)backgroundImage;
- (NSString *)backgroundImageSource;
- (TimeValue)duration;
- (void)setDuration:(TimeValue)dur; // word to the wise:  don't change this after adding sprites
- (void)refreshView:(NSView *)aView;

- (NSString *)description;
- (id)childAtIndex:(int)index;
- (int)numberOfChildren;
- (BOOL)isExpandable;
- (id)objectForKey:(id)key;
- (BOOL)shouldEditKey:(id)key;

@end
