#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] = "Course"; colwidth[1] = 7 ; colvalue[1] = vUMIXED; coltitle[2] = "Lec 1"; colwidth[2] = 7 ; colvalue[2] = vUMIXED; coltitle[3] = "Lec 2"; colwidth[3] = 7 ; colvalue[3] = vUMIXED; coltitle[4] = "Lec 3"; colwidth[4] = 7 ; colvalue[4] = vUMIXED; coltitle[5] = "Flag"; colwidth[5] = 1 ; colvalue[5] = vUMIXED; rowtitle[1] = "Course 1"; rowtitle[2] = "Course 2"; rowtitle[3] = "Course 3"; rowtitle[4] = "Course 4"; rowtitle[5] = "Course 5"; rowtitle[6] = "Course 6"; rowtitle[7] = "Course 7"; rowtitle[8] = "Course 8"; /* Create the title. */ title = "This is the CDK\nmatrix widget.\n<#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] = "You hit escape. No information passed back."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (courseList->exitType == vNORMAL) { mesg[0] = "You exited the matrix normally."; mesg[1] = "To get the contents of the matrix cell, you can"; mesg[2] = "dereference the info array off of the matrix widget."; mesg[3] = ""; mesg[4] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 5); } /* Clean up. */ destroyCDKMatrix (courseList); destroyCDKScreen (cdkscreen); delwin (cursesWin); endCDK(); exit (0); }