//
//	MiscInfo.m -- a class to sit underneath an Info panel
//		Written by Don Yacktman (c) 1994 by Don Yacktman.
//				Version 1.0.  All rights reserved.
//
//		This notice may not be removed from this source code.
//
//	This object is included in the MiscKit by permission from the author
//	and its use is governed by the MiscKit license, found in the file
//	"LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
//	for a list of all applicable permissions and restrictions.
//	

#import <misckit/misckit.h>

#define _versionString [strings valueForStringKey:"Version"]
#define _versionDate [strings valueForStringKey:"VersionDate"]

// This interface is to avoid compile time warnings until the MiscAnimatedView
// class is completed.  When the class is added, I'll remove this.
@interface Object(MiscAnimatedViewMethods)
- autoUpdate:sender;
- start:sender;
- stop:sender;
@end

@implementation MiscInfo

- init				// make sure that *Panel is nil.
{
	self = [super init];
	infoPanel = nil;
	return self;
}

- setController:sender { controller = sender; return self; }
- niftyView { return niftyView; }
- (const char *)versionString { return _versionString; }
- (const char *)versionDateString { return _versionDate; }

- infoPanel		// return the infoPanel, load it if needed.
{
	if( !infoPanel) {
		[NXApp loadNibSection:"InfoPanel.nib" owner:self withNames:NO];
		if (!strings) { // attempt to load a ".strings" file *****
		}
		if (!strings) { // failing that, use the controller's string table
			strings = [controller strings];
		}
	}
	return infoPanel;
}

- updateSerialNumber
{
	[[controller registration] fillRegistrationText:regText];
	return self;
}

- info:sender		// make the info panel be up there.
{
	id tempPanel = [self infoPanel]; // force load, but no display yet

	// set up the panel's info
	[versionText setStringValue:_versionString];
	[versionDateText setStringValue:_versionDate];
	[self updateSerialNumber];

	// bring out the panel
	[tempPanel orderFront:sender];

	// start up animation, if any.
	if ([niftyView respondsTo:@selector(start:)])
		[niftyView start:self]; // will stop automatically on close by
		// using window's delegate method -windowWillClose:
	return self;
}

@end
