~cfuhrman/+junk/netbsd-othersrc-trunk

« back to all changes in this revision

Viewing changes to dist/cdk/demos/stopSign.c

  • Committer: garbled
  • Date: 2001-01-04 19:59:48 UTC
  • Revision ID: svn-v4:288d5a72-fed7-e111-8680-000c29dcf8fe:trunk:174
Initial import of CDK 4.9.9.  The work to port this was performed by
Charles Hannum, and that is the version being imported:
cdk-4.9.9-20000407-myc3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <cdk.h>
 
2
 
 
3
#ifdef HAVE_XCURSES
 
4
char *XCursesProgramName="sillyness_ex";
 
5
#endif
 
6
 
 
7
int main(void)
 
8
{
 
9
   /* Declare variables. */
 
10
   CDKSCREEN *cdkscreen = 0;
 
11
   CDKLABEL *stopSign   = 0;
 
12
   CDKLABEL *title      = 0;
 
13
   WINDOW *cursesWin    = 0;
 
14
   int currentLight     = 0;
 
15
   char *mesg[5], *sign[4];
 
16
   chtype key;
 
17
 
 
18
   /* Set up CDK. */
 
19
   cursesWin = initscr();
 
20
   cdkscreen = initCDKScreen (cursesWin);
 
21
 
 
22
   /* Start CDK Colors. */
 
23
   initCDKColor();
 
24
 
 
25
   /* Set the labels up. */
 
26
   mesg[0] = "<C><#HL(40)>";
 
27
   mesg[1] = "<C>Press </B/16>r<!B!16> for the </B/16>red light";
 
28
   mesg[2] = "<C>Press </B/32>y<!B!32> for the </B/32>yellow light";
 
29
   mesg[3] = "<C>Press </B/24>g<!B!24> for the </B/24>green light";
 
30
   mesg[4] = "<C><#HL(40)>";
 
31
   sign[0] = " <#DI> ";
 
32
   sign[1] = " <#DI> ";
 
33
   sign[2] = " <#DI> ";
 
34
 
 
35
   /* Declare the labels. */
 
36
   title = newCDKLabel (cdkscreen, CENTER, TOP, mesg, 5, FALSE, FALSE);
 
37
   stopSign = newCDKLabel (cdkscreen, CENTER, CENTER, sign, 3, TRUE, TRUE);
 
38
 
 
39
   /* Do this until they hit q or escape. */
 
40
   while (1)
 
41
   {
 
42
      /* Draw the labels. */
 
43
      drawCDKLabel (title, FALSE);
 
44
      drawCDKLabel (stopSign, TRUE);
 
45
 
 
46
      key = waitCDKLabel (stopSign, 0);
 
47
      if (key == KEY_ESC || key == 'q' || key == 'Q')
 
48
      {
 
49
         break;
 
50
      }
 
51
      else if (key == 'r' || key == 'R')
 
52
      {
 
53
         sign[0] = "</B/16> <#DI> ";
 
54
         sign[1] = " <#DI> ";
 
55
         sign[2] = " <#DI> ";
 
56
         currentLight = 0;
 
57
      }
 
58
      else if (key == 'y' || key == 'Y')
 
59
      {
 
60
         sign[0] = " <#DI> ";
 
61
         sign[1] = "</B/32> <#DI> ";
 
62
         sign[2] = " <#DI> ";
 
63
         currentLight = 1;
 
64
      }
 
65
      else if (key == 'g' || key == 'G')
 
66
      {
 
67
         sign[0] = " <#DI> ";
 
68
         sign[1] = " <#DI> ";
 
69
         sign[2] = "</B/24> <#DI> ";
 
70
         currentLight = 2;
 
71
      }
 
72
 
 
73
      /* Set the contents of the label and re-draw it. */
 
74
      setCDKLabel (stopSign, sign, 3, TRUE);
 
75
   }
 
76
 
 
77
   /* Clean up. */
 
78
   destroyCDKLabel (title);
 
79
   destroyCDKLabel (stopSign);
 
80
   destroyCDKScreen (cdkscreen);
 
81
   delwin (cursesWin);
 
82
   endCDK();
 
83
   exit (0);
 
84
}