/*
*	menu.c
*
*	NewMenus for OneKeyII.
*
*	MWS, 3/92.
*/

#include <exec/types.h>
#include <intuition/intuition.h>
#include <libraries/gadtools.h>
#include <proto/gadtools.h>
#include "menu.h"

static struct NewMenu gt_items[] = {
	{ NM_TITLE, "OneKeyII",	NULL, 0, 0, NULL },
	{ NM_ITEM,  "Toggle Mode",      "T", MENUTOGGLE+CHECKIT, 0, NULL },
/*	{ NM_ITEM,  "Cold Reset...",	NULL,0, 0, NULL },*/
	{ NM_ITEM,  "About...",		"A", 0, 0, NULL },
	{ NM_ITEM,   NM_BARLABEL },
	{ NM_ITEM,  "Hide",		"H", 0, 0, NULL },
	{ NM_ITEM,  "Quit",		"Q", 0, 0, NULL },

	{ NM_END }
};

static APTR vi;			/* visual info for gadtools */
static struct Menu *menu;

void FreeOneKeyMenu()		/* free all menustrips and related data */
{
	if (menu) FreeMenus(menu);
	if (vi) FreeVisualInfo(vi);
}

struct Menu *
AllocOneKeyMenu(struct Window *window)	/* allocate menustrips required by program */
{
	if ((menu = CreateMenusA(gt_items, NULL)) &&
	    (vi = GetVisualInfoA(window->WScreen, NULL)) &&
 	    (LayoutMenusA(menu, vi, NULL)))
		return menu;

	FreeOneKeyMenu();	/* something failed... */
	return NULL;
}
