Exemplo n.º 1
0
void DoGoAwayBox(WindowPtr myWindow, Point mouseloc)
{
	if(TrackGoAway(myWindow,mouseloc))
	{ 
		DoCloseWindow(myWindow); 
	}
}
Exemplo n.º 2
0
void DoMouseDown(EventRecord e)
{
short	partCode;
WindowPtr	whichWindow;
Rect	dragRect;
Point 	pt;

	switch(partCode = FindWindow(e.where, &whichWindow)) {
		case inMenuBar:
			FixMenus();
			ProcessMenu(MenuSelect(e.where));
			break;

		case inSysWindow:
			SystemClick(&e, whichWindow);
			break;

		case inContent:
			if(whichWindow != FrontWindow())
				SelectWindow(whichWindow);
			if(whichWindow==nesWind)
				DoClickInNES(e);
			if(whichWindow==wpWind)
				DoClickInWP(e);
			if(whichWindow==srchWind)
				DoClickInSrch(e);

#ifdef GB_DEBUG
			if(whichWindow==statWind)
				DoClickInStat(e);
			if(whichWindow==patWind)
				DoClickInPat(e);
#endif

			break;

		case inDrag:
			dragRect = qd.screenBits.bounds;
			InsetRect(&dragRect, 5, 5);
			DragWindow(whichWindow, e.where, &dragRect);
			
			if(whichWindow == nesWind) {
				SetPt(&pt,0,0);
				SetPort(nesWind); LocalToGlobal(&pt);
				MoveWindow(nesWind,pt.h & 0xfff8,pt.v,false);

				SetPt(&pt,0,0); LocalToGlobal(&pt);
				if( (pt.h < 0) || (pt.v < 20) )
					MoveWindow(nesWind,8,40,false);

				SetPt(&pt,nesWind->portRect.right,nesWind->portRect.bottom);
				LocalToGlobal(&pt);
				if( (pt.h > scrnW) || (pt.v > scrnH) )
					MoveWindow(nesWind,8,40,false);
			}
			
			WP_RepositionWind();
			Srch_RepositionWind();
			break;

		case inGoAway:
			if(TrackGoAway(whichWindow, e.where))
				DoCloseWindow(whichWindow);
			break;

		default: break;
	}
	
	vVrtFrame = vActFrame;		// keep timing code working
}
Exemplo n.º 3
0
void ProcessMenu(long menuCode)
{
short	theMenu, theItem, daNum, err;
Str255	daName;

	if(menuCode==0) return;
	
	theMenu = menuCode>>16;
	theItem = menuCode&0xffff;
	
	switch(theMenu) {
		case kAppleMenuID: {
			if(theItem==1) DoAbout();
			else { GetMenuItemText(GetMenuHandle(kAppleMenuID), theItem, daName); daNum = OpenDeskAcc(daName); }
			break;
		}
		case kFileMenuID:
			switch(theItem) {
				case 1:
					err = OpenCart();
					break;
				case 2:
					DoCloseWindow(FrontWindow());
					break;
				case 4:
					gDone = true;
			}
			break;
		
		case kEditMenuID:
			switch(theItem) {
				case 8:		// ROM Header
					if(ROM_HeaderEdit()) {
						NES_StoreHeader();
						NES_Reset();
						FullUpdate();
					}
					break;
				case 10:	// CONTROLS
					Keys_Edit();
					break;
				case 11:	// PREFERENCES
					Prefs_Edit();
					break;
			}
			break;
		
		case kNESMenuID:
			switch(theItem) {
				case 1:		// RUN
					if(!gRunning) {
						NES_Run();
					}
					break;
				case 2:		// STOP
					if(gRunning) {
						Stat_ForceUpdate();
						FullUpdate();

						NES_Stop();
					}
					break;
				case 4:		// RESET
#ifdef GB_DEBUG
					TF_AddLine("== NES is reset.");
#endif
					NES_Reset();
					FullUpdate();
					break;				
			}
			break;

#ifdef GB_DEBUG
		
		case kExtraMenuID:
			switch(theItem) {
				case 1:		// PATTERN TABLES
					if(patWind) {
						DisposeWindow(patWind);
						patWind = 0L;
					} else {
						patWind = GetNewWindow(kPatWindID,0L,(WindowPtr)-1);
						NES_PatUpdate();
					}
					break;
				case 2:		// NAME TABLES
					if(namWind) {
						DisposeWindow(namWind);
						namWind = 0L;
					} else {
						namWind = GetNewWindow(kNamWindID,0L,(WindowPtr)-1);
						NES_NamUpdate();
					}
					break;
				case 3:		// PALETTES
					if(palWind) {
						DisposeWindow(palWind);
						palWind = 0L;
					} else {
						palWind = GetNewWindow(kPalWindID,0L,(WindowPtr)-1);
						NES_PalUpdate();
					}
					break;
				case 5:		// FRAME
					pnes->refreshFlag = 1;
					NES_Frame((long)pcpu);
					FullUpdate();
					break;
				case 6:		// STEP
					DisAsmLine();
					NES_Step((long)pcpu);
					FullUpdate();
					break;
				case 7:		// EDIT MEM
					DoEditMem(0);
					FullUpdate();
					break;
				case 9:		// NMI
					P6502_NMI((long)pcpu);
					Stat_ForceUpdate();
					break;
				case 10:	// IRQ
					P6502_IRQ((long)pcpu);
					Stat_ForceUpdate();
					break;
				case 12:	// Blub
					Blub();
					break;

			}
			break;

#endif
		
		case kSearchMenuID:
			switch(theItem) {
				case 1:	// SEARCH MEMORY
					Srch_Search();
					break;

				case 3: // SAVE WP's
					WP_SaveWatchPoints();
					break;

				case 5: // SEARCH RESULTS
					Srch_ShowResultsWindow();
					break;

				case 6: // WATCH POINTS					
					if(wpWind) {
						DisposeWindow(wpWind);
						wpWind = 0L;
					} else {
						WP_OpenWindow();
						WP_Update();
					}
					break;
			}
			break;
		
		case kLdsMenuID: // Load State SubMenu
			if((theItem>0) && (theItem<9))
				NES_LoadState(theItem-1);
				// --> UPDATE FRAME

		case kStsMenuID: // Save State SubMenu
			if((theItem>0) && (theItem<9))
				NES_SaveState(theItem-1);

		default:
			break;
	}
	
	if(!gRunning || !Prefs.doubleSize)
		HiliteMenu(0);
}