#import "DocumentController.h"
#import "StringStorage.h"

@implementation DocumentController

- init
{
   [super init];

   docType = [[StringStorage alloc] init];
   panel = nil;
   return self;
}

-free
{
   [docType free];
   return [super free];
}


- setDocType: (const char *) str
{
   [docType setStringValue: str];
   return self;
}

- makeKeyAndOrderFront:sender
{
   if(!panel)
   {
      char buf[MAXPATHLEN + 1];

      if(!*[docType stringValue])
      {
	 NXLogError("Opening a document with unknown nib name.");
	 return nil;
      }


      [[NXBundle bundleForClass:[self class]] 
            getPath: buf forResource: [docType stringValue] ofType:"nib"];
   
      [NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
   }
   
   [panel makeKeyAndOrderFront: sender];
   return self;
}

@end
