GDHandle display_device_dialog( GDSpecPtr device_spec) { GDHandle device= BestDevice(device_spec); if (device) { DialogPtr dialog= myGetNewDialog(dlogDEVICE, NULL, (WindowPtr) -1, 0); ModalFilterUPP device_dialog_filter_upp= NewModalFilterProc(device_dialog_filter_proc); short item_hit; assert(dialog); assert(device_dialog_filter_upp); /* setup globals */ device_dialog_globals.device_spec= *device_spec; device_dialog_globals.device= device; /* setup and show dialog */ device_dialog_instantiate_proc(dialog); ShowWindow(dialog); do { boolean reinstantiate= FALSE; ModalDialog(device_dialog_filter_upp, &item_hit); switch(item_hit) { case iCOLORS: device_dialog_globals.device_spec.flags|= deviceIsColor; reinstantiate= TRUE; break; case iGRAYS: device_dialog_globals.device_spec.flags&= ~deviceIsColor; reinstantiate= TRUE; break; case iDEVICE_AREA: reinstantiate= TRUE; break; case iOK: *device_spec= device_dialog_globals.device_spec; device= device_dialog_globals.device; break; } if (reinstantiate) device_dialog_instantiate_proc(dialog); } while (item_hit!=iOK && item_hit!=iCANCEL); DisposeDialog(dialog); DisposeRoutineDescriptor(device_dialog_filter_upp); } return device; }
int DoEnterNewAddressDialog(StringPtr name, StringPtr description) { short itemHit,okay=FALSE,keepGoing=TRUE; DialogPtr dlog=NIL; GrafPtr oldPort; ModalFilterUPP MyFilterUPP; GetPort(&oldPort); /* On PowerPC, need a RoutineDescriptor from heap; on 68K, no allocation */ MyFilterUPP = NewModalFilterProc(MyFilter); if (MyFilterUPP == NIL) goto cleanUp; /* Build dialog window and install its item values */ dlog = OpenThisDialog(name, description); if (dlog == NIL) goto cleanUp; /* Entertain filtered user events until dialog is dismissed */ while (keepGoing) { ModalDialog(MyFilterUPP,&itemHit); keepGoing = DoDialogItem(dlog,itemHit); } /* * Do final processing of item values, such as exporting them to caller. * DoDialogItem() has already called AnyBadValues(). */ okay = (itemHit == OK_ITEM); if (okay) { GetDlgString(dlog, EDIT5, name); GetDlgString(dlog, EDIT6, description); } /* That's all, folks! */ cleanUp: if (dlog) CloseThisDialog(dlog); if (MyFilterUPP) DisposeRoutineDescriptor(MyFilterUPP); SetPort(oldPort); return(okay); }
OSErr RVConfirmVideoRequest (VideoRequestRecPtr requestRecPtr) { short alertReturn; // Alert() return value ModalFilterUPP confirmFilterUPP; // got to have us one of them new fangled UPP thingies if (requestRecPtr->availFlags & 1<<kModeValidNotSafeBit) { // new mode is valid but not safe, so ask user to confirm SetCursor(&qd.arrow); // have to show the arrow confirmFilterUPP = NewModalFilterProc (ConfirmAlertFilter); // create a new modal filter proc UPP alertReturn = Alert(rConfirmSwtchAlrt, confirmFilterUPP); // alert the user DisposeRoutineDescriptor (confirmFilterUPP); // of course there is no DisposeModalFilterProc... if (alertReturn != iConfirmItem) return (-1); // tell the caller to switch back to a known setting else return (noErr); // all is well with the new setting, just leave it } return (noErr); // the mode was safe, so do nothing }
int DoHostListDialog() { short itemHit,okay=FALSE,keepGoing=TRUE; DialogPtr dlog=NIL; GrafPtr oldPort; ModalFilterUPP MyFilterUPP; GetPort(&oldPort); /* On PowerPC, need a RoutineDescriptor from heap; on 68K, no allocation */ MyFilterUPP = NewModalFilterProc(MyFilterHD); if (MyFilterUPP == NIL) goto cleanUp; /* Build dialog window and install its item values */ OpenPrefsFile(); dlog = OpenThisDialog(); if (dlog == NIL) goto cleanUp; /* Entertain filtered user events until dialog is dismissed */ while (keepGoing) { ModalDialog(MyFilterUPP,&itemHit); keepGoing = DoDialogItem(dlog,itemHit); } /* * Do final processing of item values, such as exporting them to caller. * DoDialogItem() has already called AnyBadValues(). */ if (itemHit == OK_ITEM) { Point theCell; short dataLen; OSErr anErr; Handle aHand; // get the current selection and store it in a global which can be accessed // from the application theCell.h = 0; theCell.v = list4.currentRow; dataLen = 255; LGetCell(&gSavedSelection[1], &dataLen, theCell, list4.hndl); gSavedSelection[0] = dataLen; // we save the current selection for the next time we use this transport // remove the current resource aHand = Get1Resource('mw2H', 1000); if (aHand != nil) { RemoveResource(aHand); DisposeHandle(aHand); aHand = nil; } // create a handle and add this resource to the resource file anErr = PtrToHand(&gSavedSelection[0], &aHand, gSavedSelection[0] + 1); // name and length byte if ( (anErr == noErr) && (aHand != nil) ) { AddResource(aHand, 'mw2H', 1000, "\pDefault Host"); WriteResource(aHand); }