Beispiel #1
0
/***************************************************************
                    wait_for_event
 PURPOSE:
 (suck up queued events)
 wait for the user to do something... anything!
 Useful if you want them to see the last message before dying.
****************************************************************/
void wait_for_event()
{
  EventType queued_event;
  do {
    EvtGetEvent(&queued_event, 0); // soak up any queued winclose events
  } while (queued_event.eType != nilEvent);
  EvtGetEvent(&queued_event, evtWaitForever);
  do {
    EvtGetEvent(&queued_event, 0); // soak up any accompanying queued events
  } while (queued_event.eType != nilEvent);
  // now you can LeaveForm() and FrmGotoForm(DeathForm) or whatever.
}
Beispiel #2
0
/**********************************************************************
 * Function: EventLoop
 * Description: this is the main event loop for the program. It 
 * listens for events for .5 seconds, if none come in, it checks 
 * wheter it should timeout and lock the program. If the unit
 * is scheduled to sleep within the next five seconds, it locks
 * the display. 
 * Note: timeout does not work properly if you overclock you 
 * palm's processor.
 * ********************************************************************/ 
static void 
EventLoop (void) 
{
	EventType event;
	UInt16 error;
	
	do
		
	{
		
			// wait a bit for an event
			EvtGetEvent (&event, 50);

				/* Dont seed with empty events!*/
			if(event.eType != nilEvent)
				random_seed((byte *) &event, sizeof(event)); 
	
			// first the system gets the event, then the Menu event handler, then the application
			// event handler, then finally the form event handler
			if (!SysHandleEvent (&event))
			if (!MenuHandleEvent (0, &event, &error))
				if (!ApplicationHandleEvent (&event))
					FrmDispatchEvent (&event);
	}
	while (event.eType != appStopEvent);
}
UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) {
	EventType event;
	Err err = 0;

	switch (cmd) {
	case sysAppLaunchCmdNormalLaunch:
		if(isTheDeviceSupported() == false) {
			FrmAlert(OldAlert);
			break;
		}
		
		FrmGotoForm(MainForm);
		do {
			UInt16 MenuError;
			EvtGetEvent(&event, evtWaitForever);
			if (! SysHandleEvent(&event))
				if (! MenuHandleEvent(0, &event, &MenuError))
					if (! AppHandleEvent(&event))
						FrmDispatchEvent(&event);
		} while (event.eType != appStopEvent);
		break;
	case sysAppLaunchCmdNotify:
		if(((SysNotifyParamType*) cmdPBP)->notifyType==sysNotifyDisplayResizedEvent) {
			EventType resizedEvent;
			MemSet(&resizedEvent,sizeof(EventType),0);
			resizedEvent.eType=winDisplayChangedEvent;
			EvtAddUniqueEventToQueue(&resizedEvent,0,true);
		}
		break;
	default:
		break;
	}    
	return(err);
}
Beispiel #4
0
//------------------------------------------------------------------------
//  Check if key abort has occurred
//
int key_abort(void)
{
#ifdef __MC68K__
   EventType event;

   EvtGetEvent(&event,1);

   if(event.eType == penDownEvent)
   		key_aborted = TRUE;

   return key_aborted;
#else               
   #ifdef _WINDOWS
      return FALSE;
   #else
      #ifdef SMALL_MEMORY_TARGET
         return FALSE;
      #else
         static int didsetup=0;
   
         if (!didsetup)
         {
            if (signal(SIGINT,sig_ctrlc) == SIG_ERR)
               printf("could not setup ctrl-c handler\n");
   
            didsetup = 1;
         }
   
         return got_interrupt; 
      #endif
   #endif
#endif
}
Beispiel #5
0
bool wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip)
{
    if(!m_prgFrame)
        return false;
    if(!newmsg.empty())
        m_msg = newmsg;
    m_cur = value;

    EventType event;

    ProgressType *prg = (ProgressType *)m_prgFrame;
    do
    {
        EvtGetEvent(&event, 0);
        Boolean handled = PrgHandleEvent(prg, &event);
        if (!PrgHandleEvent(prg, &event))
            if( PrgUserCancel(prg) )
                return false;
    }
    while(event.eType != sysEventNilEvent);

    PrgUpdateDialog(prg, 0, 0, "", true);

    m_activeSkip = m_canSkip && true;

    return true;
}
Beispiel #6
0
void RunCount(UInt32 start_tik)
{
    UInt32 tik,dtik;
    run=1;
    while(run==1) {
	tik = TimGetTicks();
	dtik = tik - start_tik;
	drawCount(dtik);

	// call this periodically to hold off auto off  
	if (stopWatchPrefs.disableAutoOff) EvtResetAutoOffTimer();

	// delay one tenth of a sec (.09 acksherly to be sly)
	SysTaskDelay((90 * SysTicksPerSecond())/1000);
	// within loop call SysHandleEvent to
	//  give system opportunity to break in? 
	// /opt/palmdev/sdk-5/include/Core/UI/Event.h
	{ 
	    UInt16 err;
	    EventType e;
	    EvtGetEvent(&e, 0);
	    if (! SysHandleEvent (&e))
		if (! MenuHandleEvent (NULL, &e, &err))
		    if (! ApplicationHandleEvent (&e))
			FrmDispatchEvent (&e);
	}
    }

}
Beispiel #7
0
/* The main event loop */
static void EventLoop(void)
{
  Word err;
  EventType e;

  do {
    if( EQIsEmpty() ) {
      EvtGetEvent(&e, .66 * SysTicksPerSecond());
    } else {
      EvtGetEvent(&e, .05 * SysTicksPerSecond());
    }
    if (! SysHandleEvent (&e))
      if (! MenuHandleEvent (NULL, &e, &err) )
	if (! ApplicationHandleEvent (&e) )
	  if( ! FrmDispatchEvent (&e) )
            GameEvents();
  } while (e.eType != appStopEvent);
}
static void
EventLoop (void)
{
    EventType	event;
    SDWord	timeout;
    UInt32	timer_next;
    Word	error;

    do
    {
        timeout = evtWaitForever;
        timer_next = 0;
        if (needRedisplay)
            timeout = 0;
        else if (game.timer_running)
        {
            UInt32  now = TimGetTicks ();
            int	    sec = (now - game.timer_start) / sysTicksPerSecond;

            timer_next = ((sec + 1) * sysTicksPerSecond + game.timer_start);
            timeout = timer_next - now;
        }
        EvtGetEvent (&event, timeout);
        DIAG (("Event %d\n", event.eType));
        if (timer_next && TimGetTicks () <= timer_next)
            DamageCount ();
        if (needRedisplay && event.eType == nilEvent)
            FrmUpdateForm (mainForm, frmRedrawUpdateCode);
        if (event.eType == nilEvent)
            continue;

        /* Give the system a chance to handle the event. */
        if (! SysHandleEvent (&event))
        {
            if (!MenuHandleEvent (0, &event, &error))
            {
                /* Give the application a chance to handle the event. */
                if (!ApplicationHandleEvent (&event))
                {
                    /* Let the form object provide default handling of the event. */
                    FrmDispatchEvent (&event);
                }
            }
        }
    }
    while (event.eType != appStopEvent);
    // ** SPECIAL NOTE **
    // In order for the Emulator to exit
    // cleanly when the File|Quit menu option is
    // selected, the running application
    // must exit.  The emulator will generate an
    // ÒappStopEventÓ when Quit is selected.
}
Beispiel #9
0
/* The main event loop */
static void EventLoop(void)
{
    UInt16 err;
    EventType e;

    do {
	EvtGetEvent(&e, evtWaitForever);
	if (! SysHandleEvent (&e))
	    if (! MenuHandleEvent (NULL, &e, &err))
		if (! ApplicationHandleEvent (&e))
		    FrmDispatchEvent (&e);
    } while (e.eType != appStopEvent);
}
Beispiel #10
0
static void EventLoop( void )
{
	EventType event;
	UInt error;

	do {
		EvtGetEvent( &event, evtWaitForever );
		if( !SysHandleEvent( &event ) )
			if( !MenuHandleEvent( 0, &event, &error ) )
				if( !ApplicationHandleEvent( &event ) )
					FrmDispatchEvent( &event );
	} while( event.eType != appStopEvent );
}
Beispiel #11
0
void PckTunesCDPlayer::setVolume(int volume) {
	_volumeLevel = volume;

	PocketTunesAction *pAction = AllocateAsynchronousActionStruct();
	if (!pAction)
		return;

	pAction->action = kPocketTunesActionSetValue;
	pAction->data.getValueAction.which = kPtunesValueVolume;
	pAction->data.getValueAction.value = (_volumeLimit * volume) / 100;

	EvtGetEvent(&_eAction, evtNoWait);
	PocketTunesCall(pAction);
}
Beispiel #12
0
UInt32 PckTunesCDPlayer::getStatus() {
	UInt32 status = kPtunesStopped;

	if (!_isPlaying || !_pAction)
		return status;

	_pAction->action = kPocketTunesActionGetStatus;

	EvtGetEvent(&_eAction, evtNoWait);
	if (PocketTunesCallSynch(_pAction) == errNone)
		status = _pAction->data.getStatusAction.status;

	return status;
}
Beispiel #13
0
void PckTunesCDPlayer::setPosition(UInt32 value) {
	if (!_isPlaying)
		return;

	PocketTunesAction *pAction = AllocateAsynchronousActionStruct();
	if (!pAction)
		return;

	pAction->action = kPocketTunesActionSetValue;
	pAction->data.getValueAction.which = kPtunesValueSongPosition;
	pAction->data.getValueAction.value = value;

	EvtGetEvent(&_eAction, evtNoWait);
	PocketTunesCall(pAction);
}
Beispiel #14
0
UInt32 PckTunesCDPlayer::getDuration() {
	UInt32 value = gVars->CD.defaultTrackLength;

	if (!_isPlaying || !_pAction)
		return value;

	_pAction->action = kPocketTunesActionGetValue;
	_pAction->data.getValueAction.which = kPtunesValueSongDuration;

	EvtGetEvent(&_eAction, evtNoWait);
	if (PocketTunesCallSynch(_pAction) == errNone)
		value = _pAction->data.getValueAction.value;

	return value;
}
Beispiel #15
0
UInt32 PckTunesCDPlayer::getVolumeLimit() {
	UInt32 value = 0;

	if (!_pAction)
		return value;

	_pAction->action = kPocketTunesActionGetValue;
	_pAction->data.getValueAction.which = kPtunesValueMaxVolume;

	EvtGetEvent(&_eAction, evtNoWait);
	if (PocketTunesCallSynch(_pAction) == errNone)
		value = _pAction->data.getValueAction.value;

	return value;
}
Beispiel #16
0
UInt32 PckTunesCDPlayer::getPosition(UInt32 deflt) {
	UInt32 value = deflt;

	if (!_isPlaying || !_pAction)
		return value;

	_pAction->action = kPocketTunesActionGetValue;
	_pAction->data.getValueAction.which = kPtunesValueSongPosition;

	EvtGetEvent(&_eAction, evtNoWait);
	if (PocketTunesCallSynch(_pAction) == errNone)
		value = _pAction->data.getValueAction.value;

	return value;
}
Beispiel #17
0
void Application_ProcessMessages(int ticks)
{
     EventType event;
     UInt32 until=TimGetTicks()+ticks;
     UInt16 error;
     do {
	     EvtGetEvent(&event, 3);
	     if(event.eType == appStopEvent) {
		     StopEvent=1;
		     break;
	     }
	     if (! SysHandleEvent(&event))
	         if (! MenuHandleEvent(0, &event, &error))
	             if (! Application_EventHandler(&event))
	                FrmDispatchEvent(&event);
     } while(TimGetTicks()<until);
}
Beispiel #18
0
static void AppEventLoop(void)
{
    UInt16 error;
    EventType event;

    do {
        /* change timeout if you need periodic nilEvents */
        EvtGetEvent(&event, SysTicksPerSecond() / 5);

        if (!SysHandleEvent(&event)) {
            if (!MenuHandleEvent(0, &event, &error)) {
                if (!AppHandleEvent(&event)) {
                    FrmDispatchEvent(&event);
                }
            }
        }
    } while (event.eType != appStopEvent);
}
Beispiel #19
0
/* This routine is the event loop */
static void EventLoop( void )
{
    EventType event;
    UInt16    err;

    do {
        EvtGetEvent( &event, evtWaitForever );

        if ( SysHandleEvent( &event ) )
            continue;

        if ( MenuHandleEvent( NULL, &event, &err ) )
            continue;

        if ( event.eType == frmLoadEvent )
            HandleFormLoad( &event );

        FrmDispatchEvent( &event );
    } while ( event.eType != appStopEvent );
}
Beispiel #20
0
DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
{
	int r;

	if (cmd != 0)
		return 0;

	r = test(0,NULL);

	for (;;)
	{
		EventType e;

		EvtGetEvent(&e,100);
		if (e.eType == appStopEvent)
			break;
		if (!SysHandleEvent(&e))
			FrmHandleEvent(FrmGetActiveForm(),&e);
	}
	return 0;
}
Beispiel #21
0
void PckTunesCDPlayer::play(int track, int num_loops, int start_frame, int duration) {
	if (!num_loops && !start_frame)
		return;

	EventType e;
	Char nameP[256], fileP[100];
	static const Char *ext[] = { "mp3", "ogg" };

	_pckTrack = track;
	_pckLoops = num_loops;
	_pckTrackStartFrame = TO_MSECS(start_frame);
	_pckTrackDuration = TO_MSECS(duration);

	VFSVolumeGetLabel(gVars->VFS.volRefNum, nameP, 256);

	StrPrintF(fileP, "/Palm/Programs/ScummVM/Audio/%s_%03ld.%s", gameP, (track + gVars->CD.firstTrack - 1), ext[gVars->CD.format]);

	if (PocketTunesOpenFile(nameP, fileP, 0) == errNone) {
		EvtGetEvent(&e, evtNoWait);
		PocketTunesPauseIfPlaying();
		_isPlaying = true;

		if (_pckTrackStartFrame == 0 && _pckTrackDuration == 0) {
			_pckTrackDuration = getDuration();
		} else {
			setPosition(_pckTrackStartFrame);
			if (_pckTrackDuration == 0)
				_pckTrackDuration = getDuration() - _pckTrackStartFrame;
		}

		PocketTunesPlay();

	} else {
		_isPlaying = false;
		_pckTrackDuration = gVars->CD.defaultTrackLength * 1000;
	}

	_pckStopTime = 0;
	_pckTrackEndFrame = _pckTrackStartFrame + _pckTrackDuration;
}
Beispiel #22
0
void EvtGetPen (Int16 *pScreenX, Int16 *pScreenY, Boolean *pPenDown)
{
	EventType	event;
	int	count=0;

	do {
		WPeekEventsDDK();
		EvtGetEvent (&event, -1);
		count++;
	} while ( !((event.eType >= 1) && (event.eType <= 3)) && 
			(count < (eventQueueSize/2)) );

	if ( (event.eType >= 1) && (event.eType <= 3) ) {
		*pScreenX = event.screenX;
		*pScreenY = event.screenY;
		*pPenDown = event.penDown;
	} else {
		*pScreenX = 0;
		*pScreenY = 0;
		*pPenDown = 0;
	}
}
Beispiel #23
0
static void AppEventLoop(void){
  EventType event;
  short error;
  UInt16 nilEvents;
  do {
    EvtGetEvent(&event, 25);
    if (MenuHandleEvent(NULL, &event, &error)) { nilEvents=0; continue; }
    if (AppHandleEvent(&event)){ if(event.eType!=nilEvent){nilEvents=0;} continue; }
    if (SysHandleEvent(&event)) { nilEvents=0; continue; }
    if (event.eType == nilEvent){
      nilEvents++;
      if(nilEvents++ > 40 * 60){
        nilEvents = 0;
        if(FrmGetActiveFormID()!=HelpForm){
          FrmGotoForm(HelpForm);
        }
        continue;
      }
    }
    FrmDispatchEvent(&event);
  } while (event.eType != appStopEvent);
}
Beispiel #24
0
int wxEventLoop::Run()
{
    status_t    error;
    EventType    event;

    do {
        wxTheApp && wxTheApp->ProcessIdle();

        EvtGetEvent(&event, evtWaitForever);

        if (SysHandleEvent(&event))
            continue;

        if (MenuHandleEvent(0, &event, &error))
            continue;

        FrmDispatchEvent(&event);

    } while (event.eType != appStopEvent);

    return 0;
}
Beispiel #25
0
static void
EventLoop (void)
{
    short err;
    int fid;
    FormPtr form;
    EventType event;

    do
    {
	EvtGetEvent(&event, 200);

	// let the system handle it's own events
	if (SysHandleEvent(&event)) continue;

	// same for menu events
	if (MenuHandleEvent((void *)0, &event, &err)) continue;

	// set up our handler when our main form is loaded
	if (event.eType == frmLoadEvent) {
	    fid = event.data.frmLoad.formID;
	    form = FrmInitForm(fid);
	    FrmSetActiveForm(form);

	    switch (fid) {
	    case fid_kartrando:
		FrmSetEventHandler(form, mainEventHandler);
		break;
	    case fid_prefs:
		FrmSetEventHandler(form, prefsEventHandler);
		break;
	    }
	}

	FrmDispatchEvent(&event);

    } while (event.eType != appStopEvent);
}
Beispiel #26
0
Err PrvProcessEvents(FlickrSocketContext& context, UInt16 timeout)
{
    Err err = errNone;
    EventType event;

    if (timeout || EvtEventAvail())
    {
        EvtGetEvent(&event, timeout);
        if (!FlickrHandleEvent(context.libRefNum, &event) && NULL != context.progress)
            PrgHandleEvent(context.progress, &event);  // update progress before waiting...
    }
    else if (NULL != context.progress)
        PrgHandleEvent(context.progress, NULL);  // update progress without event (for animation)

    if (NULL != context.progress)
    {
        err = context.progress->error;
        // check for a user cancel and handle it...
        if (PrgUserCancel(context.progress))
            err = exgErrUserCancel;
    }
    return err;
}
Beispiel #27
0
int event_loop(void) {
  UInt16 error;
  EventType event;
  FormPtr form;
  int form_id;
  Regiondesc rd;

  do {
    EvtGetEvent(&event, 0); // No timeout - return immediately
    if (!SysHandleEvent(&event))
      if (!MenuHandleEvent(NULL, &event, &error))
	if (event.eType == frmLoadEvent) {
	  // Load and activate form.
	  form_id = event.data.frmLoad.formID;
	  form = FrmInitForm(form_id);
	  FrmSetActiveForm(form);
	  switch (form_id) {
	  case formID_main_ri_sim: FrmSetEventHandler(form, (FormEventHandlerPtr) ri_sim_event); break;
	  case formID_sys_info: FrmSetEventHandler(form, (FormEventHandlerPtr) sys_info_event); break;
	  }
	} else
	    FrmDispatchEvent(&event);
  } while (event.eType != appStopEvent);
}
Beispiel #28
0
/***********************************************************************
 * main event loop; loops until appStopEvent is caught or
 * QuitApp is set
 ***********************************************************************/
static void
AppEventLoop(void)
{
  UInt16 error;
  EventType event;


  do {
    EvtGetEvent(&event, evtWaitForever);


    if (! SysHandleEvent(&event))
      if (! MenuHandleEvent(0, &event, &error))
	if (! AppHandleEvent(&event))
	  FrmDispatchEvent(&event);

    // Check the heaps after each event
#if EMULATION_LEVEL != EMULATION_NONE
    MemHeapCheck(0);
    MemHeapCheck(1);
#endif
  } while (event.eType != appStopEvent);

}
Beispiel #29
0
/* The main event loop */
static void EventLoop(void)
{
        UInt16 err;
        EventType e;
        static float timeout = .05;

        do {
                if( EQIsEmpty() &&
                    timeout < 600 &&
                    !DrawFlashies() )
                {
                        timeout *= 2;
                } else {
                        timeout = .05;
                }

                EvtGetEvent(&e, timeout * SysTicksPerSecond());
                if (! SysHandleEvent (&e))
                        if (! MenuHandleEvent (NULL, &e, &err) )
                                if (! ApplicationHandleEvent (&e) )
                                        if( ! FrmDispatchEvent (&e) )
                                                GameEvents();
        } while (e.eType != appStopEvent);
}
Beispiel #30
0
/***********************************************************************
 *
 * FUNCTION:    SelectTime
 *
 * DESCRIPTION: Display a form showing a start and end time.
 *					 Allow the user to change the time and then
 *              return them.
 *					 pTimeDiff.
 *
 * PARAMETERS:  pStartTime	- pointer to TimeType
 *              pEndTime   - pointer to TimeType
 *              untimed  	- true if there isn't a time.
 *              title	   - string containing the title
 *              startOfDay - used when "All Day" button selected.
 *					 endOfDay	- our used when "All Day" button selected.
 *              startOfDisplay - first hour initially visible
 *
 * RETURNED:	 True if the time was changed by the user.
 * 				 The first three parameters may change.
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			roger	12/2/94	Initial Revision
 *			trev	08/12/97	made non modified passed variables constant
 *			css	06/08/99	added new parameter & "All Day" button for gromit change.
 *
 ***********************************************************************/
Boolean SelectTime (TimeType * startTimeP, TimeType * endTimeP, 
	Boolean untimed, const Char * titleP, Int16 startOfDay, Int16 endOfDay, 
	Int16 startOfDisplay)
{
	Int16							firstHour;
	Char 							startTimeText [timeStringLength];
	Char 							endTimeText [timeStringLength];
	Char							timeChars [timeStringLength];
	TimePtr						timeP;
	FormType 					*originalForm, *frm;
	ListPtr 						hoursLst, minutesLst;
	ControlPtr 					startTimeCtl, endTimeCtl;
	EventType 					event;
	Boolean 						confirmed = false;
	MemHandle 						hoursItems;
	TimeType 					startTime, endTime, timeDiff;
	TimeFormatType 			timeFormat;
	ChangingTimeType			changingTime;

	// Get the time format from the system preerances;
	timeFormat = (TimeFormatType)PrefGetPreference(prefTimeFormat);


	// Because this routine only deals with minutes in five minute
	// intervals we convert the proposed times from those passed.
	startTime.hours = startTimeP->hours;
	startTime.minutes = startTimeP->minutes;
	endTime.hours = endTimeP->hours;
	endTime.minutes = endTimeP->minutes;
	TimeDifference (&endTime, &startTime, &timeDiff);
	
	// Make sure the end time is displayable (clips at 11:55 pm)
	AdjustTimes (&startTime, &endTime, &timeDiff, changingStartTime);
	
	// Clear the buffer that holds written characters.
	*timeChars = 0;

	startOfDisplay = min (startOfDisplay, 12);

	originalForm = FrmGetActiveForm();
	frm = (FormType *) FrmInitForm (TimeSelectorForm);
	FrmSetActiveForm (frm);

	hoursLst = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, TimeSelectorHourList));
	minutesLst = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, TimeSelectorMinuteList));
	startTimeCtl = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, TimeSelectorStartTimeButton));
	endTimeCtl = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, TimeSelectorEndTimeButton));


	// Set list to use either 12 or 24 hour time
	hoursItems = SysFormPointerArrayToStrings (
		((timeFormat == tfColon24h) || (timeFormat == tfDot24h)) ? 
			(Char *) Hours24Array() : (Char *) Hours12Array(), 24);
 
 	LstSetListChoices (hoursLst, MemHandleLock(hoursItems), 24);
	LstSetTopItem (hoursLst, startOfDisplay);
	//	Used to do LstMakeItemVisible (hoursLst, startTime.hours); no longer.


	if (! untimed)
		{
		LstSetSelection (hoursLst, startTime.hours);
		LstSetSelection (minutesLst, startTime.minutes / 5);

		CtlSetValue (startTimeCtl, true);
		changingTime = changingStartTime;
		}
	else
		{
		// The hour list is dynamically created and doesn't have a selection
		LstSetSelection (minutesLst, noListSelection);

		changingTime = changingNoTime;
		}


	// Set the start and end time buttons to the current times or blank them
	// if No Time is selected.
	SetTimeTriggers (startTime, endTime, startTimeText, endTimeText, 
		timeFormat, untimed);
		

	// This needs to be taken out when SelectTimeV33 goes away.  It allows for backward 
	// compatibility for this change of adding the end of day variable as a parameter.
	if (endOfDay != noDisplayOfAllDay)
	{
	  FrmShowObject (frm, FrmGetObjectIndex (frm, TimeSelectorAllDayButton));
	}
	
	FrmSetTitle (frm, (Char *) titleP);
	FrmDrawForm (frm);
	
	
	while (true)
		{
		EvtGetEvent (&event, evtWaitForever);

		if (SysHandleEvent ((EventType *)&event))
			continue;
			
		if (event.eType == appStopEvent)
			{
			// Cancel the dialog and repost this event for the app
			EvtAddEventToQueue(&event);
			confirmed = false;
			break;
			}
			
		// Handle these before the form does to overide the default behavior
		if (changingTime == changingNoTime &&
			event.eType == lstEnterEvent && 
			event.data.lstEnter.listID == TimeSelectorMinuteList)
			{
			SndPlaySystemSound(sndError);
			continue;
			}

		FrmHandleEvent (frm, &event);


		// If the start or end time buttons are pressed then change
		// the time displayed in the lists.
		if (event.eType == ctlSelectEvent)
			{
			// "Ok" button pressed?
			if (event.data.ctlSelect.controlID == TimeSelectorOKButton)
				{
				confirmed = true;
				}

			// "Cancel" button pressed?
			else if (event.data.ctlSelect.controlID == TimeSelectorCancelButton)
				{
				break;
				}

			// Start time button pressed?
			else if (event.data.ctlSelect.controlID == TimeSelectorStartTimeButton)
				{
				if (changingTime != changingStartTime)
					{
					if (changingTime == changingNoTime)
						{
						SetTimeTriggers (startTime, endTime, startTimeText, 
							endTimeText, timeFormat, false);
						}

					CtlSetValue (endTimeCtl, false);
					LstSetSelection (hoursLst, startTime.hours);
					LstSetSelection (minutesLst, startTime.minutes / 5);
					changingTime = changingStartTime;
					}
				else
					CtlSetValue(startTimeCtl, true);
				}

			// End time button pressed?
			else if (event.data.ctlSelect.controlID == TimeSelectorEndTimeButton)
				{
				if (changingTime != changingEndTime)
					{
					if (changingTime == changingNoTime)
						{
						SetTimeTriggers (startTime, endTime, startTimeText, 
							endTimeText, timeFormat, false);
						}

					CtlSetValue(startTimeCtl, false);
					LstSetSelection (hoursLst, endTime.hours);
					LstSetSelection (minutesLst, endTime.minutes / 5);
					changingTime = changingEndTime;
					}
				else
					CtlSetValue(endTimeCtl, true);
				}

			// No time button pressed?
			else if (event.data.ctlSelect.controlID == TimeSelectorNoTimeButton)
				{
				if (changingTime != changingNoTime)
					{
					if (changingTime == changingStartTime)
						CtlSetValue(startTimeCtl, false);
					else
						CtlSetValue(endTimeCtl, false);
					SetTimeTriggers (startTime, endTime, startTimeText, 
						endTimeText, timeFormat, true);
					
					LstSetSelection (hoursLst, noListSelection);
					LstSetSelection (minutesLst, noListSelection);
					changingTime = changingNoTime;
					}
					// Get us out of this form display now.
					confirmed = true;
				}

			// All day button pressed?
			else if (event.data.ctlSelect.controlID == TimeSelectorAllDayButton)
				{
				if (changingTime != changingNoTime)
					{
					if (changingTime == changingStartTime)
						CtlSetValue(startTimeCtl, false);
					else
						CtlSetValue(endTimeCtl, false);
					
					LstSetSelection (hoursLst, noListSelection);
					LstSetSelection (minutesLst, noListSelection);
					changingTime = changingNoTime;
					}
											
					// No matter what, the minutes are 0 for both because only the hour is registered for start/end
					// times.
					startTime.minutes = 0;
					endTime.minutes 	= 0;
					startTime.hours 	= startOfDay;
					endTime.hours 		= endOfDay;
					
					// Set the times to the new times.
					SetTimeTriggers (startTime, endTime, startTimeText, 
						endTimeText, timeFormat, true);
					// Get us out of this form display now.  First set the changing time to anything but the changingNoTime value
					// so that the pointers at the end of this function get set correctly.
					changingTime = changingStartTime;
					confirmed = true;
				}

			// Clear the buffer that holds written characters.
			*timeChars = 0;
			}


		// If either list is changed then get the new time.  If the
		// start time is changed then change the end time so that the
		// the time difference remains the same.  If the end time is
		// changed then make sure the end time isn't before the start
		// time.  Also calculate a new time difference.
		else if (event.eType == lstSelectEvent)
			{
         // First, get the info from the list which has changed.
			if (event.data.lstSelect.listID == TimeSelectorHourList)
				{
				if (changingTime == changingStartTime)
               startTime.hours = (UInt8) LstGetSelection (hoursLst);
           	else if (changingTime == changingEndTime)
               endTime.hours = (UInt8) LstGetSelection (hoursLst);
           	else if (changingTime == changingNoTime)
           		{
               startTime.hours = (UInt8) LstGetSelection (hoursLst);
					SetTimeTriggers (startTime, endTime, startTimeText, 
						endTimeText, timeFormat, false);
					CtlSetValue (endTimeCtl, false);
					LstSetSelection (minutesLst, startTime.minutes / 5);
					changingTime = changingStartTime;
					}
				}
         else if (event.data.lstSelect.listID == TimeSelectorMinuteList)
				{
				if (changingTime == changingStartTime)
               startTime.minutes = (UInt8) LstGetSelection (minutesLst) * 5;
           	else if (changingTime == changingEndTime)
					endTime.minutes = (UInt8) LstGetSelection (minutesLst) * 5;
           	else if (changingTime == changingNoTime)
           		{
               ErrNonFatalDisplay("lstEnterEvent not being filtered.");
               }
				}


			if (AdjustTimes (&startTime, &endTime, &timeDiff, changingTime))
				{
				if (changingTime == changingStartTime)
					{
					TimeToAscii (startTime.hours, startTime.minutes, timeFormat, 
						startTimeText);
					CtlSetLabel (startTimeCtl, startTimeText);
					}
				else if (changingTime == changingEndTime)
					{
					LstSetSelection (hoursLst, startTime.hours);
					LstSetSelection (minutesLst, startTime.minutes / 5);
					}
				}
			TimeToAscii(endTime.hours, endTime.minutes, timeFormat, endTimeText);
			CtlSetLabel(endTimeCtl, endTimeText);


			// Clear the buffer that holds written characters.
			*timeChars = 0;
			}


		// Handle character written in the time picker.
		else if (event.eType == keyDownEvent)
			{
			if (changingTime == changingEndTime)
				{
				timeP = &endTime;
				firstHour = startTime.hours;
				}
			else
				{
				timeP = &startTime;
				firstHour = startOfDisplay;
				}
		
			// If a backspace character was written, change the time picker's
			// current setting to "no-time".
			if (event.data.keyDown.chr == backspaceChr)
				{
				*timeChars = 0;
				if (changingTime != changingNoTime)
					{
					if (changingTime == changingStartTime)
						CtlSetValue (startTimeCtl, false);
					else
						CtlSetValue (endTimeCtl, false);
					SetTimeTriggers (startTime, endTime, startTimeText, 
						endTimeText, timeFormat, true);
					LstSetSelection (hoursLst, noListSelection);
					LstSetSelection (minutesLst, noListSelection);
					changingTime = changingNoTime;
					}
				}

			// A linefeed character confirms the dialog box.
			else if (event.data.keyDown.chr == linefeedChr)
				{
				confirmed = true;
				}

			// If next-field character toggle between start time in end
			// time.
			else if (event.data.keyDown.chr == nextFieldChr)
				{
				*timeChars = 0;
				if (changingTime == changingStartTime)
					{
					CtlSetValue (startTimeCtl, false);
					CtlSetValue (endTimeCtl, true);
					changingTime = changingEndTime;
					}
				else
					{
					CtlSetValue (endTimeCtl, false);
					CtlSetValue (startTimeCtl, true);
					changingTime = changingStartTime;
					}
				}


			// If a valid time character was written, translate the written 
			// character into a time and update the time picker's UI.
			else if (TranslateTime (timeFormat, event.data.keyDown.chr, 
				firstHour, timeChars, timeP))
				{
				if (changingTime == changingNoTime)
					{
					changingTime = changingStartTime;
					CtlSetValue (startTimeCtl, true);
					}

				AdjustTimes (&startTime, &endTime, &timeDiff, changingTime);
				
				SetTimeTriggers (startTime, endTime, startTimeText, 
					endTimeText, timeFormat, false);

				LstSetSelection (hoursLst, timeP->hours);
				LstSetSelection (minutesLst, timeP->minutes / 5);
				}
			}

		// Has the dialog been confirmed.
		if (confirmed)
			{
			if (changingTime != changingNoTime)
				{
				*startTimeP = startTime;
				*endTimeP = endTime;
				}
			else
				{
				TimeToInt(*startTimeP) = noTime;
				TimeToInt(*endTimeP) = noTime;
				}
			break;
			}

		}

	FrmEraseForm (frm);
	FrmDeleteForm (frm);
	MemHandleFree (hoursItems);
	
	FrmSetActiveForm(originalForm);
	
	return (confirmed);
	}