/* Menus.c
   Copyright (c) 1990,1991,1992 by Thomas E. Janzen
   All Rights Reserved

   THIS SOFTWARE IS FURNISHED FREE OF CHARGE FOR STUDY AND USE AND MAY
   BE COPIED ONLY FOR PERSONAL USE OR COMPLETELY AS OFFERED WITH NO
   CHANGES FOR FREE DISTRIBUTION.  NO TITLE TO AND OWNERSHIP OF THE
   SOFTWARE IS HEREBY TRANSFERRED.  THOMAS E. JANZEN ASSUMES NO 
   RESPONSBILITY FOR THE USE OR RELIABILITY OF THIS SOFTWARE.
   
   Thomas E. Janzen
   58A School St. Apt. 2-L
   Hudson, MA 01749
   (508)562-1295
*/
/*
**  FACILITY:
**
**	AlgoRhythms music improviser on Commodore (TM) Amiga (TM)
**	compiled with SAS/C V5.10b
**
**  ABSTRACT:
**
**	Menus.c manages menu set-up and interaction.
**
**  AUTHORS: Thomas E. Janzen
**
**  CREATION DATE:	26-MAR-1990
**
**  MODIFICATION HISTORY:
**    DATE	NAME	DESCRIPTION
**    19 OCT 91 T. Janzen add menu name niceties.
**  4 Jan 92 TEJ  last changes for 2.0
**--
*/

#include <stdio.h>
#include <intuition/intuition.h>
#include <graphics/text.h>
#include <proto/dos.h>
#include <proto/graphics.h>
#include <proto/exec.h>
#include <proto/mathffp.h>
#include <proto/intuition.h>
#include "Window.h"
#include "AlgoRhythms.h"

#define PROJTITLWID  68 /* width of project menu header                 */
#define FORMTITLWID  48 /* width of form menu header                    */
#define SCALETITLWID 48 /* width of scale title header                  */
#define PROJECTWIDTH (105 + COMMWIDTH)    /* width of project menu items*/
#define FORMWIDTH    (108 + COMMWIDTH)   /* width of form menu items    */
#define SCALEWIDTH   125 /* width of scale menu items                   */
#define SUBWIDTH     106 /* width of form sub-menu items                */
#define VOICEWIDTH   87

/*Voice items*/

static char voice_string[MAXVOICE][16];
static struct IntuiText voice_txt[MAXVOICE];
static struct MenuItem voice_item[MAXVOICE];

const char ChannelMenuString[16] = "Voices";
static struct Menu ChannelMenu  =
	{NULL, PROJTITLWID + FORMTITLWID + SCALETITLWID, 0, 
	80, 0, MIDRAWN | MENUENABLED, 
	ChannelMenuString, &voice_item[0]};

/*
** Scale Menu 
*/

const char QuintalString[16] = "Quintal"; /* 19 */
const static struct IntuiText QuintalTxt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, QuintalString, NULL};
static struct MenuItem QuintalItem = 
	{NULL, 0, 160, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), 
   ~(0xFFE00001 + (1 << 20)), 
	(APTR)&QuintalTxt, NULL, 0, NULL, 0};

const char QuartalString[16] = "Quartal"; /* 18 */
const static struct IntuiText QuartalTxt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, QuartalString, NULL};
static struct MenuItem QuartalItem = 
	{&QuintalItem, 0, 152, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), 
   ~(0xFFE00001 + (1 << 19)), 
	(APTR)&QuartalTxt, NULL, 0, NULL, 0};

const char M3m2String[16] = "M 3rd m 2nd"; /* 18 */
const static struct IntuiText M3m2Txt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, M3m2String, NULL};
static struct MenuItem M3m2Item = 
	{&QuartalItem, 0, 144, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), 
   ~(0xFFE00001 + (1 << 18)), 
	(APTR)&M3m2Txt, NULL, 0, NULL, 0};

const char MTSString[16] = "m 3rd M 2nd"; /* 17 */
const static struct IntuiText MTSTxt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, MTSString, NULL};
static struct MenuItem MTSItem = 
	{&M3m2Item, 0, 136, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), 
   ~(0xFFE00001 + (1 << 17)), 
	(APTR)&MTSTxt, NULL, 0, NULL, 0};

const char Mode7String[16] = "Mode 7"; /* 16 */
const static struct IntuiText Mode7Txt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, Mode7String, NULL};
static struct MenuItem Mode7Item = 
	{&MTSItem, 0, 128, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), 
   ~(0xFFE00001 + (1 << 16)), 
	(APTR)&Mode7Txt, NULL, 0, NULL, 0};

const char Mode6String[16] = "Mode 6"; /* 15 */
const static struct IntuiText Mode6Txt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, Mode6String, NULL};
static struct MenuItem Mode6Item = 
	{&Mode7Item, 0, 120, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), 
   ~(0xFFE00001 + (1 << 15)), 
	(APTR)&Mode6Txt, NULL, 0, NULL, 0};

const char Mode5String[16] = "Mode 5"; /* 14 */
const static struct IntuiText Mode5Txt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, Mode5String, NULL};
static struct MenuItem Mode5Item = 
	{&Mode6Item, 0, 112, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), ~(0xFFE00001 + 16384), 
	(APTR)&Mode5Txt, NULL, 0, NULL, 0};

const char Mode4String[16] = "Mode 4"; /* 13 */
const static struct IntuiText Mode4Txt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, Mode4String, NULL};
static struct MenuItem Mode4Item = 
	{&Mode5Item, 0, 104, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), ~(0xFFE00001 + 8192), 
	(APTR)&Mode4Txt, NULL, 0, NULL, 0};

const char Mode3String[16] = "Mode 3"; /* 12 */
const static struct IntuiText Mode3Txt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, Mode3String, NULL};
static struct MenuItem Mode3Item = 
	{&Mode4Item, 0, 96, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), ~(0xFFE00001 + 4096), 
	(APTR)&Mode3Txt, NULL, 0, NULL, 0};

const char LongPentaString[16] = "Long Pentatonic"; /* 11 */
const static struct IntuiText LongPentaTxt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, LongPentaString, NULL};
static struct MenuItem LongPentaItem = 
	{&Mode3Item, 0, 88, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), ~(0xFFE00001 + 2048), 
	(APTR)&LongPentaTxt, NULL, 0, NULL, 0};

const char DiminishedString[16] = "Diminished"; /* 10 */
const static struct IntuiText DiminishedTxt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, DiminishedString, NULL};
static struct MenuItem DiminishedItem = 
	{&LongPentaItem, 0, 80, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), ~(0xFFE00001 + 1024), 
	(APTR)&DiminishedTxt, NULL, 0, NULL, 0};

const char HungarianString[16] = "Hungarian Minor"; /* 9 */
const static struct IntuiText HungarianTxt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, HungarianString, NULL};
static struct MenuItem HungarianItem = {&DiminishedItem, 0, 72, 
		CHECKWIDTH + 129, 8, 
		(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), ~(0xFFE00001 + 512), 
	(APTR)&HungarianTxt, NULL, 0, NULL, 0};

const char HarmonicString[16] = "Harmonic Minor"; /* 8 */
const static struct IntuiText HarmonicTxt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, HarmonicString, NULL};
static struct MenuItem HarmonicItem = {&HungarianItem, 0, 64, 
    CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), ~(0xFFE00001 + 256), 
	(APTR)&HarmonicTxt, NULL, 0, NULL, 0};

const char DiatonicString[16] = "Diatonic"; /* 7 */
const static struct IntuiText DiatonicTxt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, DiatonicString, NULL};
static struct MenuItem DiatonicItem = {&HarmonicItem, 0, 56, 
    CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), ~(0xFFE00001 + 128), 
	(APTR)&DiatonicTxt, NULL, 0, NULL, 0};

const char WholeToneString[16] = "Whole Tone"; /* 6 */
const static struct IntuiText WholeToneTxt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, WholeToneString, NULL};
static struct MenuItem WholeToneItem = 
   {&DiatonicItem, 0, 48, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), ~(0xFFE00001 + 64), 
	(APTR)&WholeToneTxt, NULL, 0, NULL, 0};

const char KokinString[16] = "kokin joshi"; /* 5 */
const static struct IntuiText KokinTxt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, KokinString, NULL};
static struct MenuItem KokinItem = 
   {&WholeToneItem, 0, 40, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), ~(0xFFE00001 + 32), 
	(APTR)&KokinTxt, NULL, 0, NULL, 0};

const char KumoiString[16] = "kumoi joshi"; /* 4 */
const static struct IntuiText KumoiTxt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, KumoiString, NULL};
static struct MenuItem KumoiItem = 
   {&KokinItem, 0, 32, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), ~(0xFFE00001 + 16), 
	(APTR)&KumoiTxt, NULL, 0, NULL, 0};

const char HiraString[16] = "hira joshi"; /* 3 */
const static struct IntuiText HiraTxt = 
	{2, 1, JAM1, CHECKWIDTH, 0, &font_choice, HiraString, NULL};
static struct MenuItem HiraItem = {&KumoiItem, 0, 24, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), ~(0xFFE00001 + 8), 
	(APTR)&HiraTxt, NULL, 0, NULL, 0};

const char ShortPentaString[32] = "Short Pentatonic"; /* 2 */
const static struct IntuiText ShortPentaTxt = 
   {2, 1, JAM1, CHECKWIDTH, 0, &font_choice, ShortPentaString, NULL};
static struct MenuItem ShortPentaItem = 
   {&HiraItem, 0, 16, CHECKWIDTH + 129, 
	8, (CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), ~(0xFFE00001 + 4), 
	(APTR)&ShortPentaTxt, NULL, 0, NULL, 0};

const char ChromaticString[16] = "Chromatic"; /* 1 */
const static struct IntuiText ChromaticTxt = 
   {2, 1, JAM1, CHECKWIDTH, 0, &font_choice, ChromaticString, NULL};
static struct MenuItem ChromaticItem = 
   {&ShortPentaItem, 0, 8, CHECKWIDTH + 129, 8, 
	(CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED), ~(0xFFE00001 + 2), 
	(APTR)&ChromaticTxt, NULL, 0, NULL, 0};

const char TransposeString[16] = "Transpose..."; /* 0 */
const static struct IntuiText TransposeTxt = 
	{2, 1, JAM1, 0, 0, &font_choice, TransposeString, NULL};
static struct MenuItem TransposeItem = 
	{&ChromaticItem, 0, 0, CHECKWIDTH + 129, 8, 
		(ITEMTEXT | HIGHCOMP | COMMSEQ | ITEMENABLED), 
		0, (APTR)&TransposeTxt, NULL, (BYTE)'T', NULL, 0};

const char ScaleString[16] = "Scale";
static struct Menu ScaleMenu  =
	{&ChannelMenu, PROJTITLWID + FORMTITLWID, 0,
	SCALETITLWID, 0, MIDRAWN | MENUENABLED,
	ScaleString, &TransposeItem};

/*End of Scales*/

/* 
** Character menus 
*/

const char MeanPeriodString[16] = "Mean Period...";
static struct IntuiText MeanPeriodTxt = 
	{2, 1, JAM1, 0, 0, &font_choice, MeanPeriodString, NULL};
static struct MenuItem MeanPeriodItem = {NULL, 
	FORMWIDTH - 2, 0, SUBWIDTH, 8, 
	(ITEMTEXT | HIGHCOMP | ITEMENABLED), 0, (APTR)&MeanPeriodTxt, 
	NULL, 0, NULL, 0};

const char MeanPhaseString[16] = "Mean Phase...";
const static struct IntuiText MeanPhaseTxt = 
	{2, 1, JAM1, 0, 0, &font_choice, MeanPhaseString, NULL};
static struct MenuItem MeanPhaseItem = {&MeanPeriodItem, 
	FORMWIDTH - 2, 8, SUBWIDTH, 8, 
	(ITEMTEXT | HIGHCOMP | ITEMENABLED), 0, (APTR)&MeanPhaseTxt, 
	NULL, 0, NULL, 0};

const char SpreadPeriodString[18] = "Spread Period...";
const static struct IntuiText SpreadPeriodTxt = 
	{2, 1, JAM1, 0, 0, &font_choice, SpreadPeriodString, NULL};
static struct MenuItem SpreadPeriodItem = {&MeanPhaseItem, 
	FORMWIDTH - 2, 16, SUBWIDTH, 8, 
	(ITEMTEXT | HIGHCOMP | ITEMENABLED), 0, 
	(APTR)&SpreadPeriodTxt, NULL, 0, NULL, 0};

const char SpreadPhaseString[16] = "Spread Phase...";
const static struct IntuiText SpreadPhaseTxt = 
	{2, 1, JAM1, 0, 0, &font_choice, SpreadPhaseString, NULL};
static struct MenuItem SpreadPhaseItem = {&SpreadPeriodItem, 
	FORMWIDTH - 2, 24, SUBWIDTH, 8, 
	(ITEMTEXT | HIGHCOMP | ITEMENABLED), 0, (APTR)&SpreadPhaseTxt, 
	NULL, 0, NULL, 0};

const char RandomizeString[16] = "Randomize";
const static struct IntuiText RandomizeTxt = 
	{2, 1, JAM1, 0, 0, &font_choice, RandomizeString, NULL};
static struct MenuItem RandomizeItem = {&SpreadPhaseItem, 
	FORMWIDTH - 2, 32, SUBWIDTH, 8, 
	(ITEMTEXT | HIGHCOMP | ITEMENABLED), 0, (APTR)&RandomizeTxt, 
	NULL, 0, NULL, 0};

const char MaxVoicesString[] = "Max Voices...";
const static struct IntuiText MaxVoicesTxt = {2, 1, JAM1, 0,0,&font_choice,
	MaxVoicesString, NULL};
static struct MenuItem MaxVoicesItem = {NULL, 0, 0, FORMWIDTH, 8, 
	(ITEMTEXT | COMMSEQ | HIGHCOMP | ITEMENABLED), 0, 
	(APTR)&MaxVoicesTxt, NULL, (BYTE)'V', NULL, 0};

const char ReDrawString[10] = "Redraw...";
const static struct IntuiText ReDrawTxt = 
   {2, 1, JAM1, 0, 0, &font_choice, ReDrawString, NULL};
static struct MenuItem ReDrawItem = {&MaxVoicesItem, 0, 8, FORMWIDTH, 8, 
	(ITEMTEXT | COMMSEQ | HIGHCOMP | ITEMENABLED), 0, (APTR)&ReDrawTxt, 
	NULL, (BYTE)'R', NULL, 0};

const char PulseString[16] = "Pulse...";
const static struct IntuiText PulseTxt = 
   {2, 1, JAM1, 0, 0, &font_choice, PulseString, NULL};
static struct MenuItem PulseItem = {&ReDrawItem, 0, 16, FORMWIDTH, 8, 
	(ITEMTEXT | COMMSEQ | HIGHCOMP | ITEMENABLED), 0, 
   (APTR)&PulseTxt, NULL, (BYTE)'N', NULL, 0};

const char DurationString[16] = "Duration...";
const static struct IntuiText DurationTxt = 
	{2, 1, JAM1, 0, 0, &font_choice, DurationString, NULL};
static struct MenuItem DurationItem = {&PulseItem, 0, 24, FORMWIDTH, 8, 
	(ITEMTEXT | COMMSEQ | HIGHCOMP | ITEMENABLED), 0, (APTR)&DurationTxt, 
	NULL, (BYTE)'D', NULL, 0};

const char PitchString[16] = "Pitch         \273";
const static struct IntuiText PitchTxt = 
   {2, 1, JAM1, 0, 0, &font_choice, PitchString, NULL};
static struct MenuItem PitchItem = {&DurationItem, 0, 32, FORMWIDTH, 8, 
	(ITEMTEXT | HIGHCOMP | ITEMENABLED), 0, (APTR)&PitchTxt, NULL, 0, 
	&RandomizeItem, 0};

const char RhythmString[16] = "Rhythm        \273";
const static struct IntuiText RhythmTxt = 
   {2, 1, JAM1, 0, 0, &font_choice, RhythmString, NULL};
static struct MenuItem RhythmItem = {&PitchItem, 0, 40, FORMWIDTH, 8, 
	(ITEMTEXT | HIGHCOMP | ITEMENABLED), 0, (APTR)&RhythmTxt, NULL, 0, 
	&RandomizeItem, 0};

const char DynamicString[16] = "Dynamic       \273";
const static struct IntuiText DynamicTxt = 
   {2, 1, JAM1, 0, 0, &font_choice, DynamicString, NULL};
static struct MenuItem DynamicItem = {&RhythmItem, 0, 48, FORMWIDTH, 8, 
	(ITEMTEXT | HIGHCOMP | ITEMENABLED), 0, (APTR)&DynamicTxt, NULL, 0, 
	&RandomizeItem, 0};

const static struct IntuiText TSpreadPhaseTxt = 
	{2, 1, JAM1, 0, 0, &font_choice, SpreadPhaseString, NULL};
static struct MenuItem TSpreadPhaseItem = {NULL, 
	FORMWIDTH - 5, 0, SUBWIDTH, 8, 
	(ITEMTEXT | HIGHCOMP | ITEMENABLED), 0, (APTR)&TSpreadPhaseTxt, 
		NULL, 0, NULL, 0};

const static struct IntuiText TSpreadPeriodTxt = 
	{2, 1, JAM1, 0, 0, &font_choice, SpreadPeriodString, NULL};
static struct MenuItem TSpreadPeriodItem = {&TSpreadPhaseItem, 
	FORMWIDTH - 5, 8, SUBWIDTH, 8, 
	(ITEMTEXT | HIGHCOMP | ITEMENABLED), 0, 
	(APTR)&TSpreadPeriodTxt, NULL, 0, NULL, 0};

const static struct IntuiText TRandomizeTxt = 
	{2, 1, JAM1, 0, 0, &font_choice, RandomizeString, NULL};
static struct MenuItem TRandomizeItem = {&TSpreadPeriodItem, 
	FORMWIDTH - 2, 16, SUBWIDTH, 8, 
	(ITEMTEXT | HIGHCOMP | ITEMENABLED), 0, (APTR)&TRandomizeTxt, 
	NULL, 0, NULL, 0};

const char TextureString[16] = "Texture       \273";
const static struct IntuiText TextureTxt = 
   {2, 1, JAM1, 0, 0, &font_choice, TextureString, NULL};
static struct MenuItem TextureItem = {&DynamicItem, 0, 56, FORMWIDTH, 8, 
	(ITEMTEXT | HIGHCOMP | ITEMENABLED), 0, (APTR)&TextureTxt, NULL, 0, 
	&TRandomizeItem, 0};

const char MaximumString[16] = "Maximum...";
const static struct IntuiText MaximumTxt = 
   {2, 1, JAM1, 0, 0, &font_choice, MaximumString, NULL};
static struct MenuItem MaximumItem = {NULL, FORMWIDTH - 2, 8, SUBWIDTH, 8, 
	(ITEMTEXT | HIGHCOMP | ITEMENABLED), 0, (APTR)&MaximumTxt, NULL, 0, 
	NULL, 0};

const char MinimumString[16] = "Minimum...";
const static struct IntuiText MinimumTxt = {2, 1, JAM1, 0, 0, &font_choice,
	MinimumString, NULL};
static struct MenuItem MinimumItem = {&MaximumItem, 
	FORMWIDTH - 2, 0, SUBWIDTH, 8, 
	(ITEMTEXT | HIGHCOMP | ITEMENABLED), 0, (APTR)&MinimumTxt, NULL, 0, 
	NULL, 0};

const char NoteLenString[16] = "Note Length   \273";
const static struct IntuiText NoteLenTxt = {2, 1, JAM1, 0, 0, &font_choice,
	NoteLenString, NULL};
static struct MenuItem NoteLenItem = {&TextureItem, 0, 64, FORMWIDTH, 8, 
	(ITEMTEXT | HIGHCOMP | ITEMENABLED), 0, (APTR)&NoteLenTxt, NULL, 0, 
	&MinimumItem, 0};

const char FormString[16] = "Form";
static struct Menu FormMenu  =  {&ScaleMenu, 
	PROJTITLWID, 0, FORMTITLWID, 
	0, (MIDRAWN | MENUENABLED), FormString, &NoteLenItem};

/*
** Project Menu
*/

const char PlayString[16] = "Play";
const static struct IntuiText PlayTxt = 
   {2, 1, JAM1, 0, 0, &font_choice, PlayString, NULL};
static struct MenuItem PlayItem = {NULL, 0, 0, CHECKWIDTH + PROJECTWIDTH, 
   8, (ITEMTEXT | COMMSEQ | HIGHCOMP | ITEMENABLED), 0, (APTR)&PlayTxt, 
   NULL, (BYTE)'P', NULL, 0};
	
const char StopString[16] = "Stop";
const static struct IntuiText StopTxt =
   {2, 1, JAM1, 0, 0, &font_choice, StopString, NULL};
static struct MenuItem StopItem = {&PlayItem, 0, 8, 
   CHECKWIDTH + PROJECTWIDTH, 8,
   (ITEMTEXT | COMMSEQ | HIGHCOMP | ITEMENABLED), 0, (APTR)&StopTxt, NULL,
   (BYTE)'S', NULL, 0};

const char ContinueString[16] = "Continue";
const static struct IntuiText ContinueTxt = {2, 1, JAM1, 0,0, &font_choice,
	ContinueString, NULL};
static struct MenuItem ContinueItem = {&StopItem, 0, 16, 
   CHECKWIDTH + PROJECTWIDTH, 8, 
   (ITEMTEXT | COMMSEQ | HIGHCOMP | ITEMENABLED), 0, (APTR)&ContinueTxt, 
   NULL, (BYTE)'C', NULL, 0};

const char LoadString[16] = "Load Form...";
const static struct IntuiText LoadTxt = 
   {2, 1, JAM1, 0, 0, &font_choice, LoadString, NULL};
static struct MenuItem LoadItem = {&ContinueItem, 0, 24, 
   CHECKWIDTH + PROJECTWIDTH, 8, 
   (ITEMTEXT | HIGHCOMP | COMMSEQ | ITEMENABLED), 0, (APTR)&LoadTxt, NULL, 
   (BYTE)'L', NULL, 0};

const char SaveString[16] = "Save Form...";
const static struct IntuiText SaveTxt = 
   {2, 1, JAM1, 0, 0, &font_choice, SaveString, NULL};
static struct MenuItem SaveItem = {&LoadItem, 0, 32, 
   CHECKWIDTH + PROJECTWIDTH, 8, 
   (ITEMTEXT | HIGHCOMP | COMMSEQ | ITEMENABLED), 0, (APTR)&SaveTxt, NULL, 
   (BYTE)'F', NULL, 0};

const char RecordString[16] = "Record";
const static struct IntuiText RecordTxt = 
   {2, 1, JAM1, CHECKWIDTH, 0, &font_choice, RecordString, NULL};
static struct MenuItem RecordItem = {&SaveItem, 0, 40, 
   CHECKWIDTH + PROJECTWIDTH, 8, 
   (CHECKIT | ITEMTEXT | HIGHCOMP | ITEMENABLED | COMMSEQ | MENUTOGGLE), 
   0, (APTR)&RecordTxt, NULL, (BYTE)'I', NULL, 0};

const char EraseString[16] = "Erase";
const static struct IntuiText EraseTxt = 
   {2, 1, JAM1, 0, 0, &font_choice, EraseString, NULL};
static struct MenuItem EraseItem = {&RecordItem, 0, 48, 
   CHECKWIDTH + PROJECTWIDTH, 8, 
   (ITEMTEXT | HIGHCOMP | ITEMENABLED | COMMSEQ), 
   0, (APTR)&EraseTxt, NULL, (BYTE)'E', NULL, 0};

const char SaveMIDIString[16] = "Save MIDI...";
const static struct IntuiText SaveMIDITxt = 
   {2, 1, JAM1, 0, 0, &font_choice, SaveMIDIString, NULL};
static struct MenuItem SaveMIDIItem = {&EraseItem, 0, 56, 
   CHECKWIDTH + PROJECTWIDTH, 8,
   (ITEMTEXT | HIGHCOMP | COMMSEQ | ITEMENABLED), 0, (APTR)&SaveMIDITxt, 
   NULL, (BYTE)'M', NULL, 0};

const char AboutString[16] = "About...";
const static struct IntuiText AboutTxt = 
	{2, 1, JAM1, 0, 0, &font_choice, AboutString, NULL};
static struct MenuItem AboutItem = {&SaveMIDIItem, 0, 64, 
   CHECKWIDTH + PROJECTWIDTH, 8, 
   (ITEMTEXT | HIGHCOMP | COMMSEQ | ITEMENABLED), 0, (APTR)&AboutTxt, 
   NULL, (BYTE)'A', NULL, 0};

const char QuitString[16] = "Quit";
const static struct IntuiText QuitTxt = 
   {2, 1, JAM1, 0, 0, &font_choice, QuitString, NULL};
static struct MenuItem QuitItem = {&AboutItem, 0, 72, 
   CHECKWIDTH + PROJECTWIDTH, 8, 
   (ITEMTEXT | COMMSEQ | HIGHCOMP | ITEMENABLED), 0, 
   (APTR)&QuitTxt, NULL, (BYTE)'Q', NULL, 0};

const char ProjectString[16] = "Project";
static struct Menu ProjectMenu  =  {&FormMenu, 0, 0, PROJTITLWID, 0, 
	MIDRAWN | MENUENABLED, ProjectString, &QuitItem};

extern void Init_Menu (void)
{
   auto int voice = 0;
   
   for (voice = 0; voice < MAXVOICE; voice++)
   {
      sprintf (voice_string[voice], "Voice %2d...", voice);
      voice_txt[voice].FrontPen = 2;
      voice_txt[voice].BackPen = 1;
      voice_txt[voice].DrawMode = JAM1;
      voice_txt[voice].LeftEdge = 0;
      voice_txt[voice].TopEdge = 0;
      voice_txt[voice].ITextFont = NULL;
      voice_txt[voice].IText = voice_string[voice];
      voice_txt[voice].NextText = NULL;
      if (voice == (MAXVOICE - 1))
      {
         voice_item[voice].NextItem = NULL;
      }
      else
      {
         voice_item[voice].NextItem = &voice_item[voice + 1];
      }
      voice_item[voice].LeftEdge = 0;
      voice_item[voice].TopEdge = voice * 8;
      voice_item[voice].Width = VOICEWIDTH;
      voice_item[voice].Height = 8;
      voice_item[voice].Flags = (ITEMTEXT | HIGHCOMP | ITEMENABLED);
      voice_item[voice].MutualExclude = 0;
      voice_item[voice].ItemFill = (APTR)&voice_txt[voice];
      voice_item[voice].SelectFill = NULL;
      voice_item[voice].Command = 0;
      voice_item[voice].SubItem = NULL;
      voice_item[voice].NextSelect = 0;
     
   }
	SetMenuStrip (w, &ProjectMenu);
	OnMenu (w, 0);
}

extern int CheckMenu (int *class, int *code)
{
	register int TakeAction = 0; /* This should just be a macro = TRUE */
	struct IntuiMessage *message;

	TakeAction = 0;
	*class = 0;
	*code = 0;

	message = (struct IntuiMessage *) GetMsg (w->UserPort);
	if (message !=  NULL) 
   {
		*class  =  message->Class;
		*code   =  message->Code;
		ReplyMsg ((struct Message *)message);
      if ((*class == MENUPICK) && (*code == MENUNULL))
      {
         TakeAction = 0;
      }
      else
      {
         TakeAction = 1;
      }
	}
   return TakeAction;
}

extern void CloseMenu (void) 
{
	ClearMenuStrip (w);
   return;
}

extern void Clear_Record (void)
{
   RecordItem.Flags &= ~CHECKED;
   return;
}

extern void Set_Record (void)
{
   RecordItem.Flags |= CHECKED;
   return;
}

