/* $Id: swindow_ex.c,v 1.14 2016/12/04 15:22:16 tom Exp $ */ #include #ifdef HAVE_XCURSES char *XCursesProgramName = "swindow_ex"; #endif #if !defined (HAVE_SLEEP) && defined (_WIN32) /* Mingw */ #define sleep(x) _sleep(x*1000) #endif /* * Demonstrate a scrolling-window. */ int main (int argc, char **argv) { /* *INDENT-EQLS* */ CDKSCREEN *cdkscreen = 0; CDKSWINDOW *swindow = 0; const char *title = "Error Log"; const char *mesg[5]; CDK_PARAMS params; CDKparseParams (argc, argv, ¶ms, CDK_CLI_PARAMS); cdkscreen = initCDKScreen (NULL); /* Start CDK colors. */ initCDKColor (); /* Create the scrolling window. */ swindow = newCDKSwindow (cdkscreen, CDKparamValue (¶ms, 'X', CENTER), CDKparamValue (¶ms, 'Y', CENTER), CDKparamValue (¶ms, 'H', 6), CDKparamValue (¶ms, 'W', 65), title, 100, CDKparamValue (¶ms, 'N', TRUE), CDKparamValue (¶ms, 'S', FALSE)); /* Is the window null. */ if (swindow == 0) { /* Exit CDK. */ destroyCDKScreen (cdkscreen); endCDK (); printf ("Cannot create the scrolling window. "); printf ("Is the window too small?\n"); ExitProgram (EXIT_FAILURE); } /* Draw the scrolling window. */ drawCDKSwindow (swindow, ObjOf (swindow)->box); /* Load up the scrolling window. */ addCDKSwindow (swindow, "TOP: This is the first line.", BOTTOM); addCDKSwindow (swindow, "Sleeping for 1 second.", BOTTOM); sleep (1); addCDKSwindow (swindow, "1: This is another line.", BOTTOM); addCDKSwindow (swindow, "Sleeping for 1 second.", BOTTOM); sleep (1); addCDKSwindow (swindow, "2: This is another line.", BOTTOM); addCDKSwindow (swindow, "Sleeping for 1 second.", BOTTOM); sleep (1); addCDKSwindow (swindow, "3: This is another line.", BOTTOM); addCDKSwindow (swindow, "Sleeping for 1 second.", BOTTOM); sleep (1); addCDKSwindow (swindow, "4: This is another line.", BOTTOM); addCDKSwindow (swindow, "Sleeping for 1 second.", BOTTOM); sleep (1); addCDKSwindow (swindow, "5: This is another line.", BOTTOM); addCDKSwindow (swindow, "Sleeping for 1 second.", BOTTOM); sleep (1); addCDKSwindow (swindow, "6: This is another line.", BOTTOM); addCDKSwindow (swindow, "Sleeping for 1 second.", BOTTOM); sleep (1); addCDKSwindow (swindow, "Done. You can now play.", BOTTOM); addCDKSwindow (swindow, "This is being added to the top.", TOP); /* Activate the scrolling window. */ activateCDKSwindow (swindow, 0); /* Check how the user exited this widget. */ if (swindow->exitType == vESCAPE_HIT) { mesg[0] = "You hit escape to leave this widget."; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3); } else if (swindow->exitType == vNORMAL) { mesg[0] = "You hit return to exit this widget."; mesg[1] = ""; mesg[2] = "Press any key to continue."; popupLabel (cdkscreen, (CDK_CSTRING2) mesg, 3); } /* Clean up. */ destroyCDKSwindow (swindow); destroyCDKScreen (cdkscreen); endCDK (); ExitProgram (EXIT_SUCCESS); }