home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / c / agl103p.lha / src / agl / RCS / clip.c,v < prev    next >
Encoding:
Text File  |  1994-12-09  |  6.1 KB  |  391 lines

  1. head    1.2;
  2. branch    1.2.1.99;
  3. access;
  4. symbols;
  5. locks; strict;
  6. comment    @ * @;
  7.  
  8.  
  9. 1.2
  10. date    94.08.24.04.19.39;    author jason;    state Exp;
  11. branches
  12.     1.2.1.1;
  13. next    ;
  14.  
  15. 1.2.1.1
  16. date    94.09.13.03.47.14;    author jason;    state Exp;
  17. branches;
  18. next    1.2.1.2;
  19.  
  20. 1.2.1.2
  21. date    94.11.16.06.23.56;    author jason;    state Exp;
  22. branches;
  23. next    1.2.1.3;
  24.  
  25. 1.2.1.3
  26. date    94.12.09.05.29.56;    author jason;    state Exp;
  27. branches;
  28. next    ;
  29.  
  30.  
  31. desc
  32. @clipping mask using Region's
  33. @
  34.  
  35.  
  36. 1.2
  37. log
  38. @original revision
  39. @
  40. text
  41. @/******************************************************************************
  42.  
  43. $Id: $
  44.  
  45. $Log: $
  46.  
  47. ******************************************************************************/
  48.  
  49.  
  50. #ifndef NOT_EXTERN
  51. #include"agl.h"
  52. #endif
  53.  
  54.  
  55. short ClipLimits[MAX_WINDOWS][4];
  56.  
  57.  
  58. /******************************************************************************
  59. void    scrmask(Screencoord left,Screencoord right,
  60.                                             Screencoord bottom,Screencoord top)
  61.  
  62. ******************************************************************************/
  63. /*PROTOTYPE*/
  64. void scrmask(Screencoord left,Screencoord right,Screencoord bottom,Screencoord top)
  65.     {
  66.     struct Region *old_region;
  67.  
  68.     long y1,y2;
  69.  
  70.     ClipLimits[CurrentWid][0]=left;
  71.     ClipLimits[CurrentWid][1]=right;
  72.     ClipLimits[CurrentWid][2]=top;
  73.     ClipLimits[CurrentWid][3]=bottom;
  74.  
  75.     y1=CurrentHeight-top-1;
  76.     y2=CurrentHeight-bottom-1;
  77.  
  78.     if( (old_region=clip_window(GLWindow[CurrentWid]->WLayer,left,y1,right,y2) != NULL )
  79.         DisposeRegion(old_region);
  80.     }
  81.  
  82.  
  83. /******************************************************************************
  84. void    getscrmask(Screencoord *left,Screencoord *right,
  85.                                         Screencoord *bottom,Screencoord *top)
  86.  
  87. ******************************************************************************/
  88. /*PROTOTYPE*/
  89. void getscrmask(Screencoord *left,Screencoord *right,Screencoord *bottom,Screencoord *top)
  90.     {
  91.     left=    ClipLimits[CurrentWid][0];
  92.     right=    ClipLimits[CurrentWid][1];
  93.     top=    ClipLimits[CurrentWid][2];
  94.     bottom=    ClipLimits[CurrentWid][3];
  95.     }
  96.  
  97.  
  98. /******************************************************************************
  99. void    unclip_window(struct Window *window)
  100.  
  101.     install NULL region
  102.     dispose of old region, if one existed
  103.  
  104. ******************************************************************************/
  105. /*PROTOTYPE*/
  106. void unclip_window(struct Window *window)
  107.     {
  108.     struct Region *old_region;
  109.  
  110.     if( (old_region=InstallClipRegion(window->WLayer,NULL)) != NULL )
  111.         DisposeRegion(old_region);
  112.     }
  113.  
  114.  
  115. /******************************************************************************
  116. struct Region *clip_window(struct Window *window,
  117.                                     long minx,long miny,long maxx,long maxy)
  118.  
  119.     clip window to given bounds
  120.     return old region, if one existed
  121.  
  122. ******************************************************************************/
  123. /*PROTOTYPE*/
  124. struct Region *clip_window(struct Window *window,long minx,long miny,long maxx,long maxy)
  125.     {
  126.     struct Region *new_region;
  127.     struct Rectangle rectangle;
  128.  
  129.     rectangle.minx=minx;
  130.     rectangle.miny=miny;
  131.     rectangle.maxx=maxx;
  132.     rectangle.maxy=maxy;
  133.  
  134.     if( (new_region=NewRegion()) != NULL )
  135.         {
  136.         if( OrRectRegion(new_region,&rectangle) == FALSE )
  137.             DisposeRegion(new_region);
  138.             new_region=NULL;
  139.         }
  140.  
  141.     return(InstallClipRegion(window->WLayer,new_region));
  142.     }
  143. @
  144.  
  145.  
  146. 1.2.1.1
  147. log
  148. @debugged and tested
  149. @
  150. text
  151. @d3 1
  152. a3 1
  153. $Id: clip.c 1.2 1994/08/24 04:19:39 jason Exp jason $
  154. d5 1
  155. a5 4
  156. $Log: clip.c $
  157.  * Revision 1.2  1994/08/24  04:19:39  jason
  158.  * original revision
  159.  *
  160. d26 4
  161. d35 2
  162. a36 4
  163.     if(left==0 && right==CurrentWidth-1 && bottom==0 && top==CurrentHeight-1)
  164.         Clipped[CurrentWid]=FALSE;
  165.     else
  166.         Clipped[CurrentWid]=TRUE;
  167. d38 2
  168. a39 1
  169.     activate_clipping();
  170. a42 1
  171.  
  172. d51 4
  173. a54 45
  174.     *left=        ClipLimits[CurrentWid][0];
  175.     *right=        ClipLimits[CurrentWid][1];
  176.     *top=        ClipLimits[CurrentWid][2];
  177.     *bottom=    ClipLimits[CurrentWid][3];
  178.     }
  179.  
  180.  
  181. /******************************************************************************
  182. void    activate_clipping(void)
  183.  
  184.     activates clipping in current window
  185. ******************************************************************************/
  186. /*PROTOTYPE*/
  187. void activate_clipping(void)
  188.     {
  189.     struct Region *old_region;
  190.  
  191.     Screencoord left,right,bottom,top;
  192.  
  193.     long y1,y2;
  194.  
  195.     if(Clipped[CurrentWid])
  196.         {
  197.         getscrmask(&left,&right,&bottom,&top);
  198.  
  199.         y1=CurrentHeight-top-1;
  200.         y2=CurrentHeight-bottom-1;
  201.  
  202.         if( (old_region=clip_window(GLWindow[CurrentWid],(long)left,y1,(long)right,y2)) != NULL )
  203.             DisposeRegion(old_region);
  204.         }
  205.     else
  206.         unclip_window(GLWindow[CurrentWid]);
  207.     }
  208.  
  209.  
  210. /******************************************************************************
  211. void    deactivate_clipping(void)
  212.  
  213.     activates clipping in current window
  214. ******************************************************************************/
  215. /*PROTOTYPE*/
  216. void deactivate_clipping(void)
  217.     {
  218.     unclip_window(GLWindow[CurrentWid]);
  219. d89 4
  220. a92 4
  221.     rectangle.MinX=minx;
  222.     rectangle.MinY=miny;
  223.     rectangle.MaxX=maxx;
  224.     rectangle.MaxY=maxy;
  225. a96 3
  226.             {
  227.             printf("Error setting clipping region\n");
  228.  
  229. a98 1
  230.             }
  231. a99 2
  232.     else
  233.         printf("Error creating clipping region\n");
  234. @
  235.  
  236.  
  237. 1.2.1.2
  238. log
  239. @separate calls to activate/deactivate clipping for specific windows
  240. @
  241. text
  242. @d3 1
  243. a3 1
  244. $Id: clip.c,v 1.2.1.1 1994/09/13 03:47:14 jason Exp jason $
  245. d5 1
  246. a5 4
  247. $Log: clip.c,v $
  248.  * Revision 1.2.1.1  1994/09/13  03:47:14  jason
  249.  * debugged and tested
  250.  *
  251. d34 1
  252. a34 1
  253.     if(!Bordered[CurrentWid] && left==0 && right==CurrentWidth-1 && bottom==0 && top==CurrentHeight-1)
  254. d39 1
  255. a39 1
  256.     activate_clipping(CurrentWid);
  257. d60 1
  258. a60 1
  259. void    activate_clipping(long wid)
  260. d65 1
  261. a65 1
  262. void activate_clipping(long wid)
  263. d73 1
  264. a73 1
  265.     if(Clipped[wid])
  266. d80 1
  267. a80 10
  268.         if(Bordered[wid])
  269.             {
  270.             left+=BorderWidth;
  271.             right+=BorderWidth;
  272.  
  273.             y1+=BorderWidth+BorderHeight;
  274.             y2+=BorderWidth+BorderHeight;
  275.             }
  276.  
  277.         if( (old_region=clip_window(GLWindow[wid],(long)left,y1,(long)right,y2)) != NULL )
  278. d84 1
  279. a84 1
  280.         unclip_window(GLWindow[wid]);
  281. d89 1
  282. a89 1
  283. void    deactivate_clipping(long wid)
  284. d94 1
  285. a94 1
  286. void deactivate_clipping(long wid)
  287. d96 1
  288. a96 1
  289.     unclip_window(GLWindow[wid]);
  290. @
  291.  
  292.  
  293. 1.2.1.3
  294. log
  295. @added copyright
  296. @
  297. text
  298. @d3 1
  299. a3 4
  300. Copyright © 1994 Jason Weber
  301. All Rights Reserved
  302.  
  303. $Id: clip.c,v 1.2.1.2 1994/11/16 06:23:56 jason Exp jason $
  304. a5 3
  305.  * Revision 1.2.1.2  1994/11/16  06:23:56  jason
  306.  * separate calls to activate/deactivate clipping for specific windows
  307.  *
  308. @
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.