Esempio n. 1
0
void handleMenuSelection(long result)
{
	int menuID, menuItem;
	RgnHandle rgnHandle = NewRgn();
	
	menuID = HiWord(result);
	menuItem = LoWord(result);
	
	if (menuID == FILE_MENU) {
		if (menuItem == FILE_SAVE)
			saveToPICTFile();
		else if (menuItem == FILE_QUIT)
			gDone = true;
		else if (menuItem == FILE_CLOSE) {
			DisposeWindow(FrontWindow());
			if (FrontWindow() == NULL)
				gDone = true;
		}
		else if (menuItem == FILE_NEW) {
		
		}
		else if (menuItem == FILE_REFRESH) {
			createImage();
			drawImage(FrontWindow());
			QDFlushPortBuffer(GetWindowPort(FrontWindow()), GetPortVisibleRegion(GetWindowPort(FrontWindow()), rgnHandle));
		}
	}
	HiliteMenu(0);
	DisposeRgn(rgnHandle);
}
Esempio n. 2
0
static void DoMenuCommand( long menuAndItem ) {
	int			myMenuNum;
	int			myItemNum;
	int			myResult;
	Str255		myDAName;
	WindowPtr	myWindow;
	
	myMenuNum	= HiWord(menuAndItem);
	myItemNum	= LoWord(menuAndItem);
	
	GetPort(&myWindow);
	
	switch (myMenuNum)  {
	case mApple:
		switch( myItemNum ) {
		case iAbout: 
			DoAboutBox();
			break;
		default: 
			GetMenuItemText(GetMenuHandle(mApple), myItemNum, myDAName);
			myResult = OpenDeskAcc(myDAName);
			break;
		}
		break;
	case mFile:
		switch (myItemNum) {
		case iQuit:
			Com_Quit_f();
			break;
		}
		break;
	}
	
	HiliteMenu(0);
}
Esempio n. 3
0
File: ugView.c Progetto: rolk/ug
static void DoCommand (long mResult)
{
  short temp,theItem,theMenu;
  Str255 name;

  theItem = LoWrd(mResult);
  theMenu = HiWrd(mResult);

  switch (theMenu)
  {

  case appleID :
    if (theItem==1)
    {
      ScheduleCommand(theMenu,theItem);
    }
    else
    {
      GetMenuItemText(myMenus[appleM],theItem,name);
      temp = OpenDeskAcc(name);
    }
    break;

  default :
    ScheduleCommand(theMenu,theItem);
    break;
  }
  HiliteMenu(0);
}
Esempio n. 4
0
void DoCommand(long mResult)
{
	short theItem;
	short theMenu;
	Str255		daName;
	short		daRefNum;
	
	theItem = LoWord(mResult);
	theMenu = HiWord(mResult);
	
	switch (theMenu)
	{
		case appleID:
		{
			if (theItem == 1)
			{
				Alert(rUserAlert, nil);
			}
			else
			{
				/* all non-About items in this menu are DAs */
				/* type Str255 is an array in MPW 3 */
				GetMenuItemText(GetMenuHandle(appleID), theItem, daName);
				daRefNum = OpenDeskAcc(daName);
			}
			break;
		}
		case fileID:
		{
			quit = 1;
			break;
		}
		case editID:
		{
			if (!SystemEdit(theItem-1)) // call Desk Manager to handle editing command if desk accessory window is the active window
			{
				switch (theItem) {
					case cutCommand:
						TECut(textH);
						break;
					case copyCommand:
						TECopy(textH);
						break;
					case pasteCommand:
						TEPaste(textH);
						break;
					case clearCommand:
						TEDelete(textH);
						break;
					default:
						break;
				}
			}
		}
		default:
			break;
	}
	
	HiliteMenu(0);
}
Esempio n. 5
0
void StartCarbonModalDialog(void)
{
	HiliteMenu(0);
	DisableMenus();
	if (gWindow)
		HideWindow(gWindow);
}
Esempio n. 6
0
void DoMenuCommand(long menuResult)
{
    short	menuID;		/* the resource ID of the selected menu */
    short	menuItem;	/* the item number of the selected menu */
	
    menuID = HiWord(menuResult);    /* use macros to get item & menu number */
    menuItem = LoWord(menuResult);
	
    switch (menuID) 
    {
        case mApple:
            switch (menuItem) 
            {
                case iAbout:
                    DoAboutBox();
                    break;
                    
                case iQuit:
                    ExitToShell();
                    break;
				
                default:
                    break;
            }
            break;
        
        case mFile:
            break;
		
        case mEdit:
            break;
    }
    HiliteMenu(0);	/* unhighlight what MenuSelect (or MenuKey) hilited */
}
EXPORT(sqInt) primitiveHiliteMenu(void) {
	sqInt menuID;

	menuID = interpreterProxy->stackIntegerValue(0);
	if (interpreterProxy->failed()) {
		return null;
	}
	HiliteMenu(menuID);
	return null;
}
Esempio n. 8
0
static void handlemenu (long codeword) {
	
	short idmenu, iditem;
	
	iditem = LoWord (codeword);
	
	idmenu = HiWord (codeword);
	
	if (SharedMenuHit (idmenu, iditem)) /*See Step #3*/	
		goto exit;
	
	switch (idmenu) {
	
		case applemenu: 
			switch (iditem) {
				
				case aboutitem:
					Alert (262, nil);
					
					break;
			
				default: {
					Str255 s;
					
					GetItem (happlemenu, iditem, s);
					
					OpenDeskAcc (s);
					
					break;
					}
				} /*switch*/
			
			break; /*apple menu*/

		case filemenu: 
			switch (iditem) {
				
				case quititem:
				
					flexitmainloop = true;
					
					break;
				} /*switch*/
			
			break; /*file menu*/
			
		} /*switching on which menu was invoked*/
		
	exit:
	
	HiliteMenu (0);
	} /*handlemenu*/
Esempio n. 9
0
void HandleMouseDown(EventRecord *event)
{
	short	part;
	WindowRef	window;
	MacWindow   *macwin;
	Rect		growRect={100,100,32000,32000};
	long		size;
	
	part=FindWindow(event->where, &window);
	macwin = (MacWindow*)GetWRefCon(window);
	
	switch(part)
	{
	case inMenuBar:
		mac_AdjustMenus(event->modifiers);
		mac_HandleMenuSelect(MenuSelect(event->where), event->modifiers);
		HiliteMenu(0);
		break;
	case inContent:
		SetPortWindowPort(window);
		SelectWindow(window);
		GlobalToLocal(&event->where);
		if(macwin) macwin->click(event->where, event->modifiers);
		break;
	case inDrag:
		DragWindow(window, event->where, &qd.screenBits.bounds);
		break;
	case inGrow:
		SetPortWindowPort(window);
		size=GrowWindow(window, event->where, &growRect);
		if( size )
		{
			SizeWindow(window, size&0x0000FFFF, size>>16, 0);
			EraseRect(&GetWindowPort(window)->portRect);
			InvalRect(&GetWindowPort(window)->portRect);
			if( macwin ) macwin->message(MW_GROW, size);
		}
		break;
	case inGoAway:
		if( TrackGoAway(window, event->where) ){
			if( macwin ){
				macwin->goaway(macwin);
			}
		}
		break;
	//case inZoomIn:
	//case inZoomOut:
	//	break;
	}
}
Esempio n. 10
0
static void doMenu( long menuSelection )
{
	short whichMenu = HiWord(menuSelection);
	short whichMenuItem = LoWord(menuSelection);
	
	switch (whichMenu) {
	case kAppleMenuID:
		switch (whichMenuItem) {
		case kAppleMenuAbout:
			Alert(128, NULL);
			break;

		default:
			break;
		}
		break;

	case kFileMenuID:
		switch (whichMenuItem) {
		case kFileMenuQuit:
			gDone = true;
			break;
		}
		break;
	
	case kDemoMenuID:
		if (window) { DisposeWindow( window ); window = NULL; };
		switch (whichMenuItem) {
		case kDemoMenuDraw: DrawImage(); break;
		case kDemoMenuScaleRotate: ScaleAndRotate(); break;
		case kDemoMenuAlpha: AlphaComposite(); break;
		case kDemoMenuMoreInfo: GetMoreInfo(); break;
		case kDemoMenuMultipleImage: MultipleImage(); break;
		case kDemoMenuURLImage: ImageFromURL(); break;
		case kDemoMenuFiltersExport: FilterExport(); break;
		case kDemoMenuMovieImage: MovieToImage(); break;
		case kDemoMenuDeepImages: DeepImages(); break;
        case kDemoMenuDrawCMYK: DrawCMYK(); break;
        case kDemoMenuDrawUsingCGImage: DrawUsingCGImage(); break;
        case kDemoMenuExportFromCGBitmapContext: ExportFromCGBitmapContext(); break;
		default:
			break;
		} // switch
	}
	
	HiliteMenu(0);
}
Esempio n. 11
0
static void mac_menucommand(long result)
{
    short menu, item;
    WindowPtr window;
#if !TARGET_API_MAC_CARBON
    Str255 da;
#endif

    menu = HiWord(result);
    item = LoWord(result);
    window = FrontWindow();
    /* Things which do the same whatever window we're in. */
    switch (menu) {
      case mApple:
        switch (item) {
          case iAbout:
	    mac_openabout();
            goto done;
#if !TARGET_API_MAC_CARBON
          default:
            GetMenuItemText(GetMenuHandle(mApple), item, da);
            OpenDeskAcc(da);
            goto done;
#endif
        }
        break;
      case mFile:
        switch (item) {
	  case iNew:
	    mac_newkey();
	    goto done;
          case iClose:
            mac_closewindow(window);
            goto done;
          case iQuit:
            cleanup_exit(0);
            goto done;
        }
        break;
    }
    /* If we get here, handling is up to window-specific code. */
    if (mac_wininfo(window)->menu != NULL)
	(*mac_wininfo(window)->menu)(window, menu, item);

  done:
    HiliteMenu(0);
}
int _handle_user_event( unsigned long ticks)
{
	EventRecord event;

	if( WaitNextEvent(everyEvent, &event, ticks, nil)){
		long      menuResult = 0;
		short     menuID, menuItem;
		WindowPtr window;
		Str255    daName;

		switch ( event.what ) {
		case mouseDown:
			if( FindWindow(event.where, &window) == inMenuBar)
				menuResult = MenuSelect(event.where);
			break;
		case keyDown:
			if( event.modifiers & cmdKey )
				menuResult = MenuKey((short)event.message & charCodeMask);
			break;
		case kHighLevelEvent:
			AEProcessAppleEvent(&event);
			break;
		}

		menuID = HiWord(menuResult);
		menuItem = LoWord(menuResult);
		switch ( menuID ) {
		case mFile:
			MLDone = MLAbort = 1;
			break;
		case mApple:
			switch ( menuItem ) {
			case iAbout:
				do_about_box();
				break;
			default:
				GetMenuItemText(GetMenuHandle(mApple), menuItem, daName);
				break;
			}
			HiliteMenu(0);
		}
	}
	return MLDone;
}
Esempio n. 13
0
long wait ()
{
  EventRecord event;
  WindowPtr window;
  MenuInfo **m;
  long r;
  Str255 tmp;
				/* wait for an event */
  WaitNextEvent (everyEvent,&event,(long) 6,NIL);
  switch (event.what) {		/* got one -- what is it? */
  case mouseDown:		/* mouse clicked */
    switch (FindWindow (event.where,&window)) {
    case inMenuBar:		/* menu bar item? */
				/* yes, interesting event? */	
      if (r = MenuSelect (event.where)) {
				/* round-about test for Apple menu */
	  if ((*(m = GetMHandle (HiWord (r))))->menuData[1] == appleMark) {
				/* get desk accessory name */ 
	  GetItem (m,LoWord (r),tmp);
	  OpenDeskAcc (tmp);	/* fire it up */
	  SetPort (window);	/* put us back at our window */
	}
	else SysBeep (60);	/* the fool forgot to disable it! */
      }
      HiliteMenu (0);		/* unhighlight it */
      break;
    case inContent:		/* some window was selected */
      if (window != FrontWindow ()) SelectWindow (window);
      break;
    default:			/* ignore all others */
      break;
    }
    break;
  case keyDown:			/* key hit - if COMMAND/. then punt */
    if ((event.modifiers & cmdKey) && (event.message & charCodeMask) == '.')
      return NIL;
    break;
  default:			/* ignore all others */
    break;
  }
  return T;			/* try wait test again */
}
Esempio n. 14
0
OSStatus _glfwMouseEventHandler( EventHandlerCallRef handlerCallRef,
                                 EventRef event,
                                 void *userData )
{
    switch( GetEventKind( event ) )
    {
        case kEventMouseDown:
        {
            WindowRef window;
            EventRecord oldStyleMacEvent;
            ConvertEventRefToEventRecord( event, &oldStyleMacEvent );
            if( FindWindow ( oldStyleMacEvent.where, &window ) == inMenuBar )
            {
                MenuSelect( oldStyleMacEvent.where );
                HiliteMenu(0);
                return noErr;
            }
            else
            {
                EventMouseButton button;
                if( GetEventParameter( event,
                                       kEventParamMouseButton,
                                       typeMouseButton,
                                       NULL,
                                       sizeof( EventMouseButton ),
                                       NULL,
                                       &button ) == noErr )
                {
                    button -= kEventMouseButtonPrimary;
                    if( button <= GLFW_MOUSE_BUTTON_LAST )
                    {
                        _glfwInputMouseClick( button
                                              + GLFW_MOUSE_BUTTON_LEFT,
                                              GLFW_PRESS );
                    }
                    return noErr;
                }
            }
            break;
        }

        case kEventMouseUp:
        {
            EventMouseButton button;
            if( GetEventParameter( event,
                                   kEventParamMouseButton,
                                   typeMouseButton,
                                   NULL,
                                   sizeof( EventMouseButton ),
                                   NULL,
                                   &button ) == noErr )
            {
                button -= kEventMouseButtonPrimary;
                if( button <= GLFW_MOUSE_BUTTON_LAST )
                {
                    _glfwInputMouseClick( button
                                          + GLFW_MOUSE_BUTTON_LEFT,
                                          GLFW_RELEASE );
                }
                return noErr;
            }
            break;
        }

        case kEventMouseMoved:
        case kEventMouseDragged:
        {
            HIPoint mouseLocation;
	    if( _glfwWin.MouseLock )
	    {
		if( GetEventParameter( event,
				       kEventParamMouseDelta,
				       typeHIPoint,
				       NULL,
				       sizeof( HIPoint ),
				       NULL,
				       &mouseLocation ) != noErr )
		{
		    break;
		}

		_glfwInput.MousePosX += mouseLocation.x;
		_glfwInput.MousePosY += mouseLocation.y;
	    }
	    else
	    {
		if( GetEventParameter( event,
				       kEventParamMouseLocation,
				       typeHIPoint,
				       NULL,
				       sizeof( HIPoint ),
				       NULL,
				       &mouseLocation ) != noErr )
		{
		    break;
		}

		_glfwInput.MousePosX = mouseLocation.x;
		_glfwInput.MousePosY = mouseLocation.y;

		if( !_glfwWin.Fullscreen )
		{
		    Rect content;
		    GetWindowBounds( _glfwWin.MacWindow,
		                     kWindowContentRgn,
				     &content );

		    _glfwInput.MousePosX -= content.left;
		    _glfwInput.MousePosY -= content.top;
		}
	    }

	    if( _glfwWin.MousePosCallback )
	    {
		_glfwWin.MousePosCallback( _glfwInput.MousePosX,
					   _glfwInput.MousePosY );
	    }

            break;
        }

        case kEventMouseWheelMoved:
        {
            EventMouseWheelAxis axis;
            if( GetEventParameter( event,
                                   kEventParamMouseWheelAxis,
                                   typeMouseWheelAxis,
                                   NULL,
                                   sizeof( EventMouseWheelAxis ),
                                   NULL,
                                   &axis) == noErr )
            {
                long wheelDelta;
                if( axis == kEventMouseWheelAxisY &&
                    GetEventParameter( event,
                                       kEventParamMouseWheelDelta,
                                       typeLongInteger,
                                       NULL,
                                       sizeof( long ),
                                       NULL,
                                       &wheelDelta ) == noErr )
                {
                    _glfwInput.WheelPos += wheelDelta;
                    if( _glfwWin.MouseWheelCallback )
                    {
                        _glfwWin.MouseWheelCallback( _glfwInput.WheelPos );
                    }
                    return noErr;
                }
            }
            break;
        }
    }

    return eventNotHandledErr;
}
Esempio n. 15
0
void do_menu_command(
	long menuResult) 
{
	short menuID;
	short menuItem;

	menuID= GET_MENU_ID(menuResult);
	menuItem= GET_MENU_ITEM(menuResult);
	
	switch (menuID) 
	{
		case mApple:
			switch (menuItem) 
			{
				case iAbout:
					break;
				default:
#if defined(OP_PLATFORM_MAC_CFM) && !defined(OP_PLATFORM_MAC_CARBON_FLAG)
					{
						Str255 daName;
						
						GetMenuItemText(GetMenuHandle(mApple), menuItem, daName);
						OpenDeskAcc(daName);
					}
#endif
					break;
			}
			break;

		case mFile:
			switch (menuItem) 
			{
				case iOpen:
				case iOpenPassive:
					handle_open(menuItem==iOpen, false);
					break;
					
				case iOpenActiveUI:
				case iOpenPassiveUI:
					handle_open(menuItem==iOpenActiveUI, true);
					break;
					
				case iClose:
					close_front_window();
					break;
					
				case iQuit:
					handle_quit();
					break;
			}
			break;
			
		case mSpecial:
			switch(menuItem)
			{
				case iSendPacket:
					send_packet();
					break;
				
				case iSendStream:
					send_stream();
					break;
					
				case iProtocolAlive:
					is_alive();
					break;
					
				case iAcceptingConnections:
					accepting_connections= !accepting_connections;
					check_menu_item(menuID, menuItem, accepting_connections);
					break;

				case iActiveEnumeration:
					active_enumeration= !active_enumeration;
					check_menu_item(menuID, menuItem, active_enumeration);
					break;
					
				case iSetTimeout:
					set_timeout();
					break;
					
				case iGetInfo:
					report_info();
					break;
					
				case iGetConfigString:
//					get_config_string();
					break;
			}
			break;
			
		case mWindowMenu:
			switch(menuItem)
			{
				case iCascade:
				case iTile:
					cascade_or_tile_windows(menuItem==iCascade);
					break;
			}
	}
#if OP_PLATFORM_MAC_CFM || OP_PLATFORM_MAC_MACHO
	HiliteMenu(0);
#endif
	adjust_menus();

	return;
}
Esempio n. 16
0
//default mouse event handler
static OSStatus MouseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData)
{
    OSStatus result = noErr;
	UInt32 class = GetEventClass (event);
	UInt32 kind = GetEventKind (event); 

	result = CallNextEventHandler(nextHandler, event);
	
	if(class == kEventClassMouse)
	{
		WindowPtr tmpWin;
		Point mousePos;
		Point winMousePos;

		GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &mousePos);
		GetEventParameter(event, kEventParamWindowMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &winMousePos);

		switch (kind)
		{
			case kEventMouseMoved:
			{
				if(vo_quartz_fs)
				{
					CGDisplayShowCursor(kCGDirectMainDisplay);
					mouseHide = FALSE;
				}
			}
			break;
			
			case kEventMouseWheelMoved:
			{
				int wheel;
				short part;
				
				GetEventParameter(event, kEventParamMouseWheelDelta, typeSInt32, 0, sizeof(int), 0, &wheel);

				part = FindWindow(mousePos,&tmpWin);
				
				if(part == inContent)
				{
					if(wheel > 0)
						mplayer_put_key(MOUSE_BTN3);
					else
						mplayer_put_key(MOUSE_BTN4);
				}
			}
			break;
			
			case kEventMouseDown:
			{
				EventMouseButton button;
				short part;
				Rect bounds;
				
				GetWindowPortBounds(theWindow, &bounds);
				GetEventParameter(event, kEventParamMouseButton, typeMouseButton, 0, sizeof(EventMouseButton), 0, &button);
				
				part = FindWindow(mousePos,&tmpWin);
				
				if( (winMousePos.h > (bounds.right - 15)) && (winMousePos.v > (bounds.bottom)) )
				{
					if(!vo_quartz_fs)
					{
						GrowWindow(theWindow, mousePos, NULL);
					}
				}
				else if(part == inMenuBar)
				{
					MenuSelect(mousePos);
					HiliteMenu(0);
				}
				else if(part == inContent)
				{
					switch(button)
					{ 
						case 1: mplayer_put_key(MOUSE_BTN0);break;
						case 2: mplayer_put_key(MOUSE_BTN2);break;
						case 3: mplayer_put_key(MOUSE_BTN1);break;
				
						default:result = eventNotHandledErr;break;
					}
				}
			}		
			break;
			
			case kEventMouseUp:
			break;
			
			case kEventMouseDragged:
			break;
				
			default:result = eventNotHandledErr;break;
		}
	}

    return result;
}
Esempio n. 17
0
static void HandleMenuChoice(long wParam) {

	UINT	update;
	Str255	applname;
#if defined(SUPPORT_STATSAVE)
	UINT	num;
	char	ext[16];
#endif

	update = 0;
	switch(wParam) {
		case IDM_ABOUT:
			AboutDialogProc();
			break;

		case IDM_RESET:
			pccore_cfgupdate();
			pccore_reset();
			break;

		case IDM_CONFIGURE:
			ConfigDialogProc();
			break;

		case IDM_NEWDISK:
			dialog_newdisk();
			break;

		case IDM_FONT:
			dialog_font();
			break;

		case IDM_EXIT:
			np2running = FALSE;
			break;

		case IDM_FDD1OPEN:
			dialog_changefdd(0);
			break;

		case IDM_FDD1EJECT:
			diskdrv_setfdd(0, NULL, 0);
			break;

		case IDM_FDD2OPEN:
			dialog_changefdd(1);
			break;

		case IDM_FDD2EJECT:
			diskdrv_setfdd(1, NULL, 0);
			break;

		case IDM_FDD3OPEN:
			dialog_changefdd(2);
			break;

		case IDM_FDD3EJECT:
			diskdrv_setfdd(2, NULL, 0);
			break;

		case IDM_FDD4OPEN:
			dialog_changefdd(3);
			break;

		case IDM_FDD4EJECT:
			diskdrv_setfdd(3, NULL, 0);
			break;

		case IDM_SASI1OPEN:
			dialog_changehdd(0x00);
			break;

		case IDM_SASI1REMOVE:
			diskdrv_sethdd(0x00, NULL);
			break;

		case IDM_SASI2OPEN:
			dialog_changehdd(0x01);
			break;

		case IDM_SASI2REMOVE:
			diskdrv_sethdd(0x01, NULL);
			break;

		case IDM_SCSI0OPEN:
			dialog_changehdd(0x20);
			break;

		case IDM_SCSI0REMOVE:
			diskdrv_sethdd(0x20, NULL);
			break;

		case IDM_SCSI1OPEN:
			dialog_changehdd(0x21);
			break;

		case IDM_SCSI1REMOVE:
			diskdrv_sethdd(0x21, NULL);
			break;

		case IDM_SCSI2OPEN:
			dialog_changehdd(0x22);
			break;

		case IDM_SCSI2REMOVE:
			diskdrv_sethdd(0x22, NULL);
			break;

		case IDM_SCSI3OPEN:
			dialog_changehdd(0x23);
			break;

		case IDM_SCSI3REMOVE:
			diskdrv_sethdd(0x23, NULL);
			break;

		case IDM_ROLNORMAL:
			menu_setrotate(0);
			changescreen(scrnmode & (~SCRNMODE_ROTATEMASK));
			break;

		case IDM_ROLLEFT:
			menu_setrotate(1);
			changescreen((scrnmode & (~SCRNMODE_ROTATEMASK)) |
														SCRNMODE_ROTATELEFT);
			break;

		case IDM_ROLRIGHT:
			menu_setrotate(2);
			changescreen((scrnmode & (~SCRNMODE_ROTATEMASK)) |
														SCRNMODE_ROTATERIGHT);
			break;

		case IDM_DISPSYNC:
			menu_setdispmode(np2cfg.DISPSYNC ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_RASTER:
			menu_setraster(np2cfg.RASTER ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_NOWAIT:
			menu_setwaitflg(np2oscfg.NOWAIT ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_AUTOFPS:
			menu_setframe(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_60FPS:
			menu_setframe(1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_30FPS:
			menu_setframe(2);
			update |= SYS_UPDATECFG;
			break;

		case IDM_20FPS:
			menu_setframe(3);
			update |= SYS_UPDATECFG;
			break;

		case IDM_15FPS:
			menu_setframe(4);
			update |= SYS_UPDATECFG;
			break;

		case IDM_SCREENOPT:
			dialog_scropt();
			break;

		case IDM_MOUSE:
			mousemng_toggle(MOUSEPROC_SYSTEM);
			menu_setmouse(np2oscfg.MOUSE_SW ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MIDIOPT:
			MPU98DialogProc();
			break;

		case IDM_MIDIPANIC:
			rs232c_midipanic();
			mpu98ii_midipanic();
			pc9861k_midipanic();
			break;

		case IDM_KEY:
			menu_setkey(0);
			keystat_resetjoykey();
			update |= SYS_UPDATECFG;
			break;

		case IDM_JOY1:
			menu_setkey(1);
			keystat_resetjoykey();
			update |= SYS_UPDATECFG;
			break;

		case IDM_JOY2:
			menu_setkey(2);
			keystat_resetjoykey();
			update |= SYS_UPDATECFG;
			break;

		case IDM_MOUSEKEY:
			menu_setkey(3);
			keystat_resetjoykey();
			update |= SYS_UPDATECFG;
			break;

		case IDM_XSHIFT:
			menu_setxshift(np2cfg.XSHIFT ^ 1);
			keystat_forcerelease(0x70);
			update |= SYS_UPDATECFG;
			break;

		case IDM_XCTRL:
			menu_setxshift(np2cfg.XSHIFT ^ 2);
			keystat_forcerelease(0x74);
			update |= SYS_UPDATECFG;
			break;

		case IDM_XGRPH:
			menu_setxshift(np2cfg.XSHIFT ^ 4);
			keystat_forcerelease(0x73);
			update |= SYS_UPDATECFG;
			break;

		case IDM_F11KANA:
			menu_setf11key(0);
			mackbd_resetf11();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F11STOP:
			menu_setf11key(1);
			mackbd_resetf11();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F11NFER:
			menu_setf11key(3);
			mackbd_resetf11();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F11USER:
			menu_setf11key(4);
			mackbd_resetf11();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12MOUSE:
			menu_setf12key(0);
			mackbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12COPY:
			menu_setf12key(1);
			mackbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12XFER:
			menu_setf12key(3);
			mackbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12USER:
			menu_setf12key(4);
			mackbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_BEEPOFF:
			menu_setbeepvol(0);
			beep_setvol(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_BEEPLOW:
			menu_setbeepvol(1);
			beep_setvol(1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_BEEPMID:
			menu_setbeepvol(2);
			beep_setvol(2);
			update |= SYS_UPDATECFG;
			break;

		case IDM_BEEPHIGH:
			menu_setbeepvol(3);
			beep_setvol(3);
			update |= SYS_UPDATECFG;
			break;

		case IDM_NOSOUND:
			menu_setsound(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_14:
			menu_setsound(0x01);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_26K:
			menu_setsound(0x02);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_86:
			menu_setsound(0x04);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_26_86:
			menu_setsound(0x06);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_86_CB:
			menu_setsound(0x14);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_118:
			menu_setsound(0x08);
			update |= SYS_UPDATECFG;
			break;

		case IDM_SPEAKBOARD:
			menu_setsound(0x20);
			update |= SYS_UPDATECFG;
			break;

		case IDM_SPARKBOARD:
			menu_setsound(0x40);
			update |= SYS_UPDATECFG;
			break;

		case IDM_AMD98:
			menu_setsound(0x80);
			update |= SYS_UPDATECFG;
			break;

		case IDM_JASTSND:
			menu_setjastsnd(np2oscfg.jastsnd ^ 1);
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_SEEKSND:
			menu_setmotorflg(np2cfg.MOTOR ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM640:
			menu_setextmem(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM16:
			menu_setextmem(1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM36:
			menu_setextmem(3);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM76:
			menu_setextmem(7);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM116:
			menu_setextmem(11);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM136:
			menu_setextmem(13);
			update |= SYS_UPDATECFG;
			break;

		case IDM_BMPSAVE:
			dialog_writebmp();
			break;

		case IDM_CALENDAR:
			CalendarDialogProc();
			break;

		case IDM_DISPCLOCK:
			menu_setdispclk(np2oscfg.DISPCLK ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_DISPFLAME:
			menu_setdispclk(np2oscfg.DISPCLK ^ 2);
			update |= SYS_UPDATECFG;
			break;

		case IDM_JOYX:
			menu_setbtnmode(np2cfg.BTN_MODE ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_RAPID:
			menu_setbtnrapid(np2cfg.BTN_RAPID ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_I286SAVE:
			debugsub_status();
			break;

		default:
			if (HiWord(wParam) == IDM_APPLE) {
				GetMenuItemText(GetMenuHandle(IDM_APPLE), 
											LoWord(wParam), applname);
#if !TARGET_API_MAC_CARBON
				(void)OpenDeskAcc(applname);
#endif
			}
#if defined(SUPPORT_STATSAVE)
			else if (HiWord(wParam) == IDM_STATSAVE) {
				num = LoWord(wParam);
				if ((num >= 1) && (num < (1 + 10))) {
					SPRINTF(ext, np2flagext, num - 1);
					flagsave(ext);
				}
				else if ((num >= 12) && (num < (12 + 10))) {
					SPRINTF(ext, np2flagext, num - 12);
					flagload(ext, TRUE);
				}
			}
#endif
			break;
	}
	sysmng_update(update);
	HiliteMenu(0);
}
Esempio n. 18
0
void 
TkMacHandleMenuSelect(
    long mResult,
    int optionKeyPressed)
{
    short theItem = LoWord(mResult);
    short theMenu = HiWord(mResult);
    Str255 name;
    Tk_Window tkwin;
    Window window;
    TkDisplay *dispPtr;

    if (mResult == 0) {
    	TkMacHandleTearoffMenu();
	TkMacClearMenubarActive();
	return;
    }

    switch (theMenu) {
	
	case kAppleMenu:
	    switch (theItem) {
		case kAppleAboutItem:
		    {
			Tcl_CmdInfo dummy;
			
			if (optionKeyPressed || gInterp == NULL ||
			    Tcl_GetCommandInfo(gInterp,
				    "tkAboutDialog", &dummy) == 0) {
			    TkAboutDlg();
			} else {
			    Tcl_Eval(gInterp, "tkAboutDialog");
			}
			break;
		    }
		default:
		    GetMenuItemText(tkAppleMenu, theItem, name);
		    HiliteMenu(0);
		    OpenDeskAcc(name);
		    return;
	    }
	    break;
	case kFileMenu:
	    switch (theItem) {
		case kSourceItem:
		    /* TODO: source script */
		    SourceDialog();
		    break;
		case kCloseItem:
		    /* Send close event */
		    if (TkMacHaveAppearance() >= 0x110) {
		        window = TkMacGetXWindow(FrontNonFloatingWindow());
		    } else {
		        window = TkMacGetXWindow(FrontWindow());
		    }
		    dispPtr = TkGetDisplayList();
		    tkwin = Tk_IdToWindow(dispPtr->display, window);
		    TkGenWMDestroyEvent(tkwin);
		    break;
		case kQuitItem:
		    /* Exit */
		    if (optionKeyPressed || gInterp == NULL) {
			Tcl_Exit(0);
		    } else {
			Tcl_Eval(gInterp, "exit");
		    }
		    break;
	    }
	    break;
	case kEditMenu:
	    /*
	     * This implementation just send keysyms
	     * the Tk thinks are associated with function keys that
	     * do Cut, Copy & Paste on a Sun keyboard.
	     */
	    GenerateEditEvent(theItem);
	    break;
	default:
	    TkMacDispatchMenuEvent(theMenu, theItem);
	    TkMacClearMenubarActive();
	    break;
    }

    /*
     * Finally we unhighlight the menu.
     */
    HiliteMenu(0);
} /* TkMacHandleMenuSelect */
Esempio n. 19
0
// 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 );
}
Esempio n. 20
0
void shellhandlekeystroke (void) {
	
	/*
	if it's a cmd-key we first offer it to the frontmost window, if he doesn't
	consume it, we pass it on to the menubar.
	
	if it's shift-enter, we close the frontmost window.
	
	otherwise we pass the keystroke to the front window's handler.
	
	7/18/90 DW: add hooks.  they're allowed to consume a keystroke by returning
	false.
	
	11/8/90 DW: add support for style keys -- cmd-shift BIOUS.
	
	12/6/91 dmb: give menubar priority over cmdkeyfilter
	*/
	
	unsigned int chkb;
	#ifdef MACVERSION	
		register boolean fl;
		long codeword;
	#endif
	
	timelastkeystroke = gettickcount ();
	
	setkeyboardstatus (shellevent.message, shellevent.what, shellevent.modifiers); /*fill keyboardstatus record with info about the event*/
	
	if (!keyboardstatus.flautokey)	/*4.0b7 dmb: new non-repeating ouchs*/
		flouchlocked = false;

#ifdef MACVERSION	
	if (shellfilterfunctionkey (&codeword) || shellfilterfontkey (&codeword)) {
		
		fl = shellpushfrontglobals ();
		
		shellupdatemenus ();
		
		HiliteMenu (HiWord (codeword));
		
		shellhandlemenu (codeword);
		
		if (fl)
			shellpopglobals ();
			
		return;
		}
#endif
	
	if (!shellcallkeyboardhooks ())
		return;
	
	chkb = keyboardstatus.chkb; /*move into register*/

#ifdef MACVERSION	
	if (keyboardstatus.flcmdkey && (chkb >= chspace)) {
		
		if (chkb == '.') { /*cmd-period is consumed here*/
		
			keyboardsetescape ();
			
			return;
			}
		
		/*
		if (shellpushfrontglobals ()) { /%a window is open%/
			
			fl = (*shellglobals.cmdkeyfilterroutine) (keyboardstatus.chkb);
			
			shellpopglobals ();
			
			if (!fl) /%cmd-key was consumed%/
				return;
			}
		*/
		
		fl = shellpushfrontglobals ();
		
		shellupdatemenus (); /*be sure the menus are properly checked and highlighted*/
		
		if (!shellhandlemenu (MenuKey (chkb))) { /*cmd-key not consumed by menubar*/
			
			if (fl)
				(*shellglobals.cmdkeyfilterroutine) (chkb);
			}
		
		if (fl)
			shellpopglobals ();
		
		return;
		}
#endif
		
	if (shellpushfrontglobals ()) { /*a window is open to close or receive keystroke*/
	
		if (shellcalleventhooks (&shellevent, shellwindow)) /*keystroke wasn't consumed*/
			(*shellglobals.keystrokeroutine) ();
		
		shellpopglobals ();
		}
	} /*shellhandlekeystroke*/
Esempio n. 21
0
void
TkMacOSXHandleMenuSelect(
    MenuID theMenu,
    MenuItemIndex theItem,
    int optionKeyPressed)
{
    Tk_Window tkwin;
    Window window;
    TkDisplay *dispPtr;
    Tcl_CmdInfo dummy;
    int code;

    if (theItem == 0) {
	TkMacOSXClearMenubarActive();
	return;
    }

    switch (theMenu) {
    case kAppleMenu:
	switch (theItem) {
	case kAppleAboutItem:
	    if (optionKeyPressed || gInterp == NULL ||
		Tcl_GetCommandInfo(gInterp, "tkAboutDialog", &dummy) == 0) {
		TkAboutDlg();
	    } else {
		code = Tcl_EvalEx(gInterp, "tkAboutDialog", -1,
			TCL_EVAL_GLOBAL);
		if (code != TCL_OK) {
		    Tcl_BackgroundException(gInterp, code);
		}
		Tcl_ResetResult(gInterp);
	    }
	    break;
	}
	break;
    case kFileMenu:
	switch (theItem) {
	case kSourceItem:
	    if (gInterp) {
		if (Tcl_EvalEx(gInterp, "tk_getOpenFile -filetypes {"
			"{{TCL Scripts} {.tcl} TEXT} {{Text Files} {} TEXT}}",
			-1, TCL_EVAL_GLOBAL) == TCL_OK) {
		    Tcl_Obj *path = Tcl_GetObjResult(gInterp);
		    int len;

		    Tcl_GetStringFromObj(path, &len);
		    if (len) {
			Tcl_IncrRefCount(path);
			code = Tcl_FSEvalFile(gInterp, path);
			if (code != TCL_OK) {
			    Tcl_BackgroundException(gInterp, code);
			}
			Tcl_DecrRefCount(path);
		    }
		}
		Tcl_ResetResult(gInterp);
	    }
	    break;
	case kDemoItem:
	    if (gInterp) {
		Tcl_Obj *path = GetWidgetDemoPath(gInterp);

		if (path) {
		    Tcl_IncrRefCount(path);
		    code = Tcl_FSEvalFile(gInterp, path);
		    if (code != TCL_OK) {
			Tcl_BackgroundException(gInterp, code);
		    }
		    Tcl_DecrRefCount(path);
		    Tcl_ResetResult(gInterp);
		}
	    }
	    break;
	case kCloseItem:
	    /* Send close event */
	    window = TkMacOSXGetXWindow(ActiveNonFloatingWindow());
	    dispPtr = TkGetDisplayList();
	    tkwin = Tk_IdToWindow(dispPtr->display, window);
	    TkGenWMDestroyEvent(tkwin);
	    break;
	}
	break;
    case kEditMenu:
	/*
	 * This implementation just send the keysyms Tk thinks are associated
	 * with function keys that do Cut, Copy & Paste on a Sun keyboard.
	 */

	GenerateEditEvent(theItem);
	break;
    default:
	TkMacOSXDispatchMenuEvent(theMenu, theItem);
	break;
    }

    /*
     * Finally we unhighlight the menu.
     */

    HiliteMenu(0);
}
Esempio n. 22
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);
}
Esempio n. 23
0
void Sys_EventLoop(void) {
    EventRecord event;
    Point mousePos;
    WindowRef winref;
    WindowPartCode part;
    Rect tmpRect;
    SInt32 menuChoice;
    MenuID menuID;
    MenuItemIndex menuItem;
    menu_t menu;
    void (*itemCallback)(void);

    /* track mouse movements */
    GetMouse(&mousePos);
    if (!g_Window.fs) {
        /* offset mousePos by windowRect coords */
        mousePos.h -= windowRect.left;
        mousePos.v -= windowRect.top;
    }
    if (mousePos.h > g_Window.width)
        mousePos.h = g_Window.width;
    if (mousePos.v > g_Window.height)
        mousePos.v = g_Window.height;

    atlUpdateMousePos(atlMouseToSpace(mousePos.h, mousePos.v));

    if (WaitNextEvent(everyEvent, &event, 1, NULL)) {
        switch (event.what) {
            case keyDown:
            case autoKey:
                keysPressed[event.message & charCodeMask] = true;
                atlEscapePressed = isKeyPressed(KEY_ESCAPE);
                break;

            case keyUp:
                keysPressed[event.message & charCodeMask] = false;
                break;

            case mouseDown:
                mousePos = event.where;
                if (!g_Window.fs) {
                    part = FindWindow(event.where, &winref);
                    /* offset by rect.top and rect.left pixels */
                    mousePos.h -= windowRect.left;
                    mousePos.v -= windowRect.top;

                    switch (part) {
                        case inMenuBar:
                            menuChoice = MenuSelect(event.where);
                            menuID = HiWord(menuChoice);
                            menuItem = LoWord(menuChoice);

                            if (menuID == 0)
                                break;

                            menu = menus[menuID];
                            itemCallback = menu.callbacks[menuItem];
                            if (itemCallback)
                                itemCallback();

                            HiliteMenu(0);
                            break;

                        default:
                            break;
                    }
                }

                g_Mouse.clickPos = atlMouseToSpace(mousePos.h, mousePos.v);
                g_Mouse.leftClickDown = true;

                break;

            case mouseUp:
                FindWindow(event.where, &winref);
                if (winref) {
                    /* mousePos is based on windowRect, so if the window moves,
                     * windowRect needs to be updated */
                    GetWindowBounds(winref, kWindowContentRgn, &tmpRect);
                    if (tmpRect.left != windowRect.left ||
                        tmpRect.top != windowRect.top) {
                        windowRect = tmpRect;
                    }
                }

                g_Mouse.leftClickDown = false;
                g_Mouse.clickPos = cpvzero;
                break;

            default:
                break;
        }
    }
}