home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / PROCWRKB.ZIP / BENCH1.ZIP / HELP / POPUP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-23  |  2.8 KB  |  131 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. char HlpInUse[]  = "Help message in use...\n       Retry?";
  48. char FreeWLock[] = "popup(): free of write lock on index failed";
  49. char RLockFail[] = "popup(): read lock on index failed";
  50.  
  51.  
  52. void popup_menu(hptr)
  53.     struct help_hdr * hptr;
  54. {
  55.     int        deleted = 1;
  56.     int        command = EDIT;
  57.     int        func = EDIT;
  58.     int        row;
  59.     int        col;
  60.  
  61.     while (lock_index(h_num, WLOK) == FALSE)
  62.     {
  63.         if (!warning(-1, HlpInUse))
  64.             return;
  65.         flushscr();
  66.     }
  67.  
  68.     /* popup a menu giving window modification selections */
  69.     do
  70.     {
  71.         if (deleted)
  72.         {
  73.             row = hptr->row + 1;
  74.             row = (row > (w_nrows - POP_HEIGHT) ? w_nrows - POP_HEIGHT : row);
  75.             col = hptr->col + 2;
  76.             col = (col > (w_ncols - POP_WIDTH) ? w_ncols - POP_WIDTH : col);
  77.  
  78.             create_w(row, col, POP_HEIGHT, POP_WIDTH);
  79.             border_w(0, NORMAL);
  80.             deleted = 0;
  81.         }
  82.         command = do_options(options, func, 0);
  83.         if (command >= 0)
  84.             func = command;
  85.  
  86.         switch (command)
  87.         {
  88.         case RESIZE:        /* resize the help window */
  89.             delete_w();        /* get rid of popup */
  90.             deleted = 1;
  91.             resize_hw(hptr);
  92.             func = MOVE;
  93.             break;
  94.  
  95.         case MOVE:        /* move the help window */
  96.             delete_w();
  97.             deleted = 1;
  98.             move_w(hptr);
  99.             func = RESIZE;
  100.             break;
  101.  
  102.         case EDIT:
  103.         /* Order is important here due to redrawing new & old text */
  104.             delete_w();
  105.             deleted = 1;
  106.             invoke_editor();
  107.             return;
  108.  
  109.         case CHANGE:
  110.             change_setup(hptr);
  111.             func = SAVE;
  112.             break;
  113.  
  114.         case SAVE:
  115.             write_hdr(&h_ndx);
  116.             command = -1; /* Quit */
  117.  
  118.         default:
  119.             /* do nothing */
  120.             break;
  121.         }
  122.     } while (command  >=  0);
  123.  
  124.     /* delete the popup */
  125.     delete_w();
  126.     if (lock_index(h_num, ULOK) == FALSE)
  127.         errmsg(FreeWLock);
  128.     if (lock_index(h_num, RLOK) == FALSE)
  129.         errmsg(RLockFail);
  130. }
  131.