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 91 92 93 94 95
|
#include "cdk.h"
#ifdef HAVE_XCURSES
char *XCursesProgramName="matrix_ex";
#endif
/*
* This program demonstrates the Cdk matrix widget.
*/
int main (int argc, char **argv)
{
/* Declare local variables. */
CDKSCREEN *cdkscreen = (CDKSCREEN *)NULL;
CDKMATRIX *courseList = (CDKMATRIX *)NULL;
WINDOW *cursesWin = (WINDOW *)NULL;
char *title = (char *)NULL;
int rows = 8;
int cols = 5;
int vrows = 3;
int vcols = 5;
int rowSpace = 1;
int colSpace = 1;
char *coltitle[10], *rowtitle[10], *mesg[100];
int colwidth[10], colvalue[10];
/* Set up CDK. */
cursesWin = initscr();
cdkscreen = initCDKScreen (cursesWin);
/* Start CDK Colors. */
initCDKColor();
/* Create the horizontal and vertical matrix labels. */
coltitle[1] = "</B/5>Course"; colwidth[1] = 7 ; colvalue[1] = vUMIXED;
coltitle[2] = "</B/33>Lec 1"; colwidth[2] = 7 ; colvalue[2] = vUMIXED;
coltitle[3] = "</B/33>Lec 2"; colwidth[3] = 7 ; colvalue[3] = vUMIXED;
coltitle[4] = "</B/33>Lec 3"; colwidth[4] = 7 ; colvalue[4] = vUMIXED;
coltitle[5] = "</B/7>Flag"; colwidth[5] = 1 ; colvalue[5] = vUMIXED;
rowtitle[1] = "</B/6>Course 1"; rowtitle[2] = "<C></B/6>Course 2";
rowtitle[3] = "</B/6>Course 3"; rowtitle[4] = "<L></B/6>Course 4";
rowtitle[5] = "</B/6>Course 5"; rowtitle[6] = "<R></B/6>Course 6";
rowtitle[7] = "</B/6>Course 7"; rowtitle[8] = "<R></B/6>Course 8";
/* Create the title. */
title = "<C>This is the CDK\n<C>matrix widget.\n<C><#LT><#HL(30)><#RT>";
/* Create the matrix object. */
courseList = newCDKMatrix (cdkscreen,
CENTER, CENTER,
rows, cols, vrows, vcols,
title, rowtitle, coltitle,
colwidth, colvalue,
-1, -1, '.',
COL, TRUE, TRUE, TRUE);
/* Check to see if the matrix is NULL. */
if (courseList == (CDKMATRIX *)NULL)
{
/* Clean up. */
destroyCDKScreen (cdkscreen);
endCDK();
/* Print out a little message. */
printf ("Oops. Can't seem to create the matrix widget. Is the window too small ?\n");
exit (1);
}
/* Activate the matrix. */
activateCDKMatrix (courseList, (chtype *)NULL);
/* Check if the user hit escape or not. */
if (courseList->exitType == vESCAPE_HIT)
{
mesg[0] = "<C>You hit escape. No information passed back.";
mesg[1] = "",
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, mesg, 3);
}
else if (courseList->exitType == vNORMAL)
{
mesg[0] = "<C>You exited the matrix normally.";
mesg[1] = "<C>To get the contents of the matrix cell, you can";
mesg[2] = "<C>dereference the info array off of the matrix widget.";
mesg[3] = "";
mesg[4] = "<C>Press any key to continue.";
popupLabel (cdkscreen, mesg, 5);
}
/* Clean up. */
destroyCDKMatrix (courseList);
destroyCDKScreen (cdkscreen);
delwin (cursesWin);
endCDK();
exit (0);
}
|