#include "cdk.h" #ifdef HAVE_XCURSES char *XCursesProgramName="template_ex"; #endif /* * This program demonstrates the Cdk template widget. */ int main (int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen = (CDKSCREEN *)NULL; CDKTEMPLATE *phoneNumber = (CDKTEMPLATE *)NULL; WINDOW *cursesWin = (WINDOW *)NULL; char *title = "Title"; char *label = "Phone Number:"; char *overlay = "(___) ___-____"; char *plate = "(###) ###-####"; char *info, *mixed, temp[256], *mesg[10]; /* Set up CDK*/ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors. */ initCDKColor(); /* Declare the template. */ phoneNumber = newCDKTemplate (cdkscreen, CENTER, CENTER, title, label, plate, overlay, TRUE, TRUE); /* Is the template pointer NULL? */ if (phoneNumber == (CDKTEMPLATE *)NULL) { /* Exit CDK. */ destroyCDKScreen (cdkscreen); endCDK(); /* Print out a message and exit. */ printf ("Oops. Can;'t seem to create template. Is the window too small?"); exit (1); } /* Activate the template. */ info = activateCDKTemplate (phoneNumber, (chtype *)NULL); /* Tell them what they typed. */ if (phoneNumber->exitType == vESCAPE_HIT) { mesg[0] = "You hit escape. No information typed in."; mesg[1] = "", mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 3); } else if (phoneNumber->exitType == vNORMAL) { /* Mix the plate and the number. */ mixed = mixCDKTemplate (phoneNumber); /* Create the message to display. */ sprintf (temp, "Phone Number with out plate mixing : %s", info); mesg[0] = copyChar (temp); sprintf (temp, "Phone Number with the plate mixed in: %s", mixed); mesg[1] = copyChar (temp); mesg[2] = ""; mesg[3] = "Press any key to continue."; popupLabel (cdkscreen, mesg, 4); freeChar (mesg[1]); } /* Clean up. */ destroyCDKTemplate (phoneNumber); destroyCDKScreen (cdkscreen); delwin (cursesWin); endCDK(); exit (0); }