home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / c / pcw_c.zip / LDEMO.C < prev    next >
C/C++ Source or Header  |  1991-08-12  |  5KB  |  127 lines

  1. /**********************************************************/
  2. /* File Id.                  Ldemo.C                      */
  3. /* Author.                   Stan Milam.                  */
  4. /* Date Written              05/30/89.                    */
  5. /*                                                        */
  6. /* Comments: This is really a hack!  I took the test code */
  7. /* changed it around a little and integrated into a larger*/
  8. /* program.  Does not check for errors so beware!         */
  9. /**********************************************************/
  10.  
  11. #include <stdio.h>
  12. #include <pcwproto.h>
  13. #include <menu.h>
  14.  
  15. /* First set up arrays of type LMNUFLDS */
  16.  
  17. static LMNUFLDS menu1[] = {
  18.    { 'A', 2,  "Add",      "Add An Entry"},
  19.    { 'H', 15, "C(h)ange", "Change An Entry"},
  20.    { 'D', 30, "Delete",   "Delete An Entry"},
  21.    { NULL, NULL, NULL, NULL}
  22. };
  23.  
  24. static LMNUFLDS menu2[] = {
  25.    { 'S',  2, "Search", "Search For An Entry"},
  26.    { 'F', 16, "First",  "First Entry In Index"},
  27.    { 'L', 33, "Last",   "Last Entry In Index"},
  28.    { NULL, NULL, NULL, NULL}
  29. };
  30.  
  31. static LMNUFLDS menu3[] = {
  32.    { 'M',  2, "Methodology", "Multicam & Excelerator"},
  33.    { 'P', 15, "Pascal",      "Pascal Programming Environment"},
  34.    { 'C', 23, "C Language",  "C Programming Environment"},
  35.    { 'I', 35, "ITI",         "ITI Mainframe Commnuications"},
  36.    { NULL, NULL, NULL, NULL}
  37. };
  38.  
  39. static LMNUFLDS exit_menu[] = {
  40.    { 'E', 2, "Exit", "Esc or Right Mouse Key - Exit"},
  41.    { NULL, NULL, NULL, NULL}
  42. };
  43.  
  44. /* Now create an array of pointers back to our menus */
  45.  
  46. static LMNUFLDS *menus[] = {menu1, menu2, menu3, exit_menu, NULL};
  47.  
  48. /**********************************************************/
  49. /* LMNUTYPE is a structure that contains information for  */
  50. /* makelmenu() & lmenuinput().  It contains a pointer to a*/
  51. /* window, window parameters, titles....and finally a     */
  52. /* pointer to an array of pointers of LMNUFLDS.           */
  53. /**********************************************************/
  54.  
  55. static LMNUTYPE l_menu = {
  56.      NULL,                                     /* For Window Pointer */
  57.      15,20,18,60, BLUE,LIGHTGRAY,              /* Window parms */
  58.      DOUBLEALL, RED,LIGHTGRAY,                 /* Border Parms */
  59.      " A Sorta Lotus Menu ",                   /* The window title */
  60.      TOP, LEFT, BLACK,LIGHTGRAY,               /* Where title & color */
  61.      WHITE,BLUE,                               /* Selection bar color */
  62.      0,0,                                      /* Which menu & item */
  63.      menus                                     /* Point back to menus */
  64. };
  65.  
  66. static char *choices[] = {
  67.    "Add", "Change", "Delete",                  /* A table of messages */
  68.    "Search", "First", "Last",
  69.    "Methodology", "Pascal",
  70.    "C Langauge", "ITI"
  71. };
  72.  
  73. static char *instructions[] = {                /* Some instructions */
  74.    "To use this menu you may use the arrow keys, PgUp, PgDn,",
  75.    "Home and the End keys. More than one menu may be stacked",
  76.    "into one window, therefore, you may  page  through them.",
  77.    "Arrow to your selection and press enter, or  use the hot",
  78.    "character (usually the first character of the selection)",
  79.    "or use the Mouse.  You may use the Mouse to page through",
  80.    "the menus by clicking on the arrows at  either  side  of",
  81.    "the menu.  Play with it .... it will suprise you!       ",
  82.    NULL
  83. };
  84.  
  85. int lmenu_demo(void) {
  86.  
  87.     char   select = 0;
  88.     int    index, mxr, mxc;
  89.     WNDPTR *menuwnd, *savewnd, *iwnd;
  90.  
  91.     chk_video_state(&mxr, &mxc);
  92.     savewnd = wpush(1,1,mxr,mxc);                  /* Save entire screen */
  93.     bordercolor(BLUE, LIGHTGRAY);
  94.     titlecolor(RED,LIGHTGRAY); 
  95.     iwnd = wexplode(2,10,13,70,BLACK,LIGHTGRAY);
  96.     wtitle(iwnd,TOP,RITE," Lmenu Instructions ");
  97.     w_block_write(iwnd, 2, CENTER, instructions);
  98.     qputs(20, 30, WHITE, RED,"Your Choice: ");    /* Message line */
  99.     menuwnd = makelmenu(&l_menu);                /* Draw the menu */
  100.     while (select != 27 && select != 'E') {
  101.        select = lmenuinput(&l_menu);             /* Get return val from menu */
  102.        switch(select) {                          /* Make a decision */
  103.           case 'A' :  index = 0; break;          /* About our index to */
  104.           case 'H' :  index = 1; break;          /* Message table */
  105.           case 'D' :  index = 2; break;
  106.           case 'S' :  index = 3; break;
  107.           case 'F' :  index = 4; break;
  108.           case 'L' :  index = 5; break;
  109.           case 'M' :  index = 6; break;
  110.           case 'P' :  index = 7; break;
  111.           case 'C' :  index = 8; break;
  112.           case 'I' :  index = 9; break;
  113.           default  :  continue;
  114.        }
  115.        qhchar(20,43,LIGHTGRAY,BLUE,176,37);        /* Clear prev message */
  116.        qputs(20,43,BLUE,LIGHTGRAY,choices[index]); /* Write new one */
  117.     }
  118.  
  119.     if (mpresent) {                                /* If rat home */
  120.        hide_mouse();                               /* Hide it */
  121.     }
  122.     iwnd    = wpop(iwnd);                          /* Remove instructions */
  123.     menuwnd = wpop(menuwnd);
  124.     savewnd = wpop(savewnd);                       /* Remove trash */
  125.     return(0);
  126. }
  127.