
/* 	InspectorManager.m
	created by Robert Vasvari - July 1994
*/

#import "STSwapBoxManager.h"
#import "STUtil.h"
#import "STAdjFontTextField.h"
#import "STAppController.h"
#import "STClockView.h"

#import "InspectorManager.h"
#import "DocumentClass.h"

@implementation InspectorManager

- awakeFromNib
{	
	[super awakeFromNib];
	  /* set up the textfields */
	[nameText setFontString:"Helvetica"];
	[nameText setAttributes:4 :8
		align:NX_CENTERED
		lines:1];
	[pathText setFontString:"Helvetica"];
	[pathText setAttributes:0 :4
		align:NX_LEFTALIGNED
		lines:2];
	[panel setDocEdited:NO];
	
	return self;
}

- updateInspector:sender
{
id doc=[[NXApp delegate] currentDoc];
	
	//printf("in updateInspector\n");
	if(!doc) 
	 { name=nil;
	   path=nil;
	   cTime=nil;
	   mTime=nil;
	   return self;
	 }
	[doc getInspectorData:&name :&path :&tag :&cTime :&mTime];
	
	return self;
}

- loadDataFor:(int)boxTag
{
/* 	this method loads the data into the currently selected
	screen.
 */
	switch(boxTag)
	{ case 0:
	   [nameText setStringValue:name ? [name cString] : ""];
	   [pathText setStringValue:path ? [path cString] : ""];
	   [createClock setValue:cTime];
	   [modifyClock setValue:mTime];
	   [tagText setIntValue:tag];
	   [panel setTitle:"Screen 1 Inspector"];
	   
	    break;
	  case 1:
	     [panel setTitle:"Screen 2 Inspector"];
	  break;
	  default:fprintf(stderr,"loadDataFor: bad boxTag:%d\n",boxTag);
	}
	return self;
}

- getPanelWithScreen:(int)index
{	/* this needed to be overridden to make sure
       updateInspector gets called
	 */
	[panel disableFlushWindow];
	[panel disableDisplay];
	[self updateInspector:nil];
	[super getPanelWithScreen:index];
	[panel reenableDisplay];
	[panel display];
	[panel reenableFlushWindow];
	[panel flushWindow];
	return self;
}

- windowDidUpdate:sender
{	
	//printf("in Inspector windowDidUpdate\n");
	[panel disableFlushWindow];
	[panel disableDisplay];
	if([panel isVisible]) [self updateInspector:nil];
	
	/* this will call loadData */
	[super windowDidUpdate:sender];
	[panel reenableDisplay];
	[panel display];
	[panel reenableFlushWindow];
	[panel flushWindow];
	return self;
}

@end

