//*****************************************************************************
//
//	InfoAnimator.m  
//
//		Controls Info panel animation
//
//			by	Felipe A. Rodriguez		
//
//	This code is supplied "as is" the author makes no warranty as to its 
//	suitability for any purpose.  This code is free and may be distributed 
//	in accordance with the terms of the:
//		
//			GNU GENERAL PUBLIC LICENSE
//			Version 2, June 1991
//			copyright (C) 1989, 1991 Free Software Foundation, Inc.
// 			675 Mass Ave, Cambridge, MA 02139, USA
//
//*****************************************************************************

#import <appkit/appkit.h>
#import "InfoAnimator.h"
#import "GKdefs.h"





@interface InfoAnimator (Private)


static void InfoAnimate();						// called by timed entry events
	static DPSTimedEntry aniTimeTag;


@end
@implementation InfoAnimator

//*****************************************************************************
//
// 		register timed entry 
//
//*****************************************************************************

- startAnimTimer
{
	if(!aniTimeTag)  
		aniTimeTag = DPSAddTimedEntry(			// register function Animate
			0.08, 								// to be called every period of 		
			(DPSTimedEntryProc)InfoAnimate, 	// arg0
			(id)self, 
			NX_BASETHRESHOLD);
 	[versionStrView setStringValue:NXGetDefaultValue([NXApp appName],VERSION)];
    [[sView window] center];
    [[sView window] makeKeyAndOrderFront:self];

	return self;
}
//*****************************************************************************
//
// 		animate		target of timed entry
//
//*****************************************************************************
 
- _animate
{
	return [sView display];		
}
//*****************************************************************************
//
// 		remove the timed entry when connection is made or we exit
//
//*****************************************************************************
 
- removeTimedEntry
{
	if(aniTimeTag)  
		DPSRemoveTimedEntry(aniTimeTag);
	aniTimeTag = 0;
		
	return self;
}
//********************** Window delegate method *******************************
//*****************************************************************************
//
// 		called whenever the user closes our window.
//
//*****************************************************************************

- windowWillClose:sender  
{
    return [self removeTimedEntry];
}

@end
@implementation InfoAnimator (Private)

//*****************************************************************************
//
//		This fucntion is registered by DPSaddtimedentry.
//		It is subsequently called every period t as registered  
//		in arg 0 of DPSaddtimedentry.
//
//*****************************************************************************
 
static void InfoAnimate(DPSTimedEntry time_tag, double now, id self)
{
	[self _animate];
}

@end
