static OSErr AddReplaceRecord(DialogPtr dialog,Boolean incrementDepth,Boolean replace,DepthValuesSet dvals) { long n,itemnum,curSelection; OSErr err=0; if(!err) { // will need to define InsertSorted for the CDOG profiles data type, sort by depth err=sgDepthVals->InsertSorted ((Ptr)&dvals,&itemnum,false);// false means don't allow duplicate times if(!err) // new record { VLAddItem(1,&sgObjects); VLSetSelect(itemnum, &sgObjects); VLAutoScroll(&sgObjects); VLUpdate(&sgObjects); if(incrementDepth)IncrementDepth(dialog,dvals.depth); } else if(err == -2) // found existing record. Replace if okay to replace { if(replace) { sgDepthVals->DeleteItem(itemnum); VLDeleteItem(itemnum,&sgObjects); err = AddReplaceRecord(dialog,!INCREMENT_DEPTH,REPLACE,dvals); VLUpdate(&sgObjects); if(incrementDepth)IncrementDepth(dialog,dvals.depth); err=0; } else { printError("A record with the specified depth already exists." "If you want to edit the existing record, select it." "If you want to add a new record, change the specified depth."); VLUpdate(&sgObjects); } } else SysBeep(5); } return err; }
// -------------------------------------------------------------------------------------- OSStatus handleCommand(HICommand command) { OSStatus result = eventNotHandledErr; switch (command.commandID) { /* Note that we're not handling the Quit HI Command here. Instead we let the default handler process it which sends us a Quit Application Apple Event, which we are "required" to handle anyways. Similarly we are letting the default handler process the Close HI Command which sends a close window Carbon Event to the appropriate window. */ case kHICommandAbout: SysBeep(30); result = noErr; break; case kCommandPrWin: OpenPrefsWindow(); result = noErr; break; case kCommandPrDlg: OpenPrefsDialog(); result = noErr; break; default: // there isn't a recognized command ID; see if it's a menu item we know if ((command.attributes & kHICommandFromMenu) != 0) { MenuID menuID; menuID = GetMenuID(command.menu.menuRef); switch (menuID) { // all of our menu items have commands but if they didn't we } // would further switch on command.menu.menuItemIndex } } return result; }
/* Activate the system beeper */ void msec_beep(int delay, int freq, int msec) { a1logd(g_log,8, "msec_beep %d msec\n",msec); if (delay > 0) { if (beep_thread != NULL) beep_thread->del(beep_thread); beep_delay = delay; beep_freq = freq; beep_msec = msec; if ((beep_thread = new_athread(delayed_beep, NULL)) == NULL) a1logw(g_log, "msec_beep: Delayed beep failed to create thread\n"); } else { a1logd(g_log,8, "msec_beep activate\n"); #ifdef __APPLE__ # if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 AudioServicesPlayAlertSound(kUserPreferredAlert); # else SysBeep((msec * 60)/1000); # endif #else /* UNIX */ fprintf(stdout, "\a"); fflush(stdout); #endif } }
// Set s_bSkipExitConfirmation to true if cancelled because of logging out or shutting down OSErr QuitAppleEventHandler( const AppleEvent *appleEvt, AppleEvent* reply, UInt32 refcon ) { DescType senderType; Size actualSize; ProcessSerialNumber SenderPSN; ProcessInfoRec pInfo; FSSpec fileSpec; OSStatus anErr; // Refuse to quit if a modal dialog is open. // Unfortunately, I know of no way to disable the Quit item in our Dock menu if (wxGetApp().IsModalDialogDisplayed()) { SysBeep(4); return userCanceledErr; } anErr = AEGetAttributePtr(appleEvt, keyAddressAttr, typeProcessSerialNumber, &senderType, &SenderPSN, sizeof(SenderPSN), &actualSize); if (anErr == noErr) { pInfo.processInfoLength = sizeof( ProcessInfoRec ); pInfo.processName = NULL; pInfo.processAppSpec = &fileSpec; anErr = GetProcessInformation(&SenderPSN, &pInfo); // Consider a Quit command from our Dock menu as coming from this application if ( (pInfo.processSignature != 'dock') && (pInfo.processSignature != 'BNC!') ) { s_bSkipExitConfirmation = true; // Not from our app, our dock icon or our taskbar icon // The following may no longer be needed under wxCocoa-3.0.0 wxGetApp().ExitMainLoop(); // Prevents wxMac from issuing events to closed frames } } wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, wxID_EXIT); wxGetApp().GetFrame()->GetEventHandler()->AddPendingEvent(evt); return noErr; }
void InformUserOfCrash( const CString &sPath ) { CFStringRef error; error = CFStringCreateWithCString(kCFAllocatorDefault, "StepMania has crashed. Debug " "information has been output to\n\n " + sPath + "\n\nPlease report a bug at:" "\n\nhttp://sourceforge.net/tracker/" "?func=add&group_id=37892&atid=421366", kCFStringEncodingASCII); CFStringRef OK = CFSTR("Open crashinfo"); CFStringRef Cancel = CFSTR("Cancel"); struct AlertStdCFStringAlertParamRec params = {kStdCFStringAlertVersionOne, true, false, OK, Cancel, NULL, kAlertStdAlertOKButton, kAlertStdAlertCancelButton, kWindowAlertPositionParentWindowScreen, NULL}; DialogRef dialog; SInt16 button; CreateStandardAlert(kAlertStopAlert, error, NULL, ¶ms, &dialog); AutoSizeDialog(dialog); RunStandardAlert(dialog, NULL, &button); switch (button) { case kAlertStdAlertOKButton: // This is lazy, and easy, and it seems to work. if (system(NULL)) system("/usr/bin/open '" + sPath + "'"); else SysBeep(30); break; } CFRelease(OK); CFRelease(Cancel); CFRelease(error); }
// True for OK, false for cancel bool Configure_ChaseCam(ChaseCamData &Data) { short ItemType; Rect Bounds; DialogPtr Dialog = myGetNewDialog(ChaseCam_Dialog, NULL, (WindowPtr)(-1), 0); assert(Dialog); ControlHandle Behind_CHdl; GetDialogItem(Dialog, Behind_Item, &ItemType, (Handle *)&Behind_CHdl, &Bounds); SetFloat(Behind_CHdl,Data.Behind/FLOAT_WORLD_ONE); ControlHandle Upward_CHdl; GetDialogItem(Dialog, Upward_Item, &ItemType, (Handle *)&Upward_CHdl, &Bounds); SetFloat(Upward_CHdl,Data.Upward/FLOAT_WORLD_ONE); ControlHandle Rightward_CHdl; GetDialogItem(Dialog, Rightward_Item, &ItemType, (Handle *)&Rightward_CHdl, &Bounds); SetFloat(Rightward_CHdl,Data.Rightward/FLOAT_WORLD_ONE); MacCheckbox PassThruWall_CB(Dialog, PassThruWall_Item, TEST_FLAG(Data.Flags,_ChaseCam_ThroughWalls)); MacCheckbox NeverActive_CB(Dialog, NeverActive_Item, TEST_FLAG(Data.Flags,_ChaseCam_NeverActive)); MacCheckbox OnWhenEntering_CB(Dialog, OnWhenEntering_Item, TEST_FLAG(Data.Flags,_ChaseCam_OnWhenEntering)); ControlHandle Damping_CHdl; GetDialogItem(Dialog, Damping_Item, &ItemType, (Handle *)&Damping_CHdl, &Bounds); SetFloat(Damping_CHdl,Data.Damping); ControlHandle Spring_CHdl; GetDialogItem(Dialog, Spring_Item, &ItemType, (Handle *)&Spring_CHdl, &Bounds); SetFloat(Spring_CHdl,Data.Spring); ControlHandle Opacity_CHdl; GetDialogItem(Dialog, CC_Opacity_Item, &ItemType, (Handle *)&Opacity_CHdl, &Bounds); SetFloat(Opacity_CHdl,Data.Opacity); // Where to make the color picker Point Center = {-1,-1}; RGBColor NewColor; // Get void color from OpenGL-parameters data OGL_ConfigureData& OGLData = Get_OGL_ConfigureData(); MacCheckbox VoidColorOnOff_CB(Dialog, VoidColorOnOff_Item, TEST_FLAG(OGLData.Flags,OGL_Flag_VoidColor)); // Reveal it #if USE_SHEETS SetThemeWindowBackground(GetDialogWindow(Dialog), kThemeBrushSheetBackgroundTransparent, false); ShowSheetWindow(GetDialogWindow(Dialog), ActiveNonFloatingWindow()); #else SelectWindow(GetDialogWindow(Dialog)); ShowWindow(GetDialogWindow(Dialog)); #endif bool WillQuit = false; bool IsOK = false; short New_Behind = 0, New_Upward = 0, New_Rightward = 0; float FloatTemp = 0; bool BadValue; float New_Damping, New_Spring, New_Opacity; while(!WillQuit) { short ItemHit; ModalDialog(NULL, &ItemHit); switch(ItemHit) { case OK_Item: // Check before quitting BadValue = false; // Now doing roundoff correctly // Using a modification of AlexJLS's corrected version if (GetFloat(Behind_CHdl,FloatTemp)) New_Behind = FloatRoundoff(WORLD_ONE * FloatTemp); else BadValue = true; if (GetFloat(Upward_CHdl,FloatTemp)) New_Upward = FloatRoundoff(WORLD_ONE * FloatTemp); else BadValue = true; if (GetFloat(Rightward_CHdl,FloatTemp)) New_Rightward = FloatRoundoff(WORLD_ONE * FloatTemp); else BadValue = true; if (GetFloat(Damping_CHdl,FloatTemp)) { // Simple validation of the damping factor New_Damping = PIN(FloatTemp,-1,1); if (New_Damping != FloatTemp) { BadValue = true; SetFloat(Damping_CHdl,New_Damping); } } else BadValue = true; if (GetFloat(Spring_CHdl,FloatTemp)) { New_Spring = FloatTemp; } else BadValue = true; if (GetFloat(Opacity_CHdl,FloatTemp)) { New_Opacity = PIN(FloatTemp,0,1); if (New_Opacity != FloatTemp) { BadValue = true; SetFloat(Opacity_CHdl,New_Opacity); } } else BadValue = true; // Do validation: will the chase cam be unstable? if (!BadValue) { if (New_Spring >= 0) { // Oscillatory case float NewDampSq = New_Damping*New_Damping; BadValue = ((NewDampSq + New_Spring) >= 1); if (BadValue) { New_Spring = 1 - NewDampSq; SetFloat(Spring_CHdl,New_Spring); } } else { // Overdamped case float NewDampAbs = fabs(New_Damping); BadValue = ((NewDampAbs + sqrt(-New_Spring)) >= 1); if (BadValue) { float Temp = 1 - NewDampAbs; New_Spring = - Temp*Temp; SetFloat(Spring_CHdl,New_Spring); } } } if (BadValue) { SysBeep(30); break; } IsOK = true; WillQuit = true; break; case Cancel_Item: IsOK = false; WillQuit = true; break; case VoidColorSelect_Item: // Need to set color here so the preview can work properly if (GetColor(Center,"\pWhat color for the void?",&OGLData.VoidColor,&NewColor)) OGLData.VoidColor = NewColor; break; default: if (PassThruWall_CB.ToggleIfHit(ItemHit)) break; if (NeverActive_CB.ToggleIfHit(ItemHit)) break; if (OnWhenEntering_CB.ToggleIfHit(ItemHit)) break; if (VoidColorOnOff_CB.ToggleIfHit(ItemHit)) break; break; } } if (IsOK) { Data.Behind = New_Behind; Data.Upward = New_Upward; Data.Rightward = New_Rightward; SET_FLAG(Data.Flags,_ChaseCam_ThroughWalls,PassThruWall_CB.GetState()); SET_FLAG(Data.Flags,_ChaseCam_NeverActive,NeverActive_CB.GetState()); SET_FLAG(Data.Flags,_ChaseCam_OnWhenEntering,OnWhenEntering_CB.GetState()); SET_FLAG(OGLData.Flags,OGL_Flag_VoidColor,VoidColorOnOff_CB.GetState()); Data.Damping = New_Damping; Data.Spring = New_Spring; Data.Opacity = New_Opacity; } // Clean up #if USE_SHEETS HideSheetWindow(GetDialogWindow(Dialog)); #else HideWindow(GetDialogWindow(Dialog)); #endif DisposeDialog(Dialog); return IsOK; }
short EditProfilesClick(DialogPtr dialog, short itemNum, long lParam, VOIDPTR data) { Point pos,mp,clippedPos; Rect r; double speed, direction; long curSelection; long dir,i,n; unsigned long incr; char s[30]; OSErr err=0,settingsErr = 0; CProfilesList *tlist; DepthValuesSet dvals; //if (AddRecordRowIsSelected2()) if (VLAddRecordRowIsSelected(&sgObjects)) { //Last row is selected //Disable delete button MyEnableControl(dialog,EPDELETEROWS_BTN,FALSE); // And change title in replace dialog to "Add new record" MySetControlTitle(dialog, EPREPLACE, "Add New Record"); } else { MySetControlTitle(dialog, EPREPLACE, "Replace Selected"); MyEnableControl(dialog,EPDELETEROWS_BTN,TRUE); } switch(itemNum) { case EPOK: { // don't retrieve increment here // Just use the value from the last time they incremented. // Why bother them if we are not going to use the value. //if(ShowAutoIncrement2()) err = RetrieveIncrementDepth(dialog); //if(err) break; //sgSpeedUnits = GetPopSelection(dialog, EPSPEEDPOPUP); if(sgDepthVals) { DepthValuesSetH dvalsh = sgDepthValuesH; n = sgDepthVals->GetItemCount(); if(n == 0) { // no items are entered, tell the user char msg[512],buttonName[64]; GetWizButtonTitle_Cancel(buttonName); sprintf(msg,"You have not entered any data values. Either enter data values and use the 'Add New Record' button, or use the '%s' button to exit the dialog.",buttonName); printError(msg); break; } // check that all the values are in range - if there is some range // or may allow the user to change units for(i=0; i<n; i++) { char errStr[256] = ""; err=sgDepthVals->GetListItem((Ptr)&dvals,i); if(err) { SysBeep(5); // this shouldn't ever happen break; } /*UV2RTheta(dvals.value.u,dvals.value.v,&r,&theta); err = CheckWindSpeedLimit(r,sgSpeedUnits,errStr); if(err) { strcat(errStr," Check your units and each of the records you entered."); printError(errStr); return 0; // stay in the dialog }*/ } //sCellLength = EditText2Float(dialog,EPDXDY); // use map size instead and calculate km from that //sNumCells = EditText2Float(dialog,EPNUMCELLS); // will want to check that spill is inside of the grid, and grid is not super small ///////////// // point of no return ////////////// if(dvalsh == 0) { dvalsh = (DepthValuesSetH)_NewHandle(n*sizeof(DepthValuesSet)); if(!dvalsh) { TechError("EditProfilesClick:OKAY", "_NewHandle()", 0); //return EPCANCEL; break; // make them cancel so that code gets executed } sgDepthValuesH = dvalsh; } else { _SetHandleSize((Handle)dvalsh,n*sizeof(DepthValuesSet)); if(_MemError()) { TechError("EditProfilesClick:OKAY", "_NewHandle()", 0); //return EPCANCEL; break; // make them cancel, so that code gets executed } } for(i=0; i<n; i++) { if(err=sgDepthVals->GetListItem((Ptr)&dvals,i))return EPOK; (*dvalsh)[i]=dvals; } } ///////////////////////////// DisposeEPStuff(); return EPOK; } case EPCANCEL: //SetEPDialogNonPtrFields(sgWindMover,&sharedEPDialogNonPtrFields); DisposeEPStuff(); return EPCANCEL; break; case EPINCREMENT: case EPDEPTH: case EPTEMP: case EPSAL: //case EPDXDY: CheckNumberTextItem(dialog, itemNum, TRUE); // allow decimals break; case EPU: case EPV: //case EPDXDY: CheckNumberTextItemAllowingNegative(dialog, itemNum, TRUE); // allow decimals break; //case EPNUMCELLS: //CheckNumberTextItem(dialog, itemNum, FALSE); // don't allow decimals //break; case EPDELETEALL: sgDepthVals->ClearList(); VLReset(&sgObjects,1); UpdateDisplayWithCurSelection(dialog); break; case EPDELETEROWS_BTN: if (VLGetSelect(&curSelection, &sgObjects)) { sgDepthVals->DeleteItem(curSelection); VLDeleteItem(curSelection,&sgObjects); if(sgObjects.numItems == 0) { VLAddItem(1,&sgObjects); VLSetSelect(0,&sgObjects); } --curSelection; if(curSelection >-1) { VLSetSelect(curSelection,&sgObjects); } VLUpdate(&sgObjects); } UpdateDisplayWithCurSelection(dialog); break; //case EPSPEEDPOPUP: //{ //PopClick(dialog, itemNum, &sgSpeedUnits); //} //break; case EPREPLACE: err = RetrieveIncrementDepth(dialog); if(err) break; if (VLGetSelect(&curSelection, &sgObjects)) { err=GetDepthVals(dialog,&dvals); if(err) break; if(curSelection==sgDepthVals->GetItemCount()) { // replacing blank record err = AddReplaceRecord(dialog,INCREMENT_DEPTH,!REPLACE,dvals); SelectNthRow(dialog, curSelection+1 ); } else // replacing existing record { VLGetSelect(&curSelection,&sgObjects); sgDepthVals->DeleteItem(curSelection); VLDeleteItem(curSelection,&sgObjects); err = AddReplaceRecord(dialog,!INCREMENT_DEPTH,REPLACE,dvals); } } break; case EPLIST: // retrieve every time they click on the list // because clicking can cause the increment to be hidden // and we need to verify it before it gets hidden err = RetrieveIncrementDepth(dialog); if(err) break; /////////// pos=GetMouseLocal(GetDialogWindow(dialog)); VLClick(pos, &sgObjects); VLUpdate(&sgObjects); VLGetSelect(&curSelection,&sgObjects); if(curSelection == -1 ) { curSelection = sgObjects.numItems-1; VLSetSelect(curSelection,&sgObjects); VLUpdate(&sgObjects); } //ShowHideAutoIncrement(dialog,curSelection); // moved into UpdateDisplayWithCurSelection() //if (AddRecordRowIsSelected2()) if (VLAddRecordRowIsSelected(&sgObjects)) { DepthValuesSet dvals; sgDepthVals->GetListItem((Ptr)&dvals,sgDepthVals->GetItemCount()-1); err = RetrieveIncrementDepth(dialog); if(err) break; IncrementDepth(dialog,dvals.depth); } UpdateDisplayWithCurSelection(dialog); break; } return 0; }
Boolean FTTdriverNode::TT1pGo(void){ if(!pTree->D.initInfo.TT1p.memoryOK || pTree->D.initInfo.TT1p.done){ actOnFailure(t1p); return TRUE; } if(!TT1p){ send(calibrateTT1pmsg); if(pTree->D.bank.TT1paccount.minRequired<TT1pminRequired) pTree->D.bank.TT1paccount.minRequired=TT1pminRequired; if(pTree->D.bank.TT1paccount.payCheck<TT1pPayCheck) pTree->D.bank.TT1paccount.payCheck=TT1pPayCheck; if(TT1pRepeatMax==AUTO_SET) TT1pRepeatMax=currentPres->f->numItems; TT1p=new FTT1pnode(this,pTree,currentPres); if(!TT1p->initOK){ delete TT1p;TT1p=0; actOnFailure(t1p); return TRUE; } TT1pRepeatNum=0; } #ifdef Frank_GenuineMac TRY{ #endif if(!TT1p->run()){ delete TT1p;TT1p=0; lowFail("FTTdriverNode::TT1pGo::after releasing memory"); if(newPres){ mailPerson=LibMail; } else{ actOnFailure(t1p); } } #ifdef Frank_GenuineMac } CATCH{ if(gLastError==memFullErr){ // we have run out of memory. // set the memory flag FALSE and // post warning. pTree->D.initInfo.TT1p.memoryOK=FALSE; SysBeep(1); tout <= "TT1p is out of memory and cannot" <=" determine if this relator is a " <="consequence of the others. The enumeration" <=" of presentations has been COMPROMISED." <= "\n"; // clean up delete TT1p;TT1p=0; actOnFailure(t1p); NO_PROPAGATE; } } ENDTRY; #endif return(TRUE); }
/* VARARGS ARGSUSED */ void TclpPanic TCL_VARARGS_DEF(CONST char *, format) { va_list varg; char msg[256]; WindowRef macWinPtr, foundWinPtr; Rect macRect; Rect buttonRect = PANIC_BUTTON_RECT; Rect iconRect = PANIC_ICON_RECT; Rect textRect = PANIC_TEXT_RECT; ControlHandle okButtonHandle; EventRecord event; Handle stopIconHandle; int part; Boolean done = false; va_start(varg, format); vsprintf(msg, format, varg); va_end(varg); /* * Put up an alert without using the Resource Manager (there may * be no resources to load). Use the Window and Control Managers instead. * We want the window centered on the main monitor. The following * should be tested with multiple monitors. Look and see if there is a way * not using qd.screenBits. */ macRect.top = (qd.screenBits.bounds.top + qd.screenBits.bounds.bottom) / 2 - (PANICHEIGHT / 2); macRect.bottom = (qd.screenBits.bounds.top + qd.screenBits.bounds.bottom) / 2 + (PANICHEIGHT / 2); macRect.left = (qd.screenBits.bounds.left + qd.screenBits.bounds.right) / 2 - (PANICWIDTH / 2); macRect.right = (qd.screenBits.bounds.left + qd.screenBits.bounds.right) / 2 + (PANICWIDTH / 2); macWinPtr = NewWindow(NULL, &macRect, "\p", true, dBoxProc, (WindowRef) -1, false, 0); if (macWinPtr == NULL) { goto exitNow; } okButtonHandle = NewControl(macWinPtr, &buttonRect, "\pOK", true, 0, 0, 1, pushButProc, 0); if (okButtonHandle == NULL) { CloseWindow(macWinPtr); goto exitNow; } SelectWindow(macWinPtr); SetCursor(&qd.arrow); stopIconHandle = GetIcon(kStopIcon); while (!done) { if (WaitNextEvent(mDownMask | keyDownMask | updateMask, &event, 0, NULL)) { switch(event.what) { case mouseDown: part = FindWindow(event.where, &foundWinPtr); if ((foundWinPtr != macWinPtr) || (part != inContent)) { SysBeep(1); } else { SetPortWindowPort(macWinPtr); GlobalToLocal(&event.where); part = FindControl(event.where, macWinPtr, &okButtonHandle); if ((kControlButtonPart == part) && (TrackControl(okButtonHandle, event.where, NULL))) { done = true; } } break; case keyDown: switch (event.message & charCodeMask) { case ENTERCODE: case RETURNCODE: HiliteControl(okButtonHandle, 1); HiliteControl(okButtonHandle, 0); done = true; } break; case updateEvt: SetPortWindowPort(macWinPtr); TextFont(systemFont); BeginUpdate(macWinPtr); if (stopIconHandle != NULL) { PlotIcon(&iconRect, stopIconHandle); } TETextBox(msg, strlen(msg), &textRect, teFlushDefault); DrawControls(macWinPtr); EndUpdate(macWinPtr); } } } CloseWindow(macWinPtr); exitNow: #ifdef TCL_DEBUG Debugger(); #else abort(); #endif }
A4(PRIVATE, void, dobuttons, INTEGER, id, INTEGER, offsetx, INTEGER, offsety, BOOLEAN, demo_button_p) { struct bdef *bp; struct sdef *sp; struct pdef *pp; int i; EventRecord evt; int done; int tcnt, twid; Point p; #define BILLBUTTONS /* */ #if defined (BILLBUTTONS) INTEGER h, v; #endif /* BILLBUTTONS */ char *textp; if ((bp = (struct bdef *) findid(id))) { for (i = 0; i < Cx(bp->nbut); i++) { /* Offset buttons; this hack is to center the splash screen * on non-512x342 root windows...yuck! */ C_OffsetRect (&bp->buts[i].butloc, offsetx, offsety); if ((sp = (struct sdef *)findid(CW(bp->buts[i].butstrid)))) { if (demo_button_p && sp->text[0] == 'O' && sp->text[1] == 'K') textp = "Demo"; else textp = sp->text; tcnt = strlen(textp); twid = TextWidth((Ptr) textp, 0, tcnt); MoveTo((CW(bp->buts[i].butloc.left) + CW(bp->buts[i].butloc.right) - twid) / 2, (CW(bp->buts[i].butloc.top) + CW(bp->buts[i].butloc.bottom)) / 2 + 4); DrawText((Ptr) textp, 0, tcnt); } #if defined (BILLBUTTONS) h = CW(bp->buts[i].butloc.right) - CW(bp->buts[i].butloc.left); v = (CW(bp->buts[i].butloc.bottom) - CW(bp->buts[i].butloc.top))/2; if (h > v) h = v; if (!(ROMlib_options & ROMLIB_RECT_SCREEN_BIT)) FrameRoundRect(&bp->buts[i].butloc, h, v); else FrameRect(&bp->buts[i].butloc); #else /* BILLBUTTONS */ if (!(ROMlib_options & ROMLIB_RECT_SCREEN_BIT)) FrameRoundRect(&bp->buts[i].butloc, 10, 10); else FrameRect(&bp->buts[i].butloc); #endif /* BILLBUTTONS */ } for (done = 0; !done;) { C_GetNextEvent(mDownMask|keyDownMask, &evt); if (evt.what == CWC(mouseDown) || evt.what == CWC(keyDown)) { p.h = CW(evt.where.h); p.v = CW(evt.where.v); for (i = 0; !done && i < CW(bp->nbut); i++) { if (PtInRect(p, &bp->buts[i].butloc) || ((evt.what == CWC(keyDown)) && (((CL(evt.message) & charCodeMask) == '\r') || ((CL(evt.message) & charCodeMask) == NUMPAD_ENTER))) ) { if ((pp = (struct pdef *) findid(CW(bp->buts[i].butprocid)))) /* NOTE: we will have to do a better job here sometime */ (*(void (*)(void))MR(pp->proc))(); done = 1; } } if (!done) SysBeep(1); } } if (evt.what == CWC(mouseDown)) while (!C_GetNextEvent(mUpMask, &evt)) ; /* Move all buttons back. */ for (i = 0; i < Cx(bp->nbut); i++) C_OffsetRect (&bp->buts[i].butloc, -offsetx, -offsety); } }
void spend_xp_event_filter (short item_hit) { short pc_num; bool talk_done = false; pc_num = store_train_pc; switch (item_hit) { case 73: dialog_answer = 0; talk_done = true; break; case 3: case 4: if ((store_h >= 250) && (item_hit == 4)) SysBeep(2); else { if (item_hit == 3) { store_g += 10; store_h -= 2; store_skp += 1; } else { if ((store_g < 10) || (store_skp < 1)) { SysBeep(2); } else { store_g -= 10; store_h += 2; store_skp -= 1; } } update_gold_skills(); cd_set_item_num(1010,52,store_h); draw_xp_skills(); } break; case 5: case 6: if ((store_sp >= 150) && (item_hit == 6)) SysBeep(2); else { if (item_hit == 5) { store_g += 15; store_sp -= 1; store_skp += 1; } else { if ((store_g < 15) || (store_skp < 1)) { SysBeep(2); } else { store_sp += 1; store_g -= 15; store_skp -= 1; } } update_gold_skills(); cd_set_item_num(1010,53,store_sp); draw_xp_skills(); } break; case 48: do_xp_keep(pc_num,0); dialog_answer = 1; talk_done = true; break; case 49: do_xp_keep(pc_num,0); do { pc_num = (pc_num == 0) ? 5 : pc_num - 1; } while (univ.party[pc_num].main_status != 1); store_train_pc = pc_num; do_xp_draw(); break; case 50: do_xp_keep(pc_num,0); do { pc_num = (pc_num == 5) ? 0 : pc_num + 1; } while (univ.party[pc_num].main_status != 1); store_train_pc = pc_num; do_xp_draw(); break; case 100: break; default: if (item_hit >= 100) { } else { which_skill = (item_hit - 7) / 2; if (((store_skills[which_skill] >= skill_max[which_skill]) && ((item_hit - 7) % 2 == 1)) || ((store_skills[which_skill] == 0) && ((item_hit - 7) % 2 == 0) && (which_skill > 2)) || ((store_skills[which_skill] == 1) && ((item_hit - 7) % 2 == 0) && (which_skill <= 2))) SysBeep(2); else { if ((item_hit - 7) % 2 == 0) { store_g += skill_g_cost[which_skill]; store_skills[which_skill] -= 1; store_skp += skill_cost[which_skill]; } else { if ((store_g < skill_g_cost[which_skill]) || (store_skp < skill_cost[which_skill])) { SysBeep(2); } else { store_skills[which_skill] += 1; store_g -= skill_g_cost[which_skill]; store_skp -= skill_cost[which_skill]; } } update_gold_skills(); cd_set_item_num(1010,54 + which_skill,store_skills[which_skill]); draw_xp_skills(); } } break; } store_train_pc = pc_num; if (talk_done == true) { toast_dialog(); } }
/*-----------------------------------------------------------* * Inflation *-----------------------------------------------------------*/ OSErr ExtractCoreFile(short srcVRefNum, long srcDirID, short tgtVRefNum, long tgtDirID) { OSErr err = noErr; StringPtr coreFile = 0; UInt32 endTicks; short fullPathLen = 0; Handle fullPathH = 0; Ptr fullPathStr = 0; PRInt32 rv = 0; void *hZip = 0, *hFind = 0; /* if there's a core file... */ HLock(gControls->cfg->coreFile); if (*gControls->cfg->coreFile != NULL) { /* make local copy and unlock handle */ coreFile = CToPascal(*gControls->cfg->coreFile); if (!coreFile) { err = memFullErr; goto cleanup; } } else return fnfErr; HUnlock(gControls->cfg->coreFile); ERR_CHECK_RET(GetFullPath(srcVRefNum, srcDirID, coreFile, &fullPathLen, &fullPathH), err); /* --- o p e n a r c h i v e --- */ /* extract the full path string from the handle so we can NULL terminate */ HLock(fullPathH); fullPathStr = NewPtrClear(fullPathLen+1); strncat(fullPathStr, *fullPathH, fullPathLen); *(fullPathStr+fullPathLen) = '\0'; rv = ZIP_OpenArchive( fullPathStr, &hZip ); HUnlock(fullPathH); if (rv!=ZIP_OK) goto cleanup; /* initialize the search */ hFind = ZIP_FindInit( hZip, NULL ); /* null to match all files in archive */ /* --- i n f l a t e a l l f i l e s --- */ err = InflateFiles(hZip, hFind, tgtVRefNum, tgtDirID); if (err!=noErr) goto cleanup; /* XXX review later: this check may be pointless */ /* --- c l o s e a r c h i v e --- */ cleanup: //if (hFind) // rv = ZIP_FindFree( hFind ); #ifdef MIW_DEBUG if (rv!=ZIP_OK) SysBeep(10); #endif if (hZip) rv = ZIP_CloseArchive( &hZip ); #ifdef MIW_DEBUG if (rv!=ZIP_OK) SysBeep(10); #endif if (coreFile) DisposePtr((Ptr)coreFile); if (fullPathH) DisposeHandle(fullPathH); if (fullPathStr) DisposePtr(fullPathStr); /* pause till frag registry is updated */ endTicks = TickCount() + 60; while (TickCount() < endTicks) { YieldToAnyThread(); } return err; }
/**************************************************************** PopDraw() is the function associated with the user item that invokes the popup menu. We draw the box to look like a menu cell, and then call the appropriate drawProc to fill in the cell with the actual contents. If the drawProc is nil, we draw the menu item as text. We gray the cell if the menu is disabled. Finally, we draw a down arrow to indicate that the button is a popup menu. If the popup item is static, we only draw the cell contents. ****************************************************************/ pascal_ifMac void PopDraw(DialogPtr theDialog, short itemNum) { GrafPtr savePort; short theType; Handle itemHandle; Rect itemBox; Rect cellBox; MenuHandle theMenu; //SysEnvRec theWorld; RGBColor SaveBack, SaveFore, DefaultBack, DefaultFore; char name[256]; short i; short drawStringFlag; // Added by Glen to code for support of Type-in Pop-Up menus // if drawStringFlag = 1 then we don't draw text string ... drawStringFlag = 0; for ( i = 0 ; i < sa_numPopUps ; i++ ) if ( (sa_popTable[i].dialogPtr == theDialog) && (sa_popTable[i].popupItemNum == itemNum) ) break; if (i == sa_numPopUps) { SysBeep(1); return; } // should not happen since the dialog must have been registered // for PopDraw to have been called GetPortGrafPtr(&savePort); SetPortDialogPort(theDialog); // SysEnvirons(curSysEnvVers,&theWorld); // if (theWorld.hasColorQD) { if (ColorQDAvailable()) { GetForeColor(&SaveFore); GetBackColor(&SaveBack); DefaultMenuColors(&DefaultFore, &DefaultBack); if (sa_popTable[i].bStatic) { DefaultFore = SaveFore; DefaultBack = SaveBack; } } theMenu = GetMenuHandle(sa_popTable[i].menuID); if (!theMenu) { SysBeep(1); return; } /* change item's width to match the menu */ GetDialogItem(theDialog,itemNum,&theType,&itemHandle,&itemBox); CalcMenuSize(theMenu); if (sa_popTable[i].itemWidth == 0) { if (sa_popTable[i].drawProc == nil) // itemBox.right = itemBox.left + (**theMenu).menuWidth + 20 + 2; itemBox.right = itemBox.left + GetMenuWidth(theMenu) + 20 + 2; else //itemBox.right = itemBox.left + (**theMenu).menuWidth + 2; itemBox.right = itemBox.left + GetMenuWidth(theMenu) + 2; } else if (sa_popTable[i].itemWidth == -1) { // Type-in Pop-Up Menu itemBox.right = itemBox.left + 20 + 2; drawStringFlag = 1; } else itemBox.right = itemBox.left + sa_popTable[i].itemWidth + 2; SetDialogItem(theDialog,itemNum,theType,itemHandle,&itemBox); /* draw the box */ if (TRUE) { // !sa_popTable[i].bStatic // if (theWorld.hasColorQD) RGBBackColor(&DefaultBack); if (ColorQDAvailable()) RGBBackColor(&DefaultBack); EraseRect( &itemBox ); // if (theWorld.hasColorQD) RGBForeColor(&SaveFore); if (ColorQDAvailable()) RGBForeColor(&SaveFore); PenNormal(); // if (sa_popTable[i].bStatic) PenPat((ConstPatternParam)&qd.gray); //if (sa_popTable[i].bStatic) PenPat((ConstPatternParam)&GRAY_BRUSH()); //if (sa_popTable[i].bStatic) PenPat((ConstPatternParam)&GRAY_BRUSH); if (sa_popTable[i].bStatic) PenPatQDGlobalsGray(); FrameRect(&itemBox); /* draw the shadow */ MoveTo(itemBox.left + 3, itemBox.bottom); Line((itemBox.right - itemBox.left) - 3, 0); Line(0, -((itemBox.bottom - itemBox.top) - 2)); PenNormal(); } else EraseRect( &itemBox ); /* draw the current item in the box */ // if (theWorld.hasColorQD) RGBForeColor(&DefaultFore); if (ColorQDAvailable()) RGBForeColor(&DefaultFore); // Draw text if no Type-in Pop-Up if(drawStringFlag == 0){ if (sa_popTable[i].drawProc != nil) { cellBox = itemBox; InsetRect(&cellBox, 1, 1); (* sa_popTable[i].drawProc) (theMenu, sa_popTable[i].lastItemSelected, &cellBox, // so the drawProc gets the same-size rect, // whether it's drawing in the menu or in the pop-box true, // since we are indeed drawing a pop box item //&theWorld, &DefaultFore, &DefaultBack); } else { MoveTo(itemBox.left + 15, itemBox.top + 4 + (itemBox.bottom - itemBox.top)/2); GetMenuItemText(theMenu, sa_popTable[i].lastItemSelected, (unsigned char *)name); DrawString((unsigned char *)name); } } if (TRUE) { // !sa_popTable[i].bStatic /* cover the item in gray if the menu is disabled */ // if (!((**theMenu).enableFlags & ENABLE_BIT)) { #if TARGET_API_MAC_CARBON Boolean menuIsEnabled = IsMenuItemEnabled(theMenu,0); #else Boolean menuIsEnabled = (**theMenu).enableFlags & ENABLE_BIT; #endif if (!menuIsEnabled) { //PenPat((ConstPatternParam)&qd.gray); //PenPat((ConstPatternParam)&GRAY_BRUSH); PenPatQDGlobalsGray(); PenMode(patOr); //if (theWorld.hasColorQD) RGBForeColor(&DefaultBack); if (ColorQDAvailable()) RGBForeColor(&DefaultBack); else ForeColor(whiteColor); PaintRect(&itemBox); PenNormal(); // if (theWorld.hasColorQD) RGBForeColor(&DefaultFore); if (ColorQDAvailable()) RGBForeColor(&DefaultFore); else ForeColor(blackColor); } /* draw the down arrow */ itemBox.left = itemBox.right - 20; DrawArrow(&itemBox, kDown, sa_popTable[i].bStatic); } //if (theWorld.hasColorQD) { if (ColorQDAvailable()) { RGBForeColor(&SaveFore); RGBBackColor(&SaveBack); } SetPortGrafPort(savePort); }
static Boolean MySystem6or7DialogFilter(DialogRef theDialog, EventRecord *inEvent, DialogItemIndex *itemHit) { if ((inEvent->what == keyDown) || (inEvent->what == autoKey)) { char c = (inEvent->message & charCodeMask); // return or enter key? if ((c == kReturnCharCode) || (c == kEnterCharCode)) { *itemHit = 1; return true; } // tab key or arrow keys? if (c == kTabCharCode) return false; if (c == kLeftArrowCharCode) return false; if (c == kRightArrowCharCode) return false; if (c == kUpArrowCharCode) return false; if (c == kDownArrowCharCode) return false; // digits only for edittext box item #9 ? // pre-Carbon, this would have been: ((DialogPeek)theDialog)->editField+1 == 9 if (GetDialogKeyboardFocusItem(theDialog) == 9) { if ((c < '0') || (c > '9')) { SysBeep(1); return true; } } } // we got a click! if (inEvent->what == mouseDown) { DialogItemType itemType; Handle itemHandle; Rect itemBox; GetDialogItem(theDialog, 13, &itemType, &itemHandle, &itemBox); // is the user item enabled? if (!(itemType & itemDisable)) { CGrafPtr savePort; GetPort(&savePort); SetPortDialogPort(theDialog); Point thePoint = inEvent->where; GlobalToLocal(&thePoint); Boolean inside = PtInRect(thePoint, &itemBox); // is the click inside the user item? if (inside) { // let's constrain and move the spot! // it's possible to track the spot here but it's complex // so we just move on the click and don't track. // that's typical of dialog's user items of that era. Rect userRect1 = {gUserV-4, gUserH-4, gUserV+4, gUserH+4}; EraseRect(&userRect1); InvalWindowRect(GetDialogWindow(theDialog), &userRect1); gUserH = thePoint.h; gUserV = thePoint.v; if (gUserH < itemBox.left+4) gUserH = itemBox.left+4; if (gUserH > itemBox.right-4) gUserH = itemBox.right-4; if (gUserV < itemBox.top+4) gUserV = itemBox.top+4; if (gUserV > itemBox.bottom-4) gUserV = itemBox.bottom-4; Rect userRect2 = {gUserV-4, gUserH-4, gUserV+4, gUserH+4}; InvalWindowRect(GetDialogWindow(theDialog), &userRect2); } SetPort(savePort); } } return false; }
// draw a box, with an optional shadow & connectors void _box(int top, int left, int bottom, int right, int style, int attribute, int fill, int box_flags, int connector) { int width; int v_zoom_top, v_zoom_bottom, h_zoom_left, h_zoom_right; int row_diff, col_diff, row_inc, col_inc, fWait = 0; // zoom the window? if (box_flags & BOX_ZOOMED) { fWait = 1; // zooming requires a fill color; use default if none specified if (fill == -1) GetAtt((unsigned int *)&fill,(unsigned int *)&v_zoom_top); v_zoom_top = v_zoom_bottom = (top + bottom) / 2; h_zoom_left = h_zoom_right = (left + right) / 2; // get the increment for each zoom // (This makes the zoom smooth in all dimensions) if ((row_diff = v_zoom_top - top) <= 0) row_diff = 1; if ((col_diff = h_zoom_left - left) <= 0) col_diff = 1; if (row_diff > col_diff) { // tall skinny box row_inc = (row_diff / col_diff); col_inc = 1; } else { // short wide box col_inc = (col_diff / row_diff); row_inc = 1; } } else { v_zoom_top = top; v_zoom_bottom = bottom; h_zoom_left = left; h_zoom_right = right; } do { if (box_flags & BOX_ZOOMED) { // if zooming, increment the box size v_zoom_top -= row_inc; if (v_zoom_top < top) v_zoom_top = top; v_zoom_bottom += row_inc; if (v_zoom_bottom > bottom) v_zoom_bottom = bottom; h_zoom_left -= col_inc; if (h_zoom_left < left) h_zoom_left = left; h_zoom_right += col_inc; if (h_zoom_right > right) h_zoom_right = right; } // clear the box to the specified attribute if (fill != -1) Scroll(v_zoom_top,h_zoom_left,v_zoom_bottom,h_zoom_right,0,fill); if (style == 0) width = 0; else if ((style == 2) || (style == 4)) width = 2; else width = 1; // draw the two horizontals & the two verticals _line(v_zoom_top,h_zoom_left,(h_zoom_right-h_zoom_left)+1,width,0,attribute,connector); _line(v_zoom_bottom,h_zoom_left,(h_zoom_right-h_zoom_left)+1,width,0,attribute,connector); if (style == 3) width = 2; else if (style == 4) width = 1; _line(v_zoom_top,h_zoom_left,(v_zoom_bottom-v_zoom_top)+1,width,1,attribute,connector); _line(v_zoom_top,h_zoom_right,(v_zoom_bottom-v_zoom_top)+1,width,1,attribute,connector); // if on a fast system, slow things down a bit if (fWait) SysBeep(0,1); } while ((box_flags & BOX_ZOOMED) && ((v_zoom_top > top) || (v_zoom_bottom < bottom) || (h_zoom_left > left) || (h_zoom_right < right))); // check for a shadow if (box_flags & BOX_SHADOWED) { left += 2; right++; if ( left >= right ) left = right - 1; // read the character and attribute, and change // the attribute to black background, low intensity // foreground SetLineColor(++bottom,left,(right-left),7); // shadow the right side of the window for (top++; (top <= bottom); top++) SetLineColor(top,right,2,7); } }
bool Configure_ChaseCam_HandlerData::VerifyAndAdjust() { float Temp; float Damping, Spring; bool IsOK = true; // First, check the spring-constant factors if (GetFloat(DampingCtrl,Damping)) { // Simple damping-factor validation float NewTemp = PIN(Damping, -1, 1); if (NewTemp != Damping) { Damping = NewTemp; SetFloat(DampingCtrl,Damping); IsOK = false; } } else IsOK = false; IsOK = IsOK && GetFloat(SpringCtrl,Spring); if (IsOK) { // Do validation: will the chase cam be unstable? if (Spring >= 0) { // Oscillatory case float DampSq = Damping*Damping; if ((DampSq + Spring) >= 1) { Spring = 1 - DampSq; SetFloat(SpringCtrl,Spring); IsOK = false; } } else { // Overdamped case float DampAbs = fabs(Damping); if ((DampAbs + sqrt(-Spring)) >= 1) { float DACmpl = 1 - DampAbs; Spring = - DACmpl*DACmpl; SetFloat(SpringCtrl,Spring); IsOK = false; } } } // Don't really need these values here IsOK = IsOK && GetFloat(BehindCtrl,Temp); IsOK = IsOK && GetFloat(UpwardCtrl,Temp); IsOK = IsOK && GetFloat(RightwardCtrl,Temp); // Get the opacity to within a reasonable range if (GetFloat(CC_OpacityCtrl,Temp)) { float NewTemp = PIN(Temp, 0, 1); if (NewTemp != Temp) { SetFloat(CC_OpacityCtrl, NewTemp); IsOK = false; } } else IsOK = false; if (!IsOK) SysBeep(30); return IsOK; }
int #ifdef ACTIVEGS macmain #else main #endif (int argc, char* argv[]) { ProcessSerialNumber my_psn; IBNibRef nibRef; EventHandlerUPP handlerUPP; EventTypeSpec cmd_event[3]; GDHandle g_gdhandle; Rect win_rect; OSStatus err; char *argptr; int slash_cnt; int i; #ifndef ACTIVEGS /* Prepare argv0 */ slash_cnt = 0; argptr = argv[0]; for(i = strlen(argptr); i >= 0; i--) { if(argptr[i] == '/') { slash_cnt++; if(slash_cnt == 3) { strncpy(&(g_argv0_path[0]), argptr, i); g_argv0_path[i] = 0; } } } printf("g_argv0_path is %s\n", g_argv0_path); g_mac_argv[0] = argv[0]; g_mac_argc = 1; i = 1; while((i < argc) && (g_mac_argc < MAX_MAC_ARGS)) { if(!strncmp(argv[i], "-psn", 4)) { /* skip this argument */ } else { g_mac_argv[g_mac_argc++] = argv[i]; } i++; } #endif InitCursor(); g_event_rgnhandle = NewRgn(); g_status_font_family = FMGetFontFamilyFromName("\pCourier"); SetRect(&win_rect, 0, 0, X_A2_WINDOW_WIDTH, X_A2_WINDOW_HEIGHT // OG Remove status line from ActiveGS window #ifndef ACTIVEGS + MAX_STATUS_LINES*16 + 8 #endif ); OffsetRect(&win_rect, 64, 50); // Create a Nib reference passing the name of the nib file // CreateNibReference only searches into the application bundle. err = CreateNibReference(CFSTR("main"), &nibRef); require_noerr( err, CantGetNibRef ); // Once the nib reference is created, set the menu bar. err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar")); require_noerr( err, CantSetMenuBar ); #ifndef ACTIVEGS err = CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute, &win_rect, &g_main_window); err = SetWindowTitleWithCFString(g_main_window, CFSTR("GSport")); #else err = CreateNewWindow(kDocumentWindowClass, (kWindowCloseBoxAttribute /*| kWindowFullZoomAttribute */| kWindowCollapseBoxAttribute /*| kWindowResizableAttribute*/) /*kWindowStandardDocumentAttributes*/ | kWindowStandardHandlerAttribute, &win_rect, &g_main_window); extern CFStringRef activeGSversionSTR; err = SetWindowTitleWithCFString(g_main_window, activeGSversionSTR); #endif //printf("CreateNewWindow ret: %d, g_main_window: %p\n", (int)err, g_main_window); // We don't need the nib reference anymore. DisposeNibReference(nibRef); SysBeep(120); handlerUPP = NewEventHandlerUPP( my_cmd_handler ); cmd_event[0].eventClass = kEventClassCommand; cmd_event[0].eventKind = kEventProcessCommand; InstallWindowEventHandler(g_main_window, handlerUPP, 1, &cmd_event[0], (void *)g_main_window, NULL); handlerUPP = NewEventHandlerUPP(my_win_handler); cmd_event[0].eventClass = kEventClassWindow; cmd_event[0].eventKind = kEventWindowDrawContent; cmd_event[1].eventClass = kEventClassWindow; cmd_event[1].eventKind = kEventWindowUpdate; cmd_event[2].eventClass = kEventClassWindow; cmd_event[2].eventKind = kEventWindowClose; err = InstallWindowEventHandler(g_main_window, handlerUPP, 3, &cmd_event[0], (void *)g_main_window, NULL); require_noerr(err, CantCreateWindow); // Get screen depth g_gdhandle = GetGDevice(); g_screen_mdepth = (**((**g_gdhandle).gdPMap)).pixelSize; g_screen_depth = g_screen_mdepth; if(g_screen_depth > 16) { /* 32-bit display */ g_red_mask = 0xff; g_green_mask = 0xff; g_blue_mask = 0xff; /* if (macUsingCoreGraphics) { g_red_left_shift = 0; g_green_left_shift = 8; g_blue_left_shift = 16; } else */ { g_red_left_shift = 16; g_green_left_shift = 8; g_blue_left_shift = 0; } g_red_right_shift = 0; g_green_right_shift = 0; g_blue_right_shift = 0; } else if(g_screen_depth > 8) { /* 16-bit display */ g_red_mask = 0x1f; g_green_mask = 0x1f; g_blue_mask = 0x1f; g_red_left_shift = 10; g_green_left_shift = 5; g_blue_left_shift = 0; g_red_right_shift = 3; g_green_right_shift = 3; g_blue_right_shift = 3; } // show_alert("About to show window", (int)g_main_window); update_main_window_size(); update_window(); // The window was created hidden so show it. ShowWindow( g_main_window ); BringToFront( g_main_window ); update_window(); // Make us pop to the front a different way err = GetCurrentProcess(&my_psn); if(err == noErr) { (void)SetFrontProcess(&my_psn); } // Call the event loop temp_run_application_event_loop(); CantCreateWindow: CantSetMenuBar: CantGetNibRef: show_simple_alert("ending", "", "error code", err); return err; }
short DrawBullet(ListItem item, RECTPTR r, Boolean draw, RECTPTR box) { Rect b; Rect frame; PicHandle p = nil; #ifdef MAC MySetRect(&b, 5 + item.indent * 12, r->top + 4, 5 + item.indent * 12 + 6, r->bottom - 4); #else MySetRect(&b, 7 + item.indent * 12, r->top + 4, 7 + item.indent * 12 + 6, r->bottom - 5); #endif if (draw) { PenNormal(); RGBForeColor(&colors[BLACK]); switch (item.bullet) { case BULLET_DASH: MyMoveTo(b.left, (b.top + b.bottom) / 2); MyLineTo(b.right, (b.top + b.bottom) / 2); break; case BULLET_EMPTYBOX: b.left+=1;b.right+=1; #ifdef MAC p = GetPicture (EMPTYBOXPICT); if (!p) { SysBeep(1);break; } //frame = (**p).picFrame; frame = GetPICTFrame(p); MyOffsetRect(&frame, b.left, b.top); DrawPicture(p, &frame); #else MyFrameRect(&b); #endif b.left-=1;b.right-=1; break; case BULLET_FILLEDBOX: b.left+=1;b.right+=1; #ifdef MAC p = GetPicture (FILLEDBOXPICT); if (!p) { SysBeep(1);break; } //frame = (**p).picFrame; frame = GetPICTFrame(p); MyOffsetRect(&frame, b.left, b.top); DrawPicture(p, &frame); #else PaintRect(&b); #endif // MyFrameRect(&b); // MyMoveTo(b.left,b.top); // MyLineTo(b.right-1,b.bottom-1); // MyMoveTo(b.right-1,b.top); // MyLineTo(b.left,b.bottom-1); b.left-=1;b.right-=1; break; case BULLET_OPENTRIANGLE: case BULLET_CLOSEDTRIANGLE: DrawTriangle(b, item.bullet); break; } } if (box) (*box) = b; // line up the text with an indented bullet b.right += 3; // mac tweek by sohail return b.right; }
// draw a box, with an optional shadow & connectors void PASCAL _box( register int nTop, int nLeft, int nBottom, int nRight, int nStyle, int nAttribute, int nFill, int nFlags, int nConnector ) { register int nWidth; int nZoomTop, nZoomBottom, nZoomLeft, nZoomRight; int nRowDiff, nColumnDiff, nRowInc = 0, nColumnInc = 0; // zoom the window? if ( nFlags & BOX_ZOOMED ) { // zooming requires a fill color; use default if none specified if ( nFill == -1 ) GetAtt( (unsigned int *)&nFill, (unsigned int *)&nZoomTop ); nZoomTop = nZoomBottom = ( nTop + nBottom ) / 2; nZoomLeft = nZoomRight = ( nLeft + nRight ) / 2; // get the increment for each zoom // (This makes the zoom smooth in all dimensions) if (( nRowDiff = nZoomTop - nTop ) <= 0 ) nRowDiff = 1; if (( nColumnDiff = nZoomLeft - nLeft ) <= 0 ) nColumnDiff = 1; if ( nRowDiff > nColumnDiff ) { // tall skinny box nRowInc = ( nRowDiff / nColumnDiff ); nColumnInc = 1; } else { // short wide box nColumnInc = ( nColumnDiff / nRowDiff ); nRowInc = 1; } } else { nZoomTop = nTop; nZoomBottom = nBottom; nZoomLeft = nLeft; nZoomRight = nRight; } do { if ( nFlags & BOX_ZOOMED ) { // if zooming, increment the box size nZoomTop -= nRowInc; if ( nZoomTop < nTop ) nZoomTop = nTop; nZoomBottom += nRowInc; if ( nZoomBottom > nBottom ) nZoomBottom = nBottom; nZoomLeft -= nColumnInc; if ( nZoomLeft < nLeft ) nZoomLeft = nLeft; nZoomRight += nColumnInc; if ( nZoomRight > nRight ) nZoomRight = nRight; } // clear the box to the specified attribute if ( nFill != -1 ) Scroll( nZoomTop, nZoomLeft, nZoomBottom, nZoomRight, 0, nFill ); if ( nStyle == 0 ) nWidth = 0; else if (( nStyle == 2 ) || ( nStyle == 4 )) nWidth = 2; else nWidth = 1; // draw the two horizontals & the two verticals _line( nZoomTop, nZoomLeft, (nZoomRight-nZoomLeft)+1, nWidth, 0, nAttribute, nConnector ); _line( nZoomBottom, nZoomLeft, (nZoomRight-nZoomLeft)+1, nWidth, 0, nAttribute, nConnector ); if ( nStyle == 3 ) nWidth = 2; else if ( nStyle == 4 ) nWidth = 1; _line( nZoomTop, nZoomLeft, (nZoomBottom-nZoomTop)+1, nWidth, 1, nAttribute, nConnector ); _line( nZoomTop, nZoomRight, (nZoomBottom-nZoomTop)+1, nWidth, 1, nAttribute, nConnector ); // slow things down a bit SysBeep( 0, 1 ); } while (( nFlags & BOX_ZOOMED ) && (( nZoomTop > nTop ) || ( nZoomBottom < nBottom ) || ( nZoomLeft > nLeft ) || ( nZoomRight < nRight ))); // check for a shadow if ( nFlags & BOX_SHADOWED ) { nLeft += 2; nRight++; if ( nLeft >= nRight ) nLeft = nRight - 1; // read the character and attribute, and change // the attribute to black background, low intensity // foreground SetLineColor( ++nBottom, nLeft, (nRight-nLeft), 7 ); // shadow the right side of the window for ( nTop++; ( nTop <= nBottom ); nTop++ ) SetLineColor( nTop, nRight, 2, 7 ); } }
/******************************************************************************* ** TileBadge *******************************************************************************/ void TileBadge( Boolean inRestoreTileBeforeBadging ) { OSStatus theErr; PicHandle theBadge; PicHandle theBadgeMask; GWorldPtr theBadgeWorld; GWorldPtr theBadgeMaskWorld; Rect theRect = { 0, 0, 128, 128 }; CGImageRef theBadgeImage; GDHandle theSavedDevice; GrafPtr theSavedPort; // *** // // PITFALL! // // Rebadging the tile will composite over the old one! // You might want to restore the tile before badging. // // *** if ( inRestoreTileBeforeBadging ) RestoreApplicationDockTileImage(); // Load the pictures theBadge = GetPicture( kBadge ); require( theBadge != NULL, CantLoadBadge ); theBadgeMask = GetPicture( kBadgeMask ); require( theBadgeMask != NULL, CantLoadBadgeMask ); // Make some GWorlds theErr = NewGWorld( &theBadgeWorld, 32, &theRect, NULL, NULL, 0 ); require_noerr( theErr, CantMakeBadgeWorld ); theErr = NewGWorld( &theBadgeMaskWorld, 32, &theRect, NULL, NULL, 0 ); require_noerr( theErr, CantMakeBadgeMaskWorld ); // Draw the pictures into the GWorlds GetGWorld( &theSavedPort, &theSavedDevice ); SetGWorld( theBadgeWorld, NULL ); DrawPicture( theBadge, &theRect ); SetGWorld( theBadgeMaskWorld, NULL ); DrawPicture( theBadgeMask, &theRect ); SetGWorld( theSavedPort, theSavedDevice ); // *** // // Make a CGImage from the GWorlds' pixmaps // // *** theErr = CreateCGImageFromPixMaps( GetGWorldPixMap( theBadgeWorld ), GetGWorldPixMap( theBadgeMaskWorld ), &theBadgeImage ); if ( theErr != noErr ) SysBeep( 0 ); require_noerr( theErr, CantMakeBadgeImage ); // *** // // Badge the tile // // *** theErr = OverlayApplicationDockTileImage( theBadgeImage ); if ( theBadgeImage != NULL ) CGImageRelease( theBadgeImage ); CantMakeBadgeImage: DisposeGWorld( theBadgeMaskWorld ); CantMakeBadgeMaskWorld: DisposeGWorld( theBadgeWorld ); CantMakeBadgeWorld: ReleaseResource( (Handle) theBadgeMask ); CantLoadBadgeMask: ReleaseResource( (Handle) theBadge ); CantLoadBadge: ; }
void c_port_close(void) { static char cf[128]; int slf; int lpdport; int cfid; long msg; /* ************************************************************** * * Now lets see if it looks like we can close the spoolfile * * Check for the following: * * 1) We are at level 1 for spool files... * * (otherwise simply decrement the count and return) * * 2) We have an open spool file * * 3) No errors have occured * * ************************************************************** */ if (open_count > 1) { open_count--; return; }; if ((data_file_ptr == (KS_FILE_PTR) NULL) || (port_status != PORT_SPOOLING)) { return; }; /* ************************************************************** * * Close the spool file and reset the file pointer to be NULL * * so we know that the file has been closed. * * * * Note: I haven't added error checking here because there really* * isn't anything we can do if an error occurs... * * ************************************************************** */ KS_FILE_CLOSE(data_file_ptr, error); data_file_ptr = NULL; open_count = 0; port_status = PORT_NOT_ACTIVE; lpdport = pgetport("LPD"); if (lpdport == -1) { error_message = DAEMON_NOT_ACTIVE; goto ERROR_DAEMON_NOT_ACTIVE; } msg = (1l << 16) | getpid(); psend(lpdport,msg); while ((cfid = (int) procreceive()) != -1); sprintf(cf,PATH_LPQ ":cf.%05d",cfid); slf = open(cf,O_WRONLY); if (slf < 0) { SysBeep(); SysBeep(); } write(slf,"l",1); write(slf,tmp,strlen(tmp)); write(slf,"\r",1); write(slf,"U",1); write(slf,tmp,strlen(tmp)); write(slf,"\r",1); close(slf); /* register the job */ msg = (2l << 16) | cfid; if (psend(lpdport,msg) == -1) SysBeep(); /* ************************************************************** * * Everything is all set - return to our caller... * * ************************************************************** */ return; ERROR_DAEMON_NOT_ACTIVE: /* ************************************************************** * * First we close the spool file (can't use it anymore now...) * * then give our user some feed back (like an error message). * * ************************************************************** */ KS_FILE_CLOSE(data_file_ptr, error2); /* delete the spool file */ remove(tmp); data_file_ptr = (KS_FILE_PTR) NULL; open_count--; port_status = PORT_ERROR; ERROR_DIALOG(error_message, error, button); return; }
void DrawMapPoly (CMap* theMap, PolyObjectHdl MapPolyHdl, DrawSpecRecPtr drawSettings) { RGBColor saveColor; drawSettings -> bClosed = IsPolyClosed (MapPolyHdl); #ifdef MAC long PointCount; //drawSettings -> bClosed = IsPolyClosed (MapPolyHdl); GetForeColor (&saveColor); /* save original forecolor */ if (drawSettings -> bClosed) { if (drawSettings -> mode == kPictMode) { DrawSectPoly (theMap, MapPolyHdl, drawSettings); /* changed 11/21/95 due to postscript errors */ // DrawNoSectPoly (theMap, MapPolyHdl, drawSettings); /* changed back on 3/28/96 } else { //PointCount = GetPolyPointCount (MapPolyHdl); //if (PointCount > 7000) //{ // /* draw polygon interior without any frame */ // drawSettings -> frameCode = kNoFrameCode; // DrawNoSectPoly (theMap, MapPolyHdl, drawSettings); // /* then draw polygon outline without using poly-routines */ // drawSettings -> frameCode = kPaintFrameCode; // drawSettings -> fillCode = kNoFillCode; // DrawNoSectPoly (theMap, MapPolyHdl, drawSettings); //} //else DrawNoSectPoly (theMap, MapPolyHdl, drawSettings); } } else /* hollow polygon, no fill of any kind */ { DrawNoSectPoly (theMap, MapPolyHdl, drawSettings); } RGBForeColor (&saveColor); return; #else long numPts = (**MapPolyHdl).pointCount; POINT **pointsH = (POINT**)_NewHandle(numPts *sizeof(POINT)); LongPoint** thisPointsHdl=nil; Point pt; LongPoint wPt; long i, esiCode; long penWidth = 2, halfPenWidth = 0; Boolean bDrawBlackAndWhite = (sharedPrinting && settings.printMode != COLORMODE); Boolean offQuickDrawPlane = false, drawingESILayer = false; if(!pointsH) {SysBeep(5); return;} thisPointsHdl = (LongPoint**) (**MapPolyHdl).objectDataHdl; GetObjectESICode ((ObjectRecHdl) MapPolyHdl,&esiCode); if (esiCode>0) // -500 is the default { //halfPenWidth = penWidth/2; PenStyle(BLACK,penWidth); drawingESILayer = true; } for(i = 0; i< numPts;i++) { wPt = INDEXH(thisPointsHdl,i); //pt.h = SameDifferenceX(wPt.h); //pt.v = (gRect.bottom + gRect.top) - SameDifferenceY(wPt.v); pt = GetQuickDrawPt(wPt.h,wPt.v,&gRect,&offQuickDrawPlane); //pt.h += drawSettings -> offsetDx; //pt.v += drawSettings -> offsetDy; INDEXH(pointsH,i) = MakePOINT(pt.h-halfPenWidth,pt.v-halfPenWidth); // code goes here, make sure this point does not equal previous point JLM } GetForeColor (&saveColor); /* save original forecolor */ //Our_PmForeColor (bDrawBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd);//JLM // make sure the blackandwhite bitmaps come out right Our_PmForeColor (bDrawBlackAndWhite || gDrawBitmapInBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd);//JLM if (drawSettings -> fillCode == kNoFillCode && drawSettings->backColorInd == kWaterColorInd) Our_PmForeColor (drawSettings -> foreColorInd); else { if(bDrawBlackAndWhite) { //SetPenPat(UPSTRIPES); // we want solid outline and a patterned inside FillPat(UPSTRIPES); PenStyle(BLACK,1); } } //if(numPts > 2) Polygon(currentHDC,*pointsH,numPts); // 6/11/03 PC wasn't recognizing the flag for not filling a land polygon if (drawSettings -> bClosed) { if(numPts > 2) Polygon(currentHDC,*pointsH,numPts); } else { //POINT p[2]; //p[0] = INDEXH(pointsH,numPts-1); //p[1] = INDEXH(pointsH,0); //RGBForeColor(&colors[BLACK]); if(numPts >= 2) { Polyline(currentHDC,*pointsH,numPts); //if (!drawingESILayer) //Polyline(currentHDC,p,2); // close the polygon } } if(bDrawBlackAndWhite) SetPenPat(BLACK); RGBForeColor (&saveColor); DisposeHandle((Handle)pointsH); #endif }
static void process_event( EventRecord *event) { WindowPtr window; short part_code; Rect size_rect; long new_size; GrafPtr old_port; switch(event->what) { case kHighLevelEvent: AEProcessAppleEvent(event); break; case mouseDown: /* Did we hit one of the floaters? */ part_code= FindWindow(event->where, &window); switch (part_code) { case inSysWindow: break; case inMenuBar: do_menu_command(MenuSelect(event->where)); break; case inContent: if(window != FrontWindow()) SelectWindow(window); click_in_log_window(window,event->where,(event->modifiers & shiftKey) != 0); break; case inDrag: #ifdef OP_PLATFORM_MAC_CARBON_FLAG { Rect tempRect; GetRegionBounds(GetGrayRgn(), &tempRect); DragWindow(window, event->where, &tempRect); } #else DragWindow(window, event->where, &qd.screenBits.bounds); #endif break; case inGrow: #ifdef OP_PLATFORM_MAC_CARBON_FLAG GetRegionBounds(GetGrayRgn(), &size_rect); #else size_rect = qd.screenBits.bounds; #endif InsetRect(&size_rect, 4, 4); new_size= GrowWindow(window, event->where, &size_rect); if(new_size) { /* Resize the window */ SizeWindow(window, LoWord(new_size), HiWord(new_size), true); } break; case inGoAway: if(TrackGoAway(window, event->where)) { /* Close the window... */ handle_close(window); } break; case inZoomIn: case inZoomOut: if(TrackBox(window, event->where, part_code)) { GetPort(&old_port); SetPortWindowPort(window); #ifdef OP_PLATFORM_MAC_CARBON_FLAG { Rect windowBounds; GetWindowPortBounds(window, &windowBounds); EraseRect(&windowBounds); } #else EraseRect(&window->portRect); #endif ZoomWindow(window, part_code, true); SetPort(old_port); } break; } break; case keyDown: case autoKey: if(!process_key(event, event->message&charCodeMask)) { /* Not handled by anyone.. */ SysBeep(-1); } break; case updateEvt: /* Update the window.. */ update_window((WindowPtr)event->message); break; case activateEvt: /* Activate event->message, event->modifiers&activeFlag.. */ break; case osEvt: switch ((event->message>>24) & 0xff) { case suspendResumeMessage: if (event->message&resumeFlag) { /* resume */ #ifdef OP_PLATFORM_MAC_CARBON_FLAG { Cursor arrowCursor; SetCursor(GetQDGlobalsArrow(&arrowCursor)); } #else SetCursor(&qd.arrow); #endif } else { /* suspend */ } break; case mouseMovedMessage: break; } break; } return; }
void Display::ring_bell(int) { SysBeep(30); }
void play_sound(short which, short how_many_times) { // if < 0, play asynch #if defined(__APPLE__) Handle sndhandle; unsigned long dummy; OSErr err; SndCommand theCommand; if (!play_sounds || how_many_times == 0) return; if (abs(which) > NUM_SOUNDS) { //char msg[50]; /*s*/printf(/*msg,*/"Error: Sound #%i does not exist.\n",abs(which)); //give_error(msg,"",0); return; } channel++; if (channel > numchannel) channel = 0; if (!sound_going(abs(which)) && load_when_play[abs(which)]) sndhandle = GetResource('snd ',20000 + abs(which)); else sndhandle = sound_handles[abs(which)]; if (which > 0) if (always_asynch[which]) which *= -1; if (sndhandle != NULL) { HLock(sndhandle); if (which < 0) err = SndPlay(chan[channel],(SndListHandle) sndhandle,true); // Normal SndPlay else { err = SndPlay(chan[channel],(SndListHandle) sndhandle,false); } if (err != 0) { printf("Sound error.\n"); //add_string_to_buf("Sound Error. Error codes:"); //print_nums(channel,which,err); //add_string_to_buf("Your system could not play a sound."); //add_string_to_buf("Make sure editor isn't running."); //add_string_to_buf("Turn off sounds if necessary."); } HUnlock(sndhandle); snd_played[channel] = abs(which); theCommand.cmd = callBackCmd; theCommand.param1 = 0; #ifndef EXILE_BIG_GUNS theCommand.param2 = SetCurrentA5(); #endif #ifdef EXILE_BIG_GUNS theCommand.param2 = 0; #endif SndDoCommand(chan[channel],&theCommand,true); } else SysBeep(20); if (which < 0) Delay(sound_delay[-1 * which],&dummy); if(how_many_times > 1) play_sound(which, how_many_times - 1); #elif defined(WIN32) short i,num_fails = 0; char snd_name[30]; bool asyn = false,a_sound_did_get_played = false; bool not_asyn = false,check_sound; HRSRC h; if ((sounds_missing) || (!play_sounds) || (how_many_times == 0)) return; if (which < 0) { asyn = true; which = which * -1; } if (which >= 1000) { which -= 1000; not_asyn = true; } if (which >= 100) return; if ((always_asynch[which] == true) && ((can_ignore[which] == 1) || (can_ignore[which] >= 3))) asyn = true; if ((can_ignore[which] > 0) && (can_ignore[which] < 5) && (party.stuff_done[305][5] == 1)) return; if ((can_ignore[which] != 1) && (can_ignore[which] < 3)) asyn = false; if ((party.stuff_done[305][5] == 1) && (can_ignore[which] < 5)) asyn = false; if (not_asyn == true) asyn = false; if ((load_when_play[which] == true) && (sound_handles[which] == NULL)) { asyn = false; sprintf((char *)snd_name,"#%d",which + 1); h = FindResource(hModule,snd_name,"#100"); sound_handles[which] = LoadResource(hModule,h); snds[which] = (char *) LockResource(sound_handles[which]); } if (store_last_sound_played == 6) sndPlaySound(NULL,0); if (asyn == true) { if (can_ignore[which] >= 4) check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY | SND_NOSTOP); else check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY); while (check_sound == false) { if (can_ignore[store_last_sound_played] == 4) {// then sound goes away return; } num_fails++; if (num_fails < 40) sound_pause(25); else { MessageBox(mainPtr,"Cannot play sounds - Sounds stuck error a. Game can still be played, but quietly. Check to make sure your sound drivers are up to date and not corrupted.", "Sound Error",MB_OK | MB_ICONEXCLAMATION); print_nums(111,which,num_fails); sounds_fucked = true; return; } sndPlaySound(NULL,0); if (can_ignore[which] >= 4) check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY | SND_NOSTOP); else check_sound = sndPlaySound(snds[which],SND_ASYNC | SND_MEMORY); } a_sound_did_get_played = true; } else { if (can_ignore[which] >= 4) check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY | SND_NOSTOP); else check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY); while (check_sound == false) { if (can_ignore[store_last_sound_played] == 4) {// then sound goes away return; } num_fails++; if (num_fails < 40) sound_pause(25); else { MessageBox(mainPtr,"Cannot play sounds - Sounds stuck error b. Game can still be played, but quietly. Check to make sure your sound drivers are up to date and not corrupted.", "Sound Error",MB_OK | MB_ICONEXCLAMATION); print_nums(222,which,num_fails); sounds_fucked = true; return; } sndPlaySound(NULL,0); if (can_ignore[which] >= 4) check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY | SND_NOSTOP); else check_sound = sndPlaySound(snds[which],SND_SYNC | SND_MEMORY); } a_sound_did_get_played = true; } store_last_sound_played = which; if ((load_when_play[which] == true) && (asyn == false)) sound_handles[which] = NULL; for (i = 0; i < NUM_SOUNDS; i++) if ((load_when_play[which] == true) && (sound_handles[which] != NULL) && (a_sound_did_get_played == true) && (i != which)) { sound_handles[i] = NULL; } #endif }