VOID DrawClock (HPS hpsDraw) { RECTL rcl; WinQueryWindowRect (hwndClient, &rcl); WinFillRect (hpsBuffer, &rcl, cp.clrBackground); /* draw the face, the hour hand, and the minute hand */ ClkDrawRing (hpsDraw); ClkDrawFace (hpsDraw); ClkDrawDate (hpsDraw, DM_REDRAW); ClkDrawHand (hpsDraw, HT_HOUR_SHADE, dt.hours); ClkDrawHand (hpsDraw, HT_MINUTE_SHADE, dt.minutes); ClkDrawHand (hpsDraw, HT_HOUR, dt.hours); ClkDrawHand (hpsDraw, HT_MINUTE, dt.minutes); /* draw the tick marks */ if ((cp.usMajorTickPref == CLKTM_ALWAYS) || ((cp.usMajorTickPref == CLKTM_NOTICONIC) && ! fIconic)) ClkDrawTicks (hpsDraw, CLK_MAJORTICKS); if ((cp.usMinorTickPref == CLKTM_ALWAYS) || ((cp.usMinorTickPref == CLKTM_NOTICONIC) && !fIconic)) ClkDrawTicks (hpsDraw, CLK_MINORTICKS); }
/****************************************************************\ * Name:ClkTimer() * * Purpose: Handles window timer events * Returns: * 1 - if sucessful execution completed * 0 - if error \****************************************************************/ VOID ClkTimer (HWND hwnd) { /* if we must move the hour and minute hands, redraw it all */ if (dtNew.minutes != dt.minutes) { ClkDrawFace(hpsBuffer); ClkDrawDate(hpsBuffer, DM_REDRAW); ClkDrawHand(hpsBuffer, HT_HOUR_SHADE, dtNew.hours); ClkDrawHand(hpsBuffer, HT_MINUTE_SHADE, dtNew.minutes); ClkDrawHand(hpsBuffer, HT_HOUR, dtNew.hours); ClkDrawHand(hpsBuffer, HT_MINUTE, dtNew.minutes); UpdateScreen (hps, NULL); } }
/****************************************************************\ * *-------------------------------------------------------------- * * Name:ClkTimer() * * Purpose: Handles window timer events * * * * Usage: * * Method: * - * * - * - * * - * - * * Returns: * 1 - if sucessful execution completed * 0 - if error \****************************************************************/ VOID ClkTimer (HWND hwnd) { DATETIME dtNew; static LONG lTimeChangeCheck = 0L; LONG lTime; DosGetDateTime ( &dtNew ) ; if (cp.usDispMode & DM_ANALOG) { /* get the new time */ DosGetDateTime (&dtNew); /* adjust the hour hand */ dtNew.hours = (dtNew.hours * (UCHAR) 5 ) % (UCHAR) 60 + dtNew.minutes / (UCHAR)12; /* if we must move the hour and minute hands, redraw it all */ if (dtNew.minutes != dt.minutes) { ClkDrawFace(hpsBuffer); ClkDrawDate(hpsBuffer, DM_REDRAW); ClkDrawHand(hpsBuffer, HT_HOUR_SHADE, dtNew.hours); ClkDrawHand(hpsBuffer, HT_MINUTE_SHADE, dtNew.minutes); ClkDrawHand(hpsBuffer, HT_HOUR, dtNew.hours); ClkDrawHand(hpsBuffer, HT_MINUTE, dtNew.minutes); UpdateScreen (hps, NULL); if (fShowSecondHand && (cp.usDispMode & DM_SECONDHAND)) { GpiSetMix(hps, FM_INVERT); ClkDrawHand(hps, HT_SECOND, dtNew.seconds); } } /* otherwise just undraw the old second hand and draw the new */ else if (fShowSecondHand && (cp.usDispMode & DM_SECONDHAND)) { GpiSetMix(hps, FM_INVERT); ClkDrawHand(hps, HT_SECOND, dt.seconds); ClkDrawHand(hps, HT_SECOND, dtNew.seconds); } dt = dtNew ; } else /*Must be Digital*/ { DrawDigitalTime(hwnd); } /* *if this is the first *time through init it */ if(!lTimeChangeCheck) { time(&lTimeChangeCheck); } /* *a quick check to see if *any other session *adjusted our time *if so reset the timer */ else { time(&lTime); /* *did the clock get changed by more than 60 seconds */ if( lTime > ( lTimeChangeCheck + 60L ) || lTimeChangeCheck > ( lTime + 60L ) ) { AlarmSetTimer(cp.alarm.uchHour, cp.alarm.uchMinutes); } lTimeChangeCheck = lTime; } }