/*
 *	Menus.c - Copyright © 1990 by S.R. & P.C.
 *
 *	Created:	16 Jun 1990
 *	Modified:	20 Nov 1990  21:13:18
 *
 *	Make>> make
 */

extern struct WBStartup *WBenchMsg;


static struct IntuiText SubText2 = {
	3,2,JAM1,	/* front and back text pens, drawmode and fill byte */
	22,1,		/* XY origin relative to container TopLeft */
	NULL,		/* font pointer or NULL for default */
	(UBYTE *)"Shell",	/* pointer to text */
	NULL		/* next IntuiText structure */
};

static struct MenuItem SubItem2 = {
	NULL,		/* next SubItem structure */
	104,10,		/* XY of Item hitbox relative to TopLeft of parent hitbox */
	72,10,		/* hit box width and height */
	CHECKIT+ITEMTEXT+ITEMENABLED+HIGHCOMP,	/* Item flags */
	1,			/* each bit mutually-excludes a same-level Item */
	NULL,	/* Item render  (IntuiText or Image or NULL) */
	NULL,		/* Select render */
	NULL,		/* alternate command-key */
	NULL,		/* no SubItem list for SubItems */
	MENUNULL	/* filled in by Intuition for drag selections */
};

static struct IntuiText SubText1 = {
	3,2,JAM1,	/* front and back text pens, drawmode and fill byte */
	22,1,		/* XY origin relative to container TopLeft */
	NULL,		/* font pointer or NULL for default */
	(UBYTE *)"Simple",	/* pointer to text */
	NULL		/* next IntuiText structure */
};

struct MenuItem SubItem1 = {
	NULL,	/* next SubItem structure */
	104,0,		/* XY of Item hitbox relative to TopLeft of parent hitbox */
	72,10,		/* hit box width and height */
	CHECKIT+ITEMTEXT+ITEMENABLED+HIGHCOMP+CHECKED,	/* Item flags */
	2,			/* each bit mutually-excludes a same-level Item */
	NULL,	/* Item render  (IntuiText or Image or NULL) */
	NULL,		/* Select render */
	NULL,		/* alternate command-key */
	NULL,		/* no SubItem list for SubItems */
	MENUNULL	/* filled in by Intuition for drag selections */
};


struct Menu Menu1 = {
	NULL,		/* next Menu structure */
	0,0,		/* XY origin of Menu hit box relative to screen TopLeft */
	48,0,		/* Menu hit box width and height */
	MENUENABLED,	/* Menu flags */
	"ParM",		/* text of Menu name */
	NULL		/* MenuItem linked list pointer */
};

static struct IntuiText Line = {
	2, 0, JAM1,	/* front and back text pens, drawmode and fill byte */
	0, 9,		/* XY origin relative to container TopLeft */
	NULL,		/* font pointer or NULL for default */
	(UBYTE *)"-------------",		/* pointer to text */
	NULL		/* next IntuiText structure */
};

static struct {
	char *MenuName;
	char Command;
	char line;
} MenuTab[] = {
	{"Open",'O',0},
	{"UpDate",'U',0},
	{"Std Cfg",0,1},
	{"Cmd Mode",0,0},
	{"Command",'C',1},
	{"Change Dir",0,1},
	{"Quit",'Q',0}
};

#define NUMBER_OF_ITEM 7

void CreateParMenu(short Color)
{
	struct MenuItem *mi,**miptr;
	struct IntuiText *it;
	struct Menu *ParM;
	short top = 0,i;

	ParM = &Menu1;
	miptr = &ParM->FirstItem;
	Line.FrontPen = Color;
	for( i=0 ; i<NUMBER_OF_ITEM ; i++ ) {
		mi = ArpAlloc(sizeof(struct MenuItem));
		it = ArpAlloc(sizeof(struct IntuiText));
		mi->ItemFill = (APTR)it;
		mi->Width = 104;
		mi->Height = 10;
		mi->TopEdge = top;
		mi->Flags = ITEMTEXT+ITEMENABLED+HIGHCOMP;
		if (MenuTab[i].Command) {
			mi->Command = MenuTab[i].Command;
			mi->Flags |= COMMSEQ;
		}
		top += 10;
		it->IText = (UBYTE *)MenuTab[i].MenuName;
		it->FrontPen = Color;
		it->LeftEdge = it->TopEdge = 1;
		if (MenuTab[i].line) {
			it->NextText = &Line;
			top += 5;
		}
		if (i == 3) {
			SubItem1.ItemFill = (APTR)&SubText1;
			SubText1.FrontPen = Color;
			SubItem1.NextItem = &SubItem2;
			SubItem2.ItemFill = (APTR)&SubText2;
			SubText2.FrontPen = Color;
			mi->SubItem = &SubItem1;
		}
		*miptr = mi;
		miptr = &mi->NextItem;
	}
}

