/* Implementation of CustomView class
 *
 * Copyright (C)  1993  The Board of Trustees of  
 * The Leland Stanford Junior University.  All Rights Reserved.
 *
 * Authors: Paul Kunz and Imran Qureshi
 *
 * This file is part of an Objective-C class library for a window system
 *
 * CustomView.m,v 1.15 1995/06/13 21:49:57 briggs Exp
 */


#include "CustomView.h"

#include <objc/objc-api.h>
#include <stdlib.h>

/* From Application.m */
extern id  nibOwner;


  
@implementation CustomView
- initFrame:(const NXRect *)frameRect
{	
	Class	theClass;

	if (realObject) {
		fprintf(stderr, "CustomView: object already exists\n");
		return self;
	}
	if (strcmp(realClassName,"FileOwner")==0) {
		realObject = nibOwner;
		return self;
	}
		
	theClass = objc_get_class(realClassName);
	realObject = [[theClass alloc] initFrame:frameRect];
	instancename = "CustomView";
	return self;
} 

- write:(TypedStream *)stream
{
	[super write:stream];
	objc_write_type(stream,"*", realClassName);
	return self;
}
- read:(TypedStream *)stream
{
	[super read:stream];
	objc_read_type(stream,"*",&realClassName);
	return self;

}
- awake
{
	if (amAwake) {
		return self;
	}
	amAwake = YES;
        [self initFrame:&frame];
	return self;
}
-awakeFromNib
{
	if ( [realObject respondsTo:@selector(awakeFromNib)] ) {
		 [realObject awakeFromNib];
	}
	return self;
}

-nibInstantiate
{
	 return realObject;
}

@end
