
/* Generated by Interface Builder */

#import "NewInspector.h"
#import <appkit/Box.h>
#import <appkit/Button.h>
#import <appkit/PopUpList.h>
#import <appkit/Matrix.h>

@implementation NewInspector

static id theInspector = nil;

/* makes sure there is only one instantiation of this object */
+ new
{
	if (!theInspector) {
		theInspector = self = [super new];
		[NXApp loadNibSection:"NewInspector.nib" owner:self];
		[self init];
	} else
		self = theInspector;
		
    return self;
}

-init
{
	//[super init];
		
	ViewsList = [[List alloc] init];
	SupervisorList = [[List alloc] init];
	
	
	thePopUpList = [thePopUpListButton target];
	[thePopUpList setTarget:self];
	[thePopUpList setAction:@selector(toggleInspectorPanels:)];
	[thePopUpList removeItemAt:0];  
	/* IB comes up with atleast one item in the popupList. We do this to get rid of that.*/
	
	return self;
}

-inspectorPanel
{
	return InspectorPanel;
}

-free
{
	[ViewsList free];
	[SupervisorList free];
	[InspectorPanel orderOut:self];
	return [super free];
}
- orderFrontPanel:sender
{
	[InspectorPanel orderFront:self];
    return self;
}
- orderBackPanel:sender
{
	[InspectorPanel orderBack:self];
    return self;
}

-setTitle:(char *)theTitle
{
	[InspectorPanel setTitle:theTitle];
	return self;
}
-addView:(id)aView withName:(char *)Name withSupervisor:(id)aSupervisor
{
	[ViewsList addObject:aView];
	[SupervisorList addObject:aSupervisor];
	
	[thePopUpList addItem:Name];
	
	[InspectorBox setContentView:aView];
	[InspectorBox display];
	
	[thePopUpListButton setTitle:Name];
	return self;
}

-remove:(char *)Name
{
	int	i;
	
	i = [thePopUpList indexOfItem:Name];
	[thePopUpList removeItemAt:i];
	[ViewsList removeObjectAt:i];
	return self;
}

-show:(char *)Name
{
	int	i;
	
	i = [thePopUpList indexOfItem:Name];
	[thePopUpListButton setTitle:Name];
	[InspectorBox setContentView:[ViewsList objectAt:i]];
	[InspectorBox display];
	return self;

}

-updateDisplay
{
	[InspectorBox display];
	return self;
}
- windowDidUpdate:sender
{
	[SupervisorList makeObjectsPerform:@selector(windowDidUpdate:) with:sender];
	return self;
}
-toggleInspectorPanels:sender
{
	int i;
	
	i = [sender selectedRow];
	[InspectorBox setContentView:[ViewsList objectAt:i]];
	[InspectorBox display];
	return self;
}


@end
