//  ShowAnimApp.m
// 1993 Christoph Marquardt
//  You may freely copy, distribute, and reuse the code in this program.
//  the author disclaims any warranty of any kind, expressed or  implied, as to its
//  fitness for any particular use.

#import "ShowAnimApp.h"

@implementation ShowAnimApp : Application

- init
{
  [super init];
  infoPanel = nil;
  return self;
}

- info:sender
/*
 * Brings up the information panel.
 */
{
    if (!infoPanel) {
	[self loadNibSection:"InfoPanel.nib" owner:self withNames:NO fromZone:[self zone]];
	[infoPanel setFrameAutosaveName:"InfoPanel"];
    }

    [infoPanel orderFront:self];

    return self;
}

- open:sender
{
  char *theTypes[] = {"anim", NULL};
  
  if ([[OpenPanel new] runModalForTypes:theTypes]) {
	const char *fileName = [[OpenPanel new] filename];
	[animView openAnim:fileName];
    }

  return self;
}

- appDidInit:(Application *)sender
{
    int i;
    
    [[animView window] setDelegate:animView];
    [ControlPanel setFrameAutosaveName:[ControlPanel title]];
    [ControlPanel setBecomeKeyOnlyIfNeeded:YES];
    [ControlPanel setFloatingPanel:YES];
    [ControlPanel orderFront:self];

    if (NXArgc > 1) {
	    [animView openAnim:NXArgv[1]];
    }
    
    return self;
}

- (int)app:sender openFile:(const char *)path type:(const char *)type
/*
 * This method is performed whenever a user double-clicks on an icon
 * in the Workspace Manager representing a .anim bundle.
 */
{
    if (type && !strcmp(type, "anim")) {
	[animView openAnim:path];
	return YES;
    }
    return NO;
}

- (BOOL)appAcceptsAnotherFile:(Application *)sender
/*
 * We only handle one anim file.
 */
{
    return YES;
}

- appDidHide:sender
{
  [animView pauseAnim:self];
  return self;
}

- appDidUnhide:sender
{
  [animView pauseAnim:self];
  return self;
}

@end
