/* * MENU.C * * (c)Copyright 1987 Matthew Dillon, All Rights Reserved. * */ #include "files.h" #define NI 0 /* means 'not initialized' */ static ITEXT IText[] = { { 0, 1, JAM2, 0, 0, NULL, (ubyte *)"Save" }, { 0, 1, JAM2, 0, 0, NULL, (ubyte *)"SaveAs" }, { 0, 1, JAM2, 0, 0, NULL, (ubyte *)"Load" }, { 0, 1, JAM2, 0, 0, NULL, (ubyte *)"LoadDefault" }, { 0, 1, JAM2, 0, 0, NULL, (ubyte *)"Quit" }, { 0, 1, JAM2, 0, 0, NULL, (ubyte *)"AddKillPat" }, }; static ITEM Item[] = { { &Item[1], 0, NI, NI, NI, 0, 0, (APTR)&IText[0], NULL }, { &Item[2], 0, NI, NI, NI, 0, 0, (APTR)&IText[1], NULL }, { &Item[3], 0, NI, NI, NI, 0, 0, (APTR)&IText[2], NULL }, { &Item[4], 0, NI, NI, NI, 0, 0, (APTR)&IText[3], NULL }, { NULL , 0, NI, NI, NI, 0, 0, (APTR)&IText[4], NULL }, { NULL , 0, NI, NI, NI, 0, 0, (APTR)&IText[5], NULL }, }; static MENU Menu[] = { { &Menu[1], NI, 0, NI, NI, NI, "Project" , NI }, { NULL , NI, 0, NI, NI, NI, "Control", NI } }; addmenus() { MENU *menu; ITEM *item, *nit; short left = 5; short height; short width; for (menu = Menu, item = Item; menu; menu = menu->NextMenu) { height = 0; width = strlen(menu->MenuName); menu->FirstItem = item; for (item = menu->FirstItem; item; item = item->NextItem) { if (width < strlen(((ITEXT *)item->ItemFill)->IText)) width = strlen(((ITEXT *)item->ItemFill)->IText); } width *= Win->RPort->TxWidth; for (item = menu->FirstItem; item; nit = item, item = item->NextItem) { item->Width = width; item->Height = Win->RPort->TxHeight + 2; item->TopEdge = height; item->Flags |= ITEMTEXT|ITEMENABLED|HIGHCOMP; height += item->Height; } menu->LeftEdge = left; menu->Width = width; menu->Height = height; menu->Flags = MENUENABLED; item = nit + 1; left += width + 4; } SetMenuStrip(Win, Menu); } remmenus() { ClearMenuStrip(Win); } getmenu(im) IMESS *im; { register short mn = MENUNUM(im->Code); register short in = ITEMNUM(im->Code); switch(mn) { case 0: switch(in) { case 0: return(MEN_SAVE); case 1: return(MEN_SAVEAS); case 2: return(MEN_LOAD); case 3: return(MEN_LOADEF); case 4: return(MEN_QUIT); } break; case 1: switch(in) { case 0: return(MEN_KILLPAT); } break; } return(0); }