home *** CD-ROM | disk | FTP | other *** search
- /*----------------------------------------------------------------------*
- Ied.c version 3.0 - © Copyright 1991 Jaba Development
-
- Author : Jan van den Baard
- Purpose: The editing on items and subitems.
- *----------------------------------------------------------------------*/
- /*---------------------------------------------------*
- Gadgets created with GadgetEd V2.5
- which is (c) Copyright 1990-91 by Jaba Development
- written by Jan van den Baard
- *---------------------------------------------------*/
-
- static SHORT Border0_pairs[] = {
- -1,-1,266,-1,266,140,-1,140,-1,-1 };
- static SHORT Border1_pairs[] = {
- -1,-1,266,-1,266,9,-1,9,-1,-1 };
-
- static struct Border Border_bord[] = {
- 3,2,0,0,JAM1,5,(SHORT *)&Border0_pairs,&Border_bord[1],
- 3,2,0,0,JAM1,5,(SHORT *)&Border1_pairs,NULL };
-
- static struct IntuiText Render_text = {
- 0,1,JAM1,84,3,NULL,(UBYTE *)"Edit MenuItem",NULL };
- static struct IntuiText Render_text1 = {
- 0,1,JAM1,88,3,NULL,(UBYTE *)"Edit SubItem",NULL };
-
- static SHORT CANCEL_pairs0[] = {
- -1,-1,58,-1,58,35,-1,35,-1,-1 };
-
- static struct Border CANCEL_bord = {
- 0,0,0,0,JAM1,5,(SHORT *)&CANCEL_pairs0,NULL };
-
- static struct IntuiText CANCEL_text = {
- 0,1,JAM1,5,14,NULL,(UBYTE *)"CANCEL",NULL };
-
- #define CANCEL_ID 17
-
- static struct Gadget CANCEL = {
- NULL,205,103,58,35,
- GADGHCOMP,
- RELVERIFY,
- BOOLGADGET,
- (APTR)&CANCEL_bord,NULL,
- &CANCEL_text,NULL,NULL,CANCEL_ID,NULL };
-
- static SHORT OKIDOKI_pairs0[] = {
- -1,-1,58,-1,58,35,-1,35,-1,-1 };
-
- static struct Border OKIDOKI_bord = {
- 0,0,0,0,JAM1,5,(SHORT *)&OKIDOKI_pairs0,NULL };
-
- static struct IntuiText OKIDOKI_text = {
- 0,1,JAM1,21,14,NULL,(UBYTE *)"OK",NULL };
-
- #define OKIDOKI_ID 16
-
- static struct Gadget OKIDOKI = {
- &CANCEL,139,103,58,35,
- GADGHCOMP,
- RELVERIFY,
- BOOLGADGET,
- (APTR)&OKIDOKI_bord,NULL,
- &OKIDOKI_text,NULL,NULL,OKIDOKI_ID,NULL };
-
- static UBYTE HEIGHT_buf[5] = "0";
-
- static struct StringInfo HEIGHT_info = {
- (UBYTE *)&HEIGHT_buf,NULL,0,5,0,0,0,0,0,0,NULL,NULL,NULL };
-
- static SHORT HEIGHT_pairs0[] = {
- -1,-1,59,-1,59,8,-1,8,-1,-1 };
-
- static struct Border HEIGHT_bord = {
- 0,0,2,0,JAM1,5,(SHORT *)&HEIGHT_pairs0,NULL };
-
- static struct IntuiText HEIGHT_text = {
- 0,1,JAM2,5,-9,NULL,(UBYTE *)"HEIGHT",NULL };
-
- #define HEIGHT_ID 15
-
- static struct Gadget HEIGHT = {
- &OKIDOKI,72,130,59,8,
- GADGHCOMP+GADGDISABLED,
- RELVERIFY+STRINGCENTER+LONGINT,
- STRGADGET,
- (APTR)&HEIGHT_bord,NULL,
- &HEIGHT_text,NULL,(APTR)&HEIGHT_info,HEIGHT_ID,NULL };
-
- static UBYTE WIDTH_buf[5] = "0";
-
- static struct StringInfo WIDTH_info = {
- (UBYTE *)&WIDTH_buf,NULL,0,5,0,0,0,0,0,0,NULL,NULL,NULL };
-
- static SHORT WIDTH_pairs0[] = {
- -1,-1,59,-1,59,8,-1,8,-1,-1 };
-
- static struct Border WIDTH_bord = {
- 0,0,2,0,JAM1,5,(SHORT *)&WIDTH_pairs0,NULL };
-
- static struct IntuiText WIDTH_text = {
- 0,1,JAM2,10,-9,NULL,(UBYTE *)"WIDTH",NULL };
-
- #define WIDTH_ID 14
-
- static struct Gadget WIDTH = {
- &HEIGHT,8,130,59,8,
- GADGHCOMP+GADGDISABLED,
- RELVERIFY+STRINGCENTER+LONGINT,
- STRGADGET,
- (APTR)&WIDTH_bord,NULL,
- &WIDTH_text,NULL,(APTR)&WIDTH_info,WIDTH_ID,NULL };
-
- static UBYTE TOP_buf[5] = "0";
-
- static struct StringInfo TOP_info = {
- (UBYTE *)&TOP_buf,NULL,0,5,0,0,0,0,0,0,NULL,NULL,NULL };
-
- static SHORT TOP_pairs0[] = {
- -1,-1,59,-1,59,8,-1,8,-1,-1 };
-
- static struct Border TOP_bord = {
- 0,0,2,0,JAM1,5,(SHORT *)&TOP_pairs0,NULL };
-
- static struct IntuiText TOP_text = {
- 0,1,JAM2,16,-9,NULL,(UBYTE *)"TOP",NULL };
-
- #define TOP_ID 13
-
- static struct Gadget TOP = {
- &WIDTH,72,111,59,8,
- GADGHCOMP+GADGDISABLED,
- RELVERIFY+STRINGCENTER+LONGINT,
- STRGADGET,
- (APTR)&TOP_bord,NULL,
- &TOP_text,NULL,(APTR)&TOP_info,TOP_ID,NULL };
-
- static UBYTE LEFT_buf[5] = "0";
-
- static struct StringInfo LEFT_info = {
- (UBYTE *)&LEFT_buf,NULL,0,5,0,0,0,0,0,0,NULL,NULL,NULL };
-
- static SHORT LEFT_pairs0[] = {
- -1,-1,59,-1,59,8,-1,8,-1,-1 };
-
- static struct Border LEFT_bord = {
- 0,0,2,0,JAM1,5,(SHORT *)&LEFT_pairs0,NULL };
-
- static struct IntuiText LEFT_text = {
- 0,1,JAM2,15,-9,NULL,(UBYTE *)"LEFT",NULL };
-
- #define LEFT_ID 12
-
- static struct Gadget LEFT = {
- &TOP,8,111,59,8,
- GADGHCOMP+GADGDISABLED,
- RELVERIFY+STRINGCENTER+LONGINT,
- STRGADGET,
- (APTR)&LEFT_bord,NULL,
- &LEFT_text,NULL,(APTR)&LEFT_info,LEFT_ID,NULL };
-
- static SHORT FORMAT_pairs0[] = {
- -1,-1,124,-1,124,9,-1,9,-1,-1 };
-
- static struct Border FORMAT_bord = {
- 0,0,0,0,JAM1,5,(SHORT *)&FORMAT_pairs0,NULL };
-
- #define FORMAT_ID 11
-
- static struct Gadget FORMAT = {
- &LEFT,8,89,124,9,
- GADGHCOMP,
- RELVERIFY,
- BOOLGADGET,
- (APTR)&FORMAT_bord,NULL,
- NULL,NULL,NULL,FORMAT_ID,NULL };
-
- static SHORT DRMD_pairs0[] = {
- -1,-1,124,-1,124,9,-1,9,-1,-1 };
-
- static struct Border DRMD_bord = {
- 0,0,0,0,JAM1,5,(SHORT *)&DRMD_pairs0,NULL };
-
- #define DRMD_ID 10
-
- static struct Gadget DRMD = {
- &FORMAT,139,89,124,9,
- GADGHCOMP,
- RELVERIFY,
- BOOLGADGET,
- (APTR)&DRMD_bord,NULL,
- NULL,NULL,NULL,DRMD_ID,NULL };
-
- static UBYTE ITEXT_buf[33];
-
- static struct StringInfo ITEXT_info = {
- (UBYTE *)&ITEXT_buf,NULL,0,33,0,0,0,0,0,0,NULL,NULL,NULL };
-
- static SHORT ITEXT_pairs0[] = {
- -1,-1,124,-1,124,8,-1,8,-1,-1 };
-
- static struct Border ITEXT_bord = {
- 0,0,2,0,JAM1,5,(SHORT *)&ITEXT_pairs0,NULL };
-
- static struct IntuiText ITEXT_text = {
- 0,1,JAM2,26,-9,NULL,(UBYTE *)"ITEM TEXT",NULL };
-
- #define ITEXT_ID 9
-
- static struct Gadget ITEXT = {
- &DRMD,139,76,124,8,
- GADGHCOMP,
- RELVERIFY+STRINGCENTER,
- STRGADGET,
- (APTR)&ITEXT_bord,NULL,
- &ITEXT_text,NULL,(APTR)&ITEXT_info,ITEXT_ID,NULL };
-
- static UBYTE CK_buf[2];
-
- static struct StringInfo CK_info = {
- (UBYTE *)&CK_buf,NULL,0,2,0,0,0,0,0,0,NULL,NULL,NULL };
-
- static SHORT CK_pairs0[] = {
- -1,-1,124,-1,124,8,-1,8,-1,-1 };
-
- static struct Border CK_bord = {
- 0,0,2,0,JAM1,5,(SHORT *)&CK_pairs0,NULL };
-
- static struct IntuiText CK_text = {
- 0,1,JAM2,17,-9,NULL,(UBYTE *)"COMMAND KEY",NULL };
-
- #define CK_ID 8
-
- static struct Gadget CK = {
- &ITEXT,8,76,124,8,
- GADGHCOMP,
- RELVERIFY+STRINGCENTER,
- STRGADGET,
- (APTR)&CK_bord,NULL,
- &CK_text,NULL,(APTR)&CK_info,CK_ID,NULL };
-
- static SHORT IE_pairs0[] = {
- -1,-1,124,-1,124,9,-1,9,-1,-1 };
-
- static struct Border IE_bord = {
- 0,0,0,0,JAM1,5,(SHORT *)&IE_pairs0,NULL };
-
- static struct IntuiText IE_text = {
- 0,1,JAM1,18,1,NULL,(UBYTE *)"ITEMENABLED",NULL };
-
- #define IE_ID 7
-
- static struct Gadget IE = {
- &CK,139,54,124,9,
- GADGHCOMP+SELECTED,
- TOGGLESELECT+GADGIMMEDIATE,
- BOOLGADGET,
- (APTR)&IE_bord,NULL,
- &IE_text,NULL,NULL,IE_ID,NULL };
-
- static SHORT MT_pairs0[] = {
- -1,-1,124,-1,124,9,-1,9,-1,-1 };
-
- static struct Border MT_bord = {
- 0,0,0,0,JAM1,5,(SHORT *)&MT_pairs0,NULL };
-
- static struct IntuiText MT_text = {
- 0,1,JAM1,22,1,NULL,(UBYTE *)"MENUTOGGLE",NULL };
-
- #define MT_ID 6
-
- static struct Gadget MT = {
- &IE,139,41,124,9,
- GADGHCOMP,
- TOGGLESELECT+GADGIMMEDIATE,
- BOOLGADGET,
- (APTR)&MT_bord,NULL,
- &MT_text,NULL,NULL,MT_ID,NULL };
-
- static SHORT CI_pairs0[] = {
- -1,-1,124,-1,124,9,-1,9,-1,-1 };
-
- static struct Border CI_bord = {
- 0,0,0,0,JAM1,5,(SHORT *)&CI_pairs0,NULL };
-
- static struct IntuiText CI_text = {
- 0,1,JAM1,34,1,NULL,(UBYTE *)"CHECKIT",NULL };
-
- #define CI_ID 5
-
- static struct Gadget CI = {
- &MT,139,28,124,9,
- GADGHCOMP,
- TOGGLESELECT+GADGIMMEDIATE,
- BOOLGADGET,
- (APTR)&CI_bord,NULL,
- &CI_text,NULL,NULL,CI_ID,NULL };
-
- static SHORT CD_pairs0[] = {
- -1,-1,124,-1,124,9,-1,9,-1,-1 };
-
- static struct Border CD_bord = {
- 0,0,0,0,JAM1,5,(SHORT *)&CD_pairs0,NULL };
-
- static struct IntuiText CD_text = {
- 0,1,JAM1,34,1,NULL,(UBYTE *)"CHECKED",NULL };
-
- #define CD_ID 4
-
- static struct Gadget CD = {
- &CI,139,15,124,9,
- GADGHCOMP,
- TOGGLESELECT+GADGIMMEDIATE,
- BOOLGADGET,
- (APTR)&CD_bord,NULL,
- &CD_text,NULL,NULL,CD_ID,NULL };
-
- static SHORT CS_pairs0[] = {
- -1,-1,124,-1,124,9,-1,9,-1,-1 };
-
- static struct Border CS_bord = {
- 0,0,0,0,JAM1,5,(SHORT *)&CS_pairs0,NULL };
-
- static struct IntuiText CS_text = {
- 0,1,JAM1,34,1,NULL,(UBYTE *)"COMMSEQ",NULL };
-
- #define CS_ID 3
-
- static struct Gadget CS = {
- &CD,8,54,124,9,
- GADGHCOMP,
- TOGGLESELECT+GADGIMMEDIATE,
- BOOLGADGET,
- (APTR)&CS_bord,NULL,
- &CS_text,NULL,NULL,CS_ID,NULL };
-
- static SHORT HN_pairs0[] = {
- -1,-1,124,-1,124,9,-1,9,-1,-1 };
-
- static struct Border HN_bord = {
- 0,0,0,0,JAM1,5,(SHORT *)&HN_pairs0,NULL };
-
- static struct IntuiText HN_text = {
- 0,1,JAM1,30,1,NULL,(UBYTE *)"HIGHNONE",NULL };
-
- #define HN_ID 2
-
- static struct Gadget HN = {
- &CS,8,41,124,9,
- GADGHCOMP,
- TOGGLESELECT+GADGIMMEDIATE,
- BOOLGADGET,
- (APTR)&HN_bord,NULL,
- &HN_text,3L,NULL,HN_ID,NULL };
-
- static SHORT HB_pairs0[] = {
- -1,-1,124,-1,124,9,-1,9,-1,-1 };
-
- static struct Border HB_bord = {
- 0,0,0,0,JAM1,5,(SHORT *)&HB_pairs0,NULL };
-
- static struct IntuiText HB_text = {
- 0,1,JAM1,34,1,NULL,(UBYTE *)"HIGHBOX",NULL };
-
- #define HB_ID 1
-
- static struct Gadget HB = {
- &HN,8,28,124,9,
- GADGHCOMP,
- TOGGLESELECT+GADGIMMEDIATE,
- BOOLGADGET,
- (APTR)&HB_bord,NULL,
- &HB_text,5L,NULL,HB_ID,NULL };
-
- static SHORT HC_pairs0[] = {
- -1,-1,124,-1,124,9,-1,9,-1,-1 };
-
- static struct Border HC_bord = {
- 0,0,0,0,JAM1,5,(SHORT *)&HC_pairs0,NULL };
-
- static struct IntuiText HC_text = {
- 0,1,JAM1,30,1,NULL,(UBYTE *)"HIGHCOMP",NULL };
-
- #define HC_ID 0
-
- static struct Gadget HC = {
- &HB,8,15,124,9,
- GADGHCOMP+SELECTED,
- TOGGLESELECT+GADGIMMEDIATE,
- BOOLGADGET,
- (APTR)&HC_bord,NULL,
- &HC_text,6L,NULL,HC_ID,NULL };
-
- static struct NewWindow nw_item = {
- 24,15,272,144,0,1,
- GADGETDOWN+GADGETUP+CLOSEWINDOW,
- NOCAREREFRESH+SMART_REFRESH+ACTIVATE+RMBTRAP+BORDERLESS,
- NULL,NULL,
- NULL,NULL,NULL,
- 150,50,320,256,CUSTOMSCREEN };
-
- extern struct Window *MainWindow;
- extern struct Screen *MainScreen;
- extern struct RastPort *MainRP;
- extern struct Gadget *Gadget;
- extern struct MyMenu *ParentMenu;
- extern struct MyMenuItem *ParentItem;
- extern struct ListItem *ItemsList, *SubsList;
- extern struct MyMenu *MenuStrip;
- extern struct MemoryChain Memory;
- extern struct MyMenuItem dummy;
- extern struct MenuItem TheItem[], SubItem[];
- extern struct Menu ItemMenuStrip[], SubMenuStrip[];
-
- extern ULONG Class;
- extern UWORD Code, ItemCount, SubCount;
- extern UWORD ActEd, ItemTotal, SubTotal;
- extern UWORD FrontPen, BackPen;
- extern BOOL Saved;
-
- static struct Window *IedWindow;
- static UWORD FormatNum = 0L, DrMdNum = 0L;
-
- static UBYTE DrMd[] = { JAM1,JAM2,COMPLEMENT,INVERSVID };
-
- static struct IntuiText FmatText[] = {
- 0,1,JAM2,18,1,NULL,(UBYTE *)"AUTO FORMAT",NULL,
- 0,1,JAM2,18,1,NULL,(UBYTE *)"USER FORMAT",NULL
- };
-
- static struct IntuiText DrMdText[] = {
- 0,1,JAM2,46,1,NULL,(UBYTE *)"JAM1",NULL,
- 0,1,JAM2,46,1,NULL,(UBYTE *)"JAM2",NULL,
- 0,1,JAM2,22,1,NULL,(UBYTE *)"COMPLEMENT",NULL,
- 0,1,JAM2,26,1,NULL,(UBYTE *)"INVERSVID",NULL
- };
-
- void SetNIL( void )
- {
- register struct Gadget *g;
-
- for(g = &HB; g; g = g->NextGadget) {
- if(TestBits((ULONG)g->GadgetType,BOOLGADGET))
- g->Flags = GADGHCOMP;
- }
-
- HC.Flags = SELECTED;
- IE.Flags = SELECTED;
-
- CK_buf[0] = 0;
- ITEXT_buf[0] = 0;
-
- FormatNum = 0;
- DrMdNum = 0;
- LEFT.Flags = GADGDISABLED;
- TOP.Flags = GADGDISABLED;
- WIDTH.Flags = GADGDISABLED;
- HEIGHT.Flags = GADGDISABLED;
-
- redisplay(&ITEXT);
- }
-
- struct MyMenuItem *MakeItem( void )
- {
- struct MyMenuItem *item;
- struct IntuiText *itext;
- WORD top, width;
-
- if(NOT ITEXT_buf[0]) return(NULL);
-
- width = TEXT_WIDTH(MainRP,(char *)&ITEXT_buf[0]) + TEXTSPACING;
- if(SelectTest(&CS)) width += 40;
- if(SelectTest(&CI)) width += 20;
-
- if(ActEd == ITEMED) {
- if((width + 10) > MainScreen->Width)
- goto nfErr;
- if(ParentMenu->FirstItem == &dummy)
- top = MainScreen->BarHeight-1;
- else
- top = ItemHeight( ParentMenu->FirstItem ) + MainScreen->BarHeight-1;
- } else {
- if((width + ParentItem->Width) > MainScreen->Width)
- goto nfErr;
- if(NOT ParentItem->SubItem)
- top = ParentItem->TopEdge + MainScreen->BarHeight - 1;
- else
- top = ItemHeight(ParentItem->SubItem) + ParentItem->TopEdge + MainScreen->BarHeight - 1;
- }
-
- if(MainScreen->Width == 320)
- top += MainScreen->MenuHBorder;
-
- if((top + TEXT_HEIGHT(MainRP) + ITEMSPACING + MainScreen->MenuHBorder) > MainScreen->Height)
- goto nfErr;
-
- if(NOT(item = (struct MyMenuItem *)AllocItem(&Memory,(ULONG)sizeof(struct MyMenuItem),MEMF_PUBLIC)))
- goto itErr;
- if(NOT(itext = (struct IntuiText *)MakeIText(&ITEXT_buf[0],DrMd[DrMdNum],80L)))
- goto itErr;
-
- if(NOT FormatNum)
- item->Height = TEXT_HEIGHT(MainRP) + ITEMSPACING;
- else {
- item->LeftEdge = LEFT_info.LongInt;
- item->TopEdge = TOP_info.LongInt;
- item->Width = WIDTH_info.LongInt;
- item->Height = HEIGHT_info.LongInt;
- item->SpecialFlags = USERFORMAT;
- }
-
- if(SelectTest(&HC)) item->Flags = HIGHCOMP;
- else if(SelectTest(&HB)) item->Flags = HIGHBOX;
- else item->Flags = HIGHNONE;
-
- if(SelectTest(&CI)) { item->Flags |= CHECKIT;
- itext->LeftEdge = 18;
- }
- if(SelectTest(&CS)) { item->Flags |= COMMSEQ;
- item->Command = CK_buf[0];
- }
- if(SelectTest(&MT)) item->Flags |= MENUTOGGLE;
- if(SelectTest(&IE)) item->Flags |= ITEMENABLED;
- if(SelectTest(&CD)) item->Flags |= CHECKED;
-
- item->ItemFill = (APTR)itext;
- item->Flags |= ITEMTEXT;
- if(ActEd == ITEMED) {
- ItemCount++;
- ItemTotal++;
- } else {
- SubCount++;
- SubTotal++;
- }
- return(item);
- itErr:
- enable_window();
- ok();
- Error("Out of memory!");
- if(item) FreeMenuItem(item);
- return(NULL);
- nfErr:
- enable_window();
- ok();
- Error("Item won't fit!");
- return(NULL);
- }
-
- void RemoveItem( struct ListItem *l )
- {
- struct MyMenuItem *item, *pitem;
- struct ListItem *pred;
- UWORD count;
- WORD width, left;
- UBYTE message[36];
-
- Saved = FALSE;
-
- if(ActEd == ITEMED)
- item = l->Item;
- else
- item = l->SubItem;
-
- StringFormat((char *)&message,"Delete: %.27s",((struct IntuiText *)item->ItemFill)->IText);
- if(Ask(&message[0],"Are you sure?") == FALSE)
- return;
-
- ClearMenuStrip(MainWindow);
-
- if(ActEd == ITEMED) {
- if(l == ItemsList) {
- for(count = 1; count < 5; count++)
- TheItem[count].SubItem = l->AItem.NextItem;
- ItemsList = (struct ListItem *)l->AItem.NextItem;
- } else {
- pred = (struct ListItem *)FindPredItem(ItemsList, l);
- pred->AItem.NextItem = l->AItem.NextItem;
- }
- } else {
- if(l == SubsList) {
- for(count = 1; count < 4; count++)
- SubItem[count].SubItem = l->AItem.NextItem;
- SubsList = (struct ListItem *)l->AItem.NextItem;
- } else {
- pred = (struct ListItem *)FindPredItem(SubsList,l);
- pred->AItem.NextItem = l->AItem.NextItem;
- }
- }
-
- if(ActEd == ITEMED) {
- if(item == ParentMenu->FirstItem) {
- ParentMenu->FirstItem = item->NextItem;
- if(NOT item->NextItem) ParentMenu->FirstItem = (struct MyMenuItem *)&dummy;
- } else {
- pitem = (struct MyMenuItem *)FindPredItem(ParentMenu->FirstItem, item);
- pitem->NextItem = item->NextItem;
- }
- } else {
- if(item == ParentItem->SubItem)
- ParentItem->SubItem = item->NextItem;
- else {
- pitem = (struct MyMenuItem *)FindPredItem(ParentItem->SubItem,item);
- pitem->NextItem = item->NextItem;
- }
- }
- FreeMenuItem(item);
- if(ActEd == ITEMED) {
- ItemCount--;
- ItemTotal--;
- } else {
- SubCount--;
- SubTotal--;
- }
- Mistake:
- ReformatM();
- ReformatList(ActEd);
- if(ActEd == ITEMED)
- SetMenuStrip(MainWindow,&ItemMenuStrip[0]);
- else
- SetMenuStrip(MainWindow,&SubMenuStrip[0]);
- SetMainMenus();
- }
-
- ULONG CheckHotKey( UBYTE key )
- {
- register struct MyMenu *menu;
- register struct MyMenuItem *it, *sb;
-
- for(menu = MenuStrip; menu; menu = menu->NextMenu) {
- if(menu->FirstItem != &dummy) {
- for(it = menu->FirstItem; it; it = it->NextItem) {
- if(it->Command == key)
- return(TRUE);
- if(it->SubItem) {
- for(sb = it->SubItem; sb; sb = sb->NextItem) {
- if(sb->Command == key)
- return(TRUE);
- }
- }
- }
- }
- }
- return(FALSE);
- }
-
- struct MyMenuItem *EditItem( struct ListItem *l, ULONG ModeIns )
- {
- struct MyMenuItem *TheItem, *Last, *Edit, *TheList;
- struct IntuiText *itext, *tt;
- BOOL running = TRUE;
- ULONG flags;
- WORD left, width;
-
- SetNIL();
-
- if(ActEd == ITEMED) {
- tt = &Render_text;
- TheList = ParentMenu->FirstItem;
- } else {
- tt = &Render_text1;
- TheList = ParentItem->SubItem;
- }
-
- if((NOT l) || ModeIns) {
- LEFT_info.LongInt = 0;
- if(TheList == &dummy || NOT TheList)
- TOP_info.LongInt = 0;
- else
- TOP_info.LongInt = ItemHeight(TheList);
- StringFormat((char *)&TOP_buf[0],"%ld",TOP_info.LongInt);
- WIDTH_info.LongInt = 10;
- HEIGHT_info.LongInt = 9;
- strcpy((char *)&LEFT_buf[0],"0");
- strcpy((char *)&WIDTH_buf[0],"10");
- strcpy((char *)&HEIGHT_buf[0],"9");
- } else if(l && (NOT ModeIns)) {
- if(ActEd == ITEMED)
- Edit = l->Item;
- else
- Edit = l->SubItem;
- itext = (struct IntuiText *)Edit->ItemFill;
- strcpy((char *)&ITEXT_buf[0],itext->IText);
- flags = (ULONG)Edit->Flags;
- HC.Flags = IE.Flags = NULL;
- if(TestBits(flags,HIGHNONE)) HN.Flags = SELECTED;
- else if(TestBits(flags,HIGHCOMP)) HC.Flags = SELECTED;
- else HB.Flags = SELECTED;
- if(TestBits(flags,CHECKIT)) CI.Flags = SELECTED;
- if(TestBits(flags,COMMSEQ)) { CS.Flags = SELECTED;
- CK_buf[0] = Edit->Command;
- CK_buf[1] = 0;
- }
- if(TestBits(flags,MENUTOGGLE)) MT.Flags = SELECTED;
- if(TestBits(flags,ITEMENABLED)) IE.Flags = SELECTED;
- if(TestBits(flags,CHECKED)) CD.Flags = SELECTED;
-
- LEFT_info.LongInt = Edit->LeftEdge;
- TOP_info.LongInt = Edit->TopEdge;
- WIDTH_info.LongInt = Edit->Width;
- HEIGHT_info.LongInt = Edit->Height;
- StringFormat((char *)&LEFT_buf[0],"%ld",Edit->LeftEdge);
- StringFormat((char *)&TOP_buf[0],"%ld",Edit->TopEdge);
- StringFormat((char *)&WIDTH_buf[0],"%ld",Edit->Width);
- StringFormat((char *)&HEIGHT_buf[0],"%ld",Edit->Height);
-
- if(TestBits((ULONG)Edit->SpecialFlags,USERFORMAT)) {
- LEFT.Flags = GADGHCOMP;
- TOP.Flags = GADGHCOMP;
- WIDTH.Flags = GADGHCOMP;
- HEIGHT.Flags = GADGHCOMP;
- FormatNum = 1;
- }
-
- for(DrMdNum = 0; DrMdNum < 4; DrMdNum++)
- if(itext->DrawMode == DrMd[DrMdNum])
- break;
- }
-
- FORMAT.GadgetText = &FmatText[FormatNum];
- DRMD.GadgetText = &DrMdText[DrMdNum];
-
- nw_item.Screen = MainScreen;
-
- if(NOT(IedWindow = (struct Window *)OpenWindow(&nw_item)))
- return(NULL);
-
- disable_window();
- buisy();
- draw(IedWindow,&HC,&Border_bord[0],tt);
- ActivateGadget(&ITEXT,IedWindow,NULL);
-
- do {
- WaitPort(IedWindow->UserPort);
- while(read_msg(IedWindow)) {
- switch(Class) {
- case GADGETUP:
- switch(Gadget->GadgetID) {
- case OKIDOKI_ID:
- if(NOT ITEXT_buf[0]) {
- DisplayBeep(MainScreen);
- break;
- }
- case CANCEL_ID:
- running = FALSE;
- break;
- case FORMAT_ID:
- if(FormatNum) {
- OffGList(IedWindow,&LEFT,NULL,4);
- FORMAT.GadgetText = &FmatText[0];
- FormatNum = 0;
- } else {
- OnGList(IedWindow,&LEFT,NULL,4);
- FORMAT.GadgetText = &FmatText[1];
- FormatNum = 1;
- }
- SetAPen(IedWindow->RPort,1);
- RectFill(IedWindow->RPort,8,89,132,98);
- RefreshGList(&FORMAT,IedWindow,NULL,1);
- break;
- case DRMD_ID:
- if(DrMdNum == 3)
- DrMdNum = 0;
- else
- DrMdNum++;
- DRMD.GadgetText = &DrMdText[DrMdNum];
- SetAPen(IedWindow->RPort,1);
- RectFill(IedWindow->RPort,139,89,263,98);
- RefreshGList(&DRMD,IedWindow,NULL,1);
- break;
- case CK_ID:
- if(NOT CK_buf[0])
- DeSelectGadget(IedWindow,&CS,NULL);
- else {
- if(NOT CheckHotKey(CK_buf[0]))
- SelectGadget(IedWindow,&CS,NULL);
- else {
- DeSelectGadget(IedWindow,&CS,NULL);
- CK_buf[0] = 0;
- enable_window();
- Error("Hotkey already used !");
- disable_window();
- RefreshGList(&CK,IedWindow,NULL,1);
- }
- }
- break;
- case LEFT_ID:
- case TOP_ID:
- case WIDTH_ID:
- case HEIGHT_ID:
- CheckNumbers(ParentMenu->LeftEdge+LEFT_info.LongInt,MainScreen->BarHeight+TOP_info.LongInt,WIDTH_info.LongInt,HEIGHT_info.LongInt);
- break;
- }
- case GADGETDOWN:
- switch(Gadget->GadgetID) {
- case HC_ID:
- case HB_ID:
- case HN_ID:
- MutualExclude(IedWindow,Gadget,&HC,NULL);
- SelectGadget(IedWindow,Gadget,NULL);
- break;
- case CS_ID:
- if(SelectTest(&CS))
- ActivateGadget(&CK,IedWindow,NULL);
- else {
- CK_buf[0] = 0;
- RefreshGList(&CK,IedWindow,NULL,1);
- }
- break;
- }
- }
- }
- } while(running == TRUE);
- CloseWindow(IedWindow);
-
- if(Gadget->GadgetID == OKIDOKI_ID && ModeIns && l) {
- Saved = FALSE;
- if(ActEd == ITEMED)
- Edit = l->Item;
- else
- Edit = l->SubItem;
- if((TheItem = MakeItem())) {
- if(l->Item == TheList || l->SubItem == TheList) {
- TheItem->NextItem = TheList;
- if(ActEd == ITEMED)
- ParentMenu->FirstItem = TheItem;
- else
- ParentItem->SubItem = TheItem;
- TheList = TheItem;
- } else {
- Last = (struct MyMenuItem *)FindPredItem(TheList,Edit);
- Last->NextItem = TheItem;
- TheItem->NextItem = Edit;
- }
- TheItem->ItsListItem = (struct ListItem *)CreateListItem((APTR)TheItem,ActEd,TRUE,l,TRUE);
- ReformatM();
- ReformatList(ActEd);
- enable_window();
- ok();
- return(NULL);
- } else
- return(NULL);
- } else if(Gadget->GadgetID == OKIDOKI_ID && (NOT l)) {
- Saved = FALSE;
- if((TheItem = MakeItem())) {
- if(TheList == &dummy || NOT TheList) {
- if(ActEd == ITEMED)
- ParentMenu->FirstItem = TheItem;
- else
- ParentItem->SubItem = TheItem;
- } else {
- Last = (struct MyMenuItem *)LastItem(TheList);
- Last->NextItem = TheItem;
- }
- TheItem->ItsListItem = (struct ListItem *)CreateListItem((APTR)TheItem, ActEd, FALSE, NULL,TRUE);
- ReformatM();
- enable_window();
- ok();
- return(NULL);
- } else
- return(NULL);
- } else if(Gadget->GadgetID == OKIDOKI_ID && l && (NOT ModeIns)) {
- Saved = FALSE;
- if(NOT FormatNum) {
- Edit->Width = TEXT_WIDTH(MainRP,(char *)&ITEXT_buf[0]) + TEXTSPACING;
- Edit->SpecialFlags = NULL;
- } else {
- Edit->LeftEdge = LEFT_info.LongInt;
- Edit->TopEdge = TOP_info.LongInt;
- Edit->Width = WIDTH_info.LongInt;
- Edit->Height = HEIGHT_info.LongInt;
- Edit->SpecialFlags = USERFORMAT;
- }
-
- if(SelectTest(&HC)) Edit->Flags = HIGHCOMP;
- else if(SelectTest(&HB)) Edit->Flags = HIGHBOX;
- else Edit->Flags = HIGHNONE;
- if(SelectTest(&CI)) { Edit->Flags |= CHECKIT;
- if(NOT FormatNum)
- Edit->Width += 20;
- itext->LeftEdge = 18;
- }
- if(SelectTest(&CS)) { Edit->Flags |= COMMSEQ;
- Edit->Command = CK_buf[0];
- if(NOT FormatNum)
- Edit->Width += 40;
- }
- if(SelectTest(&MT)) Edit->Flags |= MENUTOGGLE;
- if(SelectTest(&IE)) Edit->Flags |= ITEMENABLED;
- if(SelectTest(&CD)) Edit->Flags |= CHECKED;
- Edit->Flags |= ITEMTEXT;
-
- itext->DrawMode = DrMd[DrMdNum];
- itext->FrontPen = FrontPen;
- itext->BackPen = BackPen;
-
- strcpy((char *)itext->IText,(char *)&ITEXT_buf[0]);
- strncpy((char *)&l->Letters[0],(char *)itext->IText,9);
-
- ReformatM();
- enable_window();
- ok();
- return(NULL);
- }
- enable_window();
- ok();
- return(NULL);
- }
-