Пример #1
0
/***********************************************************************
 *
 * FUNCTION:    PrvUpdateTimeFields
 *
 * DESCRIPTION: Update the current time and new time displayed if they have
 *					 changed in the time zone dialog. Also used to update these
 *					 times in the daylight saving time dialog.
 *
 * PARAMETERS:  frm	 - the time zone or daylight saving time dialog
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			peter	4/13/00	Initial Revision
 *
 ***********************************************************************/
static void PrvUpdateTimeFields (FormPtr frm,
	DateTimeType *currentTimeP, DateTimeType *newTimeP,
	MemHandle currentTimeHandle, MemHandle newTimeHandle,
	UInt16 currentTimeFieldID, UInt16 newTimeFieldID)
{
	DateTimeType now, then;
	UInt32 delta;

	TimSecondsToDateTime(TimGetSeconds(), &now);

	if (now.minute != currentTimeP->minute ||
		now.hour != currentTimeP->hour ||
		now.day != currentTimeP->day ||
		now.month != currentTimeP->month ||
		now.year != currentTimeP->year)
	{
		then = *currentTimeP;
		*currentTimeP = now;
		PrvSetTimeField(frm, currentTimeFieldID, currentTimeHandle, currentTimeP, true);
		if (FldGetTextLength(FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, newTimeFieldID))) != 0)
		{
			delta = TimDateTimeToSeconds(newTimeP) - TimDateTimeToSeconds(&then);
			TimSecondsToDateTime(TimDateTimeToSeconds(currentTimeP) + delta, newTimeP);
			PrvSetTimeField(frm, newTimeFieldID, newTimeHandle, newTimeP, true);
		}
	}
} // PrvUpdateTimeFields
Пример #2
0
/*****************************************************************************
* Function: GadgetDrawHintNext
* Complexity: O(N), N = DmNumRecords
*
* Description: Draw info for closest upcoming event.
*****************************************************************************/
void
GadgetDrawHintNext(void)
{
  MemHandle m;
  UInt16 index=0;
  DateTimeType dt;
  Boolean found=false, foundFirst=false;
  UInt16 curTime, curMinTind=0, wantCourse=0, curMinTime=0xFFFF;
  Int16 diffTime;
  TimeDBRecord *t;

  TimSecondsToDateTime(TimGetSeconds(), &dt);

  if ((dt.weekDay > 0) && (dt.weekDay <= gGadgetDaysNum)) {
    dt.weekDay = dt.weekDay-1;
  } else {
    dt.weekDay = 0;
    dt.hour = 0;
    dt.minute = 0;
  }

  curTime = dt.weekDay * GADGET_DAYVALUE + dt.hour * 60 + dt.minute;

  // Search for record nearest in _past_ to current time
  // NOTE: We assume that the types are sorted "times -> courses"! We use that to reduce everything to ONE while loop
  while( !found && ((m = DmQueryNextInCategory(DatabaseGetRef(), &index, DatabaseGetCat())) != NULL)) {
    Char *s=MemHandleLock(m);
    if (s[0] == TYPE_TIME) {
      t = (TimeDBRecord *)s;
      if ( GadgetEventIsVisible(t) ) {
        if (! foundFirst) {
          foundFirst = true;
          curMinTind = index;
          wantCourse = t->course;
        }

        diffTime = (t->day * GADGET_DAYVALUE + t->begin.hours * 60 + t->begin.minutes) - curTime;
        if ( (diffTime > 0) && (diffTime < curMinTime) ) {
          curMinTind = index;
          curMinTime = diffTime;
          wantCourse = t->course;
        }
      }
    } else if (s[0] == TYPE_COURSE) {
      CourseDBRecord c;
      UnpackCourse(&c, s);
      if (c.id == wantCourse) {
        gCourseIndex = index;
        gTimeIndex = curMinTind;
        found=true;
      }
    }
    MemHandleUnlock(m);
    index += 1;
  }

  if (! found || ! foundFirst)  GadgetDrawHintErase();
  else                          GadgetDrawHintCurrent();

}
Пример #3
0
void ILGetCurrTime(ILCurrTime *timeValue)
{
#ifdef HAVE_GETTIMEOFDAY
	/* Try to get the current time, accurate to the microsecond */
	struct timeval tv;
	gettimeofday(&tv, 0);
	timeValue->secs = ((ILInt64)(tv.tv_sec)) + EPOCH_ADJUST;
	timeValue->nsecs = (ILUInt32)(tv.tv_usec * 1000);
#else
#ifdef IL_WIN32_PLATFORM
	/* Get the time using a Win32-specific API */
	FILETIME filetime;
	ILInt64 value;
	GetSystemTimeAsFileTime(&filetime);
	value = (((ILInt64)(filetime.dwHighDateTime)) << 32) +
			 ((ILInt64)(filetime.dwLowDateTime));
	timeValue->secs = (value / (ILInt64)10000000) + WIN32_EPOCH_ADJUST;
	timeValue->nsecs = (ILUInt32)((value % (ILInt64)10000000) * (ILInt64)100);
#elif defined(__palmos__)
	/* Use the PalmOS routine to get the time in seconds */
	timeValue->secs = ((ILInt64)(TimGetSeconds())) + PALM_EPOCH_ADJUST;
	timeValue->nsecs = 0;
#else
	/* Use the ANSI routine to get the time in seconds */
	timeValue->secs = (ILInt64)(time(0)) + EPOCH_ADJUST;
	timeValue->nsecs = 0;
#endif
#endif
}
Пример #4
0
/*****************************************************************************
* Function: GadgetDrawTimeline
*
* Description: Draws a line for the current time
*****************************************************************************/
void
GadgetDrawTimeline(GadgetTimelineDrawType drawType)
{
  DateTimeType dt;
  TimeType now;

  TimSecondsToDateTime(TimGetSeconds(), &dt);

  if (drawType == gtDraw) {
    now.hours=dt.hour;
    now.minutes=dt.minute;
    gGadgetLastTimeline.hours=now.hours;
    gGadgetLastTimeline.minutes=now.minutes;
    GadgetDrawWeekdays();
  } else {
    now.hours=gGadgetLastTimeline.hours;
    now.minutes=gGadgetLastTimeline.minutes;
  }

  if ( ((gGadgetCurScreen == GADGET_SCREEN_DAY) && (now.hours >= 8) && (now.hours < 20)) ||
       ((gGadgetCurScreen == GADGET_SCREEN_NIGHT) && ((now.hours < 8) || (now.hours >= 20))) ) {

    UInt8 y, gadgetWidth;
    UInt16 gadgetIndex;
    FormType *frm;
    RectangleType bounds;
    RGBColorType red={0x00, 0xFF, 0x00, 0x00}, old;

    y = GadgetCalcTimeTop(now);

    frm = FrmGetActiveForm();
    gadgetIndex = FrmGetObjectIndex(frm, gGadgetID);
    FrmGetObjectBounds(frm, gadgetIndex, &bounds);
    gadgetWidth=gGadgetDaysNum * gGadgetDaysWidth + gGadgetDaysNum - 1;

    WinInvertLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y+GADGET_TOP+y,
                  bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gadgetWidth-1, bounds.topLeft.y+GADGET_TOP+y);

    if (drawType == gtDraw) {
      TNSetForeColorRGB(&red, &old);
      WinDrawPixel(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+1, bounds.topLeft.y+GADGET_TOP+y);
      WinDrawLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+2, bounds.topLeft.y+GADGET_TOP+y-1,
                  bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+2, bounds.topLeft.y+GADGET_TOP+y+1);
      WinDrawLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+3, bounds.topLeft.y+GADGET_TOP+y-2,
                  bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+3, bounds.topLeft.y+GADGET_TOP+y+2);
      TNSetForeColorRGB(&old, NULL);
    } else if (drawType == gtErase) {
      RectangleType rect;
      RctSetRectangle(&rect,
                      bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+1, bounds.topLeft.y+GADGET_TOP+y-2,
                      bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+3, bounds.topLeft.y+GADGET_TOP+y+2);
      WinEraseRectangle(&rect, 0);
    }
  }
}
Пример #5
0
time_t
time (time_t *T)
{
    UInt32 sec;
    // UInt32 TimGetSeconds(void); // seconds since 1/1/1904
    // void TimSetSeconds (UInt32 seconds); // seconds since 1/1/1904
    // UInt32 TimGetTicks(void); // ticks since power on
    sec = TimGetSeconds ();
    if (T) {
        *T = sec - SEC_1904_1970;
    }
    return (sec - SEC_1904_1970);
}
Пример #6
0
/*****************************************************************************
* Function: GadgetDrawWeekdays
*
* Description: Draws the weekdays, extra function since called in
*              GadgetDrawTimeline
*****************************************************************************/
void
GadgetDrawWeekdays(void)
{
  UInt8 i;
  MemHandle mh;
  Char *text;
  RGBColorType color, prevColor;
  DateTimeType now;
  Int16 dow;
  RectangleType bounds, rect;
  UInt16 gadgetIndex;

  // Get info about Gadget
  gadgetIndex = FrmGetObjectIndex(gForm, gGadgetID);
  FrmGetObjectBounds(gForm, gadgetIndex, &bounds);

  // Initialize time constants
  TimSecondsToDateTime(TimGetSeconds(), &now);
  dow = DayOfWeek(now.month, now.day, now.year);
  
  RctSetRectangle(&rect, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y,
                         130, FntLineHeight()+2);

  // Erase background
  WinEraseRectangle(&rect, 0);

  for (i=0; i < gGadgetDaysNum; ++i) {
    Int16 leftoff;
    mh = DmGetResource(strRsc, GADGET_STRINGS_WDAYSTART+i);
    text = MemHandleLock(mh);
    leftoff = (gGadgetDaysWidth+2 - FntLineWidth(text, MemPtrSize(text))) / 2;
    if (TNisColored() && (dow == i+1)) {
      color.r = 0xFF;  color.g = 0x00;  color.b = 0x00;
      TNSetTextColorRGB(&color, &prevColor);
    }
    WinDrawChars(text, StrLen(text), bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+i*gGadgetDaysWidth+i+leftoff+2, bounds.topLeft.y);
    if (dow == i+1) {
      if (TNisColored()) {
        TNSetTextColorRGB(&prevColor, NULL);
      } else {
        // Draw some kind of underline to determine current day
        Int16 lineWidth=FntLineWidth(text, StrLen(text));
        WinDrawLine(rect.topLeft.x+i*gGadgetDaysWidth+i+leftoff+1, rect.topLeft.y+FntLineHeight(),
                    rect.topLeft.x+i*gGadgetDaysWidth+i+leftoff+1+lineWidth, rect.topLeft.y+FntLineHeight());
      }
    }
    MemHandleUnlock(mh);
  }
}
Пример #7
0
/***********************************************************************
 *
 * FUNCTION:    RescheduleAlarms
 *
 * DESCRIPTION: This routine computes the time of the next alarm and 
 *              compares it to the time of the alarm scheduled with
 *              Alarm Manager,  if they are different it reschedules
 *              the next alarm with the Alarm Manager.
 *
 * PARAMETERS:  dbP - the appointment database
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			art	9/5/95	Initial Revision
 *			rbb	4/22/99	Snoozing now disables other rescheduling of alarms
 *
 ***********************************************************************/
void RescheduleAlarms (DmOpenRef dbP)
{
	UInt32 ref;
	UInt32 timeInSeconds;
	UInt32 nextAlarmTime;
	UInt32 scheduledAlarmTime;
	PendingAlarmQueueType alarmInternals;
	
	ReserveAlarmInternals (&alarmInternals);
	
	// The pending alarm queue used to be empty, as a rule, any time that
	// RescheduleAlarms could possibly be called. With the addition of the
	// snooze feature, the pending alarm queue may not be empty and, if this
	// is the case, could be invalidated by the changes that prompted the
	// call to RescheduleAlarms. We clear them here and will rebuild the
	// queue in AlarmTriggered().
	ClearPendingAlarms (&alarmInternals);
		
	// only reschedule if we're not snoozing
	if (GetSnoozeAnchorTime (&alarmInternals) == apptNoAlarm)
    {
		scheduledAlarmTime = AlarmGetTrigger (&ref);
		timeInSeconds = TimGetSeconds ();
		if ((timeInSeconds < scheduledAlarmTime) ||
		    (scheduledAlarmTime == 0) ||
		    (ref > 0))
			scheduledAlarmTime = timeInSeconds;
		
		nextAlarmTime = ApptGetTimeOfNextAlarm (dbP, scheduledAlarmTime);
		
		// If the scheduled time of the next alarm is not equal to the
		// calculate time of the next alarm,  reschedule the alarm with 
		// the alarm manager.
		if (scheduledAlarmTime != nextAlarmTime)
        {
			AlarmSetTrigger (nextAlarmTime, 0);
        }
    }
	else
    {
    }
	
	ReleaseAlarmInternals (&alarmInternals, true);
}
Пример #8
0
/* Create new item in app database */
static UInt16
DoTheBoogie(KleenexPtr kleenexP, DmOpenRef dbR, UInt16 *index)
{
    ApptDBRecordType datebook;
    ApptDateTimeType dbwhen;
    AlarmInfoType dbalarm;
    UInt32 secs;

    MemSet(&datebook, sizeof(ApptDBRecordType), 0);
    MemSet(&dbwhen, sizeof(ApptDateTimeType), 0);
    MemSet(&dbalarm, sizeof(AlarmInfoType), 0);
    datebook.when = &dbwhen;
    datebook.alarm = &dbalarm;

    // Set up the record
    datebook.repeat = kleenexP->repeat;
    datebook.note = kleenexP->note;
    datebook.description = kleenexP->text;

    // Set date and time
    if (!(secs = kleenexP->alarm_secs))
        secs = TimGetSeconds();
    DateSecondsToDate(secs, &dbwhen.date);
    if (kleenexP->alarm_secs % 86400) {
        SetSaneTimes(secs, &dbwhen.startTime, &dbwhen.endTime);
    } else {
        TimeToInt(dbwhen.startTime) = apptNoTime;
        TimeToInt(dbwhen.endTime) = apptNoTime;
    }

    // Set the alarm
    dbalarm.advanceUnit = aauMinutes;
    if (kleenexP->alarm_secs) {
        dbalarm.advance = 0;
    } else {
        dbalarm.advance = apptNoAlarm;
        datebook.alarm = NULL;
    }

    // Add it to the DB
    return (ApptNewRecord(dbR, &datebook, index));
}
Пример #9
0
time_t time(time_t *tloc) {
	// get ROM version
	UInt32 romVersion;
	Err e = FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);

	// since 1/1/1904 12AM.
	UInt32 secs = TimGetSeconds();
	
	// form 1/1/1904 12AM to 1/1/1970 12AM
	DateTimeType Epoch = {0, 0, 0, 1, 1, 1970, 0};

	secs -= TimDateTimeToSeconds(&Epoch);

	// DST really supported from OS v4.0
	if (romVersion >= sysMakeROMVersion(4,0,0,sysROMStageRelease,0))
		secs -= (PrefGetPreference(prefTimeZone) + PrefGetPreference(prefDaylightSavingAdjustment)) * 60;
	else
		secs -= (PrefGetPreference(prefMinutesWestOfGMT) - 720) * 60;

	if (tloc)
		*tloc = secs;

	return (secs);
}
Пример #10
0
Boolean Sl2LnFormHandleEvent(EventPtr e)
{
    Boolean handled = false;
    DateType dt = {0, 0};
    FormPtr frm = FrmGetFormPtr(Sl2LnForm);

    switch (e->eType) {
    case frmOpenEvent:
        if(gbVgaExists)
       		VgaFormModify(frm, vgaFormModify160To240);

        DateSecondsToDate(TimGetSeconds(), &dt);

        DateToAsciiLong(dt.month, dt.day, dt.year + 1904,
                        gPrefdfmts, gAppErrStr);

        SetFieldTextFromStr(Sl2LnFormInput, gAppErrStr);

        FrmDrawForm(frm);
        handled = true;
        break;

    case ctlSelectEvent:
        switch(e->data.ctlSelect.controlID) {
        case Sl2LnFormConvert:
        {
            HappyDaysFlag dummy;
            Int16 year, month, day;
            int lyear, lmonth, lday;
            Char* input;
            int ret = false;

            input = FldGetTextPtr(GetObjectPointer(frm, Sl2LnFormInput));
            if ((ret = AnalysisHappyDays(input, &dummy,
                                         &year, &month, &day))) {
                int leapyes = 0;

                ret = lunarS2L(lunarRefNum, year, month, day, &lyear, &lmonth, &lday, &leapyes);
                if (ret == errNone) {
                    if (leapyes) {
                        StrCopy(gAppErrStr, "#)");
                    }
                    else {
                        StrCopy(gAppErrStr, "-)");
                    }
                    DateToAsciiLong(lmonth, lday, lyear, gPrefdfmts, &gAppErrStr[2]);
                          
                    FldDrawField(SetFieldTextFromStr(Sl2LnFormResult,
                                                     gAppErrStr));
                }
                else DisplayInvalidDateErrorString(Sl2LnFormResult);

            }
            else DisplayInvalidDateErrorString(Sl2LnFormResult);

            handled = true;
            break;
        }

        case Sl2LnFormOk:
            FrmReturnToForm(0);

            handled = true;
            break;
            
        default:
            break;
                
        }
        break;

    case menuEvent:
        handled = TextMenuHandleEvent(e->data.menu.itemID, Sl2LnFormInput);
        break;

    default:
        break;
    }

    return handled;
}
Пример #11
0
// Get local time as milliseconds since 00:00:00, Jan 1st 1970
wxLongLong wxGetLocalTimeMillis()
{
    wxLongLong val = 1000l;

    // If possible, use a function which avoids conversions from
    // broken-up time structures to milliseconds

#if defined(__WXPALMOS__)
    DateTimeType thenst;
    thenst.second  = 0;
    thenst.minute  = 0;
    thenst.hour    = 0;
    thenst.day     = 1;
    thenst.month   = 1;
    thenst.year    = 1970;
    thenst.weekDay = 5;
    uint32_t now = TimGetSeconds();
    uint32_t then = TimDateTimeToSeconds (&thenst);
    return SysTimeToMilliSecs(SysTimeInSecs(now - then));
#elif defined(__WXMSW__) && (defined(__WINE__) || defined(__MWERKS__))
    // This should probably be the way all WXMSW compilers should do it
    // Go direct to the OS for time

    SYSTEMTIME thenst = { 1970, 1, 4, 1, 0, 0, 0, 0 };  // 00:00:00 Jan 1st 1970
    FILETIME thenft;
    SystemTimeToFileTime( &thenst, &thenft );
    wxLongLong then( thenft.dwHighDateTime, thenft.dwLowDateTime );   // time in 100 nanoseconds

    SYSTEMTIME nowst;
    GetLocalTime( &nowst );
    FILETIME nowft;
    SystemTimeToFileTime( &nowst, &nowft );
    wxLongLong now( nowft.dwHighDateTime, nowft.dwLowDateTime );   // time in 100 nanoseconds

    return ( now - then ) / 10000.0;  // time from 00:00:00 Jan 1st 1970 to now in milliseconds

#elif defined(HAVE_GETTIMEOFDAY)
    struct timeval tp;
    if ( wxGetTimeOfDay(&tp) != -1 )
    {
        val *= tp.tv_sec;
        return (val + (tp.tv_usec / 1000));
    }
    else
    {
        wxLogError(_("wxGetTimeOfDay failed."));
        return 0;
    }
#elif defined(HAVE_FTIME)
    struct timeb tp;

    // ftime() is void and not int in some mingw32 headers, so don't
    // test the return code (well, it shouldn't fail anyhow...)
    (void)::ftime(&tp);
    val *= tp.time;
    return (val + tp.millitm);
#else // no gettimeofday() nor ftime()
    // We use wxGetLocalTime() to get the seconds since
    // 00:00:00 Jan 1st 1970 and then whatever is available
    // to get millisecond resolution.
    //
    // NOTE that this might lead to a problem if the clocks
    // use different sources, so this approach should be
    // avoided where possible.

    val *= wxGetLocalTime();

// GRG: This will go soon as all WIN32 seem to have ftime
// JACS: unfortunately not. WinCE doesn't have it.
#if defined (__WIN32__)
    // If your platform/compiler needs to use two different functions
    // to get ms resolution, please do NOT just shut off these warnings,
    // drop me a line instead at <*****@*****.**>

    // FIXME
#ifndef __WXWINCE__
    #warning "Possible clock skew bug in wxGetLocalTimeMillis()!"
#endif

    SYSTEMTIME st;
    ::GetLocalTime(&st);
    val += st.wMilliseconds;
#else // !Win32
    // If your platform/compiler does not support ms resolution please
    // do NOT just shut off these warnings, drop me a line instead at
    // <*****@*****.**>

    #if defined(__VISUALC__) || defined (__WATCOMC__)
        #pragma message("wxStopWatch will be up to second resolution!")
    #elif defined(__BORLANDC__)
        #pragma message "wxStopWatch will be up to second resolution!"
    #else
        #warning "wxStopWatch will be up to second resolution!"
    #endif // compiler
#endif

    return val;

#endif // time functions
}
Пример #12
0
static void
ExamDetailsFormInit(FormType *frm)
{
  UInt16 selectedCourse=0;
  ListType *course;
  ControlType *course_tr, *date_tr, *time_tr;

  course = GetObjectPtr(LIST_exd_course);
  course_tr = GetObjectPtr(LIST_exd_course_trigger);
  date_tr = GetObjectPtr(SELECTOR_exd_date);
  time_tr = GetObjectPtr(SELECTOR_exd_time);

  gExamDetailsNumCourses = CountCourses();

  gExamDetailsItemList = (Char **) MemPtrNew(gExamDetailsNumCourses * sizeof(Char *));
  gExamDetailsItemIDs = (UInt16 *) MemPtrNew(gExamDetailsNumCourses * sizeof(UInt16));
  gExamDetailsItemInd = (UInt16 *) MemPtrNew(gExamDetailsNumCourses * sizeof(UInt16));

  if (gExamsLastSelRowUID == 0) {
    // ADD
    DateTimeType dt;

    selectedCourse = CourseListGen(gExamDetailsItemList, gExamDetailsItemIDs, gExamDetailsItemInd, gExamDetailsNumCourses, 0, CLIST_SEARCH_INDEX);

    TimSecondsToDateTime(TimGetSeconds(), &dt);
    gExamDetailsDate.year=dt.year-MAC_SHIT_YEAR_CONSTANT;

    gExamDetailsDate.month=dt.month;
    gExamDetailsDate.day=dt.day;

    gExamDetailsBegin.hours=14;
    gExamDetailsBegin.minutes=0;

    gExamDetailsEnd.hours=15;
    gExamDetailsEnd.minutes=30;

  } else {
    MemHandle mex, mRoom, old;
    ExamDBRecord *ex;
    UInt16 index=0;
    Char *buffer;
    FieldType *fldRoom;

    fldRoom=GetObjectPtr(FIELD_exd_room);

    DmFindRecordByID(DatabaseGetRefN(DB_MAIN), gExamsLastSelRowUID, &index);

    mex = DmQueryRecord(DatabaseGetRefN(DB_MAIN), index);
    ex = (ExamDBRecord *)MemHandleLock(mex);

    selectedCourse = CourseListGen(gExamDetailsItemList, gExamDetailsItemIDs, gExamDetailsItemInd, gExamDetailsNumCourses, ex->course, CLIST_SEARCH_ID);

    gExamDetailsDate.year=ex->date.year;
    gExamDetailsDate.month=ex->date.month;
    gExamDetailsDate.day=ex->date.day;

    gExamDetailsBegin.hours=ex->begin.hours;
    gExamDetailsBegin.minutes=ex->begin.minutes;

    gExamDetailsEnd.hours=ex->end.hours;
    gExamDetailsEnd.minutes=ex->end.minutes;

    // Copy contents to the memory handle
    mRoom=MemHandleNew(StrLen(ex->room)+1);
    buffer=(Char *)MemHandleLock(mRoom);
    MemSet(buffer, MemPtrSize(buffer), 0);
    StrNCopy(buffer, ex->room, StrLen(ex->room));
    MemHandleUnlock(mRoom);

    // Load fields
    old = FldGetTextHandle(fldRoom);
    FldSetTextHandle(fldRoom, mRoom);
    if (old != NULL)    MemHandleFree(old); 

    MemHandleUnlock(mex);
  }


  LstSetListChoices(course, gExamDetailsItemList, gExamDetailsNumCourses);
  if (gExamDetailsNumCourses < 5)  LstSetHeight(course, gExamDetailsNumCourses);
  else                 LstSetHeight(course, 5);
  LstSetSelection(course, selectedCourse);
  CtlSetLabel(course_tr, LstGetSelectionText(course, selectedCourse));

  ExamDetailsSetTriggers(date_tr, time_tr);
  EditTimeSetSelectorText(time_tr, &gExamDetailsBegin, &gExamDetailsEnd, gExamDetailsTimeTrigger);

}
Пример #13
0
void PrivDrawCell(void* table, Int16 row, Int16 column, RectanglePtr bounds)
{
	char string[50];
	FontID font = stdFont;

	if (g_CurrentRow != row) {
		if (g_CurrentMemHandle) {
			MemHandleUnlock(g_CurrentMemHandle);
			g_CurrentMemHandle = NULL;
		}
	}
	if (g_CurrentMemHandle == NULL) {
		Err err = GetSMSRecord(g_SmsDb, g_SelectedCategory, row + g_CurrentPage * TABLE_PAGE_SIZE, 
			g_CurrentRecord, g_CurrentMemHandle, true);
		if (err) return;
		g_CurrentRow = row;
	}
		
	switch(column) {
		case 0:
			StrCopy(string, "");
			if (g_SelectedCategory == CAT_INBOX) {
				if (IsRecordRead(&g_CurrentRecord)) {
					StrCopy(string, "");
				} else {
					font = symbolFont;
					StrCopy(string, "\020");
				}
			} else if (g_SelectedCategory == CAT_SENT) {
				if (IsRecordRequestReport(&g_CurrentRecord)) {
					font = symbolFont;
					if (IsRecordDelivered(&g_CurrentRecord)) {
						StrCopy(string, "\026");
					} else {
						StrCopy(string, "\024");
					}
				}
			}
			break;
		case 1:
			StrNCopy(string, g_CurrentRecord.personName, 48);
			if (StrLen(string) == 0) {
				StrNCopy(string, g_CurrentRecord.phoneNumber, 48);
			}
			break;
		case 2:
			StrNCopy(string, g_CurrentRecord.content, 48);
			break;
		case 3:
			{
				DateTimeType smsDatetime;
				TimSecondsToDateTime(g_CurrentRecord.time, &smsDatetime);

				UInt32 nowSeconds = TimGetSeconds();
				DateTimeType nowDatetime;
				TimSecondsToDateTime(nowSeconds, &nowDatetime);
				
				if ((nowDatetime.year == smsDatetime.year) && 
					(nowDatetime.month == smsDatetime.month) &&
					(nowDatetime.day == smsDatetime.day)) {
					TimeToAscii(smsDatetime.hour, smsDatetime.minute, tfColon24h, string);
				} else {
					StrCopy(string, DayOfWeekInChinese[DayOfWeek(smsDatetime.month, smsDatetime.day, smsDatetime.year)]);
					DateTemplateToAscii(" ^3z-^0z", smsDatetime.month, smsDatetime.day, smsDatetime.year, string + 2, 47);
				}
				MemHandleUnlock(g_CurrentMemHandle);
				g_CurrentMemHandle = NULL;
			}
			break;
		default:
			StrCopy(string, "");
	}

	WinPushDrawState();
	
	RGBColorType foreColor, backColor;

	foreColor.index = 0;
	backColor.index = 0;
	if ((row == g_CurrentSelection) && (column != 0)) {
		foreColor.r = 255;
		foreColor.g = 255;
		foreColor.b = 255;
		
		backColor.r = 10;
		backColor.g = 36;
		backColor.b = 106;
	} else if (row % 2 == 0) {
		backColor.r = 255;
		backColor.g = 255;
		backColor.b = 255;
		
		foreColor.r = 0;
		foreColor.g = 0;
		foreColor.b = 0;
	} else {
		backColor.r = 220;
		backColor.g = 220;
		backColor.b = 220;
		
		foreColor.r = 0;
		foreColor.g = 0;
		foreColor.b = 0;
	}
	WinSetForeColorRGB(&foreColor, NULL);
	WinSetTextColorRGB(&foreColor, NULL);
	WinSetBackColorRGB(&backColor, NULL);
	
	WinSetUnderlineMode(noUnderline);
		
	FntSetFont(font);

	Int16 width = bounds->extent.x - 2;
	Int16 len = StrLen(string);
	Boolean noFit = false;
	FntCharsInWidth(string, &width, &len, &noFit);
	
	UInt16 x = bounds->topLeft.x;
	UInt16 y = bounds->topLeft.y;
	
	bounds->topLeft.x += - 1;
	bounds->topLeft.y += 0;
	bounds->extent.x += 2;
	bounds->extent.y += 0;
	
	WinEraseRectangle(bounds, 0);
	WinDrawGrayLine(
		bounds->topLeft.x + bounds->extent.x - 2, 
		bounds->topLeft.y,
		bounds->topLeft.x + bounds->extent.x - 2, 
		bounds->topLeft.y + bounds->extent.y);// - 2);
		
	WinDrawChars(string, len, x, y);
	
	WinPopDrawState();
}
Пример #14
0
static Boolean MainFormHandleEvent (EventPtr e)
{
    Boolean handled = false;
    FormPtr frm;
    static UInt32 start_sec=0;
    static UInt32 start_tik;
    static UInt32 end_sec;
    static UInt32 end_tik;
    //static int run = 0;
    
    switch (e->eType) {
    case frmOpenEvent:
	frm = FrmGetActiveForm();
	FrmDrawForm(frm);

	// resume interrupted count
	// note now stopWatchPrefs.tik_timestamp != stopWatchPrefs.timestamp
        // now this does work okay when switching away from app BUT
        // not when palm is turned off & on but stays in app
        // I think possibly GetTicks gets ticks from start of app
        // when palm off the ticks do not increment
	if (stopWatchPrefs.timestamp != 0) {
	    stopWatchPrefs.tik_timestamp = TimGetSeconds();
	    start_tik = TimGetTicks();
	    RunCount(start_tik);
	}

	handled = true;
	break;

    case menuEvent:
	MenuEraseStatus(NULL);

	switch(e->data.menu.itemID) {
	    // TODO add to TestTemp code
	    //case itemBar:
	    case itemRun:
		if (start_sec == 0) {
		    stopWatchPrefs.tik_timestamp =
			stopWatchPrefs.timestamp = 
			start_sec = TimGetSeconds();
		    start_tik = TimGetTicks();
		}
		RunCount(start_tik);
		break;
	    case itemHold:
		// break the run loop
		run = 0;
		break;
	    case itemStop:
		// break the run loop
		run = 0;
		end_sec = TimGetSeconds();
 		end_tik = TimGetTicks();
		break;
	    case itemClear:
		// break the run loop
		run = 0;
		start_sec = 0;
		stopWatchPrefs.timestamp = 0;
		stopWatchPrefs.tik_timestamp = 0;
		end_tik = 0;
		drawCount(0);
		break;

	    case itemPrefs:
		FrmPopupForm(PrefForm);
		break;

	    case itemTest1:

		WinDrawLine(20,20,50,50);
//void WinDrawChar (WChar theChar, Coord x, Coord y)
///void WinDrawChars (const Char *chars, Int16 len, Coord x, Coord y)
//void WinPaintChar (WChar theChar, Coord x, Coord y)
//void WinPaintChars (const Char *chars, Int16 len, Coord x, Coord y)
///opt/palmdev/sdk-5/include/Core/System/Window.h
// Font.h
		WinDrawChar('X',20,50);
		FntSetFont(symbol11Font);
		WinDrawChar('Y',40,50);
		FntSetFont(largeFont);
		WinDrawChar('Z',60,50);
		WinDrawChars("large Font",10,80,50);
		FntSetFont(largeBoldFont);
		WinDrawChars("large Bold",10,110,50);

		{
		    char buf[100];
		    int l=0;
		    UInt32 t = SysTicksPerSecond();
		    l+=StrPrintF(buf+l, "SysTicksPerSec is %lu", t);
		    FntSetFont(largeBoldFont);
		    WinPaintChars(buf,l,1,20);
		}

		if (0){
		    digiFontType ft;
		    ft.h = 20;
		    ft.w = 16;
		    ft.th = 4; ft.tw = 7;
		    drawHSeg(11,9,ft,WinDrawLineF);
		    drawVSeg(10,10,ft,WinDrawLineF);
		    drawHSeg(11,36,ft,WinDrawLineF);
		    drawVSeg(39,10,ft,WinDrawLineF);
		}

		if (0){
		    digiFontType ft;
		    ft.h = 20;
		    ft.w = 12;
		    ft.th = 4; ft.tw = 7;
		    drawHSeg(11,59,ft,WinDrawLineF);
		    drawVSeg(10,60,ft,WinDrawLineF);
		    drawVSeg(38,60,ft,WinDrawLineF);
		    drawHSeg(11,79,ft,WinDrawLineF);
		    drawVSeg(10,80,ft,WinDrawLineF);
		    drawVSeg(38,80,ft,WinDrawLineF);
		    drawHSeg(11,99,ft,WinDrawLineF);
		}

		bigDigit(5,20,'2',WinDrawLineF);
		bigDigit(40,20,'5',WinDrawLineF);
		bigDigit(5,70,'7',WinDrawLineF);
		break;

	    case itemTest2:

		bigDigit(5,20,'8',WinEraseLineF);
		bigDigit(40,20,'8',WinEraseLineF);
		bigDigit(5,70,'8',WinEraseLineF);

		WinDrawChars("Hello",5,20,80);
		WinPaintChars("Paint",5,20,110);

		//Err err; err = TimInit();
		{
		    char buf[100];
		    int l=0;
		    UInt32 s,t;
		    UInt32 hour,min,sec;
		    UInt32 day;
		    // seconds since 1/1/1904
		    //void TimSetSeconds(UInt32 seconds) 	
		    // ticks since power on
		    t = TimGetTicks();
		    s = TimGetSeconds();
		    
		    l+=StrPrintF(buf+l, "Secs %lu", s);
		    FntSetFont(largeBoldFont);
		    WinPaintChars(buf,l,1,20);

		    l=0;
		    l+=StrPrintF(buf+l, "Ticks %lu", t);
		    FntSetFont(largeBoldFont);
		    WinPaintChars(buf,l,1,40);

		    day = s / (UInt32)(24 * 60 * 60);
		    s = s - day * (24 * 60 * 60);
		    hour = s / (60 * 60);
		    s = s - hour * (60 * 60);
		    min = s / 60;
		    sec = s - min * 60;
		    l=0;
		    l+=StrPrintF(buf+l, "%07d:%02d:%02d:%02d", day, hour,min,sec);
		    FntSetFont(largeBoldFont);
		    WinPaintChars(buf,l,1,60);

		}
		break;

		// call this periodically to hold off auto off  
		// Err EvtResetAutoOffTimer(void)

// SystemMgr.h
//Err SysTimerCreate(UInt32 *timerIDP, UInt32 *tagP, 
//            SysTimerProcPtr timerProc, UInt32 periodicDelay, UInt32	param)
//Err		SysTimerDelete(UInt32 timerID)
//Err		SysTimerWrite(UInt32 timerID, UInt32 value)
//Err		SysTimerRead(UInt32 timerID, UInt32 *valueP)

//      SysTaskDelay((100 * SysTicksPerSecond())/1000);

	    case itemOptHelp:
		FrmHelp(hlpHelp);
		break;
		//case itemOptDbgDump:
		//debugDump(e->eType);
		//break;
	    case itemOptCopy:
		FrmHelp(hlpCopy);
		break;
	    case itemOptAbout:
		FrmCustomAlert(alertInfo, 
			       "stopWatch v" VERSION " not even Alpha. "
			       "Built " __DATE__ ", " __TIME__ ". "
			       "James Coleman http://www.dspsrv.com/~jamesc "
			       "copyleft me.", "", "");
		break;

	}

	//DEBUGBOX("menuEvent","");

    	handled = true;
	break;

    case ctlSelectEvent:
	switch(e->data.ctlSelect.controlID) {

	    case btnRun:
		if (start_sec == 0) {
		    stopWatchPrefs.tik_timestamp =
			stopWatchPrefs.timestamp = 
			start_sec = TimGetSeconds();
		    start_tik = TimGetTicks();
		}
		RunCount(start_tik);
		break;
	    case btnHold:
		// break the run loop
		run = 0;
		break;
	    case btnStop:
		// break the run loop
		run = 0;
		end_sec = TimGetSeconds();
 		end_tik = TimGetTicks();
		break;
	    case btnClear:
		// break the run loop
		run = 0;
		stopWatchPrefs.timestamp = start_sec = 0;
		stopWatchPrefs.tik_timestamp = 0;
		end_tik = 0;
		drawCount(0);
		break;

	}
	break;

    //case ctlRepeatEvent:
    //break;

    case penDownEvent:
    case penMoveEvent:
      doPenAction( e->eType, e->screenX, e->screenY, 0, 0); 
      //FrmCustomAlert(alertInfo, "pen down", "ARGSTR1", "ARGSTR2");
      break;

    case penUpEvent:
      doPenAction( penUpEvent, 
      	   e->data.penUp.start.x, e->data.penUp.start.y, 
      	   e->data.penUp.end.x, e->data.penUp.end.y);
      break;

    case keyDownEvent:

      {
	char buf[1000];
	int l=0;
	l+=StrPrintF(buf+l, "Char: %c %02x\n",e->data.keyDown.chr,e->data.keyDown.chr);
	buf[l]=0;
	DEBUGBOX("keyDownEvent",buf);
      }

      switch(e->data.keyDown.chr) {
      case pageUpChr:
      case pageDownChr:
	handled = true;
	break;
      case prevFieldChr:
      case nextFieldChr:
      case '\n':
	handled = true;
	break;
      default:
	if (!TxtCharIsCntrl(e->data.keyDown.chr)) {
	  handled = true;                 /* Swallow event */
	}
	break;
      }
      break;

    default:
        break;
    }

    return handled;
}
Пример #15
0
datetime_t GetTimeDate()
{
    return PalmToDateTime(TimGetSeconds());
}
Пример #16
0
/***********************************************************************
 *
 * FUNCTION:    SelectTimeZone
 *
 * DESCRIPTION: Display a form showing a time zone and allow the user
 *              to select a different time zone. This is the time zone
 *					 dialog as seen in Date & Dime panel
 *
 * PARAMETERS:
 *		ioTimeZoneP				<->	pointer to time zone to change
 *		ioLocaleInTimeZoneP	<->	Ptr to locale found in time zone.
 *		titleP					 ->	String title for the dialog.
 *		showTimes				 -> 	True => show current and new times
 *		anyLocale				 ->	True => ignore ioLocaleInTimeZoneP on entry.
 *
 * RETURNED:
 *		true if the OK button was pressed (in which case *ioTimeZoneP and
 *		*ioCountryInTimeZoneP might be changed).
 *
 * HISTORY:
 *		03/02/00	peter	Created by Peter Epstein.
 *		04/03/00	peter	Allow NULL currentTimeP.
 *		04/12/00	peter API changed to get rid of trigger text
 *		04/14/00	peter Update current & new time as time passes
 *		07/31/00	kwk	Use SysTicksPerSecond() routine vs. sysTicksPerSecond macro.
 *					kwk	Re-wrote to use set of resources (name, offset, country),
 *							scrollbar vs. arrows, etc.
 *		08/01/00	kwk	Support scroll-to-key. Fixed scrollbar/list sync bugs.
 *		08/02/00	kwk	New API w/ioCountryInTimeZoneP and anyCountry parameters.
 *					kwk	Call FrmHandleEvent _after_ our event handling code has
 *							decided that it doesn't want to handle the event, not before.
 *		08/03/00	kwk	Call LstSetListChoices before calling LstGetVisibleItems,
 *							as otherwise accessing the time zone picker from the
 *							Setup app (when <showTimes> is false) gives you a two-
 *							line high display because LstGetVisibleItems returns 0.
 *		08/18/00	kwk	Play error sound if user writes letter that doesn't
 *							match any entries.
 *					kwk	Don't select item if doing scroll-to-view for entry
 *							that matches the letter the user wrote.
 *		08/21/00	kwk	Scroll-to-view with text entry now scrolls to the top
 *							of the list, versus the middle.
 *		10/09/00	peter	Get rid of scroll bar and let list do the scrolling.
 *		11/17/00	CS		Change ioCountryInTimeZoneP to ioLocaleInTimeZoneP,
 *							(and anyCountry to anyLocale, but that doesn't matter),
 *							since CountryType is only a UInt8, and this may
 *							change someday.
 *
 ***********************************************************************/
Boolean SelectTimeZone(Int16 *ioTimeZoneP, LmLocaleType* ioLocaleInTimeZoneP,
				const Char *titleP, Boolean showTimes, Boolean anyLocale)
{
	FormType* originalForm;
	FormType* dialog;
	EventType event;
	Boolean confirmed = false;
	Boolean done = false;
	Boolean adjustTimes = false;
	Boolean foundLocale = false;
	MemHandle currentTimeHandle, newTimeHandle;
	ListPtr listP;
	Int16 oldTimeZone, newTimeZone, testTimeZone;
	LmLocaleType newTimeZoneLocale;
	Int16 delta, closestDelta, timeZoneIndex, closestIndex;
	DateTimeType currentTime, newTime;
	TimeZoneEntryType* tzArrayP;
	UInt16 numTimeZones;
	MemHandle tzNamesH;
	
	if (showTimes)
	{
		TimSecondsToDateTime(TimGetSeconds(), &currentTime);
	}
	
	oldTimeZone = *ioTimeZoneP;
	newTimeZone = oldTimeZone;
	newTimeZoneLocale = *ioLocaleInTimeZoneP;
	
	originalForm = FrmGetActiveForm();
	dialog = (FormType *) FrmInitForm (TimeZoneDialogForm); 
	listP = FrmGetObjectPtr (dialog, FrmGetObjectIndex (dialog, TimeZoneDialogTimeZoneList));
	
	if (titleP)
	{
		FrmSetTitle (dialog, (Char *) titleP);
	}
	
	FrmSetActiveForm (dialog);
	
	// We need to call LstSetListChoices before calling LstSetHeight below, as otherwise
	// LstGetVisibleItems will return 0.
	tzArrayP = PrvCreateTimeZoneArray(&tzNamesH, &numTimeZones);
	LstSetListChoices(listP, (Char**)tzArrayP, numTimeZones);
	
	if (showTimes)
	{
		currentTimeHandle = MemHandleNew(timeStringLength + 1 + dowLongDateStrLength + 1);
		ErrFatalDisplayIf (!currentTimeHandle, "Out of memory");
		newTimeHandle = MemHandleNew(timeStringLength + 1 + dowLongDateStrLength + 1);
		ErrFatalDisplayIf (!newTimeHandle, "Out of memory");

		PrvSetTimeField(dialog, TimeZoneDialogCurrentTimeField, currentTimeHandle, &currentTime, false);
	}
	else
	{
		// Hide the current and new time.
		FrmHideObject(dialog, FrmGetObjectIndex (dialog, TimeZoneDialogCurrentTimeLabel));
		FrmHideObject(dialog, FrmGetObjectIndex (dialog, TimeZoneDialogCurrentTimeField));
		FrmHideObject(dialog, FrmGetObjectIndex (dialog, TimeZoneDialogNewTimeLabel));
		FrmHideObject(dialog, FrmGetObjectIndex (dialog, TimeZoneDialogNewTimeField));
		
		// Make the list show more items to take up extra the space.
		LstSetHeight(listP, LstGetVisibleItems(listP) + extraTimeZonesToShowWhenNoTimes);
	}
	
	// Find the time zone in the list closest to the current time zone, and that
	// matches <*ioLocaleInTimeZoneP> if <anyLocale> is false.
	closestDelta = hoursInMinutes * hoursPerDay;		// so big that all others will be smaller
	for (timeZoneIndex = 0; timeZoneIndex < numTimeZones; timeZoneIndex++)
	{
		Boolean checkDelta = anyLocale;
		testTimeZone = tzArrayP[timeZoneIndex].tzOffset;
		delta = Abs(testTimeZone - oldTimeZone);
		
		if (!anyLocale)
		{
			if (tzArrayP[timeZoneIndex].tzCountry == ioLocaleInTimeZoneP->country)
			{
				// If we haven't previously found a matching locale, reset the
				// delta so that this entry overrides any previous best entry.
				if (!foundLocale)
				{
					foundLocale = true;
					closestDelta = hoursInMinutes * hoursPerDay;
				}
				
				checkDelta = true;
			}
			
			// If we haven't yet found a matching locale, go for the closest delta.
			else
			{
				checkDelta = !foundLocale;
			}
		}
		
		// If we want to check the time zone delta, do it now.
		if (checkDelta && (delta < closestDelta))
		{
			closestIndex = timeZoneIndex;
			closestDelta = delta;
		}
	}
	
	// Scroll so that time zone is in the center of the screen and select it if it's an exact match.
	LstSetTopItem(listP, max(0, closestIndex - (LstGetVisibleItems(listP) / 2)));
	if ((closestDelta == 0) && (anyLocale || foundLocale))
	{
		LstSetSelection(listP, closestIndex);
		if (showTimes)
		{
			newTime = currentTime;
			PrvSetTimeField(dialog, TimeZoneDialogNewTimeField, newTimeHandle, &newTime, false);
		}
	}
	else
	{
		LstSetSelection(listP, noListSelection);
	}
	
	LstSetDrawFunction(listP, PrvTimeZoneListDrawItem);
	
	FrmDrawForm (dialog);
	
	while (!done)
	{
		Boolean handled = false;
		EvtGetEvent(&event, SysTicksPerSecond());		// so we can update the current and new time

		if (SysHandleEvent ((EventType *)&event))
		{
			continue;
		}
		
		if (event.eType == nilEvent)
		{
			if (showTimes)
			{
				PrvUpdateTimeFields(	dialog,
										&currentTime,
										&newTime,
										currentTimeHandle,
										newTimeHandle,
										TimeZoneDialogCurrentTimeField,
										TimeZoneDialogNewTimeField);
			}
		}
		
		else if (event.eType == ctlSelectEvent)
		{
			handled = true;
			
			switch (event.data.ctlSelect.controlID)
			{
				case TimeZoneDialogOKButton:
					// Set the new time zone.
					*ioTimeZoneP = newTimeZone;
					*ioLocaleInTimeZoneP = newTimeZoneLocale;

					done = true;
					confirmed = true;
				break;

				case TimeZoneDialogCancelButton:
					done = true;
				break;
				
				default:
					ErrNonFatalDisplay("Unknown control in form");
				break;
			}
		}
		
		// User tapped on a time zone in the list.
		else if (event.eType == lstSelectEvent)
		{
			UInt16 localeIndex;
			
			ErrNonFatalDisplayIf(event.data.lstSelect.listID != TimeZoneDialogTimeZoneList,
										"Unknown list in form");
			
			newTimeZone = tzArrayP[event.data.lstSelect.selection].tzOffset;
			newTimeZoneLocale.country =
				tzArrayP[event.data.lstSelect.selection].tzCountry;
			newTimeZoneLocale.language = lmAnyLanguage;
			if (LmLocaleToIndex(&newTimeZoneLocale, &localeIndex) == errNone)
			{
				if (LmGetLocaleSetting(	localeIndex,
												lmChoiceLocale,
												&newTimeZoneLocale,
												sizeof(newTimeZoneLocale)))
				{
					ErrNonFatalDisplay("Can\'t get locale");
				}
			}
			adjustTimes = showTimes;
			handled = true;
		}

		else if (event.eType == keyDownEvent)
		{
			if	(!TxtCharIsHardKey(event.data.keyDown.modifiers, event.data.keyDown.chr))
			{
				//	Hard scroll buttons
				if (EvtKeydownIsVirtual(&event))
				{
					if (event.data.keyDown.chr == vchrPageUp)
					{
						handled = true;
						LstScrollList(listP, winUp, LstGetVisibleItems(listP) - 1);
					}
					else if (event.data.keyDown.chr == vchrPageDown)
					{
						handled = true;
						LstScrollList(listP, winDown, LstGetVisibleItems(listP) - 1);
					}
				}
				else if (TxtCharIsPrint(event.data.keyDown.chr))
				{
					Int16 index;
					
					handled = true;
					index = PrvSearchTimeZoneNames(tzArrayP, numTimeZones, event.data.keyDown.chr);
					
					if (index != noListSelection)
					{
						Int16 delta = index - listP->topItem;
						if (delta < 0)
						{
							LstScrollList(listP, winUp, -delta);
						}
						else if (delta > 0)
						{
							LstScrollList(listP, winDown, delta);
						}
					}
					else
					{
						SndPlaySystemSound(sndError);
					}
				}
			}
		}

		else if (event.eType == appStopEvent)
		{
			EvtAddEventToQueue (&event);
			done = true;
			break;
		}
		
		// If we didn't handle the event, give the form code a crack at it.
		// This simulates the "normal" method of installing an event handler
		// for a form, which gets called, and then if it returns false, the
		// FrmHandleEvent routine gets called.
		if (!handled)
		{
			FrmHandleEvent(dialog, &event); 
		}
		
		// If something changed, and we need to update our time display,
		// do it now.
		if (adjustTimes)
		{
			adjustTimes = false;
			newTime = currentTime;
			TimAdjust(&newTime, (Int32)(newTimeZone - oldTimeZone) * minutesInSeconds);
			PrvSetTimeField(dialog, TimeZoneDialogNewTimeField, newTimeHandle, &newTime, true);
		}
	}	// end while true
		
	if (showTimes)
	{
		FldSetTextHandle(FrmGetObjectPtr (dialog, FrmGetObjectIndex (dialog, TimeZoneDialogCurrentTimeField)), NULL);
		FldSetTextHandle(FrmGetObjectPtr (dialog, FrmGetObjectIndex (dialog, TimeZoneDialogNewTimeField)), NULL);
		MemHandleFree(currentTimeHandle);
		MemHandleFree(newTimeHandle);
	}
	
	FrmEraseForm (dialog);
	FrmDeleteForm (dialog);
	FrmSetActiveForm(originalForm);

	PrvDeleteTimeZoneArray(tzArrayP, tzNamesH);

	return confirmed;
} // SelectTimeZone
Пример #17
0
Файл: gmi.c Проект: miellaby/v4p
Boolean startApplicativeLoop() {
   AlmSetProcAlarm(applicativeLoop,0,TimGetSeconds()+1);
   return success ;
}
Пример #18
0
Файл: Time.c Проект: ycheng/APDA
////////////////////////////////////////////////////////////////////////
// FUNCTION:    TimGetTicks
//
// DESCRIPTION: This routine return the tick count since the last reset.
//					 The tick count does not advance while the device is in
//					 sleep mode.
//
// PARAMETERS:  None.
//
// RETURNED:    Returns the tick count.
//
// REVISION HISTORY:
//			Name	Date		Description
//			----	----		-----------
//			Jerry	8/15/01	Initial Revision
////////////////////////////////////////////////////////////////////////
UInt32 TimGetTicks (void)
{
	UInt32	currentSeconds = TimGetSeconds ();

	return	currentSeconds-sysSecondsAfterReset;
}
Пример #19
0
Boolean Ln2SlFormHandleEvent(EventPtr e)
{
    Boolean handled = false;
    DateType dt = {0, 0};
    FormPtr frm = FrmGetFormPtr(Ln2SlForm);

    switch (e->eType) {
    case frmOpenEvent:
        if(gbVgaExists)
       		VgaFormModify(frm, vgaFormModify160To240);

        DateSecondsToDate(TimGetSeconds(), &dt);
        DateToAsciiLong(dt.month, dt.day, dt.year + 1904,
					gPrefdfmts, gAppErrStr);
        SetFieldTextFromStr(Ln2SlFormInput, gAppErrStr);

        FrmDrawForm(frm);
        handled = true;
        break;

    case ctlSelectEvent:
        switch(e->data.ctlSelect.controlID) {
        case Ln2SlFormOk:
            FrmReturnToForm(0);

            handled = true;
            break;

        case Ln2SlFormConvert:
        {
            HappyDaysFlag dummy;
            Int16 year, month, day;
            Char* input;
            int ret;
            
            input = FldGetTextPtr(GetObjectPointer(frm, Ln2SlFormInput));

            if ((ret = AnalysisHappyDays(input, &dummy,
                                         &year, &month, &day))) {
                int syear, smonth, sday;
                int leapyes
                    = CtlGetValue(GetObjectPointer(frm, Ln2SlFormInputLeap));

                ret = lunarL2S(lunarRefNum, year, month, day, leapyes, &syear, &smonth, &sday);
                if (ret == errNone) {
                    Char temp[15];
                    SysCopyStringResource(temp, DayOfWeek(smonth, sday, syear) + SunString);

                    DateToAsciiLong(smonth, sday, syear, gPrefdfmts, gAppErrStr);
                    StrNCat(gAppErrStr, " [", AppErrStrLen);
                    StrNCat(gAppErrStr, temp, AppErrStrLen);
                    StrNCat(gAppErrStr, "]", AppErrStrLen);

                    FldDrawField(SetFieldTextFromStr(Ln2SlFormResult, gAppErrStr));
                }
                else DisplayInvalidDateErrorString(Ln2SlFormResult);
            }
            else {
                DisplayInvalidDateErrorString(Ln2SlFormResult);
            }
            
            handled = true;
            break;
        }
        
        default:
            break;
                
        }
        break;

    case menuEvent:
        handled = TextMenuHandleEvent(e->data.menu.itemID, Ln2SlFormInput);
        break;

    default:
        break;
    }

    return handled;
}