/* newradii.c -- open a window to get new radii, close it, and proceed.... */ /************************ Gadget Defines ***********************************/ struct IntuiText ntext = {2,2,JAM1, 0, -11, NL, (UBYTE *) "Large radius", NL}; struct IntuiText ntext2 = {2,2,JAM1, 0, -11, NL, (UBYTE *) "Small radius", NL}; #define STRINGSIZE 5 UBYTE DefString[STRINGSIZE] = "5"; UBYTE DefString2[STRINGSIZE] = "2"; UBYTE Undo [STRINGSIZE]; UBYTE Undo2 [STRINGSIZE]; struct StringInfo TexString = { DefString, Undo, 0, STRINGSIZE, 0, 0, 2, 0, 0, 0, NULL, 0, NULL }; struct StringInfo TexString2 = { DefString2, Undo2, 0, STRINGSIZE, 0, 0, 2, 0, 0, 0, NULL, 0, NULL }; USHORT Pairs[] = { -1, -1, 55, -1, 55, 12, -1, 12, -1, -1, }; USHORT Pairs2[] = { -1, -1, 55, -1, 55, 12, -1, 12, -1, -1, }; #define NUM_PAIRS 5 struct Border StrBorder = { -1, -1, 1, 0, JAM1, NUM_PAIRS, (APTR)&Pairs, NULL }; struct Border StrBorder2 = { -1, -1, 1, 0, JAM1, NUM_PAIRS, (APTR)&Pairs2, NULL }; #define TEX_GAD 0 #define TEX_GAD2 1 struct Gadget tex_gad = { &ok_gad2, 10, 25, 50, 11, GADGHCOMP, RELVERIFY, STRGADGET, (APTR)&StrBorder, NL, &ntext, NL, (APTR)&TexString, TEX_GAD, NL }; struct Gadget tex_gad2 = { &tex_gad, 10, 50, 50, 11, GADGHCOMP, RELVERIFY, STRGADGET, (APTR)&StrBorder2, NL, &ntext2, NL, (APTR)&TexString2, TEX_GAD2, NL }; /* Used to open a Window */ struct NewWindow NewRwin = { 10,10, PLX2,PLY2, 2,BCOL, NL, /* IDCMP set up AFTER CALL */ ACTIVATE | SMART_REFRESH, &tex_gad2,NL, NL, /* FirstGadget, CheckMark, Title */ NL,NL, /* MUST SET SCREEN AFTER OPENSCREEN!!! */ PLX2,PLY2,PLX2,PLY2, CUSTOMSCREEN }; /* MinW, MinH, MaxW, MaxH */ /******************************************************************** * newradii(window) * This is the meat. This routine opens the save window and * retains control until the user selects the OK or CANCEL gadget. * The calling arguement is a window pointer. That window * is expected to have opened an IDCMP port, which save uses. ********************************************************************/ int newradii(calling_window) struct Window *calling_window; { struct Window *cW; /* save window handle */ FAST struct IntuiMessage *imsg; FAST struct Gadget *igad; FAST int class; BOOL keepon; UBYTE temp[5],temp2[5]; /* Get screen from calling window */ NewRwin.Screen = calling_window->WScreen; /* NEED TO SET SCREEN!!! */ if ( ! (cW = (struct Window *)OpenWindow(&NewRwin)) ) { return(FALSE); /* Oops... */ } cW->UserPort = calling_window->UserPort; ModifyIDCMP(cW, GADGETUP | GADGETDOWN); keepon=TRUE; strcpy(temp,DefString); strcpy(temp2,DefString2); while (keepon == TRUE) { while (imsg=(struct IntuiMessage *)GetMsg(cW->UserPort)) { class = imsg->Class; ReplyMsg(imsg); switch ( class ) { case GADGETUP: case GADGETDOWN: igad =(struct Gadget *) imsg->IAddress; switch ( igad->GadgetID ) { case CN_GAD2: strcpy(DefString,temp); strcpy(DefString2,temp2); keepon=FALSE; break; case OK_GAD2: aa=atoi(DefString); bb=atoi(DefString2); precalculate(); keepon=FALSE; break; } } } } cW->UserPort = NL; CloseWindow(cW); }