// Copyright (C) 1995
// Use is governed by the MiscKit license

#import <misckit/MiscSwapView.h>
#import "MiscSVInspector.h"

@implementation MiscSVInspector

- (id)init
/*"
    Initializes the object by loading the NIB file to set up all references. 
"*/
{
    self = [super init];
    if( !self ) return nil;

    // <<HACK>> This propably would suit a lot better into the -window method...but since there is no docu
    // it is hard to tell if window will be called  before we get any revert/ok messages.
    // Until we know...we'll just leave it here. Since inspectors are loaded on demand it might not make
    // a big difference anyway.
    
    [NSBundle loadNibNamed:@"MiscSVInspector" owner:self];
    
    return self;
}

- (void)revert:(id)sender
/*"
    Ask our object for its attributes and update the inspector controls accordingly.
"*/
{
    // First we'll deactive the color well. I am not really satisfied with that solution since
    // it should be deactiveted when our inspector view gets swapped out...since the color well will remain active
    // now until we swap in again...anyway.. it works.
    // The uglyness of this solution shows up when you switch from one swapView to another and always have
    // to reactivate the color well.
    
    [backgroundColorWell deactivate];
    [backgroundColorWell setColor:[[self object] backgroundColor]];

    [backgroundDrawingSwitch setState:[[self object] drawsBackground]];

    [[optionMatrix cellAtRow:0 column:0] setState:[[self object] doesTagComparison]];
 // [[optionMatrix cellAtRow:1 column:0] setState:[[self object] doesUseBuffering]];
    [optionMatrix display];	
}

- (void)colorChanged:(id)sender
{
    [[self object] setBackgroundColor:[backgroundColorWell color]];
    [[self object] setDrawsBackground:[backgroundDrawingSwitch state]];
    [[self object] display];

    // I don't know what ok does...but its not bad idea to call it since usually that is the place where you
    // registered that some changes have happened.
    

    [self ok:sender];
}

- (void)optionChanged:(id)sender
{
    switch( [[optionMatrix selectedCell] tag] )
    {
        case 0:		
            [[self object] setTagComparison:[[optionMatrix cellAtRow:0 column:0] state]];
            break;

        // case 1:		
        //    [[self object] setUseBuffering: [ [optionMatrix cellAtRow:1 column:0] state ] ];
        //    break;
    }
    // I don't know what ok does...but its not bad idea to call it since usually that is the place where you
    // registered that some changes have happened.
    
    [self ok:sender];
}

- (BOOL)wantsButtons
{
    return NO;
}

@end


@implementation MiscSwapView (IBInspector)

- (NSString *)inspectorClassName;
{
    return @"MiscSVInspector";
}

@end
