
/* Generated by Interface Builder */

#import <stdio.h>
#import <sys/param.h>
#import <appkit/Application.h>
#import <appkit/Panel.h>
#import <appkit/Cell.h>
#import <appkit/Button.h>
#import <appkit/PopUpList.h>
#import <appkit/Text.h>
#import <appkit/ScrollView.h>
#import "GraphicApp.h"
#import "HelpControl.h"

@implementation HelpControl

- loadHelpPage: (const char *)page
{
	char			buffer[MAXPATHLEN];
	NXStream	*myStream;
	FILE		*myFile;
		
	fprintf(stderr, "And let's set up the file to view\n");
	sprintf(buffer, "%s/Help/%s.rtf", (char *)[NXApp appPath], page); 
	fprintf(stderr, "Attempting to open %s\n", buffer);
	myFile = fopen(buffer, "r");
	if (myFile) { 
		fprintf(stderr, "File opened\n");
		myStream = NXOpenFile(fileno(myFile), NX_READONLY);
		if (myStream) {
			fprintf(stderr, "Stream opened\n");
			[[textPanel docView] readRichText: myStream];
			NXClose(myStream);
		}
		fclose(myFile);
	}

	return self;
}

- popClick
{
	[self loadHelpPage: [myPopUp selectedItem]];

	return self;
}


+ new
{
	self = [super new];
	
	return self;
}

- setTextPanel:anObject
{
	textPanel = anObject;

	[self loadHelpPage: "Title Page"];

	return self;
}

- setPopUpButton:anObject
{
	popUpButton = anObject;

	myPopUp = [popUpButton target];
	[myPopUp init];
	[myPopUp addItem: "Title Page"];
	[myPopUp addItem: "Overview"];
	[myPopUp addItem: "Menus"];
	[myPopUp addItem: "Programming"];
	[myPopUp addItem: "Bug List"];
	[myPopUp addItem: "Revision History"];
	[myPopUp addItem: "Copyrights"];
	[myPopUp addItem: "Last Words"];
	[myPopUp setAction: @selector(popClick)];
	[myPopUp setTarget: self];
	[popUpButton setTitle: "Title Page"];

	return self;
}

@end
