home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c222 / 1.ddi / SOURCE / CLIB / GR_WINDO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-10  |  2.2 KB  |  143 lines

  1. /*********************
  2.  *
  3.  *  gr_windo.c - graphics window functions.
  4.  *
  5.  *  Purpose: This file contains functions to operate in a portion of the
  6.  *           screen in graphics mode.
  7.  *
  8.  *  Blackstar C Function Library
  9.  *  (c) Copyright 1985,1989 Sterling Castle Software
  10.  *
  11.  *******/
  12.  
  13. #include "blackstr.h"
  14. #include "sc_head.h"
  15. #include "gr_head.h"
  16. #include "primitiv.h"
  17.  
  18.  
  19. /********
  20.  *
  21.  *   gr_windo(minx,miny,maxx,maxy) - set a graphics window
  22.  *
  23.  **/
  24.  
  25. void gr_windo(int minx, int miny, int maxx, int maxy)
  26. {
  27.     gr_minx_ = minx;
  28.     gr_miny_ = miny;
  29.     gr_maxx_ = maxx;
  30.     gr_maxy_ = maxy;
  31. }
  32.  
  33.  
  34. /********
  35.  *
  36.  *   gr_wfull() - set to graphic windo full screen
  37.  *
  38.  **/
  39.  
  40. void gr_wfull(void)
  41. {
  42.     gr_windo(0,0,grcols_-1,grrows_-1);
  43. }
  44.  
  45.  
  46. /********
  47.  *
  48.  *   gr_wpush() - save current graphic window
  49.  *
  50.  **/
  51.  
  52. void gr_wpush(void)
  53. {
  54.     ut_push(gr_minx_);
  55.     ut_push(gr_miny_);
  56.     ut_push(gr_maxx_);
  57.     ut_push(gr_maxy_);
  58. }
  59.  
  60.  
  61. /********
  62.  *
  63.  *   gr_wpop() - restore previous graphic window
  64.  *
  65.  **/
  66.  
  67. void gr_wpop(void)
  68. {
  69.     gr_maxy_ = ut_pop();
  70.     gr_maxx_ = ut_pop();
  71.     gr_miny_ = ut_pop();
  72.     gr_minx_ = ut_pop();
  73. }
  74.  
  75.     
  76. /********
  77.  *
  78.  * gr_clr() - clear graphics window
  79.  *
  80.  **/
  81.  
  82. void gr_clr(void)
  83. {
  84.     if( (sc_adp_&CGA_ADP) || ((sc_adp_&EGA_ADP) && (sc_mode_<7)))
  85.     /* check for CGA mode */
  86.     gr_wfill(NUL);                                                                /* fill the window      */
  87.     else
  88.     gr_wfill(grbcolr_);
  89. }
  90.  
  91.  
  92. /********
  93.  *
  94.  *   gr_wfill(color) - fill a graphic window
  95.  *
  96.  **/
  97.  
  98. void gr_wfill(int color)
  99. {
  100.     ut_push(grfcolr_);
  101.     gr_pen(NUL,color);
  102.     gr_wfill_();
  103.     grfcolr_ = ut_pop();
  104.     gr_pen(NUL,grfcolr_);
  105. }
  106.  
  107.  
  108. /********
  109.  *
  110.  *   gr_wgetp(buff) - get graphics picture to buffer
  111.  *
  112.  **/
  113.  
  114. void gr_wgetp(char *buff)
  115. {
  116.     int i,j;
  117.  
  118.     for(j=gr_miny_;j<gr_maxy_;++j)
  119.     for(i=gr_minx_;i<gr_maxx_;++i)
  120.         *buff++ = gr_getpt(i,j);
  121. }
  122.  
  123.  
  124. /********
  125.  *
  126.  *   gr_wputp(buff) - put graphics picture to window
  127.  *
  128.  **/
  129.  
  130. void gr_wputp(char *buff)
  131. {
  132.     int i,j;
  133.  
  134.     for(j=gr_miny_;j<gr_maxy_;++j)
  135.     for(i=gr_minx_;i<gr_maxx_;++i)
  136.         gr_putpt(i,j,*buff);
  137. }
  138.  
  139.  
  140.  
  141.  
  142.  
  143.