
/* Generated by Interface Builder */
// Uncopyrighted by Eric Celeste, 1991 <efc@mit.edu>

#import "ScrollTextFieldInspector.h"
#import "ScrollTextField.h"
#import <appkit/Application.h>
#import <appkit/TextFieldCell.h>
#import <appkit/TextField.h>
#import <appkit/Matrix.h>
#import <appkit/Window.h>
#import <appkit/Text.h>
#import <appkit/Box.h>

@implementation ScrollTextFieldInspector
/* << The first two class methods don't get inherited >> */

+ finishLoading:(struct mach_header *) hdr {
    NIBDidLoadClass(self, hdr);
    return nil;
}

+ startUnloading
{
    NIBWillUnloadClass(self);
    return nil;
}

- init
{
    [super init];
    [NXApp loadNibSection:"ScrollTextFieldInspector.nib" owner:self];
    return self;
}


- ok:sender
{
	int t;
	
    [[NXApp mainWindow] makeFirstResponder:[NXApp mainWindow]];
    [window endEditingFor:self];

    if ((t = [[backGrayMatrix selectedCell] tag]) == 0) {
		[object setBackgroundGray:-1.0];
    } else {
		[object setBackgroundGray:(t - 1) / 3.0];
    }

    [object setTextGray:[[textGrayMatrix selectedCell] tag] / 3.0];

	[object setBorderType:[[borderMatrix selectedCell] tag]];
	
	[object setEditable:(t = [[optionsMatrix cellAt:1 :0] state])];
	[object setMonofont:[[optionsMatrix cellAt:2 :0] state]];

	[[optionsMatrix cellAt:0 :0] setEnabled:(!t)];
	if (t) {
		[object setSelectable:t];
	} else {
		[object setSelectable:[[optionsMatrix cellAt:0 :0] state]];
	}

    return[super ok:sender];
}

- revert:sender
{
    [window endEditingFor:self];

    if ([object backgroundGray] < 0.0) {
		[backGrayMatrix selectCellAt:0 :0];
    } else {
		[backGrayMatrix selectCellAt:0 :([object backgroundGray] * 3.0) + 1];
    }
	
    [textGrayMatrix selectCellAt:0 :([object textGray] * 3.0)];

    [borderMatrix selectCellAt:0 :[object borderType]];

	[[optionsMatrix cellAt:2 :0] setState:[object isMonofont]];
	[[optionsMatrix cellAt:1 :0] setState:[object isEditable]];
	
	[[optionsMatrix cellAt:0 :0] setEnabled:(![object isEditable])];
	if ([object isEditable]) {
		[[optionsMatrix cellAt:0 :0] setState:YES];
	} else {
		[[optionsMatrix cellAt:0 :0] setState:[object isSelectable]];
	}
	
    return[super revert:sender];
}

- setOptionsSelectable:sender
{
	BOOL x;
	
	x = [[sender selectedCell] state];
	[[optionsMatrix cellAt:0 :0] setEnabled:(! x)];
	if (x) {
		[[optionsMatrix cellAt:0 :0] setState:(x)];
	}
	
	return self;
}
@end
