void CloseMacros(NewMacroInfo *macrost, DialogPtr dtemp) { short dItem; short i; Rect dBox; Str255 temp; Handle MacString[10]; if ( TelInfo->macrosModeless == dtemp ) { for (i=0; i<10; i++) { GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox); GetDialogItemText( MacString[i], temp); p2cstr(temp); setmacro(macrost, i + (10 * dialogPane), (char *) &temp); } DisposeHandle(oldMacros); DisposeDialog(dtemp); //if ( TelInfo->macrosModeless ) { TelInfo->macrosModeless = 0; AdjustMenus(); DoTheMenuChecks(); //} } }
static pascal OSErr AErapp (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) { if (running) return (noErr); if (!cartOpen) { if (startopendlog) { if (SNES9X_OpenCart(NULL)) { SNES9X_Go(); QuitApplicationEventLoop(); } else AdjustMenus(); } } else { SNES9X_Go(); QuitApplicationEventLoop(); } return (noErr); }
static pascal void MyPrivateEventProc( const NavEventCallbackMessage callbackSelector, NavCBRecPtr callbackParms, NavCallBackUserData callbackUD ) { switch ( callbackSelector ) { case kNavCBEvent: { switch (callbackParms->eventData.eventDataParms.event->what) { case updateEvt: case activateEvt: HandleEvent(callbackParms->eventData.eventDataParms.event); break; } } break; case kNavCBUserAction: { if ( callbackParms->userAction == kNavUserActionOpen ) { // This is an open files action, send an AppleEvent NavReplyRecord reply; OSStatus status; status = NavDialogGetReply( callbackParms->context, &reply ); if ( status == noErr ) { SendOpenAE( reply.selection ); NavDisposeReply( &reply ); } } } break; case kNavCBTerminate: { if ( callbackParms->context == gOpenFileDialog ) { NavDialogDispose( gOpenFileDialog ); gOpenFileDialog = NULL; } // if after dismissing the dialog SimpleText has no windows open (so Activate event will not be sent) - // call AdjustMenus ourselves to have at right menus enabled if (FrontWindow() == nil) AdjustMenus(nil, true, false); } break; } }
void CancelMacros(NewMacroInfo *macrost, DialogPtr dtemp) { if ( TelInfo->macrosModeless == dtemp ) { DisposeDialog(dtemp); DisposeHandle(macrost->handle); *macrost = oldMacroIndexes; macrost->handle = oldMacros; //if ( TelInfo->macrosModeless ) { TelInfo->macrosModeless = 0; AdjustMenus(); DoTheMenuChecks(); //} } }
/* showNetNumbers - Show the current network numbers. */ void showNetNumbers( void) { char tmpout[256]; /* IP Number */ DialogPtr dptr; /* dialog box pointer */ short scratchshort; int tmp[4]; /* Integer copy of IP Number */ unsigned char tmp2[4]; if (TelInfo->ipModeless) { SelectWindow(TelInfo->ipModeless); return; } Mnetinit(); // RAB BetterTelnet 1.0fc4 netgetip(tmp2); for(scratchshort=0; scratchshort<4; scratchshort++) tmp[scratchshort] = (int)tmp2[scratchshort]; /* Get integer numbers */ sprintf(&tmpout[0],"IP Address:\r%d.%d.%d.%d",tmp[0],tmp[1],tmp[2],tmp[3]); /* create Human-readable numbers */ c2pstr(tmpout); /* BYU LSC */ // RAB BetterTelnet 1.2 - we can't use ParamText() for modeless dialogs // ParamText(0L, (StringPtr)tmpout,0L,0L); /* BYU LSC - Put Parms in Dlog */ dptr = GetNewDialog(MyIPDLOG, NULL, kInFront); SetTEText(dptr, 1, (unsigned char *)tmpout); DrawDialog(dptr); /* Display Dialog */ TelInfo->ipModeless = dptr; // ModalDialog(NULL, &scratchshort); /* Wait for a click */ // DisposeDialog(dptr); // Alert(MyIPDLOG, 0L); AdjustMenus(); DoTheMenuChecks(); }
static pascal OSErr AEodoc (const AppleEvent *theEvent, AppleEvent *theReply, long refCon) { OSErr err; FSRef ref; AEDescList docList; AEKeyword keywd; DescType rtype; Size acsize; long count; if (running) return (noErr); err = AEGetParamDesc(theEvent, keyDirectObject, typeAEList, &docList); if (err) return (noErr); err = AECountItems(&docList, &count); if (err || (count != 1)) { err = AEDisposeDesc(&docList); return (noErr); } err = AEGetNthPtr(&docList, 1, typeFSRef, &keywd, &rtype, &ref, sizeof(FSRef), &acsize); if (err == noErr) { if (SNES9X_OpenCart(&ref)) { SNES9X_Go(); QuitApplicationEventLoop(); } else AdjustMenus(); } err = AEDisposeDesc(&docList); return (noErr); }
static int ioSetFullScreenActual(int fullScreen) { Rect screen; int width, height, maxWidth, maxHeight; int oldWidth, oldHeight; static Rect rememberOldLocation = {0,0,0,0}; GDHandle dominantGDevice; windowDescriptorBlock * targetWindowBlock = windowBlockFromIndex(1); extern Boolean gSqueakBrowserWasHeadlessButMadeFullScreen; extern Boolean gSqueakBrowserSubProcess; if (browserActiveAndDrawingContextOk()) { if (!gSqueakBrowserWasHeadlessButMadeFullScreen) { gSqueakBrowserWasHeadlessButMadeFullScreen = true; SetUpMenus(); AdjustMenus(); } sqShowWindowActual(1); if (targetWindowBlock->context) //Set context to NULL, if screen is same size as fullscreen we wouldn't get new context QDEndCGContext(GetWindowPort(targetWindowBlock->handle),&targetWindowBlock->context); targetWindowBlock->context = NULL; } if ((targetWindowBlock == NULL) || (fullScreen && getFullScreenFlag() && !targetWindowBlock->isInvisible)) return 0; dominantGDevice = getThatDominateGDevice(targetWindowBlock->handle); if (dominantGDevice == null) { success(false); return 0; } screen = (**dominantGDevice).gdRect; if (fullScreen) { GetPortBounds(GetWindowPort(targetWindowBlock->handle),&rememberOldLocation); oldWidth = rememberOldLocation.right - rememberOldLocation.left; oldHeight = rememberOldLocation.bottom - rememberOldLocation.top; if (targetWindowBlock->isInvisible) { rememberOldLocation.top = 44; rememberOldLocation.left = 8; } QDLocalToGlobalRect(GetWindowPort(targetWindowBlock->handle),&rememberOldLocation); if (gSqueakBrowserSubProcess) { ProcessSerialNumber psn = { 0, kCurrentProcess }; ProcessInfoRec info; info.processName = NULL; info.processAppSpec = NULL; info.processInfoLength = sizeof(ProcessInfoRec); GetProcessInformation(&psn,&info); SetFrontProcess(&psn); } MenuBarHide(); width = screen.right - screen.left; height = (screen.bottom - screen.top); MoveWindow(targetWindowBlock->handle, screen.left, screen.top, true); SizeWindow(targetWindowBlock->handle, width, height, true); setFullScreenFlag(true); } else { MenuBarRestore(); if (gSqueakBrowserWasHeadlessButMadeFullScreen) { HideWindow(targetWindowBlock->handle); { ProcessSerialNumber psn; pid_t parent; OSStatus err; parent = getppid(); if (parent != 1) { err = GetProcessForPID(parent,&psn); if(err == 0) SetFrontProcess(&psn); } } } if (EmptyRect(&rememberOldLocation)) { /* get old window size */ width = (unsigned) getSavedWindowSize() >> 16; height = getSavedWindowSize() & 0xFFFF; /* minimum size is 1 x 1 */ width = (width > 0) ? width : 64; height = (height > 0) ? height : 64; /* maximum size is screen size inset slightly */ maxWidth = (screen.right - screen.left) - 16; maxHeight = (screen.bottom - screen.top) - 52; width = (width <= maxWidth) ? width : maxWidth; height = (height <= maxHeight) ? height : maxHeight; MoveWindow(targetWindowBlock->handle, 8, 44, true); SizeWindow(targetWindowBlock->handle, width, height, true); } else {
// LR 1.66 -- complete rewrite (basically) of this entire routine...it was UGLY! OSStatus HandleMenu( long mSelect, short modifiers ) { short menuID = HiWord( mSelect ); short menuItem = LoWord( mSelect ); short colorResID; WindowRef frontWindow; DialogPtr dlgRef = NULL; EditWindowPtr dWin = NULL; Str255 currentWindowName, newFrontWindowName; // NS: v1.6.6, for window menu WindowRef currentWindow; // NS: this too // Predetermine what type of window we have to work with frontWindow = FrontNonFloatingWindow(); if( frontWindow ) { DialogPtr dlg = GetDialogFromWindow( frontWindow ); if( kHexEditWindowTag == GetWindowKind( frontWindow ) ) dWin = (EditWindowPtr) GetWRefCon( frontWindow ); else if( g.gotoDlg == dlg || g.searchDlg == dlg ) dlgRef = dlg; } switch( menuID ) { case kAppleMenu: if( menuItem == AM_About ) HexEditAboutBox(); #if !TARGET_API_MAC_CARBON else { GrafPtr savePort; Str255 name; GetPort( &savePort ); GetMenuItemText( appleMenu, menuItem, name ); OpenDeskAcc( name ); SetPort( savePort ); } #endif break; case kFileMenu: switch( menuItem ) { case FM_New: gPrefs.overwrite = false; //LR 190 -- overwrite mode makes no sense in a new document NewEditWindow(); break; case FM_Open: AskEditWindow( kWindowNormal ); break; // HR/LR 050328 - Handle FM_Disassemble menu item case FM_Disassemble: g.disassemble = !g.disassemble; if ( g.disassemble ) { dWin->drawMode = DM_Disassembly; dWin->bytesPerLine = kDisBytesPerLine; dWin->hexStart = kDisHexStart; dWin->asciiStart = kDisASCIIStart; } else { dWin->drawMode = DM_Dump; dWin->bytesPerLine = kHexBytesPerLine; dWin->hexStart = kHexHexStart; dWin->asciiStart = kHexASCIIStart; } /* Make sure the editOffset position starts on a new line */ dWin->editOffset -= dWin->editOffset % dWin->bytesPerLine; UpdateEditWindows(); break; case FM_OtherFork: // LR: I want to see both! if( dWin ) { short fork; //LR 180 EditWindowPtr ewin; if( dWin->fork == FT_Data ) fork = FT_Resource; else fork = FT_Data; /*LR 180 -- OpenEditWindow checks for this if( NULL != (ewin = LocateEditWindow( &dWin->fsSpec, fork )) ) // LR: 1.7 - boolean typecast causes failure! { SelectWindow( ewin->oWin.theWin ); // just select existing theWin } else // try to open other fork in new theWin! */ { g.forkMode = fork; OpenEditWindow( &dWin->fsSpec, kWindowNormal, true ); } } break; case FM_CompareFiles: //LR 180 -- now pass in modifiers to allow select override if( GetCompareFiles( modifiers ) ) DoComparison(); break; //LR: 1.66 - NOTE: dWin == NULL == frontWindow! case FM_Save: if( dWin && dWin->oWin.Save ) dWin->oWin.Save( frontWindow ); break; case FM_SaveAs: if( dWin && dWin->oWin.SaveAs ) dWin->oWin.SaveAs( frontWindow ); break; case FM_Revert: if( dWin && dWin->oWin.Revert ) //LR 1.72 -- check before reverting (could be dangerous!) { ParamText( dWin->fsSpec.name, NULL, NULL, NULL ); switch( CautionAlert( alertRevert, NULL ) ) { case ok: dWin->oWin.Revert( frontWindow ); break; } } break; case FM_Close: if( dWin ) CloseEditWindow( frontWindow ); else if( dlgRef ) { HideWindow( frontWindow ); //LR: 1.7 -- no need.GetDialogWindow( dlgRef ) ); } break; case FM_Quit: if( CloseAllEditWindows() ) g.quitFlag = true; break; case FM_PageSetup: #if TARGET_API_MAC_CARBON // sel - carbon session based printing _doPageSetupDialog(&g.pageFormat); #else PrOpen(); PrStlDialog( g.HPrint ); PrClose(); #endif break; case FM_Print: if( dWin ) PrintWindow( dWin ); break; } break; case kEditMenu: #if !TARGET_API_MAC_CARBON if( !SystemEdit( menuItem -1 ) ) #endif { if( dWin ) switch( menuItem ) { case EM_Undo: UndoOperation(); break; case EM_Cut: CutSelection( dWin ); break; case EM_Copy: CopySelection( dWin ); break; case EM_Paste: PasteSelection( dWin ); break; case EM_Clear: ClearSelection( dWin ); break; case EM_SelectAll: dWin->startSel = 0; dWin->endSel = dWin->fileSize; UpdateOnscreen( dWin->oWin.theWin ); break; } else if( dlgRef ) switch( menuItem ) { case EM_Cut: DialogCut( dlgRef ); TEToScrap(); break; case EM_Copy: DialogCopy( dlgRef ); TEToScrap(); break; case EM_Paste: TEFromScrap(); DialogPaste( dlgRef ); break; case EM_Clear: DialogDelete( dlgRef ); break; case EM_SelectAll: break; } } break; case kFindMenu: switch ( menuItem ) { case SM_Find: openfind: OpenSearchDialog(); break; case SM_FindForward: gPrefs.searchForward = true; PerformTextSearch( dWin, kSearchUpdateUI ); //LR 190 -- if dWin is NULL will operate on first edit window, if any (allows search in find dialog) break; case SM_FindBackward: gPrefs.searchForward = false; PerformTextSearch( dWin, kSearchUpdateUI ); //LR 190 -- if dWin is NULL will operate on first edit window break; case SM_Replace: //LR 190 -- add replace & find next (must have a window with selection to start!) if( !dWin ) dWin = FindFirstEditWindow(); // allow this to work in find dialog, etc. if( dWin && dWin->startSel != dWin->endSel ) { EditChunk **replaceChunk; if( !g.searchBuffer[0] ) // if nothing to find open dialog goto openfind; replaceChunk = NewChunk( g.replaceText[0], 0, 0, CT_Unwritten ); if( replaceChunk ) { // Copy replacement text to chunk buffer BlockMoveData( g.replaceText+1, *(*replaceChunk)->data, g.replaceText[0] ); // Do the replacement (with undo) g.replaceAll = false; RememberOperation( dWin, EO_Paste, &gUndo ); PasteOperation( dWin, replaceChunk ); // We're done with the chunk now DisposeChunk( NULL, replaceChunk ); } // Then try to find the next occurance (in LAST direction searched!) and display it if( !PerformTextSearch( dWin, kSearchUpdateUI ) ) ScrollToSelection( dWin, dWin->startSel, true ); } break; case SM_GotoAddress: OpenGotoAddress(); break; } break; case kOptionsMenu: switch ( menuItem ) { case OM_HiAscii: gPrefs.asciiMode = !gPrefs.asciiMode; if( gPrefs.asciiMode ) g.highChar = 0xFF; else g.highChar = 0x7F; UpdateEditWindows(); break; case OM_DecimalAddr: gPrefs.decimalAddr = !gPrefs.decimalAddr; UpdateEditWindows(); break; case OM_Backups: gPrefs.backupFlag = !gPrefs.backupFlag; break; case OM_WinSize: gPrefs.constrainSize = !gPrefs.constrainSize; break; case OM_Overwrite: gPrefs.overwrite = !gPrefs.overwrite; break; case OM_NonDestructive: gPrefs.nonDestructive = !gPrefs.nonDestructive; break; case OM_MoveOnlyPaging: gPrefs.moveOnlyPaging = !gPrefs.moveOnlyPaging; break; case OM_Unformatted: gPrefs.formatCopies = !gPrefs.formatCopies; break; case OM_VertBars: gPrefs.vertBars = !gPrefs.vertBars; UpdateEditWindows(); break; case OM_ComparePref: // LR: compare options ComparisonPreferences(); break; case OM_OpenOnLaunch: gPrefs.dialogAtLaunch = !gPrefs.dialogAtLaunch; //LR -- 192 break; } break; // LR: Add color scheme menu case kColorMenu: colorResID = GetColorMenuResID( menuItem ); if( menuItem == CM_UseColor ) { gPrefs.useColor = !gPrefs.useColor; // toggle color usage } else if( dWin && dWin->csResID > 0 ) // can't color B&W windows! { if( _cmCheckedItem ) CheckMenuItem( colorMenu, _cmCheckedItem, false ); if( (modifiers & optionKey) ) // option down == change all windows (set default color) { EditWindowPtr eWin = FindFirstEditWindow(); while( eWin ) { if( GetWindowKind( eWin->oWin.theWin ) == kHexEditWindowTag ) { eWin->csResID = colorResID; eWin->csMenuID = menuItem; //LR 181 -- for menu tagging } eWin = FindNextEditWindow( eWin ); } goto savepref; } else //LR 181 -- default is (back) to changing color of a single window! { if( GetWindowKind( dWin->oWin.theWin ) == kHexEditWindowTag ) { dWin->csResID = colorResID; dWin->csMenuID = menuItem; //LR 181 -- for menu tagging } } } else { savepref: //LR 190 -- no window open == set preferred color gPrefs.csResID = colorResID; //LR 180 -- save prefs when changing all gPrefs.csMenuID = menuItem; } UpdateEditWindows(); break; // LR : 1.7 - rewrite with bug checking (could crash accessing NULL window) case kWindowMenu: GetMenuItemText( windowMenu, menuItem, newFrontWindowName ); currentWindow = FrontNonFloatingWindow(); while( currentWindow ) { GetWTitle( currentWindow, currentWindowName ); if( EqualPStrings( currentWindowName, newFrontWindowName ) ) { SelectWindow( currentWindow ); break; } currentWindow = GetNextWindow( currentWindow ); } break; } HiliteMenu( 0 ); AdjustMenus(); return( noErr ); }