//*****************************************************************************
//
//	PanelController.h.  
//
//		Preferences logic.
//
//			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 "SecondPanelController.h"
#import "../Coordinator.h"
#import "../GKdefs.h"

		// preferences controls 
	char *cList[] = { "dialPrefix", DIALINIT,  NULL};


 

@implementation SecondPanelController

//*****************************************************************************
//
//		sent to us after nib objects are unarchived and init'd 
//
//*****************************************************************************
 
- awakeFromNib
{
int i = 0;

	for(i = 0; cList[i]; i++)				// display default trigger str's
		[defaultsForm setStringValue:NXGetDefaultValue([NXApp appName],
															cList[i]) at:i];	
    return self;
}
//*****************************************************************************
//
//		returns the inspector panel we control
//
//*****************************************************************************

- inspectorPanel
{
    return 	[defaultsForm window];
}
//*****************************************************************************
//
//		user has changed a control string, store change in ddb
//
//*****************************************************************************
 
- defaultsForm:sender
{
int i = (int)[sender selectedIndex];

				// write an entry to defaults database
	if(!NXWriteDefault([NXApp appName], cList[i], [sender stringValueAt:i]))
		[[NXApp delegate] showAlert:"ddbWriteError"];

    return self;
}
//*********************** text field matrix delegation ************************
//*****************************************************************************
//
// 		as text delegate we recieve this when textfield cell is being edited 
//
//*****************************************************************************

- (BOOL)textWillChange:textObject
{
	[[defaultsForm window] setDocEdited:YES];				// indicate change 
															// is not saved
    return NO;
}
//*****************************************************************************
//
// 		text delegate receives when editing of textfield cell is ended 
//
//*****************************************************************************

- textDidEnd:textObject endChar:(unsigned short)whyEnd
{
    if ((whyEnd == 16) || (whyEnd == 17)) 					// indicate change
		[[defaultsForm window] setDocEdited:NO];			// is saved

    return self;
}

@end
