
/*
   MiscArrowButtonInspector.m
*/

#import <AppKit/AppKit.h>

#import <MiscAppKit/MiscArrowButton.h>
#import "MiscArrowButtonInspector.h"
#import "MiscArrowButtonAndGaugeView.h"

@implementation MiscArrowButtonInspector

- (id) init
/*"
   Load the Inspector.
"*/
{
    NSString* inspectorNibPath;
    id bundle;
    
    [super init];
    
    bundle = [NSBundle bundleForClass:[MiscArrowButtonAndGaugeView class]];
    inspectorNibPath = [bundle pathForResource:@"MiscABInspector" 
     	ofType:@"nib"];

    [NSBundle loadNibFile:inspectorNibPath externalNameTable:
	[NSDictionary dictionaryWithObjectsAndKeys:self, @"NSOwner", nil] 
	withZone:[self zone]];
		   
    return self;
}


- (void) revert:sender
/*"
   This method sets all the values in the inspector by getting
   the relevant info from the object. This is called when the
   inspector first appears, so the object's attributes are
   correctly displayed in the inspector.
"*/
{	
	// Set all the options.

    [[optionMatrix cellAtRow:0 column:0]
   	setState:[[self object] isBordered]];
    [[optionMatrix cellAtRow:1 column:0] 
	setState:[[self object] isTransparent]];
    [[optionMatrix cellAtRow:2 column:0] 
	setState:[[self object] isContinuous]];
    [[optionMatrix cellAtRow:3 column:0] 
	setState:![[self object] isEnabled]];
    [[optionMatrix cellAtRow:4 column:0] 
	setState:[[self object] state]];	

	[optionMatrix display];

    // Set the title, altTitle, and sound in the inspector.

    [tagField setIntValue:[[self object] tag]];
    [titleField setStringValue:[[self object] title]];
    [altTitleField setStringValue:[[self object] alternateTitle]];
//   [soundField setStringValue:[[[self object] sound] name]];

    [alignMatrix selectCellWithTag:[[self object] arrowAlignment]];
    [alignMatrix display];

    [super revert:sender];
}


- (void) optionsChanged:sender
/*"
   One of the checkbox buttons was clicked, so change the corresponding
   attribute of the object being inspected.
"*/
{
  NSCell* cell = [sender selectedCell];
  BOOL state = [cell state];

    switch ([cell tag]) {
      case 0:		// bordered			
        [[self object] setBordered:state];
        break;

      case 1:		// transparent
        [[self object] setTransparent:state];
        break;

      case 2:		// continuous
        [[self object] setContinuous:state];
        break;

      case 3:		// disabled		
        [[self object] setEnabled:!state];
        break;

      case 4:		// selected
        [[self object] setState:state];
        break;
    }
            
    [super ok:sender];
}


- (void) tagChanged: sender
/*"
	The tag FormCell in the inspector has changed so update the
	object.
"*/
{
    [[self object] setTag:[sender intValue]];
    [super ok:sender];
}


- (void) titleChanged: sender
/*"
	The title FormCell in the inspector has changed.
"*/
{
    [[self object] setTitle:[sender stringValue]];
    [super ok:sender];
}


- (void) altTitleChanged: sender
/*"
	The alt title FormCell in the inspector has changed.
"*/
{
    [[self object] setAlternateTitle:[sender stringValue]];
    [super ok:sender];
}		


- (void) soundChanged: sender
{
//    [[self object] setSound:[Sound findSoundFor:[sender stringValue]]];
    [super ok:sender];
}


- (void) alignmentChanged: sender
/*"
	The alignment matrix has changed so update the arrow button.
"*/
{
    [[self object] setArrowAlignment: [sender selectedTag] ];
    [super ok:sender];
}


- (BOOL) wantsButtons
/*"
	We return NO since we don't want no "OK" and "REVERT" buttons
	cluttering up our fine and dandy inspector.
"*/
{
	return NO;
}

@end

