1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
/* $Id: clock.c,v 1.12 2025/01/09 00:20:21 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "label_ex";
#endif
int main (int argc, char **argv)
{
/* *INDENT-EQLS* */
CDKSCREEN *cdkscreen = NULL;
CDKLABEL *demo = NULL;
int boxLabel = 0;
const char *mesg[4];
char temp[256];
time_t clck;
int ret;
/* Parse up the command line. */
while ((ret = getopt (argc, argv, "b")) != -1)
{
switch (ret)
{
case 'b':
boxLabel = 1;
}
}
cdkscreen = initCDKScreen (NULL);
/* Start CDK Colors */
initCDKColor ();
/* Set the labels up. */
mesg[0] = "</1/B>HH:MM:SS";
/* Declare the labels. */
demo = newCDKLabel (cdkscreen, CENTER, CENTER,
(CDK_CSTRING2)mesg, 1,
boxLabel, FALSE);
/* Is the label null??? */
if (demo == NULL)
{
/* Clean up the memory. */
destroyCDKScreen (cdkscreen);
/* End curses... */
endCDK ();
printf ("Cannot create the label. Is the window too small?\n");
ExitProgram (EXIT_FAILURE);
}
curs_set (0);
wtimeout (WindowOf (demo), 50);
/* Do this for-a-while... */
do
{
struct tm *currentTime;
/* Get the current time. */
time (&clck);
currentTime = localtime (&clck);
/* Put the current time in a string. */
sprintf (temp, "<C></B/29>%02d:%02d:%02d",
currentTime->tm_hour,
currentTime->tm_min,
currentTime->tm_sec);
mesg[0] = copyChar (temp);
/* Set the label contents. */
setCDKLabel (demo, (CDK_CSTRING2)mesg, 1, ObjOf (demo)->box);
/* Draw the label, and sleep. */
drawCDKLabel (demo, ObjOf (demo)->box);
napms (500);
}
while (wgetch (WindowOf (demo)) == ERR);
/* Clean up */
destroyCDKLabel (demo);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}
|