Exemple #1
0
static NMBoolean process_key(
	EventRecord *event,
	short key)
{
	NMBoolean handled= false;

	if(event->modifiers&cmdKey && event->what==keyDown)
	{
		long menu_key= MenuKey(key);
		
		/* If it was a menu key. */
		if(menu_key)
		{
			do_menu_command(menu_key);
			handled= true;
		}
	}
	
	if(!handled)
	{
		handled= true;
	}

	return handled;
}
Exemple #2
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 #3
0
Fichier : ugView.c Projet : rolk/ug
static void DoKey (EventRecord *theEvent)
{
  long theChar;

  theChar = BitAnd(theEvent->message,charCodeMask);
  if (BitAnd(theEvent->modifiers,cmdKey)!=0)
    DoCommand(MenuKey(theChar));
}
Exemple #4
0
void handleKeyPress(EventRecord *event)
{
	char	key;

	key = event->message & charCodeMask;
	
	// just check to see if we want to quit...
	
	if ( event->modifiers & cmdKey )		/* Command key down? */
		handleMenuSelection(MenuKey(key));
}
Exemple #5
0
void DoKeyDown(EventRecord e)
{
char	theKey;

	theKey = (char)e.message & charCodeMask;
	if(e.modifiers & cmdKey) {
		FixMenus();
		ProcessMenu(MenuKey(theKey));
	}

	vVrtFrame = vActFrame;		// keep timing code working
}
Exemple #6
0
void
dokeydown (EventRecord * ev)
{
    char ch;
    long val;

    if (ev->modifiers & cmdKey)
    {
        ch = ev->message & charCodeMask;
        val = MenuKey (ch);
        domenu (val);
    }
}
Exemple #7
0
/*
 * Handle a key press
 */
static void mac_keypress(EventRecord *event)
{
    WindowPtr window;

    window = FrontWindow();
    if (event->what == keyDown && (event->modifiers & cmdKey)) {
	mac_adjustmenus();
	mac_menucommand(MenuKey(event->message & charCodeMask));
    } else {
	if (mac_wininfo(window)->key != NULL)
	    (*mac_wininfo(window)->key)(window, event);
    }       
}
Exemple #8
0
static void handlekeystroke (EventRecord *ev) { /*See Step #4*/

	char ch = (*ev).message & charCodeMask;
	
	if (SharedScriptRunning ()) { /*cmd-period terminates the script*/
	
		if (((*ev).modifiers & cmdKey) && (ch == '.')) { 
			
			CancelSharedScript (); /*cancel the shared menu script, if one is running*/
		
			return;
			}
		}
	
	handlemenu (MenuKey (ch)); /*not cmd-period, process the normal way*/
	} /*handlekeystroke*/
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;
}
Exemple #10
0
// Main Function
void _main(void)
{
  HANDLE menu_handle = MenuNew (2, 240, 18);
  MenuAddText (menu_handle, 0, "First", 1, DMF_TOP_SUB);
  MenuAddText (menu_handle, 1, "Subitem 1.1", 5, DMF_CHILD_SUB);
  MenuAddText (menu_handle, 5, "Subitem 1.1.1", 8, DMF_CHILD_SUB);
  MenuAddText (menu_handle, 5, "Subitem 1.1.2", 9, DMF_CHILD);
  MenuAddText (menu_handle, 8, "Subitem 1.1.1.1", 10, DMF_CHILD);
  MenuAddText (menu_handle, 1, "Subitem 1.2", 6, DMF_CHILD);
  MenuAddText (menu_handle, 0, "Second", 2, DMF_TOP_SUB);
  MenuAddText (menu_handle, 2, "Subitem 2.1", 7, DMF_CHILD);
  MenuAddText (menu_handle, -1, "Third", 3, DMF_TOP);
  MenuAddText (menu_handle, -1, "Fourth", 4, DMF_TOP);
  HANDLE exec_handle = MenuBegin (NULL, 0, 0, MBF_HMENU, menu_handle);
  short result;
  do {
    result = MenuKey (exec_handle, ngetchx ());
  } while (result == M_NOTMENUKEY);
  MenuEnd (exec_handle);
  MenuUpdate ();
  push_shortint (result);
}
Exemple #11
0
void process_game_key(
	EventRecord *event,
	short key)
{
	switch(get_game_state())
	{
		case _game_in_progress:
			if ((event->modifiers&cmdKey) && event->what==keyDown)
			{
				long menu_key= MenuKey(key);
				short menuID, menuItem;

				menuID= menu_key>>16;
				menuItem= menu_key & 0x0000ffff;
				if(menuID)
				{
					assert(menuID==mGame);

					do_menu_item_command(menuID, menuItem, 
						has_cheat_modifiers(event));
				} else {
					handle_game_key(event, key);
				}
			} else {
Exemple #12
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*/
Exemple #13
0
void eventLoop()
{
	EventRecord 	event;
	WindowPtr		window;
	short			clickArea;
	Rect 			screenRect;
	long			sleep = 30;
	Point			point;
	
	for (;;)
	{		
		if (WaitNextEvent( everyEvent, &event, sleep, (RgnHandle)nil ))
		{
			if (event.what == mouseDown)
			{
				clickArea = FindWindow( event.where, &window );
				
				if (clickArea == inDrag)
				{
					//screenRect = (**GetGrayRgn()).rgnBBox;
					GetRegionBounds(GetGrayRgn(), &screenRect);
					DragWindow(window, event.where, &screenRect );
				}
				else if (clickArea == inGoAway)
				{
					if (TrackGoAway( window , event.where ))
						ExitToShell();
				}
				else if (clickArea == inMenuBar)
				{
					adjustMenus();
					handleMenu( MenuSelect( event.where ) );
				}
				else if (clickArea == inContent)
				{
					if (window != FrontWindow())
						SelectWindow( window );
					else
					{
						point = event.where;
						GlobalToLocal( &point );
						handleMouseDown( point );
					}
				}
			}
			else if (event.what == updateEvt)
			{
				window = (WindowPtr)event.message;
				//SetPort( window );
				SetPortWindowPort( window );
				
				BeginUpdate( window );
				updateWindow();
				EndUpdate( window );
			}
			else if (event.what ==  keyDown || event.what == autoKey)
			{
				if ((event.modifiers & cmdKey) != 0)
				{
					adjustMenus();
					handleMenu( MenuKey( (char)(event.message & charCodeMask) ) );
				}
			}
		}
	}
}
Exemple #14
0
QString MenuCommands::Get(int ind, What w) const
{
    int cur = 0;

    if (cur++ == ind)
        return (w == Key ? FileKey() : (w == Title? FileTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? NewWinKey() : (w == Title? NewWinTitle() : GetStr(NewWinShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenFileKey() : (w == Title? OpenFileTitle() : GetStr(OpenFileShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenLocKey() : (w == Title? OpenLocTitle() : GetStr(OpenLocShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SaveAsKey() : (w == Title? SaveAsTitle() : GetStr(SaveAsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SavePdfKey() : (w == Title? SavePdfTitle() : GetStr(SavePdfShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportKey() : (w == Title? ImportTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? ImportIEKey() : (w == Title? ImportIETitle() : GetStr(ImportIEShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportFFKey() : (w == Title? ImportFFTitle() : GetStr(ImportFFShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportHtmlKey() : (w == Title? ImportHtmlTitle() : GetStr(ImportHtmlShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ImportXmlKey() : (w == Title? ImportXmlTitle() : GetStr(ImportXmlShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ExportKey() : (w == Title? ExportTitle() : GetStr(ExportShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrintKey() : (w == Title? PrintTitle() : GetStr(PrintShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PreviewKey() : (w == Title? PreviewTitle() : GetStr(PreviewShortcuts())));

    if (cur++ == ind)
        return (w == Key ? QuitKey() : (w == Title? QuitTitle() : GetStr(QuitShortcuts())));

    if (cur++ == ind)
        return (w == Key ? EditKey() : (w == Title? EditTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? UndoKey() : (w == Title? UndoTitle() : GetStr(UndoShortcuts())));

    if (cur++ == ind)
        return (w == Key ? RedoKey() : (w == Title? RedoTitle() : GetStr(RedoShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CutKey() : (w == Title? CutTitle() : GetStr(CutShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CopyKey() : (w == Title? CopyTitle() : GetStr(CopyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PasteKey() : (w == Title? PasteTitle() : GetStr(PasteShortcuts())));

    if (cur++ == ind)
        return (w == Key ? FindKey() : (w == Title? FindTitle() : GetStr(FindShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NextKey() : (w == Title? NextTitle() : GetStr(NextShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrevKey() : (w == Title? PrevTitle() : GetStr(PrevShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrefsKey() : (w == Title? PrefsTitle() : GetStr(PrefsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ViewKey() : (w == Title? ViewTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? AppStylesKey() : (w == Title? AppStylesTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? StatusKey() : (w == Title? StatusTitle() : GetStr(StatusShortcuts())));

    if (cur++ == ind)
        return (w == Key ? MenuKey() : (w == Title? MenuTitle() : GetStr(MenuShortcuts())));

    if (cur++ == ind)
        return (w == Key ? TabKey() : (w == Title? TabTitle() : GetStr(TabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NavKey() : (w == Title? NavTitle() : GetStr(NavShortcuts())));

    if (cur++ == ind)
        return (w == Key ? BooksKey() : (w == Title? BooksTitle() : GetStr(BooksShortcuts())));

//  if (cur++ == ind)
//      return (w == Key ? Key() : (w == Title? Title() : GetStr(Shortcuts())));

    if (cur++ == ind)
        return (w == Key ? StopKey() : (w == Title? StopTitle() : GetStr(StopShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ReloadKey() : (w == Title? ReloadTitle() : GetStr(ReloadShortcuts())));

    if (cur++ == ind)
        return (w == Key ? LargerKey() : (w == Title? LargerTitle() : GetStr(LargerShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NormalKey() : (w == Title? NormalTitle() : GetStr(NormalShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SmallerKey() : (w == Title? SmallerTitle() : GetStr(SmallerShortcuts())));

    if (cur++ == ind)
        return (w == Key ? TextOnlyKey() : (w == Title? TextOnlyTitle() : GetStr(TextOnlyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? EncodeKey() : (w == Title? EncodeTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? SourceKey() : (w == Title? SourceTitle() : GetStr(SourceShortcuts())));

    if (cur++ == ind)
        return (w == Key ? FullKey() : (w == Title? FullTitle() : GetStr(FullShortcuts())));

    if (cur++ == ind)
        return (w == Key ? HistoryKey() : (w == Title? HistoryTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? BackKey() : (w == Title? BackTitle() : GetStr(BackShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ForwKey() : (w == Title? ForwTitle() : GetStr(ForwShortcuts())));

    if (cur++ == ind)
        return (w == Key ? HomeKey() : (w == Title? HomeTitle() : GetStr(HomeShortcuts())));

    if (cur++ == ind)
        return (w == Key ? LastTabKey() : (w == Title? LastTabTitle() : GetStr(LastTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? LastTabsKey() : (w == Title? LastTabsTitle() : GetStr(LastTabsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SessionKey() : (w == Title? SessionTitle() : GetStr(SessionShortcuts())));

    if (cur++ == ind)
        return (w == Key ? AllHistKey() : (w == Title? AllHistTitle() : GetStr(AllHistShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ClearKey() : (w == Title? ClearTitle() : GetStr(ClearShortcuts())));

    if (cur++ == ind)
        return (w == Key ? BookmarksKey() : (w == Title? BookmarksTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? AllBooksKey() : (w == Title? AllBooksTitle() : GetStr(AllBooksShortcuts())));

    if (cur++ == ind)
        return (w == Key ? AddBookKey() : (w == Title? AddBookTitle() : GetStr(AddBookShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? PrivacyKey() : (w == Title? PrivacyTitle() : ""));
    
    if (cur++ == ind)
        return (w == Key ? PrivateKey() : (w == Title? PrivateTitle() : GetStr(PrivateShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? JavaScriptKey() : (w == Title? JavaScriptTitle() : GetStr(JavaScriptShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? ImagesKey() : (w == Title? ImagesTitle() : GetStr(ImagesShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? CookiesKey() : (w == Title? CookiesTitle() : GetStr(CookiesShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? PlugInsKey() : (w == Title? PlugInsTitle() : GetStr(PlugInsShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? AgentKey() : (w == Title? AgentTitle() : GetStr(AgentShortcuts())));
    
    if (cur++ == ind)
        return (w == Key ? PopUpsKey() : (w == Title? PopUpsTitle() : GetStr(PopUpsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ProxyKey() : (w == Title? ProxyTitle() : GetStr(ProxyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? EmptyKey() : (w == Title? EmptyTitle() : GetStr(EmptyShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ResetKey() : (w == Title? ResetTitle() : GetStr(ResetShortcuts())));

    if (cur++ == ind)
        return (w == Key ? FullResetKey() : (w == Title? FullResetTitle() : GetStr(FullResetShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ToolsKey() : (w == Title? ToolsTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? CompatKey() : (w == Title? CompatTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? SearchKey() : (w == Title? SearchTitle() : GetStr(SearchShortcuts())));

    if (cur++ == ind)
        return (w == Key ? KeyboardKey() : (w == Title? KeyboardTitle() : GetStr(KeyboardShortcuts())));

    if (cur++ == ind)
        return (w == Key ? InspectorKey() : (w == Title? InspectorTitle() : GetStr(InspectorShortcuts())));

    if (cur++ == ind)
        return (w == Key ? InspectKey() : (w == Title? InspectTitle() : GetStr(InspectShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OptionsKey() : (w == Title? OptionsTitle() : GetStr(OptionsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? WindowKey() : (w == Title? WindowTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? NextTabKey() : (w == Title? NextTabTitle() : GetStr(NextTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? PrevTabKey() : (w == Title? PrevTabTitle() : GetStr(PrevTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? NewTabKey() : (w == Title? NewTabTitle() : GetStr(NewTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CloseTabKey() : (w == Title? CloseTabTitle() : GetStr(CloseTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CloseOtherKey() : (w == Title? CloseOtherTitle() : GetStr(CloseOtherShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CloneTabKey() : (w == Title? CloneTabTitle() : GetStr(CloneTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ReloadTabKey() : (w == Title? ReloadTabTitle() : GetStr(ReloadTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? ReloadAllKey() : (w == Title? ReloadAllTitle() : GetStr(ReloadAllShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenNewTabKey() : (w == Title? OpenNewTabTitle() : GetStr(OpenNewTabShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OpenAdBlockKey() : (w == Title? OpenAdBlockTitle() : GetStr(OpenAdBlockShortcuts())));

    if (cur++ == ind)
        return (w == Key ? SwapFocusKey() : (w == Title? SwapFocusTitle() : GetStr(SwapFocusShortcuts())));

    if (cur++ == ind)
        return (w == Key ? CopyAddrKey() : (w == Title? CopyAddrTitle() : ""));

    if (cur++ == ind)
        return (w == Key ? DownsKey() : (w == Title? DownsTitle() : GetStr(DownsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? TorrentsKey() : (w == Title? TorrentsTitle() : GetStr(TorrentsShortcuts())));

    if (cur++ == ind)
        return (w == Key ? HelpKey() : (w == Title? HelpTitle() : GetStr(HelpShortcuts())));

    if (cur++ == ind)
        return (w == Key ? OnlineKey() : (w == Title? OnlineTitle() : GetStr(OnlineShortcuts())));

    if (cur++ == ind)
        return (w == Key ? UpdatesKey() : (w == Title? UpdatesTitle() : GetStr(UpdatesShortcuts())));

    if (cur++ == ind)
        return (w == Key ? AboutKey() : (w == Title? AboutTitle() : GetStr(AboutShortcuts())));

    return "";
}
Exemple #15
0
/**
 * @brief   状态转换
 */
void StateTrans(void)
{
	SourceOn();
	PumpOn();

	DeviceDataInit();
	GasDataInit();

	// 获取存储的数据
	SaveReadInit();

	// 获取存储的设置
	Lcd__LangSet(sDevice.pSave->Language);

	StateSelfCheck();

	ChargeOn();

	while (1)
	{
		// 获取信号量 20mS
		rt_sem_take(&sSemSystemTime, RT_WAITING_FOREVER);

		/* Reload IWDG counter */
		IWDG_ReloadCounter();

		KEY_Get();

		DeviceDispCount();
		DeviceTimeCount();


		switch (sState)
		{
			case STATE_SELF_CHECK:
				StateLedBzVbrCheck();
				SelfCheckJumpCheck();
				break;

			case STATE_DETECT:
				StateDetect(&sGas, &sDevice);
//				DisRecSet(0, 0, 127, 63);
				break;
			case STATE_MENU:
				MenuKey(gKeyShort);
				MenuNoOperateCountdown();
				// 闪烁
//				MenuBlink(&sDevice);

				break;

			case STATE_INPUT:
				StateInputKey(gKeyShort);
				// 闪烁
				if (sDevice.pTemp->Disp.Fresh == TURN_ON)
				{
					DisBlink();
				}
				break;

			case STATE_COUNTDOWN:
				StateCountdownKey(gKeyShort);
				StateCountdownSecond();
				break;

			case STATE_RESULT:
				StateResultKey(gKeyShort);
				break;

			case STATE_SHUTDOWN:
				StateShutdownKey(gKeyLong);
				StateShutdownSecond();
				break;

			case STATE_POWER_OFF:
				break;

			case STATE_INFO:
				StateInfoKey(gKeyShort);
				StateInfoSecond();
				break;

			case STATE_CHARGE:
//				PumpOff();
//				sDevice.pTemp->Fan.State = TURN_OFF;
				break;

			default:
				break;
		}

		if (sState != STATE_SELF_CHECK)
		{
			if (gKeyTrg)
			{
				S_Buzzer lBz;

				lBz.Src = BUZZER_KEY;
				lBz.Time = BUZZER_KEY_TIME;
				BuzzerOn(&lBz);
			}
		}

		if (sState != STATE_POWER_OFF)
		{
			if (gKeyTrg || gKeyLong)
			{
				PowerSaveBglFresh();
			}
		}

		if (gKeyTrg || gKeyLong)
		{
			MenuNoOperateFresh();
		}


		// 设备倒计时
		PowerSaveBglCountdown();
		LedCountdown();
		BuzzerCountdown();
		VibrationCountdown();
		StateBatCheck();
		StateChargeCheck();

	}
}
Exemple #16
0
void DoEvent(EventRecord *event)
{
    short	part;
    Boolean	hit;
    char	key;
    Rect	tempRect;
    WindowRef	whichWindow;
        
    switch (event->what) 
    {
        case mouseDown:
            part = FindWindow(event->where, &whichWindow);
            switch (part)
            {
                case inMenuBar:  /* process a moused menu command */
                    DoMenuCommand(MenuSelect(event->where));
                    break;
                    
                case inSysWindow:
                    break;
                
                case inContent:
                    if (whichWindow != FrontWindow()) 
                        SelectWindow(whichWindow);
                    break;
                
                case inDrag:	/* pass screenBits.bounds */
                    GetRegionBounds(GetGrayRgn(), &tempRect);
                    DragWindow(whichWindow, event->where, &tempRect);
                    break;
                    
                case inGrow:
                    break;
                    
                case inGoAway:
                    DisposeWindow(whichWindow);
                    ExitToShell();
                    break;
                    
                case inZoomIn:
                case inZoomOut:
                    hit = TrackBox(whichWindow, event->where, part);
                    if (hit) 
                    {
                        SetPort(GetWindowPort(whichWindow));   // window must be current port
                        EraseRect(GetWindowPortBounds(whichWindow, &tempRect));   // inval/erase because of ZoomWindow bug
                        ZoomWindow(whichWindow, part, true);
                        InvalWindowRect(whichWindow, GetWindowPortBounds(whichWindow, &tempRect));	
                    }
                    break;
                }
                break;
		
                case keyDown:
		case autoKey:
                    key = event->message & charCodeMask;
                    if (event->modifiers & cmdKey)
                        if (event->what == keyDown)
                            DoMenuCommand(MenuKey(key));
		case activateEvt:	       /* if you needed to do something special */
                    break;
                    
                case updateEvt:
			DrawWindow((WindowRef) event->message);
			break;
                        
                case kHighLevelEvent:
			AEProcessAppleEvent( event );
			break;
		
                case diskEvt:
			break;
	}
}
int main( void )
{
	long	result = 0;
	
	// initialize for carbon & QuickTime
	InitCursor();
	if ( IsQuickTimeInstalled() )
		EnterMovies();
	else
		goto bail;
		
	GetQDGlobalsScreenBits( &screenBits );
	
	Gestalt(gestaltMenuMgrAttr, &result);
	if (result & gestaltMenuMgrAquaLayoutMask) {
		// Mmmmmm...X
		SetMenuBar(GetNewMBar(129));
		if (AEInstallEventHandler( kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP(doAEQuit), 0, false))
			goto bail;
	} else {
		SetMenuBar(GetNewMBar(128));
	}
	DrawMenuBar();
	
	while (gDone == false) {
		EventRecord theEvent;
		WindowPtr pWhichWindow;		
		short windowPart;
        Boolean SIOUXHandledEvent = false;
		
		WaitNextEvent(everyEvent, &theEvent, 0, NULL);
		
        #ifndef __MACH__
            SIOUXHandledEvent = SIOUXHandleOneEvent(&theEvent);
        #endif
        
		if ( !SIOUXHandledEvent ) {
		
			switch (theEvent.what) {
				case updateEvt:
					pWhichWindow = (WindowPtr)theEvent.message;
					
					// we don't do anything for this simple sample
					BeginUpdate(pWhichWindow);
					EndUpdate(pWhichWindow);
					break;
				
				case keyDown:
					if (theEvent.modifiers & cmdKey) {
						doMenu(MenuKey(theEvent.message & charCodeMask));
					}
					break;
				
				case mouseDown:
					windowPart = FindWindow(theEvent.where, &pWhichWindow);

					switch (windowPart) {
						case inDrag:
							DragWindow(pWhichWindow, theEvent.where, &screenBits.bounds);
							break;

						case inGoAway:
							if (TrackGoAway(pWhichWindow, theEvent.where))
								DisposeWindow( pWhichWindow );
								//gDone = true;
							break;

						case inContent:
							SelectWindow(pWhichWindow);
							break;

						case inMenuBar:
							doMenu(MenuSelect(theEvent.where));
							break;
					}
					break;
			}
		}
	}
	
bail:

	return 0;	
}
Exemple #18
0
DoKeyDown()
{
	if (ev.modifiers & cmdKey)
		DoMenuClick(MenuKey((char)ev.message));
}
Exemple #19
0
void RunLoop()
{
	EventRecord    theEvent;
	WindowPtr whichWindow;
	Rect txRect;
	
	txRect = qd.thePort->portRect;
	
	InsetRect(&txRect,4,0);
	textH = TENew(&txRect,&txRect);
	
	while (!quit)
	{
		SystemTask();
		TEIdle(textH);

		if (GetNextEvent(everyEvent, &theEvent))
		{
			switch (theEvent.what)
			{
				case mouseDown:
				{
					switch (FindWindow(theEvent.where, &whichWindow))
					{
						case inSysWindow:
						{
							SystemClick(&theEvent, whichWindow);
							break;
						}
						case inMenuBar:
						{
							DoCommand(MenuSelect(theEvent.where));
							break;
						}
						case inDrag:
						{
							DragWindow(whichWindow, theEvent.where, &qd.screenBits.bounds);
							break;
						}
						case inContent:
						{
							if (whichWindow != FrontWindow())
							{
								SelectWindow(whichWindow);
							}
							else
							{
								GlobalToLocal(&theEvent.where);
								if (theEvent.modifiers&shiftKey)
									isShift = true;
								
								TEClick(theEvent.where, isShift, textH);
							}
							break;
						}

						case inGoAway:
						{
							if (TrackGoAway(whichWindow, theEvent.where)) {
								quit = true;
							}
							break;
						}

						default:
							break;
					}
					break;
				}
				case autoKey:
				case keyDown:
				{
					char theChar = (theEvent.message&charCodeMask);
					
					if (theEvent.modifiers&cmdKey)
					{
						DoCommand(MenuKey(theChar));
						
						if (theChar == 'm')
						{
							quit = true;
						}
					}
					else
					{
						TEKey(theChar, textH);
					}
					
					break;
				}
				case activateEvt:
				{
					if (theEvent.modifiers&activeFlag)
					{
						TEActivate(textH);
					}
					else
					{
						TEDeactivate(textH);
					}
					break;
				}
				case updateEvt:
				{
					BeginUpdate((WindowPtr)theEvent.message);
					EraseRect(&(qd.thePort->portRect));
					TEUpdate(&(qd.thePort->portRect), textH);
					EndUpdate((WindowPtr)theEvent.message);
					break;
				}
				default:
					break;
			}
		}
	}
}