/***************************************************************************
 * CLASS:		MiscDVInspector (MiscDragViewInspector)
 * 
 *	See the header file for more info about this class.
 ***************************************************************************/
 
#import "MiscViews.subproj/MiscIconWell.h"
#import "MiscDVInspector.h"


@implementation MiscDVInspector

// Load the Inspector.

- init
{
    char buf[MAXPATHLEN + 1];
    id bundle;
    
    [super init];
    
    bundle = [NXBundle bundleForClass:[MiscDragView class]];

    [bundle getPath: buf forResource: "MiscDVInspector" ofType:"nib"];

    [NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
		   
    return self;
}



// This is called to set the options located on the inspector to
// be the same as the current selected object.

- revert: sender
{	
	// set all the radio buttons for dragging options
	
	[ [optionMatrix cellAt: 0 :0] setState:[object allowSourceDragging] ];	
   	[ [optionMatrix cellAt: 1 :0] setState:[object allowDestinationDragging] ];	
  	[ [optionMatrix cellAt: 2 : 0] setState: [object acceptForeignDrag] ];
	[ [optionMatrix cellAt: 3 : 0] setState: [object acceptLocalDrag] ];	
	[ [optionMatrix cellAt: 4 : 0] setState: [object acceptSelfDrag] ];		
	[ [optionMatrix cellAt: 5 : 0] setState: [object retainData] ];	
	
	[optionMatrix display];	// get matrix to redisplay values
	
	// set the border type
	
	[borderMatrix selectCellWithTag: [object borderType] ];
	
	[borderMatrix display];
		
    return [super revert:sender];
}



// This method is called when one of the buttons in the inspector
// is clicked. The object is then notified of the change so that
// it can change it's state.

- optionsChanged: sender
{
  BOOL  state = [ [sender selectedCell] state];
  
  	switch ([ [sender selectedCell] tag])
    {
	  case 0:					
	  	[object setAllowSourceDragging: state];
		break;
	  case 1: 					
	  	[object setAllowDestinationDragging: state];
		break;
	  case 2:
	  	[object setAcceptForeignDrag: state];
		break;
	  case 3:
	  	[object setAcceptLocalDrag: state];
		break;
	  case 4:
	  	[object setAcceptSelfDrag: state];
		break;
	  case 5:
	  	[object setRetainData: state];
	 }
	 
	return [super ok: sender];
}



- borderChanged: sender
{
	[object setBorderType: [ [borderMatrix selectedCell] tag] ];
	
	return [super ok: sender];
}



// Determines whether the inspector panel will have an "OK" and
// "Revert" button. 

- (BOOL)wantsButtons
{
    return NO;
}


@end
