home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 125.img / PRO-C4.ZIP / BENCH1.ZIP / HELP / POPUP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-28  |  2.7 KB  |  128 lines

  1. /* ==( help/popup.c )== */
  2. /* ----------------------------------------------- */
  3. /* Pro-C  Copyright (C) 1988 - 1990 Vestronix Inc. */
  4. /* Modification to this source is not supported    */
  5. /* by Vestronix Inc.                               */
  6. /*            All Rights Reserved                  */
  7. /* ----------------------------------------------- */
  8. /* Written   JPK  26-Sep-88                        */
  9. /* Modified  Geo  12-Dec-89  See comments below    */
  10. /* ----------------------------------------------- */
  11. /* %W%  (%H% %T%) */
  12.  
  13. /*
  14.  *  Modifications
  15.  *
  16.  *  12-Dec-89  Geo - V2 version with variable lines
  17.  *  25-Oct-89  Geo - 1.32 Merge
  18.  *
  19.  *
  20. */
  21.  
  22. # include <stdio.h>
  23. # include <bench.h>
  24. # include "help.h"
  25. # include <fileio.h>
  26.  
  27. # define POP_HEIGHT    7
  28. # define POP_WIDTH    15
  29.  
  30. # define RESIZE        0
  31. # define MOVE        1
  32. # define EDIT        2
  33. # define CHANGE        3
  34. # define SAVE        4
  35.  
  36.  
  37. static struct optab options[] =
  38. {
  39.     {2, 2, "Resize window"},
  40.     {3, 2, "Move window  "},
  41.     {4, 2, "Edit text    "},
  42.     {5, 2, "Change setup "},
  43.     {6, 2, "Save setup   "},
  44.     {NORMAL, REVVID, NULL}
  45. };
  46.  
  47.  
  48.  
  49. void popup_menu(hptr)
  50.     struct help_hdr * hptr;
  51. {
  52.     int        deleted = 1;
  53.     int        command = EDIT;
  54.     int        func = EDIT;
  55.     int        row;
  56.     int        col;
  57.  
  58.     while (lock_index(h_num, WLOK) == FALSE)
  59.     {
  60.         if (!warning(-1, "Help message in use...\n       Retry?"))
  61.             return;
  62.         flushscr();
  63.     }
  64.  
  65.     /* popup a menu giving window modification selections */
  66.     do
  67.     {
  68.         if (deleted)
  69.         {
  70.             row = hptr->row + 1;
  71.             row = (row > (w_nrows - POP_HEIGHT) ? w_nrows - POP_HEIGHT : row);
  72.             col = hptr->col + 2;
  73.             col = (col > (w_ncols - POP_WIDTH) ? w_ncols - POP_WIDTH : col);
  74.  
  75.             create_w(row, col, POP_HEIGHT, POP_WIDTH);
  76.             border_w(0, NORMAL);
  77.             deleted = 0;
  78.         }
  79.         command = do_options(options, func, 0);
  80.         if (command >= 0)
  81.             func = command;
  82.  
  83.         switch (command)
  84.         {
  85.         case RESIZE:        /* resize the help window */
  86.             delete_w();        /* get rid of popup */
  87.             deleted = 1;
  88.             resize_w(hptr);
  89.             func = MOVE;
  90.             break;
  91.  
  92.         case MOVE:        /* move the help window */
  93.             delete_w();
  94.             deleted = 1;
  95.             move_w(hptr);
  96.             func = RESIZE;
  97.             break;
  98.  
  99.         case EDIT:
  100.         /* Order is important here due to redrawing new & old text */
  101.             delete_w();
  102.             deleted = 1;
  103.             invoke_editor();
  104.             return;
  105.  
  106.         case CHANGE:
  107.             change_setup(hptr);
  108.             func = SAVE;
  109.             break;
  110.  
  111.         case SAVE:
  112.             write_hdr(&h_ndx);
  113.             command = -1; /* Quit */
  114.  
  115.         default:
  116.             /* do nothing */
  117.             break;
  118.         }
  119.     } while (command  >=  0);
  120.  
  121.     /* delete the popup */
  122.     delete_w();
  123.     if (lock_index(h_num, ULOK) == FALSE)
  124.         errmsg("popup(): free of write lock on index failed");
  125.     if (lock_index(h_num, RLOK) == FALSE)
  126.         errmsg("popup(): read lock on index failed");
  127. }
  128.