#if 0
-----------  YourWS_Inspector.h
Created 8-13-92 (Greg Burd)

History:
	
================= #import<std/disclaimer.h>
You may freely copy, distribute, and reuse the code in this example.
NeXT disclaims any warranty of any kind, expressed or  implied, as to its
fitness for any particular use.
_________________________
#endif


#import <appkit/Application.h>
#import <objc/NXBundle.h>
#import <sys/param.h>
#import "YourWS_Inspector.h"

#import "Text_Console.h"


@implementation YourWS_Inspector

// This is a class var to ensure only one copy of this object is created.
static id myself = nil;

// To make the + new method work just change the define below to
//   the main nib name that you are using.
#define MY_NIB_NAME "YourWS_Inspector"

/* ---- Responsible for loading the nib file */
+ new
{
    if (myself == nil) {
        char path[MAXPATHLEN+1];
        NXBundle *bundle = [NXBundle bundleForClass:self];
      
        self = myself = [super new];
        if ([bundle getPath:path 
                forResource:MY_NIB_NAME
                ofType:"nib"]) {
            [NXApp loadNibFile:path owner:myself];
        } else {
            fprintf (stderr, "Couldn't load %s.nib\n", MY_NIB_NAME);
            myself = nil;
        }
    }
    return myself;
}

/* ---- This is the main point of functionality: this method is
		called when the inspector is activited.
		must call [super revert:sender]
		Required in subclass */
- revert:sender
{	
	/* - Do your stuff - */
	[text printf:"--> -revert:sender\n"];
	
		//  You can change the names of the buttons in the inspector.
	[[super okButton] setTitle:"Say Hello"]; 
	
	//  The message [super revert:sender]; also makes the inspector window's
	//    'x' be complete. (eg. the window is not edited)
	/* then call super, this is required */
    [super revert:sender];
	return self;
}

/* ---- Optional, required if the inspector allows changing
		attributes of the selection
		must call [super ok:sender] */
- ok:sender
{
	/* call super ok:. This is required */
	[text printf:"--> -ok:sender\n"];
	[text printf:"Hello World!\n"];
	[text printf:"The window's 'x' should be closed.\n"];
	
	//  The message [super ok:sender]; also makes the inspector window's
	//    'x' be complete. (eg. the window is not edited)
	return [super ok:sender];
}

/* ---- Optional -
		marks the window as edited; When defined lets subclass reject touch: */
- touch:sender
{
	[text printf:"--> -touch:sender\n"];
	[text printf:"The window's 'x' should be open.\n"];
	
	//  This is making the window's 'x' open, as if there has been some
	//    editing.  The message touch: is sent automatically by textDidChange:.
	return [super touch:sender];
}
    
/* ---- Optional -
		calls touch; facilitates NIB connections of the textDelegates */
- textDidChange:sender
{
	[text printf:"--> -textDidChange:sender\n"];
	return self;
}

/*---------------------------------------*/

- setEdited:sender
{
	[text printf:"--> -setEdited:sender\n"];
	[self touch:self];
	
	return self;
}

@end
