home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume3 / awm2 / part08 / GridBox.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-02-20  |  7.7 KB  |  291 lines

  1.  
  2.  
  3.  
  4. #ifndef lint
  5. static char *rcsid_StoreGridBox_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/GridBox.c,v 1.1 89/01/23 15:34:22 jkh Exp $";
  6. #endif    lint
  7.  
  8. #include "X11/copyright.h"
  9. /*
  10.  *
  11.  * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  12.  *
  13.  * Copyright 1987 by Jordan Hubbard.
  14.  *
  15.  *
  16.  *                         All Rights Reserved
  17.  *
  18.  * Permission to use, copy, modify, and distribute this software and its
  19.  * documentation for any purpose and without fee is hereby granted,
  20.  * provided that the above copyright notice appear in all copies and that
  21.  * both that copyright notice and this permission notice appear in
  22.  * supporting documentation, and that the name of Ardent Computer
  23.  * Corporation or Jordan Hubbard not be used in advertising or publicity
  24.  * pertaining to distribution of the software without specific, written
  25.  * prior permission.
  26.  *
  27.  */
  28.  
  29. /*
  30.  * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  31.  *
  32.  *                         All Rights Reserved
  33.  *
  34.  * Permission to use, copy, modify, and distribute this software and its
  35.  * documentation for any purpose and without fee is hereby granted,
  36.  * provided that the above copyright notice appear in all copies and that
  37.  * both that copyright notice and this permission notice appear in
  38.  * supporting documentation, and that the name of Digital Equipment
  39.  * Corporation not be used in advertising or publicity pertaining to
  40.  * distribution of the software without specific, written prior permission.
  41.  *
  42.  *
  43.  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  44.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  45.  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  46.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  47.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  48.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  49.  * SOFTWARE.
  50.  */
  51.  
  52.  
  53.  
  54. /*
  55.  * MODIFICATION HISTORY
  56.  *
  57.  * 000 -- M. Gancarz, DEC Ultrix Engineering Group
  58.  * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
  59.  *  Western Software Lab. Converted to X11.
  60.  * 002 -- Jordan Hubbard, Ardent Computer.
  61.  *  Changes for titled windows.
  62.  */
  63.  
  64. #ifndef lint
  65. static char *sccsid = "@(#)StoreGridBox.c    3.8    1/24/86";
  66. #endif
  67.  
  68. /*
  69.  *    StoreGridBox - This subroutine is used by the X Window Manager (xwm)
  70.  *    to store the vertices for the movement resize grid and box in a
  71.  *    vertex list.
  72.  */
  73.  
  74. #include "awm.h"
  75.  
  76. /*
  77.  * Store the vertices for the movement resize grid and box in a vertex list.
  78.  */
  79. int StoreGridBox(box, ulx, uly, lrx, lry)
  80. register XSegment box[];
  81. int ulx;            /* Upper left X coordinate. */
  82. int uly;            /* Upper left Y coordinate. */
  83. int lrx;            /* Lower right X coordinate. */
  84. int lry;            /* Lower right Y coordinate. */
  85. {
  86.     register int xthird, ythird;
  87.     int x1third, y1third;
  88.     int x2third, y2third;
  89.  
  90.     Entry("StoreGridBox")
  91.  
  92.     /*
  93.      * Xor in.
  94.      */
  95.     box[0].x1 = ulx; box[0].y1 = uly;
  96.     box[0].x2 = lrx; box[0].y2 = uly;
  97.  
  98.     box[1].x1 = lrx; box[1].y1 = uly;
  99.     box[1].x2 = lrx; box[1].y2 = lry;
  100.  
  101.     box[2].x1 = lrx; box[2].y1 = lry;
  102.     box[2].x2 = ulx; box[2].y2 = lry;
  103.  
  104.     box[3].x1 = ulx; box[3].y1 = lry;
  105.     box[3].x2 = ulx; box[3].y2 = uly;
  106.  
  107.  
  108.     /*
  109.      * These are the X and Y calculations for the parts of the grid that
  110.      * are dependent on the division by 3 calculations.
  111.      */
  112.  
  113.     /*
  114.      * Y dimension third.
  115.      */
  116.     ythird = (lry - uly) / 3;
  117.     y1third = uly + ythird;
  118.     y2third = y1third + ythird;
  119.    
  120.     /*
  121.      * X dimension third.
  122.      */
  123.     xthird = (lrx - ulx) / 3;
  124.     x1third = ulx + xthird;
  125.     x2third = x1third + xthird;
  126.  
  127.     box[4].x1 = x1third; box[4].y1 = lry;
  128.     box[4].x2 = x1third; box[4].y2 = uly;
  129.  
  130.     box[5].x1 = x2third; box[5].y1 = lry;
  131.     box[5].x2 = x2third; box[5].y2 = uly;
  132.  
  133.     box[6].x1 = ulx; box[6].y1 = y1third;
  134.     box[6].x2 = lrx; box[6].y2 = y1third;
  135.  
  136.     box[7].x1 = ulx; box[7].y1 = y2third;
  137.     box[7].x2 = lrx; box[7].y2 = y2third;
  138.  
  139.     /*
  140.      * Do not erase if we're freezing the screen.
  141.      */
  142.     if (Freeze)
  143.         Leave(8)
  144.  
  145.     /*
  146.      * From here on we're retracing the segments to clear the
  147.      * grid using GXxor.
  148.      */
  149.     box[8].x1 = ulx; box[8].y1 = uly;
  150.     box[8].x2 = lrx; box[8].y2 = uly;
  151.  
  152.     box[9].x1 = lrx; box[9].y1 = uly;
  153.     box[9].x2 = lrx; box[9].y2 = lry;
  154.  
  155.     box[10].x1 = lrx; box[10].y1 = lry;
  156.     box[10].x2 = ulx; box[10].y2 = lry;
  157.  
  158.     box[11].x1 = ulx; box[11].y1 = lry;
  159.     box[11].x2 = ulx; box[11].y2 = uly;
  160.  
  161.     box[12].x1 = x1third; box[12].y1 = lry;
  162.     box[12].x2 = x1third; box[12].y2 = uly;
  163.  
  164.     box[13].x1 = x2third; box[13].y1 = lry;
  165.     box[13].x2 = x2third; box[13].y2 = uly;
  166.  
  167.     box[14].x1 = ulx; box[14].y1 = y1third;
  168.     box[14].x2 = lrx; box[14].y2 = y1third;
  169.  
  170.     box[15].x1 = ulx; box[15].y1 = y2third;
  171.     box[15].x2 = lrx; box[15].y2 = y2third;
  172.  
  173.  
  174.     /*
  175.      * Total number of segments is 16.
  176.      */
  177.     Leave(16)
  178. }
  179.  
  180. /*
  181.  * Store the vertices for the movement resize grid and box in a vertex list.
  182.  * This is just like the routine above, but it adds a line for titled windows.
  183.  */
  184.  
  185. int StoreTitleGridBox(box, ulx, uly, lrx, lry)
  186. register XSegment box[];
  187. int ulx;            /* Upper left X coordinate. */
  188. int uly;            /* Upper left Y coordinate. */
  189. int lrx;            /* Lower right X coordinate. */
  190. int lry;            /* Lower right Y coordinate. */
  191. {
  192.     register int xthird, ythird;
  193.     int x1third, y1third;
  194.     int x2third, y2third;
  195.  
  196.     Entry("StoreTitleGridBox")
  197.  
  198.     /*
  199.      * Xor in.
  200.      */
  201.     box[0].x1 = ulx; box[0].y1 = uly;
  202.     box[0].x2 = lrx; box[0].y2 = uly;
  203.  
  204.     box[1].x1 = ulx; box[1].y1 = uly + titleHeight + 2;
  205.     box[1].x2 = lrx; box[1].y2 = uly + titleHeight + 2;
  206.  
  207.     box[2].x1 = lrx; box[2].y1 = uly;
  208.     box[2].x2 = lrx; box[2].y2 = lry;
  209.  
  210.     box[3].x1 = lrx; box[3].y1 = lry;
  211.     box[3].x2 = ulx; box[3].y2 = lry;
  212.  
  213.     box[4].x1 = ulx; box[4].y1 = lry;
  214.     box[4].x2 = ulx; box[4].y2 = uly;
  215.  
  216.  
  217.     /*
  218.      * These are the X and Y calculations for the parts of the grid that
  219.      * are dependent on the division by 3 calculations.
  220.      */
  221.  
  222.     /*
  223.      * Y dimension third.
  224.      */
  225.     ythird = (lry - uly - titleHeight - 2) / 3;
  226.     y1third = uly + ythird + titleHeight + 2;
  227.     y2third = y1third + ythird;
  228.    
  229.     /*
  230.      * X dimension third.
  231.      */
  232.     xthird = (lrx - ulx) / 3;
  233.     x1third = ulx + xthird;
  234.     x2third = x1third + xthird;
  235.  
  236.     box[5].x1 = x1third; box[5].y1 = lry;
  237.     box[5].x2 = x1third; box[5].y2 = uly + titleHeight + 3;
  238.  
  239.     box[6].x1 = x2third; box[6].y1 = lry;
  240.     box[6].x2 = x2third; box[6].y2 = uly + titleHeight + 3;
  241.  
  242.     box[7].x1 = ulx; box[7].y1 = y1third;
  243.     box[7].x2 = lrx; box[7].y2 = y1third;
  244.  
  245.     box[8].x1 = ulx; box[8].y1 = y2third;
  246.     box[8].x2 = lrx; box[8].y2 = y2third;
  247.  
  248.     /*
  249.      * Do not erase if we're freezing the screen.
  250.      */
  251.     if (Freeze)
  252.         Leave(9)
  253.  
  254.     /*
  255.      * From here on we're retracing the segments to clear the
  256.      * grid using GXxor.
  257.      */
  258.     box[9].x1 = ulx; box[9].y1 = uly;
  259.     box[9].x2 = lrx; box[9].y2 = uly;
  260.  
  261.     box[10].x1 = ulx; box[10].y1 = uly + titleHeight + 2;
  262.     box[10].x2 = lrx; box[10].y2 = uly + titleHeight + 2;
  263.  
  264.     box[11].x1 = lrx; box[11].y1 = uly;
  265.     box[11].x2 = lrx; box[11].y2 = lry;
  266.  
  267.     box[12].x1 = lrx; box[12].y1 = lry;
  268.     box[12].x2 = ulx; box[12].y2 = lry;
  269.  
  270.     box[13].x1 = ulx; box[13].y1 = lry;
  271.     box[13].x2 = ulx; box[13].y2 = uly;
  272.  
  273.     box[14].x1 = x1third; box[14].y1 = lry;
  274.     box[14].x2 = x1third; box[14].y2 = uly + titleHeight + 3;
  275.  
  276.     box[15].x1 = x2third; box[15].y1 = lry;
  277.     box[15].x2 = x2third; box[15].y2 = uly + titleHeight + 3;
  278.  
  279.     box[16].x1 = ulx; box[16].y1 = y1third;
  280.     box[16].x2 = lrx; box[16].y2 = y1third;
  281.  
  282.     box[17].x1 = ulx; box[17].y1 = y2third;
  283.     box[17].x2 = lrx; box[17].y2 = y2third;
  284.  
  285.  
  286.     /*
  287.      * Total number of segments is 18.
  288.      */
  289.     Leave(18)
  290. }
  291.