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

  1. /***************************************************************/
  2. /* File Id.                     PCW_DEMO.C.                    */
  3. /* Author.                      Chris Balthrop.                */
  4. /*                              Stan Milam.                    */
  5. /* Date Written.                ??/??/??.                      */
  6. /*                                                             */
  7. /*             (c) Copyright 1991 by Chris Baltrop.            */
  8. /*             (c) Copyright 1991 by Stan Milam.               */
  9. /*                                                             */
  10. /* This program is a demonstration of some of the amazing cap- */
  11. /* bilities of the PC Windows Library by Stan Milam.  Make use */
  12. /* of the menus and make extensive use of the tmenu() function.*/
  13. /*                                                             */
  14. /***************************************************************/
  15.  
  16. /* === includes ======================================== */
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <dos.h>
  20. #include <conio.h>
  21. #include <ctype.h>
  22.  
  23. #include "pcwproto.h"
  24. #include "menu.h"
  25. #include "files.h"
  26.  
  27. /* === defines ========================================= */
  28. #define FALSE 0
  29. #define TRUE  1
  30. #define ESC 0x1B
  31. #define EVER ;;
  32.  
  33. #ifndef MK_FP
  34.    #define MK_FP(seg,off)  (void far *)(((long)seg << 16L) | ((long)off))
  35.    #define clrscr()  puts("\x1B[2J")
  36.    #define getche()  (char)getche()
  37. #endif
  38.  
  39.    /* pc hardware def's */
  40. #define SCROLL_LOCK (unsigned char far *)0x00400017L
  41. #define SCRN_BUF  (unsigned char far *)0xB8000000L
  42. #define SCRN_SEG 0xB800
  43. #define SCRN_OFF 0x0000
  44.  
  45. /* === global variables ================================ */
  46. char cmdbuf[80];
  47. int err_code;
  48.  
  49. char *sptr,*eptr,str[80];
  50.  
  51.    /* --- pc global vars --- */
  52. struct PTRS
  53. {
  54.    unsigned int mem_tmp;
  55.    unsigned int mem_seg;
  56.    unsigned int mem_off;
  57.    unsigned char far *mem;
  58.    unsigned char far *tmp;
  59. } ptrs;
  60.  
  61. /* static union REGS inregs,outregs;
  62.    static struct SREGS segregs; */
  63.  
  64. /* === prototypes ====================================== */
  65. char get_a_cmd(void);
  66. void do_a_cmd(char cmd);
  67. int get_hex(char *inptr);
  68. void wait_for_something(void); /* wait for key or mse */
  69.  
  70.  
  71. void cmd_b(void);      /* test function Bar */
  72. void cmd_e(void);      /* Edit command */
  73. void cmd_h(void);      /* Help command */
  74. void cmd_k(void);      /* test picKlist style menu's */
  75. void cmd_l(void);      /* test Lotus style menu's */
  76. void cmd_r(void);      /* show PCW_QREF.TXT */
  77. void cmd_p(void);      /* test Pop-up menu's */
  78. void cmd_t(void);      /* test Top style menu's */
  79. void cmd_x(void);      /* ? */
  80. int  demos_menu(void);
  81.  
  82. static char *intromsg[] = {
  83.    "PC Windows!  PCW is a windowing package written in C for C",
  84.    "using the IBM family of personal  computers and  100% true",
  85.    "compatibles.  PCW supports Microsoft C 5.0+, Turbo C 1.5+,",
  86.    "and MIX POWER C 1.3+.  PCW  not only supports windows.....",
  87.    "it features automatic sensing of the adapter & monitor  in",
  88.    "use.  It also does  QUICK  screen  writes (NO SNOW ON CGA)",
  89.    "with functions like qprintf() & qputs(). Also featured are",
  90.    "popup menus & a variation of the famous  Lotus  menu  with",
  91.    "MOUSE support.  In short, PCW gives  you  control  and all",
  92.    "the video power you can use.  Best of all, PCW is targeted",
  93.    "as FREEWARE software!   Press a key and let's take a look.",
  94.    NULL
  95. };
  96.  
  97. static char *menumsg[] = {
  98.    "Chris Balthop and I  have  prepared a little demo  for  you.",
  99.    "We are using the built-in menus of PC Windows to demonstrate",
  100.    "just how powerful PC Windows is.   We feature the menus  be-",
  101.    "cause they demonstrate many of  the  capabilites of PCW.  We",
  102.    "hope you enjoy the show.  So use your keyboard or your mouse",
  103.    "and watch PC Windows do its stuff.                          ",
  104.    NULL
  105. };
  106.  
  107. static char *goodby[] = {
  108.    "Well, I have labored long and hard to bring you PC Windows",
  109.    "and I hope you enjoy it.  After much thought and consider-",
  110.    "ation I have decided to let PCW be FREEWARE so enjoy!!!!  ",
  111.    NULL
  112. };
  113.  
  114. static char *copyright[] = {
  115.    "PC Windows",
  116.    "(c) Copyright 1989, 1990, 1991, 1992",
  117.    "by",
  118.    "Stan Milam",
  119.    NULL
  120. };
  121.  
  122.  
  123. /* === main() ========================================== */
  124. int main(void)
  125. {
  126.    int tl, bl;
  127.    int        i = 0;
  128.    WNDPTR *menuwnd, *msgwnd;
  129.  
  130.    static TMNUFLDS mainmenu1[] =
  131.       /* select_key, select_col, *item */
  132.       {{ 'F',  2, "Files"    },
  133.        { 'D', 15, "Demos"    },
  134.        { 'E', 27, "Edit"     },
  135.        { 'R', 38, "quickRef" },
  136.        { 'H', 55, "Help"     },
  137.        { 'Q', 70, "Quit"     },
  138.        {  0,   0,  NULL      }};
  139.  
  140.    static TMNUFLDS mainmenu2[] =
  141.       /* select_key, select_col, *item */
  142.       {{ 'L',  2, "Lmenu"         },
  143.        { 'P', 19, "Pmenu"         },
  144.        { 'K', 33, "picKlist menu" },
  145.        { 'T', 54, "Tmenu"         },
  146.        { 'B', 69, "funcBar"       },
  147.        {  0,   0,  NULL           }};
  148.  
  149.    static TMNUFLDS *mainmenulist[] = {mainmenu1, mainmenu2, NULL};
  150.  
  151.    static TMNUTYPE mainmenu =
  152.       { NULL,                              /* previous window pointer */
  153.         1, 1, 3, 80,                       /* urow, ucol, lrow, lcol  */
  154.         YELLOW, BLUE,                      /* fcolor, bcolor          */
  155.         SINGLEALL,LIGHTGRAY,BLUE,          /* btype, bfcolor, bbcolor */
  156.         " PCW_DEMO ",                      /* *title                  */
  157.         TOP,MIDDLE,WHITE,BLUE,      /* tvloc, thloc, tfcolor, tbcolor */
  158.         YELLOW,MAGENTA,                    /* cfcolor, cbcolor        */
  159.         0,0,mainmenulist };                /* bar_pos, wnd_pos, **tlist */
  160.  
  161.    /* --- coldstart --- */
  162.    vcls();
  163.    get_cursor_size(&tl, &bl);
  164.    set_cursor_size(0, 0);
  165.  
  166.    /* --- warmstart --- */
  167.    init_mouse();
  168.    menuwnd = maketmenu(&mainmenu);
  169.  
  170.    if ( mpresent ) hide_mouse();
  171.    bordercolor( BLUE, BLACK );
  172.    msgwnd = wexplode(6,8,20,72,YELLOW,BLACK);
  173.    w_block_write(msgwnd, 2, CENTER, intromsg);
  174.    keywait(30);
  175.    clr_wnd( msgwnd, 1 );
  176.    w_block_write(msgwnd, 4, CENTER, menumsg);
  177.    keywait(30);
  178.    clr_wnd(msgwnd, 1);
  179.    whide( msgwnd );
  180.    if ( mpresent ) show_mouse();
  181.  
  182.    while (i != 'Q') {
  183.       i = tmenuinput(&mainmenu);
  184.       switch(i) {
  185.          case 'B' : cmd_b(); break;
  186.          case 'D' : demos_menu(); break;
  187.          case 'E' : cmd_e(); break;
  188.          case 'F' : files_menu(); break;
  189.          case 'H' : cmd_h(); break;
  190.          case 'K' : cmd_k(); break;
  191.          case 'L' : cmd_l(); break;
  192.          case 'R' : cmd_r(); break;
  193.          case 'P' : cmd_p(); break;
  194.          case 'T' : cmd_t(); break;
  195.          case 'Q' : continue;
  196.       }
  197.    }
  198.    if (mpresent) hide_mouse();
  199.    wshow( msgwnd );
  200.    w_block_write( msgwnd, 3, CENTER, goodby );
  201.    set_wnd_attr( msgwnd, RED, BLACK );
  202.    w_block_write( msgwnd, 8, CENTER, copyright);
  203.    keywait( 30 );
  204.    msgwnd = wpop( msgwnd );
  205.    menuwnd = wpop(menuwnd);
  206.  
  207.    /* --- system close --- */
  208.    init_mouse();
  209.  
  210.    /* --- quit --- */
  211.    vcls();
  212.    set_cursor_size(tl, bl);
  213.    puts("---bye---\n");
  214.    return(0);
  215. }
  216. /* --- end main() -------------------------------------- */
  217.  
  218.  
  219. /* === get_hex() ======================================= */
  220. int get_hex(char *inptr) /* convert ascii at inptr to hex */
  221. {
  222.    int i;
  223.    char strbuf[7];
  224.    char *strptr,*endptr;
  225.    strptr = &strbuf[0];
  226.    *strptr++ = '0';    /* stuff in 0x so i don't have to */
  227.    *strptr++ = 'x';
  228.    i = 2;
  229.    while( *inptr == ' ') inptr++;       /* ignore spaces */
  230.    while(*inptr && (i<6))         /* copy up to 6 char's */
  231.    {
  232.       *strptr++ = *inptr++;
  233.       i++;
  234.    }
  235.    *strptr = 0;                  /* terminate str with 0 */
  236.    strptr = &strbuf[0];                 /* reset pointer */
  237.    i = (int)strtol(strptr,&endptr,16);        /* convert */
  238.    if(endptr <= &strbuf[2]) err_code = 1; /* test for err */
  239.    return(i);
  240. }
  241. /* --- end get_hex() ----------------------------------- */
  242.  
  243.  
  244. /* === cmd_b() ========================================= */
  245. void cmd_b(void)   /* display function bar */
  246. {
  247.     int row, col, bstatus, done;
  248.     static char *funcs =
  249.        "F1-help   F2-edit   F3-options   F4-next"
  250.        "    F5-goto   F6-zoom          <ESC>quit";
  251.     if (mpresent) hide_mouse();
  252.     qputs(25, 1, YELLOW, BLUE, funcs);
  253.     if (mpresent) show_mouse();
  254.  
  255.     for(done = 0; !done; )          /*wait for something */
  256.     {
  257.        if(keypressed()) { keybrd_flush(); done++; }
  258.        if(mpresent)
  259.        {
  260.           if(get_mpressed(RITEM)) done++;
  261.           if(get_mpressed(LEFTM)) done++;
  262.           get_mpos(&row, &col, &bstatus);
  263.        }
  264.     }
  265.  
  266.     if(mpresent) hide_mouse();
  267.     qfill(25,  1, 25, 80, WHITE, BLACK, SPACES);
  268.     if(mpresent) show_mouse();
  269.  
  270. }
  271. /* --- end cmd_b() ------------------------------------- */
  272.  
  273.  
  274. /* === cmd_e() ========================================= */
  275. void cmd_e(void)   /* Edit cmd */
  276. {
  277.     int row, col, bstatus, done;
  278.     if(mpresent) hide_mouse();
  279.     qputs(12,CENTER,WHITE,BLACK, "call Edit()");
  280.     if(mpresent) show_mouse();
  281.  
  282.     for(done = 0; !done; )          /*wait for something */
  283.     {
  284.        if(keypressed()) { keybrd_flush(); done++; }
  285.        if(mpresent)
  286.        {
  287.           if(get_mpressed(RITEM)) done++;
  288.           if(get_mpressed(LEFTM)) done++;
  289.           get_mpos(&row, &col, &bstatus);
  290.        }
  291.     }
  292.  
  293.     if(mpresent) hide_mouse();
  294.     qputs(12,CENTER,WHITE,BLACK, "           ");
  295.     if(mpresent) hide_mouse();
  296. }
  297. /* --- end cmd_e() ------------------------------------- */
  298.  
  299.  
  300. /* === cmd_h() ========================================= */
  301. void cmd_h(void)   /* help command */
  302. {
  303.    int row, col, bstatus, done;
  304.    WNDPTR *wnd;
  305.    static char *helpmsg[] =
  306.    { "wframe(), wtitle(), and w_block_write() can be used to",
  307.      "create pop-up help screens",
  308.      "",
  309.      "The following commands are valid   ",
  310.      "   b ---- make function Bar        ",
  311.      "   d ---- Pulldown Demos Menu      ",
  312.      "   e ---- Edit a file              ",
  313.      "   f ---- do Files stuff           ",
  314.      "   h,? -- Help (print this message)",
  315.      "   k ---- picKlist menu demo       ",
  316.      "   l ---- Lotus menu demo          ",
  317.      "   p ---- Pop up-menu demo         ",
  318.      "   q ---- Quit pcw_demo            ",
  319.      "   r ---- show pcw_qRef.txt        ",
  320.      "   t ---- Top menu demo            ",
  321.      " ", " ", "Press any key to return", "", NULL };
  322.    bordercolor(LIGHTBLUE,BLACK);
  323.    titlecolor(WHITE,RED);
  324.    if(mpresent) hide_mouse();
  325.    wnd = wframe(5, 5, 23, 75,YELLOW,BLACK);
  326.    if(wnd == NULL) return;
  327.    wtitle(wnd, TOP,LEFT," Friendly Help ");
  328.    w_block_write(wnd,2,CENTER,helpmsg);
  329.    if(mpresent) show_mouse();
  330.  
  331.    for(done = 0; !done; )          /*wait for something */
  332.    {
  333.       if(keypressed()) { keybrd_flush(); done++; }
  334.       if(mpresent)
  335.       {
  336.          if(get_mpressed(RITEM)) done++;
  337.          if(get_mpressed(LEFTM)) done++;
  338.          get_mpos(&row, &col, &bstatus);
  339.       }
  340.    }
  341.  
  342.    if(mpresent) hide_mouse();
  343.    wpop(wnd);
  344.    if(mpresent) show_mouse();
  345. }
  346. /* --- end cmd_h() ------------------------------------- */
  347.  
  348. /* === cmd_k() ========================================= */
  349. void cmd_k(void)   /* Test picKlist style menu's */
  350. {
  351.    WNDPTR *wnd, *savewnd, *iwnd;
  352.  
  353. /***********************************************************/
  354. /* Create and initialize the pick-list menu values.        */
  355. /***********************************************************/
  356.  
  357. static char *selections[] = {
  358.     "Methodology",
  359.     "Word Processors",
  360.     "C Compiler",
  361.     "Pascal Compiler",
  362.     "3270 Emulation",
  363.     "Communications",
  364.     "COBOL Compiler",
  365.     "MASM",
  366.     NULL
  367. };
  368.  
  369. /**********************************************************/
  370. /* PICKLIST contains elements concerning a picklist menu. */
  371. /* First, there is a pointer to the window to be used,    */
  372. /* then window parameters, border parms, title parms,     */
  373. /* selection bar parms, and finally a pointer back to our */
  374. /* menu options.                                          */
  375. /**********************************************************/
  376.  
  377.     static PICKLIST plmenu =  {
  378.        NULL,
  379.        15, 30, 19, 50, BLACK,LIGHTGRAY,          /* Window Parms */
  380.        2, RED,LIGHTGRAY,                         /* Border Parms */
  381.        " Main Menu ",TOP,MIDDLE,BLUE,LIGHTGRAY,  /* Title  Parms */
  382.        WHITE,BLUE,                               /* Select Bar color  */
  383.        selections,                               /* pointer to menu list */
  384.        0,0                                       /* bar position offset */
  385.     };
  386.  
  387.     static char *instructions[] = {
  388.        "To use  the Pick  List Menu  use the \30\31 arrow  keys,",
  389.        "to place the cursor  bar on  the  desired  selection",
  390.        "and then press  enter.  Or, use the Mouse  to  point",
  391.        "and shoot the  selection you want.  ESC or the right",
  392.        "Mouse  key will end the demo.   There  may  be  more",
  393.        "picks  than can be shown in the window. You may  use",
  394.        "the arrow  keys or the Mouse to scroll them.        ",
  395.        NULL
  396.     };
  397.  
  398.    int i = 0;
  399.    int mxr, mxc;
  400.  
  401.    chk_video_state(&mxr,&mxc);                   /* Get max rows & cols */
  402.    if (mpresent) hide_mouse();                   /* Hide mouse */
  403.    savewnd = wpush(1,1,mxr,mxc);                 /* Save entire screen */
  404.    if (!savewnd) return;                         /* Exit if cannot save */
  405.    bordercolor(BLUE,LIGHTGRAY);                  /* Set border color */
  406.    titlecolor(BLACK,LIGHTGRAY);                  /* Set the title color */
  407.    iwnd = wexplode(2,10,12,70,RED,LIGHTGRAY);    /* Make instruction window */
  408.    wtitle(iwnd,TOP,LEFT," Pick List Menu Instructions "); /* Title it */
  409.    w_block_write(iwnd, 2, CENTER,instructions);  /* Write instructions to it */
  410.    wnd = make_pick_list(&plmenu);                /* Make a popup window */
  411.    if (mpresent) show_mouse();                   /* Show mouse */
  412.    while (i != -1) {                             /* Do until Esc */
  413.       i = get_pick_list(&plmenu);                /* Get Menu return value */
  414.       if ( i == -1 ) continue;
  415.       if (mpresent) hide_mouse();
  416.       qhchar(22,1,BLACK,BLACK,32,80);            /* Clear msg line */
  417.       qputs(22,99,RED,7,selections[i]);          /* Write the choice */
  418.       if (mpresent) show_mouse();
  419.    }
  420.    if (mpresent) hide_mouse();                   /* Hide the mouse */
  421.    wnd     = wpop(wnd);                          /* Get rid of menu */
  422.    iwnd    = wpop(iwnd);                         /* Get rid of instructions */
  423.    savewnd = wpop(savewnd);                      /* Restore msg row */
  424.                                                  /* And go home */
  425.  
  426. }
  427. /* --- end cmd_k() ------------------------------------- */
  428.  
  429.  
  430. /* === cmd_l() ========================================= */
  431. void cmd_l(void)   /* test lotus style menu's */
  432. {
  433.    int mxr, mxc;
  434.    int i = 0;
  435.    int index = 0;
  436.    WNDPTR *menuwnd, *savewnd, *iwnd;
  437.  
  438.    static LMNUFLDS menu1[] =
  439.        /* select_key, select_col, *item, *item_msg */
  440.       {{ 'A', 2, "Add",    "Add an Entry to Database"},
  441.        { 'C', 17,"Change", "Change a Database Entry"},
  442.        { 'D', 33,"Delete", "Delete a Database Entry"},
  443.        {  0 ,  0,    NULL,  NULL}};
  444.  
  445.    static LMNUFLDS menu2[] =
  446.       {{ 'P', 2, "Purge", "Purge the Workfile"},
  447.        { 'S', 18,"Send",  "Send Electronic Mail"},
  448.        { 'E', 35,"Exit",  "Exit the Program"},
  449.        {  0,   0, NULL ,NULL }};
  450.  
  451.    static LMNUFLDS *menulist[] = {menu1, menu2, NULL};
  452.  
  453.    static LMNUTYPE lmenu =
  454.       { NULL,                         /* initial window ptr    */
  455.         22, 1, 25, 80,                /* window boundaries     */
  456.         BLUE, LIGHTGRAY,              /* window color          */
  457.         DOUBLEALL,RED,LIGHTGRAY,      /* border type and color */
  458.         " Lmenu Type ",               /* menu title            */
  459.         TOP,LEFT,BLACK,LIGHTGRAY,     /* title loc and color   */
  460.         WHITE,BLUE,                   /* select bar color      */
  461.         0,0,menulist };    /* bar pos, wnd pos, ptr to options */
  462.  
  463.    static char *selections[] =
  464.       { "call Add()     ", "call Change()  ", "call Delete()  ",
  465.         "call Purge()   ", "call Send()    ", "               " };
  466.  
  467.  
  468.    static char *instructions[] = {        /* Some instructions */
  469.       "To use this menu you may use the arrow keys, PgUp, PgDn,",
  470.       "Home and the End keys. More than one menu may be stacked",
  471.       "into one window, therefore, you may  page  through them.",
  472.       "Arrow to your selection and press enter, or  use the hot",
  473.       "character (usually the first character of the selection)",
  474.       "or use the Mouse.  You may use the Mouse to page through",
  475.       "the menus by clicking on the arrows at  either  side  of",
  476.       "the menu.  Play with it .... it will suprise you!       ",
  477.       NULL
  478.    };
  479.  
  480.  
  481.    if (mpresent) hide_mouse();
  482.    chk_video_state(&mxr, &mxc);
  483.    savewnd = wpush(1,1,mxr,mxc);                  /* Save entire screen */
  484.    bordercolor(BLUE, LIGHTGRAY);
  485.    titlecolor(RED,LIGHTGRAY);
  486.    iwnd = wexplode(2,10,13,70,BLACK,LIGHTGRAY);
  487.    wtitle(iwnd,TOP,RITE," Lmenu Instructions ");
  488.    w_block_write(iwnd, 2, CENTER, instructions);
  489.    qputs(20, 30, WHITE, RED,"Your Choice: ");    /* Message line */
  490.    menuwnd = makelmenu(&lmenu);
  491.    if (mpresent) show_mouse();
  492.    do
  493.    {
  494.       i = lmenuinput(&lmenu);
  495.       switch(i)
  496.       {
  497.          case 'A' : index = 0; break;
  498.          case 'C' : index = 1; break;
  499.          case 'D' : index = 2; break;
  500.          case 'P' : index = 3; break;
  501.          case 'S' : index = 4; break;
  502.          case 27  :
  503.          case 'E' : index = 5; break;
  504.          default  : index = 5;
  505.       }
  506.       if(mpresent) hide_mouse();
  507.       qputs(20,44,WHITE,BLACK,selections[index]);
  508.       if(mpresent) show_mouse();
  509.    }
  510.    while (i != 'E' && i != ESC);
  511.  
  512.    if (mpresent) hide_mouse();
  513.    menuwnd = wpop(menuwnd);
  514.    iwnd    = wpop(iwnd);                          /* Remove instructions */
  515.    savewnd = wpop(savewnd);                       /* Remove trash */
  516.    if (mpresent) show_mouse();
  517.  
  518. }
  519. /* --- end cmd_l() ------------------------------------- */
  520.  
  521.  
  522. /* === cmd_p() ========================================= */
  523. void cmd_p(void)   /* test pop-up menu's */
  524. {
  525.    WNDPTR *wnd, *savewnd, *iwnd;
  526.  
  527. /***********************************************************/
  528. /* Initialize the popup menu structures defined in menu.h. */
  529. /***********************************************************/
  530.  
  531.    static PMNUFLDS pitems[] = {
  532.        { '1', "1. Methodology                   "},
  533.        { '2', "2. Word Processors               "},
  534.        { '3', "3. ITI Mainframe Communications  "},
  535.        { '4', "4. C Programming Environment     "},
  536.        { '5', "5. Pascal Programming Environment"},
  537.        { 'e' ,"E. Esc or Right Mouse Key - Exit "},
  538.        {  0,  ""}
  539.     };
  540.  
  541. /**********************************************************/
  542. /* PMNUTYPE contains elements concerning a popup menu.    */
  543. /* First, there is a pointer to the window to be used,    */
  544. /* then window parameters, border parms, title parms,     */
  545. /* selection bar parms, and finally a pointer back to our */
  546. /* menu options.                                          */
  547. /**********************************************************/
  548.  
  549.     static PMNUTYPE  pmenu =  {
  550.        NULL,
  551.        13, 20, 20, 60, BLACK,LIGHTGRAY,          /* Window Parms */
  552.        2, RED,LIGHTGRAY,                         /* Border Parms */
  553.        " Main Menu ",TOP,MIDDLE,BLUE,LIGHTGRAY,  /* Title  Parms */
  554.        WHITE,BLUE,0,                             /* Select Bar   */
  555.        pitems                                    /* pointer to menu list */
  556.     };
  557.  
  558.     static char *instructions[] = {
  559.        "To use the  Popup  Menu  use  the  \30\31  arrow  keys,",
  560.        "to place the cursor bar on  the  desired  selection",
  561.        "and then press enter.  Or, use the SELECT CHARACTER",
  562.        "at left of each selection, or...use  the  Mouse  to",
  563.        "point and shoot the selection you want.  ESC or the",
  564.        "right Mouse key will end the demo.                 ",
  565.        NULL
  566.     };
  567.  
  568.     static char *selections[] = {
  569.        "Methodology",
  570.        "Word Processors",
  571.        "ITI Mainframe Communications",
  572.        "C Programming Environment",
  573.        "Pascal Programming Environment"
  574.     };
  575.  
  576.     int i = 0;
  577.     int mxr, mxc;
  578.  
  579.    chk_video_state(&mxr,&mxc);                   /* Get max rows & cols */
  580.    if (mpresent) hide_mouse();                   /* Hide the mouse */
  581.    savewnd = wpush(1,1,mxr,mxc);                 /* Save entire screen */
  582.    if (!savewnd) return;                         /* Exit if cannot save */
  583.    bordercolor(BLUE,LIGHTGRAY);                  /* Set border color */
  584.    titlecolor(BLACK,LIGHTGRAY);                  /* Set the title color */
  585.    iwnd = wexplode(2,10,11,70,RED,LIGHTGRAY);      /* Make instruction window */
  586.    wtitle(iwnd,TOP,LEFT," Popup Menu Instructions "); /* Title it */
  587.    w_block_write(iwnd, 2, CENTER,instructions);  /* Write instructions to it */
  588.    wnd = makepmenu(&pmenu);                      /* Make a popup window */
  589.    if (mpresent) show_mouse();                   /* Show the mouse */
  590.    while (i != 27 && i != 'e') {                 /* Do until Esc */
  591.       i = pmenuinput(&pmenu);                    /* Get Menu return value */
  592.       switch(i) {
  593.          case '1' :
  594.          case '2' :
  595.          case '3' :
  596.          case '4' :
  597.          case '5' :
  598.             if (mpresent) hide_mouse();
  599.             i -= 48;
  600.             qhchar(22,1,BLACK,BLACK,32,80);          /* Clear msg line */
  601.             qputs(22,99,RED,7,selections[i-1]);  /* Write the choice */
  602.             if (mpresent) show_mouse();
  603.             break;
  604.          default: break;
  605.       }
  606.    }
  607.    if (mpresent) hide_mouse();                   /* Hide the mouse */
  608.    wnd     = wpop(wnd);                          /* Get rid of menu */
  609.    iwnd    = wpop(iwnd);                         /* Get rid of instructions */
  610.    savewnd = wpop(savewnd);                      /* Restore msg row */
  611.                                                  /* And go home */
  612. }
  613.  
  614. /* --- end cmd_p() ------------------------------------- */
  615.  
  616.  
  617. /* === cmd_r() ========================================= */
  618. void cmd_r(void)   /* show quick reference */
  619. {
  620.     WNDPTR *wnd;
  621.     int mxr, mxc;
  622.  
  623.     if(mpresent) hide_mouse();
  624.     chk_video_state(&mxr, &mxc);
  625.     bordercolor(YELLOW, BLUE);
  626.     titlecolor( LIGHTGRAY, RED );
  627.     wnd = wframe(1, 1, 20, 80, LIGHTGRAY, BLUE);
  628.     wtitle(wnd, TOP, MIDDLE, " PCW_QREF.TXT ");
  629.     set_int29();
  630.  
  631.     system("type pcw_qref.txt");
  632.  
  633.     puts("====== wow! any key to return ======");
  634.     wait_for_something();
  635.     reset_int29();
  636.     wpop(wnd);
  637.  
  638.     if(mpresent) show_mouse();
  639.  
  640. }
  641. /* --- end cmd_r() ------------------------------------- */
  642.  
  643.  
  644. /* === cmd_t() ========================================= */
  645. void cmd_t(void)   /* test top style menu's */
  646. {
  647.    int    i = 0;
  648.    int    index = 0;
  649.    int    mxr, mxc;
  650.    WNDPTR *menuwnd, *iwnd, *savewnd;
  651.  
  652.    static TMNUFLDS tmenu1[] =
  653.        /* select_key, select_col, *item */
  654.       {{ 'A', 2, "Add"    },
  655.        { 'C', 17,"Change" },
  656.        { 'E', 33,"Exit" },
  657.        {  0,   0, NULL }};
  658.  
  659.    static TMNUFLDS tmenu2[] =
  660.        /* select_key, select_col, *item, *item_msg */
  661.       {{ 'P', 2, "Purge" },
  662.        { 'S', 18,"Send"  },
  663.        { 'D', 35,"Delete"  },
  664.        {  0,   0, NULL }};
  665.  
  666.    static TMNUFLDS *tmenulist[] = {tmenu1, tmenu2, NULL};
  667.  
  668.    static TMNUTYPE tmenu =
  669.       { NULL,                              /* previous window pointer */
  670.         16,  1, 18, 80,                    /* urow, ucol, lrow, lcol  */
  671.         YELLOW, BLUE,                      /* fcolor, bcolor          */
  672.         SINGLEALL,LIGHTGRAY,BLUE,          /* btype, bfcolor, bbcolor */
  673.         " Tmenu Type ",                    /* *title                  */
  674.         TOP,MIDDLE,WHITE,BLUE,      /* tvloc, thloc, tfcolor, tbcolor */
  675.         YELLOW,MAGENTA,                    /* cfcolor, cbcolor        */
  676.         0,0,tmenulist };                 /* bar_pos, wnd_pos, **tlist */
  677.  
  678.    static char *selections[] =
  679.       { "call Add()     ", "call Change()  ", "               ",
  680.         "call Purge()   ",  "call Send()    ", "call Delete() " };
  681.  
  682.    static char *instructions[] = {               /* Some instructions */
  683.       "The 'tmenu' function was generated by customizing the    ",
  684.       "'lmenu' code. The 'info' line was removed and ESC was    ",
  685.       "changed to act as a home key and bring you back to the   ",
  686.       "top menu. A specific action is required quit -- a key    ",
  687.       "entry of 'e' or 'E' or a mouse click on 'Exit' in the    ",
  688.       "menu bar. Note: The source code from Stan is well commented",
  689.       "and the effort to create a custom menu type was minimal. ",
  690.       "                              ...... Thank's Stan ...... ",
  691.       NULL
  692.    };
  693.  
  694.    chk_video_state(&mxr, &mxc);     /* Get max rows and cols */
  695.    if (mpresent) hide_mouse();      /* Hide the mouse        */
  696.    savewnd = wpush(1, 1, mxr, mxc); /* Save entire screen    */
  697.    if(!savewnd) return;             /* Exit if cannot save   */
  698.    bordercolor(WHITE, LIGHTGRAY);   /* Set the border color  */
  699.    titlecolor(BLACK, LIGHTGRAY);    /* Set the title color   */
  700.    setborder(SINGLESIDES);
  701.    iwnd = wframe(2, 10, 11, 70, RED, LIGHTGRAY); /* make window */
  702.    wtitle(iwnd, BOTTOM, RITE, " Top menu instructions ");
  703.    w_block_write(iwnd, 1, CENTER, instructions);
  704.    menuwnd = maketmenu(&tmenu);     /* Make a top menu       */
  705.    if (mpresent) show_mouse();      /* Show mouse            */
  706.    while (i != 'E' && i != 27) {    /* DO UNTIL 'Exit'       */
  707.       i = tmenuinput(&tmenu);
  708.       switch(i) {
  709.          case 'A' : index = 0; break;
  710.          case 'C' : index = 1; break;
  711.          case 'E' : index = 2; break;
  712.          case 'P' : index = 3; break;
  713.          case 'S' : index = 4; break;
  714.          case 'D' : index = 5; break;
  715.       }
  716.       if(mpresent) hide_mouse();
  717.       qputs(14,CENTER,WHITE,BLACK,selections[index]);
  718.       if(mpresent) show_mouse();
  719.    }
  720.    if (mpresent) hide_mouse();    /* Hide mouse         */
  721.    menuwnd = wpop(menuwnd);       /* Get rid of menu    */
  722.    iwnd    = wpop(iwnd);     /* Get rid of instructions */
  723.    savewnd = wpop(savewnd);          /* Restore screen  */
  724.                                          /* And go home */
  725.    if (mpresent) show_mouse();
  726.  
  727. }
  728. /* --- end cmd_t() ------------------------------------- */
  729.  
  730.  
  731. /* === wait_for_something() ============================ */
  732. void wait_for_something(void) { /* wait for key or mse */
  733.  
  734.     int done;
  735.  
  736.     for(done = 0; !done; )          /*wait for something */
  737.     {
  738.        if(keypressed()) { keybrd_flush(); done++; }
  739.     }
  740. }
  741. /* --- end wait_for_something() ------------------------ */
  742.  
  743.  
  744. /* === end pcw_demo.c ================================== */
  745.