//*****************************************************************************
//
//	HLRecord.m  
//
//		HotList Record objects, this is what the HotList is made of
//
//		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 "HLRecord.h"

@implementation HLRecord

//*****************************************************************************
//
// 		set to a Gate doc contained in the hot list directory 
//
//*****************************************************************************

- setGateDocName:(const char *)gateDocName 
{
	GateDocName = NXCopyStringBuffer(gateDocName);
	strcpy(Path, NXGetDefaultValue([NXApp appName], "HotList"));
	strcat(Path, "/");
	strcat(Path, GateDocName);
	GateDocPath = NXCopyStringBuffer(Path);			// save path to Gate doc
	strcat(Path, "/Icon.tiff");
	IconImage = [[NXImage alloc] initFromFile:Path];

    return self;
}
//*****************************************************************************
//
// 		set path to a virtual Gate doc (when storing app wrapper defaults) 
//
//*****************************************************************************

- setRecordPath:(const char *)aPath 
{
char *ptr;

	GateDocName = NXCopyStringBuffer("GateKeeper app default");
	strcpy(Path, aPath);
	ptr = Path + strlen(Path);		// point to end of name str
	ptr -= 8;						
	*ptr = '\0';						
	GateDocPath = NXCopyStringBuffer(Path);			// save path to Gate doc
	strcat(Path, "/Icon.tiff");
	IconImage = [[NXImage alloc] initFromFile:Path];

    return self;
}
- (char *)gateDocName 
{
    return GateDocName;
}
- (char *)gateDocPath 
{
    return GateDocPath;
}
- gateIcon 
{
	if([IconImage lockFocus])
		{
		[IconImage unlockFocus];
    	return IconImage;
		}
	return nil;
}
//************************************************************************
//
// 	free simply gets rid of everything we created
// 	This is how nice objects clean up.
//
//************************************************************************

- free
{
	if(GateDocName)
		free(GateDocName);
	if(GateDocPath)
		free(GateDocPath);
	if(IconImage)
		[IconImage free];

    return [super free];
}

@end
