~cfuhrman/+junk/netbsd-othersrc-trunk

« back to all changes in this revision

Viewing changes to dist/cdk/examples/matrix_ex.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="matrix_ex";
 
5
#endif
 
6
 
 
7
/*
 
8
 * This program demonstrates the Cdk matrix widget.
 
9
 */
 
10
int main (void)
 
11
{
 
12
   /* Declare local variables. */
 
13
   CDKSCREEN *cdkscreen         = 0;
 
14
   CDKMATRIX *courseList        = 0;
 
15
   WINDOW *cursesWin            = 0;
 
16
   char *title                  = 0;
 
17
   int rows                     = 8;
 
18
   int cols                     = 5;
 
19
   int vrows                    = 3;
 
20
   int vcols                    = 5;
 
21
   char *coltitle[10], *rowtitle[10], *mesg[100];
 
22
   int colwidth[10], colvalue[10];
 
23
 
 
24
   /* Set up CDK. */
 
25
   cursesWin = initscr();
 
26
   cdkscreen = initCDKScreen (cursesWin);
 
27
 
 
28
   /* Start CDK Colors. */
 
29
   initCDKColor();
 
30
 
 
31
   /* Create the horizontal and vertical matrix labels. */
 
32
   coltitle[1] = "</B/5>Course";   colwidth[1] = 7 ; colvalue[1] = vUMIXED;
 
33
   coltitle[2] = "</B/33>Lec 1";   colwidth[2] = 7 ; colvalue[2] = vUMIXED;
 
34
   coltitle[3] = "</B/33>Lec 2";   colwidth[3] = 7 ; colvalue[3] = vUMIXED;
 
35
   coltitle[4] = "</B/33>Lec 3";   colwidth[4] = 7 ; colvalue[4] = vUMIXED;
 
36
   coltitle[5] = "</B/7>Flag";     colwidth[5] = 1 ; colvalue[5] = vUMIXED;
 
37
   rowtitle[1] = "</B/6>Course 1"; rowtitle[2] = "<C></B/6>Course 2";
 
38
   rowtitle[3] = "</B/6>Course 3"; rowtitle[4] = "<L></B/6>Course 4";
 
39
   rowtitle[5] = "</B/6>Course 5"; rowtitle[6] = "<R></B/6>Course 6";
 
40
   rowtitle[7] = "</B/6>Course 7"; rowtitle[8] = "<R></B/6>Course 8";
 
41
 
 
42
   /* Create the title. */
 
43
   title = "<C>This is the CDK\n<C>matrix widget.\n<C><#LT><#HL(30)><#RT>";
 
44
 
 
45
   /* Create the matrix object. */
 
46
   courseList = newCDKMatrix (cdkscreen,
 
47
                                CENTER, CENTER,
 
48
                                rows, cols, vrows, vcols,
 
49
                                title, rowtitle, coltitle,
 
50
                                colwidth, colvalue,
 
51
                                -1, -1, '.',
 
52
                                COL, TRUE, TRUE, TRUE);
 
53
 
 
54
   /* Check to see if the matrix is null. */
 
55
   if (courseList == 0)
 
56
   {
 
57
      /* Clean up. */
 
58
      destroyCDKScreen (cdkscreen);
 
59
      endCDK();
 
60
 
 
61
      /* Print out a little message. */
 
62
      printf ("Oops. Can't seem to create the matrix widget. Is the window too small ?\n");
 
63
      exit (1);
 
64
   }
 
65
 
 
66
   /* Activate the matrix. */
 
67
   activateCDKMatrix (courseList, 0);
 
68
 
 
69
   /* Check if the user hit escape or not. */
 
70
   if (courseList->exitType == vESCAPE_HIT)
 
71
   {
 
72
      mesg[0] = "<C>You hit escape. No information passed back.";
 
73
      mesg[1] = "",
 
74
      mesg[2] = "<C>Press any key to continue.";
 
75
      popupLabel (cdkscreen, mesg, 3);
 
76
   }
 
77
   else if (courseList->exitType == vNORMAL)
 
78
   {
 
79
      mesg[0] = "<C>You exited the matrix normally.";
 
80
      mesg[1] = "<C>To get the contents of the matrix cell, you can";
 
81
      mesg[2] = "<C>dereference the info array off of the matrix widget.";
 
82
      mesg[3] = "";
 
83
      mesg[4] = "<C>Press any key to continue.";
 
84
      popupLabel (cdkscreen, mesg, 5);
 
85
   }
 
86
 
 
87
   /* Clean up. */
 
88
   destroyCDKMatrix (courseList);
 
89
   destroyCDKScreen (cdkscreen);
 
90
   delwin (cursesWin);
 
91
   endCDK();
 
92
   exit (0);
 
93
}