Ejemplo 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);
}
Ejemplo n.º 2
0
boolean clickcolorpopup (Point pt, RGBColor *rgb) {
	
	long result;
	short lo, hi;
	
	if (!flpopupinit)
		flpopupinit = initcolorpopup ();
	
	setcursortype (cursorisarrow);
	
	CalcMenuSize (colormenu);
	
	InsertMenu (colormenu, hierMenu);

	LocalToGlobal (&pt);
	
	result = PopUpMenuSelect (colormenu, pt.v, pt.h, -1);

	DeleteMenu ((**colormenu).menuID);
	
	lo = LoWord (result);
	
	hi = HiWord (result);
	
	if (hi > 0) { /*something was selected*/
	
		*rgb = (*ctable) [lo - 1].rgb;
		
		return (true);
		}
	
	return (false);
	} /*clickcolorpopup*/
Ejemplo n.º 3
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 */
}
Ejemplo 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);
}
Ejemplo n.º 5
0
void doMouseDown(EventRecord *eventStrucPtr)
{
    WindowRef      windowRef;
    WindowPartCode partCode, zoomPart;
    BitMap         screenBits;
    Rect           constraintRect, mainScreenRect;
    Point          standardStateHeightAndWidth;
    long           newSize;

    partCode = FindWindow(eventStrucPtr->where,&windowRef);

    switch(partCode)
    {
    case inMenuBar:
        break;

    case inContent:
        if(windowRef != FrontWindow())
            SelectWindow(windowRef);
        else
            doInContent(eventStrucPtr,windowRef);
        break;

    case inDrag:
        DragWindow(windowRef,eventStrucPtr->where,NULL);
        break;

    case inGoAway:
        break;

    case inGrow:
        constraintRect.top   = 75;
        constraintRect.left = 250;
        constraintRect.bottom = constraintRect.right = 32767;
        newSize = GrowWindow(windowRef,eventStrucPtr->where,&constraintRect);
        if (newSize != 0)
            SizeWindow(windowRef,LoWord(newSize),HiWord(newSize),true);
        window_adjust_scrollbars(windowRef);
        window_invalidate(windowRef);
        break;

    case inZoomIn:
    case inZoomOut:
        mainScreenRect = GetQDGlobalsScreenBits(&screenBits)->bounds;
        standardStateHeightAndWidth.v = mainScreenRect.bottom;
        standardStateHeightAndWidth.h = mainScreenRect.right;

        if(IsWindowInStandardState(windowRef,&standardStateHeightAndWidth,NULL))
            zoomPart = inZoomIn;
        else
            zoomPart = inZoomOut;

        if(TrackBox(windowRef,eventStrucPtr->where,partCode))
        {
            ZoomWindowIdeal(windowRef,zoomPart,&standardStateHeightAndWidth);
            window_adjust_scrollbars(windowRef);
        }
        break;
    }
}
Ejemplo n.º 6
0
static void mac_updatelicence(WindowPtr window)
{
    Handle h;
    int len;
    long fondsize;
    Rect textrect;

    SetPort((GrafPtr)GetWindowPort(window));
    BeginUpdate(window);
    fondsize = GetScriptVariable(smRoman, smScriptSmallFondSize);
    TextFont(HiWord(fondsize));
    TextSize(LoWord(fondsize));
    h = Get1Resource('TEXT', wLicence);
    len = GetResourceSizeOnDisk(h);
#if TARGET_API_MAC_CARBON
    GetPortBounds(GetWindowPort(window), &textrect);
#else
    textrect = window->portRect;
#endif
    if (h != NULL) {
	HLock(h);
	TETextBox(*h, len, &textrect, teFlushDefault);
	HUnlock(h);
    }
    EndUpdate(window);
}
Ejemplo n.º 7
0
    void DataSerializer::Serialize<float>(const float& value)
    {
      const uint32_t& tmp = reinterpret_cast<const uint32_t&>(value);
      const uint16_t lo = LoWord(tmp);
      const uint16_t hi = HiWord(tmp);

      *this << HiByte(hi) << LoByte(hi) << HiByte(lo) << LoByte(lo);
    }
Ejemplo n.º 8
0
static pascal long WindowMaskProc(short varCode, WindowRef window, short message, long param)
{
#pragma unused( varCode ) 
	switch (message)
	{
	case kWindowMsgGetFeatures:
		*(OptionBits*) param = kWindowCanGetWindowRegion
		                       | kWindowDefSupportsColorGrafPort;
		return 1;
	case kWindowMsgGetRegion:
		{
			GetWindowRegionRec* rgnRec  = (GetWindowRegionRec*) param;
			switch (rgnRec->regionCode)
			{
			case kWindowTitleBarRgn:
			case kWindowTitleTextRgn:
			case kWindowCloseBoxRgn:
			case kWindowZoomBoxRgn:
			case kWindowDragRgn:
			case kWindowGrowRgn:
			case kWindowCollapseBoxRgn:
				SetEmptyRgn(rgnRec->winRgn);
				break;
			case kWindowStructureRgn:
			case kWindowContentRgn:
				getWindowContentRegion(window, rgnRec->winRgn);
				break;
			case kWindowUpdateRgn:
				break;
			case kWindowOpaqueRgn:
				SetEmptyRgn(rgnRec -> winRgn);
				break;
			default:
				return errWindowRegionCodeInvalid;
			}
			return noErr;
		}
	case kWindowMsgHitTest:
		{
			Point hitPoint;
			static RgnHandle tempRgn = nil;
			if (!tempRgn)
				tempRgn = NewRgn();
			SetPt(&hitPoint, LoWord(param), HiWord(param));//get the point clicked
			if (PtInRgn(hitPoint, getWindowContentRegion(window, tempRgn)))
				return wInContent;
			else
				return wNoHit;
		}
		break;
		
	default:
		break;
	}
	return 0;
}
Ejemplo n.º 9
0
IPopupMenu* IGraphicsCarbon::CreateIPopupMenu(IPopupMenu* pMenu, IRECT* pAreaRect)
{
  // Get the plugin gui frame rect within the host's window
  HIRect rct;
  HIViewGetFrame(this->mView, &rct);

  // Get the host's window rect within the screen
  Rect wrct;
  GetWindowBounds(this->mWindow, kWindowContentRgn, &wrct);

  #ifdef RTAS_API
  int xpos = wrct.left + this->GetLeftOffset() + pAreaRect->L;
  int ypos = wrct.top + this->GetTopOffset() + pAreaRect->B + 5;
  #else
  HIViewRef contentView;
  HIViewFindByID(HIViewGetRoot(this->mWindow), kHIViewWindowContentID, &contentView);
  HIViewConvertRect(&rct, HIViewGetSuperview((HIViewRef)this->mView), contentView);

  int xpos = wrct.left + rct.origin.x + pAreaRect->L;
  int ypos = wrct.top + rct.origin.y + pAreaRect->B + 5;
  #endif

  MenuRef menuRef = CreateMenu(pMenu);

  if (menuRef)
  {
    int32_t popUpItem = 1;
    int32_t PopUpMenuItem = PopUpMenuSelect(menuRef, ypos, xpos, popUpItem);

    short result = LoWord(PopUpMenuItem) - 1;
    short menuIDResult = HiWord(PopUpMenuItem);
    IPopupMenu* resultMenu = 0;

    if (menuIDResult != 0)
    {
      MenuRef usedMenuRef = GetMenuHandle(menuIDResult);

      if (usedMenuRef)
      {
        if (GetMenuItemRefCon(usedMenuRef, 0, (URefCon*)&resultMenu) == noErr)
        {
          resultMenu->SetChosenItemIdx(result);
        }
      }
    }

    CFRelease(menuRef);

    return resultMenu;
  }
  else
  {
    return 0;
  }
}
Ejemplo n.º 10
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*/
Ejemplo n.º 11
0
void
dogrowwin (Point start, WindowPtr wp)
{
  Rect r;
  long newsize;

/* todo: find out what is normally done when there is no maximum size that needs to be enforced */
  SetRect (&r, ICONWIDTHUSED, ICONHEIGHTUSED, 32767, 32767);
  newsize = GrowWindow (wp, start, &r);
  SizeWindow (wp, LoWord (newsize), HiWord (newsize), true);
  InvalRect (&wp->portRect);
  straightenwindow (wp);
}
Ejemplo n.º 12
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);
}
Ejemplo n.º 13
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);
}
Ejemplo n.º 14
0
 virtual void PopUp( wxWindow *WXUNUSED(win), int x, int y )
 {
     long menuResult = ::PopUpMenuSelect(m_osxMenu, y, x, 0) ;
     if ( HiWord(menuResult) != 0 )
     {
         MenuCommand macid;
         GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &macid );
         int id = wxMacCommandToId( macid );
         wxMenuItem* item = NULL ;
         wxMenu* realmenu ;
         item = m_peer->FindItem( id, &realmenu ) ;
         if ( item )
         {
             m_peer->HandleCommandProcess(item, NULL );
         }
     }
 }
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;
}
Ejemplo n.º 16
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 */
}
Ejemplo n.º 17
0
static SInt32 wxShapedMacWindowHitTest(WindowRef window,SInt32 param)
{
    /*------------------------------------------------------
        Determine the region of the window which was hit
    --------------------------------------------------------*/
    Point hitPoint;
    static RgnHandle tempRgn=nil;

    if(!tempRgn)
    	tempRgn=NewRgn();

    SetPt(&hitPoint,LoWord(param),HiWord(param));//get the point clicked

     //Mac OS 8.5 or later
    wxShapedMacWindowStructureRegion(window, tempRgn);
    if (PtInRgn(hitPoint, tempRgn)) //in window content region?
        return wInContent;

    return wNoHit;//no significant area was hit.
}
Ejemplo n.º 18
0
static void mac_createeventlog(Session *s)
{
    Rect view;
    ListBounds bounds = { 0, 0, 0, 1 }; /* 1 column, 0 rows */
    Point csize = { 0, 0 };
    GrafPtr saveport;
    long fondsize;
    WinInfo *wi;

    s->eventlog_window = GetNewWindow(wEventLog, NULL, (WindowPtr)-1);
    wi = snew(WinInfo);
    memset(wi, 0, sizeof(*wi));
    wi->s = s;
    wi->wtype = wEventLog;
    wi->click = &mac_clickeventlog;
    wi->activate = &mac_activateeventlog;
    wi->grow = &mac_groweventlog;
    wi->update = &mac_updateeventlog;
    wi->close = &mac_closeeventlog;
    SetWRefCon(s->eventlog_window, (long)wi);
    GetPort(&saveport);
    SetPort((GrafPtr)GetWindowPort(s->eventlog_window));
    fondsize = GetScriptVariable(smRoman, smScriptSmallFondSize);
    TextFont(HiWord(fondsize));
    TextSize(LoWord(fondsize));
    SetPort(saveport);
#if TARGET_API_MAC_CARBON
    GetPortBounds(GetWindowPort(s->eventlog_window), &view);
#else
    view = s->eventlog_window->portRect;
#endif
    view.right -= 15; /* Scrollbar */
    s->eventlog = LNew(&view, &bounds, csize, 0, s->eventlog_window,
		       TRUE, TRUE, FALSE, TRUE);
    mac_adjusteventlogscrollbar(s);
#if TARGET_API_MAC_CARBON
    SetListSelectionFlags(s->eventlog, lExtendDrag | lNoDisjoint | lNoExtend);
#else
    (*s->eventlog)->selFlags = lExtendDrag | lNoDisjoint | lNoExtend;
#endif
}
Ejemplo n.º 19
0
void nsNativeViewerApp::DispatchMenuItemWithoutWindow(PRInt32 menuResult)
{
    long menuID = HiWord(menuResult);
    long menuItem = LoWord(menuResult);
    switch (menuID)
    {
        case menu_Apple:
            switch (menuItem)
            {
                case cmd_About:
                    ::Alert(128, nil);
                    break;
                default:
                    Str255 daName;
                    GetMenuItemText(GetMenuHandle(menu_Apple), menuItem, daName);
                    #if !TARGET_CARBON
                    OpenDeskAcc(daName);
                    #endif
                    break;
            }
            break;

        case menu_File:
            
            switch (menuItem)
            {
                case cmd_New:
                    gTheApp->OpenWindow();
                    break;
                case cmd_Open:
                    nsBrowserWindow * newWindow;
                    gTheApp->OpenWindow((PRUint32)0, newWindow);
                    newWindow->DoFileOpen();
                    break;
                case cmd_Quit:
                    gTheApp->Exit();
                    break;
            }
            break;
        }
}
Ejemplo n.º 20
0
static short local_AppearanceMgrVersion( void )
{	static short	apMgrVersion = -1;

	if ( apMgrVersion == -1 ) {
		// The first time through, we'll check Gestalt.
		OSErr		err;
		long			result;

		err = Gestalt( gestaltAppearanceAttr, &result );
		if ( ( err == noErr ) && ( result & (1 << gestaltAppearanceExists) ) ) {
			err = Gestalt( gestaltAppearanceVersion, &result );
			if ( err == noErr )
				apMgrVersion = LoWord( result );
			else
				apMgrVersion = 0x0100;	// Version 1.0 didn't advertise it's version number.
		} else
			apMgrVersion = 0x0000;
	}

	return apMgrVersion;
}
Ejemplo n.º 21
0
 void DataSerializer::Serialize<uint32_t>(const uint32_t& value)
 {
   Serialize(LoWord(value));
   Serialize(HiWord(value));
 }
Ejemplo n.º 22
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);
}
Ejemplo n.º 23
0
static void MenuBarInit(void) {

	Handle		hdl;
	MenuHandle	hmenu;

	hdl = GetNewMBar(IDM_MAINMENU);
	if (hdl == NULL) {
		ExitToShell();
	}
	SetMenuBar(hdl);
	hmenu = GetMenuHandle(IDM_APPLE);
	if (hmenu) {
		AppendResMenu(hmenu, 'DRVR');
	}
#if !defined(SUPPORT_SCSI)
	hmenu = GetMenuHandle(IDM_HARDDISK);
	if (hmenu) {
		DeleteMenuItem(hmenu, 7);
		DeleteMenuItem(hmenu, 6);
		DeleteMenuItem(hmenu, 5);
		DeleteMenuItem(hmenu, 4);
		DeleteMenuItem(hmenu, 3);
	}
#endif
	if (!np2oscfg.I286SAVE) {
		hmenu = GetMenuHandle(IDM_OTHER);
		if (hmenu) {
			DeleteMenuItem(hmenu, 9);
		}
	}
	InsertMenu(GetMenu(IDM_SASI1), -1);
	InsertMenu(GetMenu(IDM_SASI2), -1);
#if defined(SUPPORT_SCSI)
	InsertMenu(GetMenu(IDM_SCSI0), -1);
	InsertMenu(GetMenu(IDM_SCSI1), -1);
	InsertMenu(GetMenu(IDM_SCSI2), -1);
	InsertMenu(GetMenu(IDM_SCSI3), -1);
#endif
	InsertMenu(GetMenu(IDM_KEYBOARD), -1);
	InsertMenu(GetMenu(IDM_SOUND), -1);
	InsertMenu(GetMenu(IDM_MEMORY), -1);

#if TARGET_API_MAC_CARBON
	hmenu = GetMenuHandle(IDM_FDD2);
	SetItemCmd(hmenu, LoWord(IDM_FDD2OPEN), 'D');
	SetMenuItemModifiers(hmenu, LoWord(IDM_FDD2OPEN), kMenuShiftModifier);
	SetItemCmd(hmenu, LoWord(IDM_FDD2EJECT), 'E');
	SetMenuItemModifiers(hmenu, LoWord(IDM_FDD2EJECT), kMenuShiftModifier);
	hmenu = GetMenuHandle(IDM_SASI2);
	SetItemCmd(hmenu, LoWord(IDM_SASI2OPEN), 'O');
	SetMenuItemModifiers(hmenu, LoWord(IDM_SASI2OPEN), kMenuShiftModifier);
#else
	EnableItem(GetMenuHandle(IDM_DEVICE), LoWord(IDM_MOUSE));
	EnableItem(GetMenuHandle(IDM_KEYBOARD), LoWord(IDM_F12MOUSE));
#endif

	if (!(np2cfg.fddequip & 1)) {
		DeleteMenu(IDM_FDD1);
	}
	if (!(np2cfg.fddequip & 2)) {
		DeleteMenu(IDM_FDD2);
	}
	if (!(np2cfg.fddequip & 4)) {
		DeleteMenu(IDM_FDD3);
	}
	if (!(np2cfg.fddequip & 8)) {
		DeleteMenu(IDM_FDD4);
	}

#if defined(SUPPORT_STATSAVE)
	if (!np2oscfg.statsave) {
#endif
		DeleteMenu(IDM_STATSAVE);
#if defined(SUPPORT_STATSAVE)
	}
#endif

	DrawMenuBar();
}
Ejemplo n.º 24
0
/****************************************************************
   PopClick() gets called when there is a click in a dialog item
   that might be a popup item.  It determines if the click is
   in a popup and if so handles the click.  It brings up the
   popup on the item that was last selected for this menu.  It
   returns true if the item was a popup item and the mouse was
   released on a valid item.
   In that case, it also stores the value returned
   by PopUpMenuSelect in *result (a long containing the menu and
   item ID selected).  If the item selected was in this menu (as
   opposed to one of its submenus), that item is stored in the
   lastItemSelected field for this popup in the popTable.  In
   that case, the item is also checked, and the previously
   selected item is unchecked.

   For a click on a static popup item, PopClick returns false,
   returns 0 in *result and doesn't call PopUpMenuSelect.

   -- On the IBM, this simply gets the index value of the selected item.

****************************************************************/
Boolean PopClick(DialogPtr theDialog, short itemHit, LONGPTR result)
{
#ifndef IBM
   GrafPtr        savePort;
   short          theType;
   Rect           popBox;
   Rect           titleBox;
   MenuHandle     theMenu;
   long           res;
   short          count;
   char           name[256];
   Handle         itemHandle;
#else
	HANDLE itemHandle;
#endif
   short          i;
   
   #ifndef IBM
   if (OverridePopClick(theDialog, itemHit, result)) return true;
   #endif
   
   for ( i = 0 ; i < sa_numPopUps ; i++ )
      if ( (sa_popTable[i].dialogPtr == theDialog) && (sa_popTable[i].popupItemNum == itemHit) )
         break;

   if (i == sa_numPopUps || sa_popTable[i].bStatic) {
      *result = 0;
      return false;
   }

 #ifdef IBM
   itemHandle = GetDlgItem (theDialog, itemHit);
   sa_popTable[i].lastItemSelected =
    // (SendMessage (itemHandle, CB_GETCURSEL, 0, 0L)+1);  //Combo box item ID's begin at 0
     (SendMessage ((HWND)itemHandle, CB_GETCURSEL, 0, 0L)+1);  //Combo box item ID's begin at 0
	
	return FALSE;
 #else
   GetPortGrafPtr(&savePort);
   SetPortDialogPort(theDialog);
   theMenu = GetMenuHandle(sa_popTable[i].menuID);

   if (sa_popTable[i].drawProc == nil)       // grow items to match size of pop-box
      for ( count = CountMenuItems(theMenu) ; count >= 1 ; count-- ) {
         GetMenuItemText(theMenu, count, (StringPtr)name);
         my_p2cstr((StringPtr)name);
         strcat(name, "     ");
         my_c2pstr(name);
         SetMenuItemText(theMenu, count, (StringPtr)name);
         my_p2cstr((StringPtr)name);
      }

   if (sa_popTable[i].titleItemNum) {
      GetDialogItem(theDialog,sa_popTable[i].titleItemNum,&theType,&itemHandle,&titleBox);
      InvertRect(&titleBox);
   }
   GetDialogItem(theDialog,sa_popTable[i].popupItemNum,&theType,&itemHandle,&popBox);
   LocalToGlobal((Point *)(&popBox.top));
   LocalToGlobal((Point *)(&popBox.bottom));
   res = PopUpMenuSelect( theMenu, popBox.top + 1, popBox.left + 1, sa_popTable[i].lastItemSelected );
   if (sa_popTable[i].titleItemNum)
      InvertRect(&titleBox);
   if (LoWord(res) && (HiWord(res) == sa_popTable[i].menuID)) {
      SetItemMark(theMenu, sa_popTable[i].lastItemSelected, noMark);
      sa_popTable[i].lastItemSelected = LoWord(res);
      SetItemMark(theMenu, sa_popTable[i].lastItemSelected, kCheckMark);
   }

   if (sa_popTable[i].drawProc == nil)       // shrink items back to normal
      for ( count = CountMenuItems(theMenu) ; count >= 1 ; count-- ) {
         GetMenuItemText(theMenu, count, (StringPtr)name);
         my_p2cstr((StringPtr)name);
         name[strlen(name) - 5] = 0;
         my_c2pstr(name);
         SetMenuItemText(theMenu, count, (StringPtr)name);
         my_p2cstr((StringPtr)name);
      }

   *result = res;

   SetPortGrafPort(savePort);

   if (LoWord(res)) {
      PopDraw(sa_popTable[i].dialogPtr, sa_popTable[i].popupItemNum);
      return true;
   }

   return false;
 #endif //IBM
}
Ejemplo n.º 25
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 */
Ejemplo n.º 26
0
// --------------------------------------------------------------------------------------
static Boolean dialogFilter(EventRecord *event, DialogRef *theDialog, 
							DialogItemIndex *itemHit)
{
		/* See the comments for HandleKeyDown in PrefsWindow.c about why we're using 
		   virtual key codes instead of character codes. */
	Boolean eventHandled = false;
	char charCode, keyCode;
	
	switch (event->what)
	{
		case keyDown:	// handle key presses not handled by DialogSelect
		case autoKey:
			*theDialog = GetDialogFromWindow(FrontNonFloatingWindow());
			SetPortDialogPort(*theDialog);
			charCode = event->message & charCodeMask;
			keyCode = (event->message & keyCodeMask) >> 8;
			
			if ((event->modifiers & cmdKey) != 0)		// check to see if any menu commands 
			{					// were selected - this isn't necessarily handling the event
				UInt32 menuChoice;
				OSErr error;
				MenuCommand commandID;
				
				menuChoice = MenuEvent(event);
				error = GetMenuItemCommandID(GetMenuRef(HiWord(menuChoice)), 
												LoWord(menuChoice), &commandID);
				if (error == noErr)
				{
					if (commandID == 0)		// if the menu item chosen does not have a 
						commandID = (MenuCommand)menuChoice;	// command ID 
					HandleMenuChoice(commandID);				// (but they all should)
				}
			}
			
			if ( (keyCode == kEnterKeyCode) || (keyCode == kReturnKeyCode) || 
				(keyCode == kEscapeKeyCode) || 
				( ((event->modifiers & cmdKey) != 0) && (charCode == '.') ) )
			{
				ControlRef button;
				unsigned long finalTicks;
				
				if ( (keyCode == kEnterKeyCode) || (keyCode == kReturnKeyCode) )
				{
					GetDialogItemAsControl(*theDialog, kStdOkItemIndex, &button);
					*itemHit = kStdOkItemIndex;
				}
				else
				{
					GetDialogItemAsControl(*theDialog, kStdCancelItemIndex, &button);
					*itemHit = kStdCancelItemIndex;
				}
				
				HiliteControl(button, kControlButtonPart);
				Delay(8, &finalTicks);
				HiliteControl(button, kControlNoPart);
				eventHandled = true;
			}
	}
	
	return eventHandled;
}
Ejemplo n.º 27
0
	//--------------------------------------------------------------------------------
	bool CMenuController::ProcessMessage( COSWindow& Window, Cmp_long_ptr& lResult, unsigned int uMsg, Cmp_uint_ptr wParam, Cmp_long_ptr lParam )
	{
		_WINQ_FCONTEXT( "CMenuController::ProcessMessage" );

		bool bProcessed = ProcessHook( Window, lResult, uMsg, wParam, lParam );

		switch ( uMsg )
		{
		case COSWindow::wmContextMenu:
			{
				COSWindow::refType refWnd = COSWindow::FromHandle( CWindowHandle( 0, (void*)(wParam) ).Ref() );
				unsigned short wXPos = LoWord( lParam );
				unsigned short wYPos = HiWord( lParam );
				OnContextMenu( Window, refWnd, wXPos, wYPos );
				bProcessed = true;
			}
			break;
		case COSWindow::wmInitMenu:
			{
				CMenu::refType refMenu = CMenu::FromHandle( CMenuHandle( 0, (void*)(wParam) ).Ref() );
				OnInitMenu( Window, refMenu );
				lResult = 0;
				bProcessed = true;
			}
			break;
		case COSWindow::wmInitMenuPopup:
			{
				CMenu::refType refMenu = CMenu::FromHandle( CMenuHandle( 0, (void*)( wParam ) ).Ref() );
				unsigned short wPos = LoWord( lParam );
				int bWindowMenu = static_cast< int >( HiWord( lParam ) );
				OnInitMenuPopup( Window, refMenu, wPos, bWindowMenu ? true : false );
				lResult = 0;
				bProcessed = true;
			}
			break;
#if		( WINVER >= 0x0500 )
		case COSWindow::wmUninitMenuPopup:
			{
				CMenu::refType refMenu = CMenu::FromHandle( CMenuHandle( 0, (void*)(wParam) ).Ref() );
				unsigned short wDestroyedMenu = HiWord( lParam );
				OnDestroyedMenuPopup( Window, refMenu, wDestroyedMenu );
				bProcessed = true;
			}
			break;
#endif//( WINVER >= 0x0500 )
		case COSWindow::wmMenuSelect:
			{
				unsigned short wIndex = LoWord( wParam );
				unsigned short wFlags = HiWord( wParam );
				CMenu::refType refMenu = CMenu::FromHandle( CMenuHandle( 0, (void*)( lParam ) ).Ref() );
				OnMenuSelect( Window, refMenu, wIndex, wFlags );
				lResult = 0;
				bProcessed = true;
			}
			break;
		case COSWindow::wmMenuChar:
			{
				unsigned short wCharCode = LoWord( wParam );
				unsigned short wMenuType = HiWord( wParam );
				CMenu::refType refMenu = CMenu::FromHandle( CMenuHandle( 0, (void*)( lParam ) ).Ref() );
				lResult = OnMenuChar( Window, refMenu, wCharCode, wMenuType );
				bProcessed = true;
			}
			break;
		case COSWindow::wmNextMenu:
			{
				MDINextMenu* pNextMenu = reinterpret_cast< MDINextMenu* >( lParam );

				CMenu::refType refMenuIn = CMenu::FromHandle( CMenuHandle( 0, (void*)( pNextMenu->hmenuIn ) ).Ref() );
				CMenu::refType refMenuNext = CMenu::FromHandle( CMenuHandle( 0, (void*)( pNextMenu->hmenuNext ) ).Ref() );

				OnNextMenu( Window, wParam, refMenuIn, refMenuNext );
				bProcessed = true;
			}
			break;
#if		( WINVER >= 0x0500 )
		case COSWindow::wmMenuGetObject:
			{
				MenuGetObjectInfo* pMenuObjectInfo = reinterpret_cast< MenuGetObjectInfo* >( lParam );
				lResult = OnGetObject( Window, pMenuObjectInfo );
				bProcessed = true;
			}
			break;
		case COSWindow::wmMenuRButtonUp:
			{
				CMenu::refType refMenu = CMenu::FromHandle( CMenuHandle( 0, (void*)( lParam ) ).Ref() );
				OnRButtonUp( Window, refMenu, wParam );
				bProcessed = true;
			}
			break;
		case COSWindow::wmMenuCommand:
			{
				CMenu::refType refMenu = CMenu::FromHandle( CMenuHandle( 0, (void*)( lParam ) ).Ref() );

				unsigned short wItemID = static_cast< unsigned short >( -1 );
				int iIndex = 0;

				if( System().Information(QOR_PP_SHARED_OBJECT_ACCESS).IsWindows98orME() )
				{
					wItemID = LoWord( wParam );
					iIndex = static_cast< int >( HiWord( wParam ) );
				}
				else
				{
					iIndex = wParam;
				}

				OnMenuCommand( Window, refMenu, iIndex, wItemID );

				bProcessed = true;
			}
			break;
		case COSWindow::wmMenuDrag:
			{
				CMenu::refType refMenu = CMenu::FromHandle( CMenuHandle( 0, (void*)( lParam ) ).Ref() );
				lResult = OnMenuDrag( Window, refMenu, static_cast< unsigned short >( wParam ) );
				bProcessed = true;
			}
			break;
#endif//( WINVER >= 0x0500 )
		case COSWindow::wmCommand:
			{
				unsigned short wCode = HiWord( wParam );
					
				if( wCode == 0 )
				{
					unsigned short wMenuID = LoWord( wParam );						
					OnCommand( Window, wMenuID );
					lResult = 0;
					bProcessed = true;
				}
			}
			break;
		}

		return bProcessed;
	}
Ejemplo n.º 28
0
int
tgetch()

{
	char	ch;
	EventRecord	theEvent;
	Rect cursorRect,box,windowRect;
	long	message,cursorTime,start;
	MenuHandle	theMenu;
	register short	keyCode;
	short	temp;
	term_info	*t;
	GrafPtr	oldPort,oldPort1;
	static char nextCommand;
	short aboutBox();
	char mButtonDown();
	Point	mouseLoc;
	WindowPtr	theWindow;
	void	doUpdate();
#define	clearKey	0x47
#define ESCAPEkey	0x1B
	static int see, saw = 0;
	int eye, cursOff = 100;
	boolean cursRectInv;	/* should be a macflag */
	short	fInFront = TRUE;

	t = (term_info *)GetWRefCon(HackWindow);
	mouseLoc.h = (macflags & fMoveWRTMouse) ? t->tcur_x : (u.ux-1);
	mouseLoc.v = (macflags & fMoveWRTMouse) ? t->tcur_y : (u.uy+1);
	cursorRect.left = t->tcur_x * t->charWidth + Screen_Border;
	cursorRect.right = cursorRect.left + t->charWidth - 1;
	cursorRect.top = t->height * t->tcur_y + Screen_Border;
	cursorRect.bottom = cursorRect.top + t->height - 1;
	cursorTime = GetCaretTime();
	box.left = mouseLoc.h * t->charWidth + Screen_Border - 1;
	box.right = box.left + t->charWidth + 2;
	box.top = mouseLoc.v * t->height + Screen_Border - 1;
	box.bottom = box.top + t->height + 2;
	/* permit use of cursor keys and numeric keypad */
	/* does the same translation as in msdos.c but includes cursor keys */
	ch = '\0';
	/* handle extended command from menu */
	if (nextCommand && (macflags & (fExtCmdSeq1 | fExtCmdSeq2 | fExtCmdSeq3))) {
	    if (macflags & fExtCmdSeq1) {
		ch = '#';
		macflags = macflags ^ (fExtCmdSeq1 | fExtCmdSeq2);
	    } else if (macflags & fExtCmdSeq2) {
		ch = nextCommand;
		macflags = macflags ^ (fExtCmdSeq2 | fExtCmdSeq3);
		if (!(macflags & fExtCmdSeq3))
		    nextCommand = '\0';
	    } else if (macflags & fExtCmdSeq3) {
		ch = '\r';
		macflags &= ~fExtCmdSeq3;
	    }
	}
	GetPort(&oldPort);
	SetPort(HackWindow);
	if (!(macflags & fDoNonKeyEvt)) {
		cursorPos = -1;
		if (! flags.wantspace) SetCursor(&ARROW_CURSOR);
	}
	/* initialize cursor blinking */
	message = TickCount() + ((Invisible || (macflags & fMoveWRTMouse)) ? 0L : cursorTime);
	cursRectInv = FALSE;
	while (!ch) {
		(void)WaitNextEvent(everyEvent, &theEvent, (fInFront) ? 0L : 50L, 0L);
		if ((theEvent.what == keyDown || theEvent.what == autoKey) && (FrontWindow() == HackWindow)) {
			ch = 0;
			ObscureCursor();
			/* use raw key codes */
			keyCode = (LoWord(theEvent.message) & keyCodeMask)>>8;
 			if (keyCode == clearKey) {
				macflags = macflags ^ fToggleNumPad;
				SetWTitle(HackWindow,
					(macflags & fToggleNumPad)	? "\016NetHack [MOVE]"
												: "\015NetHack [NUM]");
				ch = 0;
				continue;
			}
			if ((macflags & fToggleNumPad) && (keyCode>0x40 &&keyCode < 0x5D) 
				|| (keyCode > 0x7A && keyCode<0x7F)) {
				ch = t->keyMap[keyCode-65];
				if ((theEvent.modifiers & shiftKey) && (ch)) {
					ch = (ch == '.') ? ':' : (char)toupper(ch);
				}
				if (ch)
					break;
			}
			if (t->system.keyBoardType < 4 && keyCode == 50) {
				ch = (char)ESCAPEkey;	/* ESC */
				break;
			}			/* make the command key = control key on all non-adb keyboards
						 Now, LEAVE it this way ! Otherwise you'll render non-us
keyboards useless, since here is where "<" and ">" are located */
			if ((theEvent.message & 0xFF) == 0x60) {
				ch = (char)ESCAPEkey;
				break;
			} /* This is the way to fix backquote->esc for all macs */
			if (theEvent.modifiers & cmdKey) {
				ch = (char)(theEvent.message & 0x1F);
				if(ch == ('Q' & 0x1F)) ch = 'Q'; /* For Quit */
				break;
			}
			if (theEvent.modifiers & optionKey) {
				for(start = 43; start < 56; start++) {
					if (t->keyMap[start] == (char)(theEvent.message & 0xFFL)) {
						ch = t->keyMap[start - 13];
						break;
					}
				}
			}
			/* not a cursor key or from the numeric keypad */
			if (!ch) {
				ch = (char)(theEvent.message & 0xFF);
			}
		} else {
		/* what other events to handle */
			switch (theEvent.what) {		
Ejemplo n.º 29
0
nsEventStatus
nsNativeBrowserWindow::DispatchMenuItem(PRInt32 aID)
{
    nsEventStatus status = nsEventStatus_eIgnore;
    PRInt32 xpID = 0;
    long menuID = HiWord(aID);
    long menuItem = LoWord(aID);
    
    switch (menuID)
    {
        case menu_Apple:
            switch (menuItem)
            {
                case cmd_About:
                    ::Alert(128, nil);
                    break;
                default:
                    Str255 daName;
                    GetMenuItemText(GetMenuHandle(menu_Apple), menuItem, daName);
                    #if !TARGET_CARBON
                    OpenDeskAcc(daName);
                    #endif
                    break;
            }
            break;

        case menu_File:
            switch (menuItem)
            {
                case cmd_New:           xpID = VIEWER_WINDOW_OPEN;      break;
                case cmd_Open:      xpID = VIEWER_FILE_OPEN;            break;
                case cmd_Close:
                    CloseFrontWindow();
                    status = nsEventStatus_eConsumeNoDefault;
                    break;

                case cmd_ViewSource:            xpID = VIEW_SOURCE;             break;
                case cmd_Save:          /*n.a.*/                        break;
                case cmd_SaveAs:        /*n.a.*/                        break;
                case cmd_Revert:        /*n.a.*/                        break;
                case cmd_PageSetup: /*n.a.*/                        break;
                case cmd_Print:                 xpID = VIEWER_PRINT;                break;
                case cmd_PrintSetup:        xpID = VIEWER_PRINT_SETUP;  break;
                case cmd_Quit:                  xpID = VIEWER_EXIT;                 break;
            }
            break;

        case menu_Edit:
            switch (menuItem)
            {
                case cmd_Undo:      /*n.a.*/                                                        break;
                case cmd_Cut:                   xpID = VIEWER_EDIT_CUT;                 break;
                case cmd_Copy:              xpID = VIEWER_EDIT_COPY;                break;
                case cmd_Paste:             xpID = VIEWER_EDIT_PASTE;               break;
                case cmd_Clear:     /*n.a.*/                                                        break;
                case cmd_SelectAll:     xpID = VIEWER_EDIT_SELECTALL;       break;
                case cmd_Find:              xpID = VIEWER_EDIT_FINDINPAGE;  break;
                case cmd_Preferences:   xpID = VIEWER_PREFS;                        break;
            }
            break;

        case menu_Sample:
            if ( menuItem < cmd_FirstXPToolkitSample )
                xpID = VIEWER_DEMO0 + menuItem - cmd_Sample0;
            else
                xpID = VIEWER_XPTOOLKITDEMOBASE + (menuItem - cmd_FirstXPToolkitSample);
            break;

        case menu_Debug:
            switch (menuItem)
            {
                case cmd_DebugMode:                 xpID = VIEWER_VISUAL_DEBUGGING;         break;
                case cmd_ReflowTest:                xpID = VIEWER_REFLOW_TEST;                  break;

                case cmd_DumpContents:          xpID = VIEWER_DUMP_CONTENT;                 break;
                case cmd_DumpFrames:                xpID = VIEWER_DUMP_FRAMES;                  break;
                case cmd_DumpViews:                 xpID = VIEWER_DUMP_VIEWS;                       break;

                case cmd_DumpStyleSheets:       xpID = VIEWER_DUMP_STYLE_SHEETS;        break;
                case cmd_DumpStyleContexts: xpID = VIEWER_DUMP_STYLE_CONTEXTS;  break;

                case cmd_DebugSave:                         xpID = VIEWER_DEBUGSAVE;                    break;
                case cmd_DebugOutputText:               xpID = VIEWER_DISPLAYTEXT;              break;
                case cmd_DebugOutputHTML:               xpID = VIEWER_DISPLAYHTML;              break;
                case cmd_DebugToggleSelection:  xpID = VIEWER_TOGGLE_SELECTION;         break;
                case cmd_DebugRobot:                        xpID = VIEWER_DEBUGROBOT;                       break;
#ifdef GC_LEAK_DETECTOR
                case cmd_DumpLeaks:
                    {
                        nsresult rv;
                        nsCOMPtr<nsILeakDetector> leakDetector = 
                                 do_GetService("@mozilla.org/xpcom/leakdetector;1", &rv);
                        if (NS_SUCCEEDED(rv))
                            leakDetector->DumpLeaks();
                    }
                    break;
#endif
                case cmd_GFXScrollBars:     xpID =VIEWER_GFX_SCROLLBARS_ON; break;
                case cmd_NativeScrollBars: xpID =VIEWER_GFX_SCROLLBARS_OFF; break;
            }
            break;
            
        case menu_Tools:
            switch (menuItem)
            {
                case cmd_JSConsole:                 xpID = JS_CONSOLE;                              break;
                case cmd_EditorMode:                xpID = EDITOR_MODE;                             break;
                case cmd_Top100:                        xpID = VIEWER_TOP100;                           break;
                case cmd_TableInspector:        xpID = VIEWER_TABLE_INSPECTOR;      break;
                case cmd_ImageInspector:        xpID = VIEWER_IMAGE_INSPECTOR;      break;
            }
            break;
            
    case menu_URLS:
            switch (menuItem)
            {
                case cmd_SaveURL1:                  xpID = VIEWER_SAVE_TEST_URL1;                               break;
                case cmd_SaveURL2:                  xpID = VIEWER_SAVE_TEST_URL2;                               break;
                case cmd_LoadURL1:                  xpID = VIEWER_GOTO_TEST_URL1;                               break;
                case cmd_LoadURL2:                  xpID = VIEWER_GOTO_TEST_URL2;                               break;  
            }   
      break;    
            
        case submenu_Print:
            xpID = VIEWER_ONE_COLUMN + menuItem - cmd_PrintOneColumn;
            break;
            
        case submenu_CompatibilityMode:
            switch (menuItem)
            {
                case cmd_Compatibility_UseDTD:        xpID = VIEWER_USE_DTD_MODE;   break;
                case cmd_Compatibility_NavQuirks:       xpID = VIEWER_NAV_QUIRKS_MODE;  break;
                case cmd_Compatibility_Standard:        xpID = VIEWER_STANDARD_MODE;        break;
            }
            break;
    }

    // Dispatch xp menu items
    if (xpID != 0) {
        // beard: nsBrowserWindow::DispatchMenuItem almost always returns nsEventStatus_eIgnore.
        // this causes double menu item dispatching for most items except for VIEWER_EXIT!
        nsBrowserWindow::DispatchMenuItem(xpID);
        status = nsEventStatus_eConsumeNoDefault;
    }
    return status;
}
Ejemplo n.º 30
0
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;
}