Exemple #1
0
static void eventproc(EventRecord *event) {

	int		keycode;

	keycode = (event->message & keyCodeMask) >> 8;
	switch(event->what) {
		case mouseDown:
			HandleMouseDown(event);
			break;

		case updateEvt:
			HandleUpdateEvent(event);
			break;

		case keyDown:
		case autoKey:
			if (!np2running) {
				break;
			}
#if !TARGET_API_MAC_CARBON
			if ((keycode == 0x6f) && (np2oscfg.F12KEY == 0)) {
				HandleMenuChoice(IDM_MOUSE);
				break;
			}
#endif
			if (event->modifiers & cmdKey) {
#if !TARGET_API_MAC_CARBON
				if (mackbd_keydown(keycode, TRUE)) {
					break;
				}
#endif
				soundmng_stop();
				mousemng_disable(MOUSEPROC_MACUI);
#if TARGET_API_MAC_CARBON
				HandleMenuChoice(MenuEvent(event));
#else
				HandleMenuChoice(MenuKey(event->message & charCodeMask));
#endif
				mousemng_enable(MOUSEPROC_MACUI);
				soundmng_play();
			}
			else {
				mackbd_keydown(keycode, FALSE);
			}
			break;

		case keyUp:
			mackbd_keyup(keycode);
			break;

		case mouseUp:
			mousemng_buttonevent(MOUSEMNG_LEFTUP);
			mousemng_buttonevent(MOUSEMNG_RIGHTUP);
			break;

		case activateEvt:
			mackbd_activate((event->modifiers & activeFlag)?TRUE:FALSE);
			break;
	}
}
Exemple #2
0
__myevic__ int EvtSingleFire()
{
	int vret = 0;

	switch ( Screen )
	{
		case 100:
		{
			MainView();
			vret = 1;
		}
		break;

		case 101:
		case 103:
		case 104:
		{
			vret = 1;
		}
		break;

		case 102:
		{
			vret = MenuEvent( LastEvent );
		}
		break;
	}

	return vret;
}
Exemple #3
0
__myevic__ int EvtMinusButton()
{
	int vret = 0;

	switch ( Screen )
	{
		case 101:
		{
			gFlags.edit_capture_evt = 1;
			if ( dfContrast >= 15 ) dfContrast -= 15;
			else dfContrast = 0;
			UpdateDFTimer = 50;
			DisplaySendCommand( 0x81 );
			DisplaySendCommand( dfContrast );
			gFlags.refresh_display = 1;
			ScreenDuration = 10;
			vret = 1;
		}
		break;

		case 102:
		{
			vret = MenuEvent( LastEvent );
		}
		break;

		case 103:
		{
			unsigned int cs = RTCGetClockSpeed();
			if ( cs > 10000 ) --cs;
			RTCSetClockSpeed( cs );
			gFlags.refresh_display = 1;
			ScreenDuration = 120;
			vret = 1;
		}
		break;

		case 104:
		{
			RTCAdjustClock( -1 );
			gFlags.refresh_display = 1;
			ScreenDuration = 120;
			vret = 1;
		}
		break;
	}

	return vret;
}
Exemple #4
0
__myevic__ int EvtFire()
{
	int vret = 0;

	switch ( Screen )
	{
		case 101:
		{
			gFlags.edit_capture_evt ^= 1;
			if ( gFlags.edit_capture_evt )
			{
				gFlags.refresh_display = 1;
				ScreenDuration = 10;
			}
			else
			{
				UpdateDFTimer = 1;
				UpdateDataFlash();
				MainView();
			}
			vret = 1;
		}
		break;
		
		case 102:
		{
			vret = MenuEvent( LastEvent );
		}
		break;

		case 103:
		{
			MainView();
			vret = 1;
		}
		break;

		case 104:
		{
			RTCAdjustClock( 0 );
			MainView();
			vret = 1;
		}
	}

	return vret;
}
	bool MouseEvent(int type, int mx, int my)
	{
		int olditem = mDesc->mSelectedItem;
		bool res = Super::MouseEvent(type, mx, my);

		if (mDesc->mSelectedItem == -1 || mDesc->mSelectedItem == mStartItem+7)
		{
			int y = (-mDesc->mPosition + BigFont->GetHeight() + mDesc->mItems.Size() * OptionSettings.mLinespacing) * CleanYfac_1;
			int h = (screen->GetHeight() - y) / 16;
			int fh = OptionSettings.mLinespacing * CleanYfac_1;
			int w = fh;
			int yy = y + 2 * CleanYfac_1;
			int indent = (screen->GetWidth() / 2);

			if (h > fh) h = fh;
			else if (h < 4) return res;	// no space to draw it.

			int box_y = y - 2 * CleanYfac_1;
			int box_x = indent - 16*w;

			if (mx >= box_x && mx < box_x + 16*w && my >= box_y && my < box_y + 16*h)
			{
				int cell_x = (mx - box_x) / w;
				int cell_y = (my - box_y) / h;

				if (olditem != mStartItem+7 || cell_x != mGridPosX || cell_y != mGridPosY)
				{
					mGridPosX = cell_x;
					mGridPosY = cell_y;
					//S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE);
				}
				mDesc->mSelectedItem = mStartItem+7;
				if (type == MOUSE_Release)
				{
					MenuEvent(MKEY_Enter, true);
					if (m_use_mouse == 2) mDesc->mSelectedItem = -1;
				}
				res = true;
			}
		}
		return res;
	}
Exemple #6
0
bool DMenu::MouseEventBack(int type, int x, int y)
{
    if (m_show_backbutton >= 0)
    {
        FTexture *tex = TexMan(gameinfo.mBackButton);
        if (tex != NULL)
        {
            if (m_show_backbutton&1) x -= screen->GetWidth() - tex->GetScaledWidth() * CleanXfac;
            if (m_show_backbutton&2) y -= screen->GetHeight() - tex->GetScaledHeight() * CleanYfac;
            mBackbuttonSelected = ( x >= 0 && x < tex->GetScaledWidth() * CleanXfac &&
                                    y >= 0 && y < tex->GetScaledHeight() * CleanYfac);
            if (mBackbuttonSelected && type == MOUSE_Release)
            {
                if (m_use_mouse == 2) mBackbuttonSelected = false;
                MenuEvent(MKEY_Back, true);
            }
            return mBackbuttonSelected;
        }
    }
    return false;
}
// --------------------------------------------------------------------------------------
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;
}
Exemple #8
0
BOOL
consoleGetKey (
    PKBDKEY        Key,
     BOOL           fWait
    )
/*++

Routine Description:

    Gets the next key from  the input buffer.

Arguments:

    Key     -	Supplies a pointer to a key structure
    fWait   -	Supplies a flag:
		if TRUE, the function blocks until a key is ready.
		if FALSE, the function returns immediately.

Return Value:

    TRUE if keystroke read, FALSE otherwise.

--*/
{

    PINPUT_RECORD   pEvent;

    do {
	pEvent = NextEvent( ADVANCE, fWait );

	if (pEvent) {

	    switch ( EVENT_TYPE(pEvent) ) {

	    case KEY_EVENT:
		if (KeyEvent(PKEY_EVT(pEvent), Key)) {
		    return TRUE;
		}
		break;

	    case MOUSE_EVENT:
		MouseEvent(PMOUSE_EVT(pEvent));
		break;

	    case WINDOW_BUFFER_SIZE_EVENT:
		WindowEvent(PWINDOW_EVT(pEvent));
		break;

            case MENU_EVENT:
                MenuEvent(PMENU_EVT(pEvent));
            break;

            case FOCUS_EVENT:
                if (FocusEvent(PFOCUS_EVT(pEvent), Key)) {
		    return TRUE;
		}
            break;

	    default:
		break;
	    }
	}
    } while (fWait);

    return FALSE;
}
Exemple #9
0
UInt32 UMAMenuEvent( EventRecord *inEvent )
{
        return MenuEvent( inEvent ) ;
}
// --------------------------------------------------------------------------------------
static void handleEvents(EventRecord *event)
{
	WindowRef window;
	Boolean activate;
	WindowPartCode partCode;
	OSErr error;
	Rect tempRect, newSize;
	long menuChoice;
	MenuCommand commandID;
	RgnHandle grayRegion;
	
	switch (event->what)	// handle events according to the priority 
	{						// determined by the system
		case activateEvt:
			window = (WindowRef)event->message;
			activate = (event->modifiers & activeFlag) != 0;
			HandleActivate(window, activate);
			break;
		
		case mouseDown:
			partCode = FindWindow(event->where, &window);
			
			switch(partCode)
			{
				case inMenuBar:
					menuChoice = MenuSelect(event->where);
					error = GetMenuItemCommandID(GetMenuRef(HiWord(menuChoice)), 
 													LoWord(menuChoice), &commandID);
					if (error == noErr)
					{
						if (commandID == 0)		// if the menu item clicked on does not have 
							commandID = (MenuCommand)menuChoice;	// a command ID
						HandleMenuChoice(commandID);
					}
					break;
				
				case inSysWindow:
					if (window != NULL)
						SystemClick(event, window);
					break;
				
				case inContent:		// the following window part codes will only be returned 
					if (window != FrontWindow())				// for the preferences window
						SelectWindow(window);
					else
						HandleContentClick(window, event->where, event->modifiers);
					break;
				
				case inDrag:
					grayRegion = GetGrayRgn();
					DragWindow(window, event->where, &((*grayRegion)->rgnBBox));
					break;
				
				case inGrow:	
					SetRect(&tempRect, kPrefsWindowPlatinumWidth, kPrefsWindowPlatinumHeight, 
							SHRT_MAX, SHRT_MAX);
					ResizeWindow(window, event->where, &tempRect, &newSize);
					AdjustControls(window);
					break;
				
				case inGoAway:
					ClosePrefsWindow(window);
					break;
			}
			break;
		
		case keyDown:
		case autoKey:	// a separate auto key handler would go after disk events
			if ((event->modifiers & cmdKey) != 0)
			{
				UInt32 keyMenuChoice;
				
				keyMenuChoice = MenuEvent(event);
				error = GetMenuItemCommandID(GetMenuRef(HiWord(keyMenuChoice)), 
												LoWord(keyMenuChoice), &commandID);
				if (error == noErr)
				{
					if (commandID == 0)		// if the menu item chosen does not have a 
						commandID = (MenuCommand)keyMenuChoice;		// command ID 
					HandleMenuChoice(commandID);					// (but they all should)
				}
			}
			else
			{
				window = FrontNonFloatingWindow();
				if (window != NULL)
				{
					char keyCode = (event->message & keyCodeMask) >> 8;
					
					HandleKeyDown(keyCode, window);
				}
			}
			break;
		
		case diskEvt:
			if (HiWord(event->message) != noErr) 
			{
				Point where;
			
				SetPt(&where, 70, 50);
				ShowCursor();
				DIBadMount(where, event->message);
			}		
			break;
		
		case updateEvt:
			window = (WindowRef)event->message;
			SetPortWindowPort(window);
			
			BeginUpdate(window);
			HandleDrawContent(window);
			EndUpdate(window);
			break;
		
		case kHighLevelEvent:		// an OS Event handler would go before high level events
			AEProcessAppleEvent(event);
			break;
	}
Exemple #11
0
__myevic__ int EvtPlusButton()
{
	int vret = 0;

	switch ( Screen )
	{
		case 1:
		{
			if ( EditModeTimer )
			{
				if ( EditItemIndex == 1 )
				{
					if ( dfMode < 3 )
					{
						KeyUpTimer = 5;
						EditModeTimer = 1000;

						do
						{
							if ( ++dfMode > 2 ) dfMode = 0;
						}
						while ( dfModesSel & ( 1 << dfMode ) );
						dfLastTCMode = dfMode;
						ModeChange();

						UpdateDFTimer = 50;
						gFlags.refresh_display = 1;
						vret = 1;
					}
				}
				else if ( EditItemIndex == 4 )
				{
					KeyUpTimer = 5;
					EditModeTimer = 1000;

					if ( ++dfAPT > 6 ) dfAPT = 0;
					
					UpdateDFTimer = 50;
					gFlags.refresh_display = 1;
					vret = 1;
				}
			}
		}
		break;

		case 83:
		{
			Event = EVENT_EDIT_CONTRAST;
		//	Screen = 101;
		//	ScreenDuration = 10;
		//	gFlags.refresh_display = 1;
			vret = 1;
		}
		break;

		case 101:
		{
			if ( gFlags.edit_capture_evt )
			{
				if ( dfContrast <= 240 ) dfContrast += 15;
				else dfContrast = 255;
				UpdateDFTimer = 50;
				DisplaySendCommand( 0x81 );
				DisplaySendCommand( dfContrast );
				gFlags.refresh_display = 1;
				ScreenDuration = 10;
				vret = 1;
			}
			else
			{
				Event = 40;
			}
		}
		break;

		case 102:
		{
			vret = MenuEvent( LastEvent );
		}
		break;

		case 103:
		{
			unsigned int cs = RTCGetClockSpeed();
			if ( cs < 50000 ) ++cs;
			RTCSetClockSpeed( cs );
			gFlags.refresh_display = 1;
			ScreenDuration = 120;
			vret = 1;
		}
		break;
		
		case 104:
		{
			RTCAdjustClock( 1 );
			gFlags.refresh_display = 1;
			ScreenDuration = 120;
			vret = 1;
		}
		break;
	}

	return vret;
}