home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / PROCWRKB.ZIP / BENCH1.ZIP / WIN / MIP / WMISC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-16  |  3.7 KB  |  170 lines

  1. /* ==( mip/wmisc.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   Geo  26-Aug-88                        */
  9. /* Modified  Geo  18-Jul-90  See comments below    */
  10. /* ----------------------------------------------- */
  11. /* %W%  (%H% %T%) */
  12.  
  13. /*
  14.  *  Modifications
  15.  *
  16.  *  18-Jul-90  Geo - Overhauled
  17.  *  25-Oct-89  Geo - 1.32 Merge
  18.  *
  19.  *
  20. */
  21.  
  22. /*
  23.  * Repeated display functions
  24.  * setting, boxes
  25. */
  26.  
  27. # include <stdio.h>
  28. # include <bench.h>
  29.  
  30. extern char *sysbase; /* wbase.c */
  31.  
  32. /*
  33.  * Repeat character and attribute
  34.  * len times within current window,
  35.  * horizontally
  36. */
  37. void rephoriz_w(row, col, attr, len, ch)
  38. int row, col, attr, len, ch;
  39. {
  40. /* Still to reduce this code says Geo */
  41.     if (len > 0)
  42.     {
  43.       poke_w(row, col++, attr, ch);    /* redundant col++ for direct */
  44.         while (--len)
  45.         {
  46. # ifdef WDEBUG
  47.           poke_w(row, col++, attr, ch);
  48. # else
  49.             ADDPOKE(attr, ch);
  50. # endif
  51.         }
  52.     }
  53. }
  54.  
  55. /*
  56.  * Repeat character and attribute
  57.  * len times within current window,
  58.  * vertically
  59. */
  60. void repvert_w(row, col, attr, len, ch)
  61. register int row;
  62. int col, attr;
  63. register int len;
  64. int ch;
  65. {
  66.     while (len--)
  67.       poke_w(row++, col, attr, ch);
  68. }
  69.  
  70. /*
  71.  * Sets all characters and attributes
  72.  * in the current window
  73. */
  74. void set_w(attr, ch)
  75. register int attr, ch;
  76. {
  77.     fill_w(1, 1, attr, winptr->wabs.height, winptr->wabs.width2>>1, ch);
  78. }
  79.  
  80. /*
  81.  * Fills a region with a character
  82.  * and attribute
  83. */
  84. void fill_w(row, col, attr, height, width, ch)
  85. register int row;
  86. int col, attr;
  87. register int height;
  88. int width, ch;
  89. {
  90.     while (height--)
  91.         rephoriz_w(row++, col, attr, width, ch);
  92. }
  93.  
  94. /*
  95.  * Writes a box border
  96.  * around the current window
  97.  * - does not alter global BOXSET
  98. */
  99. void border_w(bset, attr)
  100. int bset, attr;
  101. {
  102. int svboxset = boxset;
  103.     
  104.     /* Use this new boxset value */
  105. # ifdef MSDOS
  106.     boxset = bset;
  107. # endif
  108.  
  109.     /* all the edges with box lines */
  110.     box_w(1, 1, attr, winptr->wabs.height, winptr->wabs.width2/2);
  111.  
  112.     /* Restore boxset */
  113.     boxset = svboxset;
  114. }
  115.  
  116. /*
  117.  * Box within a window with attribute
  118. */
  119. void box_w(row, col, attr, height, width)
  120. int row, col, attr, height, width;
  121. {
  122. int lcol = col + width - 1;
  123. int lrow = row + height - 1;
  124.  
  125.     /* Much as I hate doing this, it makes auto boxes easier - GEO */
  126.     /* Cannot have border for 2x2 */
  127.     if (winptr->wabs.height < 2 || winptr->wabs.width2 < 4)
  128.         return;
  129.  
  130.    attr |= GRAPHIC;
  131.   
  132.    poke_w(row, col, attr , BULEFT(boxset));
  133.    rephoriz_w(row, col+1, attr, width-2, BHORIZ(boxset));
  134.    poke_w(row, lcol, attr , BURIGHT(boxset));
  135.  
  136.    poke_w(lrow, col, attr, BLLEFT(boxset));
  137.    rephoriz_w(lrow, col+1, attr, width-2, BHORIZ(boxset));
  138.    poke_w(lrow, lcol, attr , BLRIGHT(boxset));
  139.  
  140.    repvert_w(row+1,col,  attr, height-2, BVERT(boxset));
  141.    repvert_w(row+1,lcol,  attr, height-2, BVERT(boxset));
  142. }
  143.  
  144. /*
  145.  * Horizontal box line with 2 end T pieces
  146. */
  147. void underln_w(row, col, attr, width)
  148. int row, col, attr, width;
  149. {
  150.    attr |= GRAPHIC;
  151.  
  152.    poke_w(row, col, attr , BLEFTT(boxset));
  153.    rephoriz_w(row, col+1, attr, width-2, BHORIZ(boxset));
  154.    poke_w(row, col+width-1, attr , BRIGHTT(boxset));
  155. }
  156.  
  157. /*
  158.  * Vertical box line with 2 end T pieces
  159. */
  160. void upperln_w(row, col, attr, height)
  161. int row, col, attr, height;
  162. {
  163.    attr |= GRAPHIC;
  164.  
  165.    poke_w(row, col, attr , BTOPT(boxset));
  166.    repvert_w(row+1, col, attr, height-2, BVERT(boxset));
  167.    poke_w(row+height-1, col, attr , BBOTTY(boxset));
  168. }
  169.  
  170.