home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
IDLECLK.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-31
|
2KB
|
88 lines
/*
idleclk.c 11/05/88
% idle_Clock
Keyboard Idle clock function.
Places a clock window in the bottom ot the display
C-scape 3.2
Copyright (c) 1988, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
7/24/89 gam Fixed for mouse. Now paints only when necessary
3/28/90 jmd ansi-fied
5/17/90 jmd modified for new kb_Idle scheme
10/16/90 jmd added cast to menu_Printf for DG
10/25/90 jmd sed_Top is now called every second
11/31/90 ted added oak_notused call in idle_Clock().
*/
#include <stdio.h>
#include "cscape.h"
#include <time.h>
#include "cstime.h"
#include "kbidle.h"
#include "scancode.h" /* for KEY_NONE */
int idle_Clock(int msg, unsigned wait)
/*
Places a clock in a window.
*/
{
menu_type menu;
static sed_type timesed = NULL;
static struct tm t;
static short oldsec;
oak_notused(wait);
switch (msg) {
case IDLE_START:
/* create timesed */
/* this is called when kb_Idle first sets up the idle func */
menu = menu_Open();
menu_Printf(menu, "@f[##:##:##]", (VOID *) &t, &time_funcs);
menu_Flush(menu);
timesed = sed_Open(menu);
sed_SetPosition(timesed, disp_GetHeight() - 1, disp_GetWidth() - 10);
/* Get current time */
tm_Now(&t);
oldsec = (short)t.tm_sec;
/* Paint the sed */
sed_Repaint(timesed);
break;
case IDLE_CHECK:
case IDLE_READ:
/* Get current time */
tm_Now(&t);
/* Paint the field */
if (oldsec != t.tm_sec) {
oldsec = (short)t.tm_sec;
sed_RepaintField(timesed, 0);
/* Make sure window is visible */
sed_Top(timesed);
}
break;
case IDLE_STOP:
/* Destroy the sed */
sed_Close(timesed);
break;
}
return(KEY_NONE);
}