home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v92.tgz / v92.tar / v92 / src / runtime / rpmgraph.ri < prev    next >
Text File  |  1996-03-22  |  18KB  |  702 lines

  1. /*
  2.  * rpmgraph.ri - Presentation Manager graphics support routines.
  3.  */
  4. #ifdef Graphics
  5. /*
  6.  * drawarcs() - assumes x and y are already fixed up for the bitmap
  7.  */
  8. void drawarcs(wbinding *wb, XArc *arcs, int narcs)
  9.    {
  10.    int i, diff, bheight;
  11.    unsigned long a1, a2;
  12.    STDLOCALS(wb);
  13.  
  14.    bheight = ws->pixheight;
  15.    /*
  16.     * Fix up coordinates for window-system calls
  17.     */
  18.    for (i = 0; i < narcs; i++) {
  19.       /*
  20.        * width and height must be from center point... half them,
  21.        * and add the radii to (x,y) to get the center point.
  22.        */
  23.       arcs[i].arcp.lP >>= 1;
  24.       arcs[i].arcp.lQ >>= 1;
  25.       arcs[i].arcp.lR = arcs[i].arcp.lS = 0;
  26.       arcs[i].x += arcs[i].arcp.lP;
  27.       arcs[i].y += arcs[i].arcp.lQ;
  28.       arcs[i].y = bheight - arcs[i].y - 1;
  29.       }
  30.    MutexOn(ws);
  31.    /*
  32.     * make sure our line context is loaded
  33.     */
  34.    SetLineContext(wb, ws, wc);
  35.    /*
  36.     * check if we have to do wide line
  37.     */
  38.    if (wc->lineBundle.lGeomWidth > 0) {
  39.       /*
  40.        * load our area context to get the color right, and
  41.        * load the default pattern to fill the line
  42.        */
  43.       SetAreaContext(wb, ws, wc);
  44.       GpiSetPatternSet(stdbit, LCID_DEFAULT);
  45.       GpiSetPattern(stdbit, PATSYM_SOLID);
  46.       /*
  47.        * do the drawing on the bitmap
  48.        */
  49.       for (i = 0; i < narcs; i++) {
  50.      /*
  51.       * set the parameters
  52.       */
  53.      GpiSetArcParams(stdbit, &arcs[i].arcp);
  54.      a1 = arcs[i].angle1 * 1024;
  55.      a2 = arcs[i].angle2 * 1024;
  56.      if (a2 < MAKEFIXED(360, 0)) { /* partial arc */
  57.         /*
  58.          * sweep all the way around to find starting point
  59.          */
  60.         GpiSetLineType(stdbit, LINETYPE_INVISIBLE);
  61.         GpiPartialArc(stdbit, (PPOINTL)(&arcs[i].x), MAKEFIXED(1, 0),
  62.               a1, MAKEFIXED(360, 0));
  63.         /*
  64.          * set the line back and do the actual draw
  65.          */
  66.         GpiSetLineType(stdbit, wc->lineBundle.usType);
  67.         GpiBeginPath(stdbit, 1);
  68.         GpiPartialArc(stdbit, (PPOINTL)(&arcs[i].x), MAKEFIXED(1, 0),
  69.               a1, a2);
  70.         }
  71.      else { /* full arc */
  72.         /*
  73.          * move the center of the ellipse
  74.          */
  75.         GpiMove(stdbit, (PPOINTL)(&arcs[i].x));
  76.         GpiBeginPath(stdbit, 1);
  77.         GpiFullArc(stdbit, DRO_OUTLINE, MAKEFIXED(1, 0));
  78.         }
  79.      GpiEndPath(stdbit);
  80.      GpiStrokePath(stdbit, 1, 0);
  81.      }
  82.       if (stdwin && !(ws->winState & WS_MIN)) {
  83.      GpiSetPatternSet(stdwin, LCID_DEFAULT);
  84.      GpiSetPattern(stdwin, PATSYM_SOLID);
  85.      diff = ws->pixheight - ws->height;
  86.      for (i = 0; i < narcs; i++) {
  87.         arcs[i].y -= diff;
  88.         /*
  89.          * set the parameters
  90.          */
  91.         GpiSetArcParams(stdwin, &arcs[i].arcp);
  92.         a1 = arcs[i].angle1 * 1024;
  93.         a2 = arcs[i].angle2 * 1024;
  94.         if (a2 < MAKEFIXED(360, 0)) { /* partial arc */
  95.            /*
  96.         * sweep all the way around to find starting point
  97.         */
  98.            GpiSetLineType(stdwin, LINETYPE_INVISIBLE);
  99.            GpiPartialArc(stdwin, (PPOINTL)(&arcs[i].x), MAKEFIXED(1, 0),
  100.                  a1, MAKEFIXED(360, 0));
  101.            /*
  102.         * set the line back and do the actual draw
  103.         */
  104.            GpiSetLineType(stdwin, wc->lineBundle.usType);
  105.            GpiBeginPath(stdwin, 1);
  106.            GpiPartialArc(stdwin, (PPOINTL)(&arcs[i].x), MAKEFIXED(1, 0),
  107.                  a1, a2);
  108.            }
  109.         else { /* full arc */
  110.            /* move the center of the ellipse */
  111.            GpiMove(stdwin, (PPOINTL)(&arcs[i].x));
  112.            GpiBeginPath(stdwin, 1);
  113.            GpiFullArc(stdwin, DRO_OUTLINE, MAKEFIXED(1, 0));
  114.            }
  115.         GpiEndPath(stdwin);
  116.         GpiStrokePath(stdwin, 1, 0);
  117.         }
  118.      }
  119.       /*
  120.        * unset the area context
  121.        */
  122.       ws->areaContext = NULL;
  123.       }
  124.    else {
  125.       /*
  126.        * do the drawing on the bitmap
  127.        */
  128.       for (i = 0; i < narcs; i++) {
  129.      /*
  130.       * set the parameters
  131.       */
  132.      GpiSetArcParams(stdbit, &arcs[i].arcp);
  133.      a1 = arcs[i].angle1 * 1024;
  134.      a2 = arcs[i].angle2 * 1024;
  135.      if (a2 < MAKEFIXED(360, 0)) { /* partial arc */
  136.         /*
  137.          * sweep all the way around to find starting point
  138.          */
  139.         GpiSetLineType(stdbit, LINETYPE_INVISIBLE);
  140.         GpiPartialArc(stdbit, (PPOINTL)(&arcs[i].x), MAKEFIXED(1, 0),
  141.               a1, MAKEFIXED(360, 0));
  142.         /*
  143.          * set the line back and do the actual draw
  144.          */
  145.         GpiSetLineType(stdbit, wc->lineBundle.usType);
  146.         GpiPartialArc(stdbit, (PPOINTL)(&arcs[i].x), MAKEFIXED(1, 0),
  147.               a1, a2);
  148.         }
  149.      else { /* full arc */
  150.         /*
  151.          * move the center of the ellipse
  152.          */
  153.         GpiMove(stdbit, (PPOINTL)(&arcs[i].x));
  154.         GpiFullArc(stdbit, DRO_OUTLINE, MAKEFIXED(1, 0));
  155.         }
  156.      }
  157.       if (stdwin && !(ws->winState & WS_MIN)) {
  158.      diff = ws->pixheight - ws->height;
  159.      for (i = 0; i < narcs; i++) {
  160.         arcs[i].y -= diff;
  161.         /*
  162.          * set the parameters
  163.          */
  164.         GpiSetArcParams(stdwin, &arcs[i].arcp);
  165.         a1 = arcs[i].angle1 * 1024;
  166.         a2 = arcs[i].angle2 * 1024;
  167.         if (a2 < MAKEFIXED(360, 0)) { /* partial arc */
  168.            /*
  169.         * sweep all the way around to find starting point
  170.         */
  171.            GpiSetLineType(stdwin, LINETYPE_INVISIBLE);
  172.            GpiPartialArc(stdwin, (PPOINTL)(&arcs[i].x), MAKEFIXED(1, 0),
  173.                  a1, MAKEFIXED(360, 0));
  174.            /*
  175.         * set the line back and do the actual draw
  176.         */
  177.            GpiSetLineType(stdwin, wc->lineBundle.usType);
  178.            GpiPartialArc(stdwin, (PPOINTL)(&arcs[i].x), MAKEFIXED(1, 0),
  179.                  a1, a2);
  180.            }
  181.         else { /* full arc */
  182.            /*
  183.         * move the center of the ellipse
  184.         */
  185.            GpiMove(stdwin, (PPOINTL)(&arcs[i].x));
  186.            GpiFullArc(stdwin, DRO_OUTLINE, MAKEFIXED(1, 0));
  187.            }
  188.         }
  189.      }
  190.       }
  191.    MutexOff(ws);
  192.    return;
  193.    }
  194.  
  195.  
  196. /*
  197.  * drawlines - Support routine for XDrawLine
  198.  */
  199. void drawlines(wbinding *wb, XPoint *points, int npoints)
  200.    {
  201.    int i, diff, bheight;
  202.    STDLOCALS(wb);
  203.  
  204.    MutexOn(ws);
  205.  
  206.    bheight = ws->pixheight;
  207.    for (i = 0; i < npoints; i++)
  208.       points[i].y = bheight - points[i].y - 1;
  209.  
  210.    /*
  211.     * make sure our line context is loaded
  212.     */
  213.    SetLineContext(wb, ws, wc);
  214.    /*
  215.     * check if we have to do a wide line
  216.     */
  217.    if (wc->lineBundle.lGeomWidth > 0) {
  218.       /*
  219.        * load our area also - to get the colors right
  220.        */
  221.       SetAreaContext(wb, ws, wc);
  222.       GpiSetPatternSet(stdbit, LCID_DEFAULT);
  223.       GpiSetPattern(stdbit, PATSYM_SOLID);
  224.       /*
  225.        * move to the first point in bitmap
  226.        */
  227.       GpiBeginPath(stdbit, 1);
  228.       GpiMove(stdbit, (PPOINTL)points);
  229.       GpiPolyLine(stdbit, npoints - 1, (PPOINTL)&points[1]);
  230.       GpiEndPath(stdbit);
  231.       GpiStrokePath(stdbit, 1, 0);
  232.       /*
  233.        * do the window output - have to fixup the points
  234.        */
  235.       if (stdwin && !(ws->winState & WS_MIN)) {
  236.      diff = ws->pixheight - ws->height;
  237.      /*
  238.       * see if we can save ourselves some work
  239.       */
  240.      if (diff != 0)
  241.         for (i = 0; i < npoints; i++) points[i].y -= diff;
  242.      /*
  243.       * move to the first point
  244.       */
  245.      GpiSetPatternSet(stdwin, LCID_DEFAULT);
  246.      GpiSetPattern(stdwin, PATSYM_SOLID);
  247.      GpiBeginPath(stdwin, 1);
  248.      GpiMove(stdwin, (PPOINTL)points);
  249.      GpiPolyLine(stdwin, npoints - 1, (PPOINTL)&points[1]);
  250.      GpiEndPath(stdwin);
  251.      GpiStrokePath(stdwin, 1, 0);
  252.      }
  253.       /*
  254.        * unset our area for this window, since we change the PS
  255.        */
  256.       ws->areaContext = NULL;
  257.       }
  258.    else {
  259.       /*
  260.        * move to the first point in bitmap
  261.        */
  262.       GpiMove(stdbit, (PPOINTL)points);
  263.       GpiPolyLine(stdbit, npoints - 1, (PPOINTL)&points[1]);
  264.       /*
  265.        * do the window output - have to fixup the points
  266.        */
  267.       if (stdwin && !(ws->winState & WS_MIN)) {
  268.      diff = ws->pixheight - ws->height;
  269.      /*
  270.       * see if we can save ourselves some work
  271.       */
  272.      if (diff != 0)
  273.         for (i = 0; i < npoints; i++) points[i].y -= diff;
  274.      /*
  275.       * move to the first point
  276.       */
  277.      GpiMove(stdwin, (PPOINTL)points);
  278.      GpiPolyLine(stdwin, npoints - 1, (PPOINTL)&points[1]);
  279.      }
  280.       }
  281.  
  282.    MutexOff(ws);
  283.    return;
  284.    }
  285.  
  286. /*
  287.  * drawpoints() -
  288.  *  Parameters - the window binding for output, an array of points (assumed
  289.  *         to be fixed up for bitmap) and the number of points
  290.  */
  291. void drawpoints(wbinding *wb, XPoint *points, int npoints)
  292.    {
  293.    int i, diff, bheight;
  294.    STDLOCALS(wb);
  295.    MutexOn(ws);
  296.    bheight = ws->pixheight;
  297.    /*
  298.     * make sure our context is loaded
  299.     */
  300.    SetLineContext(wb, ws, wc);
  301.    /*
  302.     * fixup and draw the points to the bitmap first
  303.     */
  304.    for (i = 0; i < npoints; i++) {
  305.       points[i].y = bheight - points[i].y - 1;
  306.       GpiSetPel(stdbit, &points[i]);
  307.       }
  308.    /*
  309.     * if there is a window, fix up the points and draw them
  310.     */
  311.    if (stdwin && !(ws->winState & WS_MIN)) {
  312.       diff = ws->pixheight - ws->height;
  313.       for (i = 0; i < npoints; i++) {
  314.      points[i].y -= diff;
  315.      GpiSetPel(stdwin, &points[i]);
  316.      } /* End of for - run through points again, this time put to stdwin */
  317.       } /* End of if - window is there */
  318.    MutexOff(ws);
  319.    return;
  320.    }
  321.  
  322. /*
  323.  * drawsegments() -
  324.  */
  325. void drawsegments(wbinding *wb, XSegment *segs, int nsegs)
  326.    {
  327.    int i, diff, bheight;
  328.    STDLOCALS(wb);
  329.  
  330.    /*
  331.     * check for wide lines
  332.     */
  333.    if (wc->lineBundle.lGeomWidth > 0) {
  334.       /*
  335.        * Just break them into individual lines and pass to drawlines.
  336.        * This cast (seg to 2 points) should work because of the layout of
  337.        * the structures in graphics.h.
  338.        */
  339.       for (i = 0; i < nsegs; i++) drawlines(wb, (XPoint *)&segs[i], 2);
  340.       }
  341.    else {
  342.       MutexOn(ws);
  343.       bheight = ws->pixheight;
  344.       for (i = 0; i < nsegs; i++) {
  345.      segs[i].y1 = bheight - segs[i].y1 - 1;
  346.      segs[i].y2 = bheight - segs[i].y2 - 1;
  347.      }
  348.       /*
  349.        * make sure our context is loaded
  350.        */
  351.       SetLineContext(wb, ws, wc);
  352.       /*
  353.        * draw to the bitmap
  354.        */
  355.       GpiPolyLineDisjoint(stdbit, (nsegs << 1), (PPOINTL)segs);
  356.       /*
  357.        * draw to the window
  358.        */
  359.       if (stdwin && !(ws->winState & WS_MIN)) {
  360.      /*
  361.       * fix up points previously made for bitmap
  362.       */
  363.      diff = ws->pixheight - ws->height;
  364.      /*
  365.       * see if we can save some work
  366.       */
  367.      if (diff != 0)
  368.         for (i = 0; i < nsegs; i++) {
  369.            segs[i].y1 -= diff;
  370.            segs[i].y2 -= diff;
  371.            }
  372.      /*
  373.       * do the output
  374.       */
  375.      GpiPolyLineDisjoint(stdwin, (nsegs << 1), (PPOINTL)segs);
  376.      }
  377.       MutexOff(ws);
  378.       }
  379.    return;
  380.    }
  381.  
  382.  
  383. /*
  384.  * drawstrng()
  385.  */
  386. void drawstrng(wbinding *wb, int x, int y, char *s, int slen)
  387.    {
  388.    POINTL pt;
  389.    STDLOCALS(wb);
  390.  
  391.    MutexOn(ws);
  392.    /*
  393.     * make sure our context is loaded
  394.     */
  395.    SetCharContext(wb, ws, wc);
  396.    pt.x = x; pt.y = ws->pixheight - y;
  397.    GpiCharStringAt(stdbit, &pt, slen, s);
  398.    /*
  399.     * draw to window, if any
  400.     */
  401.    if (stdwin && !(ws->winState & WS_MIN)) {
  402.       pt.y = ws->height - y;
  403.       GpiCharStringAt(stdwin, &pt, slen, s);
  404.       }
  405.    MutexOff(ws);
  406.    return;
  407.    }
  408.  
  409. /*
  410.  * fillarcs
  411.  */
  412. void fillarcs(wbp wb, XArc *arcs, int narcs)
  413.    {
  414.    int i, diff, bheight;
  415.    unsigned long a1,a2;
  416.    STDLOCALS(wb);
  417.    bheight = ws->pixheight;
  418.    /*
  419.     * Fix up coordinates for window-system calls
  420.     */
  421.    for (i = 0; i < narcs; i++) {
  422.       /*
  423.        * width and height must be from center point... half them,
  424.        * and add the radii to (x,y) to get the center point.
  425.        */
  426.       arcs[i].arcp.lP >>= 1;
  427.       arcs[i].arcp.lQ >>= 1;
  428.       arcs[i].arcp.lR = arcs[i].arcp.lS = 0;
  429.       arcs[i].x += arcs[i].arcp.lP;
  430.       arcs[i].y += arcs[i].arcp.lQ;
  431.       arcs[i].y = bheight - arcs[i].y - 1;
  432.       }
  433.  
  434.    MutexOn(ws);
  435.    /*
  436.     * make sure our area context is loaded
  437.     */
  438.    SetAreaContext(wb, ws, wc);
  439.    /*
  440.     * set the line invisible for the partial arcs
  441.     */
  442.    GpiSetLineType(stdbit, LINETYPE_INVISIBLE);
  443.    /*
  444.     * do the drawing on the bitmap
  445.     */
  446.    for (i = 0; i < narcs; i++) {
  447.       /*
  448.        * set the parameters
  449.        */
  450.       GpiSetArcParams(stdbit, &arcs[i].arcp);
  451.       a1 = arcs[i].angle1 * 1024;
  452.       a2 = arcs[i].angle2 * 1024;
  453.       if (a2 < MAKEFIXED(360, 0)) { /* partial arc */
  454.      /*
  455.       * draw the arc invisible first so we know the ending point
  456.       */
  457.      GpiPartialArc(stdbit, (PPOINTL)(&arcs[i].x), MAKEFIXED(1, 0),
  458.                a1,  a2);
  459.      /*
  460.       * start an area
  461.       */
  462.      GpiBeginArea(stdbit, BA_BOUNDARY);
  463.      GpiLine(stdbit,(PPOINTL)(&arcs[i].x));
  464.      GpiPartialArc(stdbit, (PPOINTL)(&arcs[i].x), MAKEFIXED(1, 0),
  465.                a1, a2);
  466.      GpiEndArea(stdbit);
  467.      }
  468.       else { /* full arc */
  469.      /*
  470.       * move the center of the ellipse, then draw it
  471.       */
  472.      GpiMove(stdbit, (PPOINTL)(&arcs[i].x));
  473.      GpiFullArc(stdbit, DRO_FILL, MAKEFIXED(1, 0));
  474.      }
  475.       }
  476.  
  477.    if (ws->lineContext)
  478.       GpiSetLineType(stdbit, ws->lineContext->lineBundle.usType);
  479.    if (stdwin && !(ws->winState & WS_MIN)) {
  480.       diff = ws->pixheight - ws->height;
  481.       GpiSetLineType(stdwin, LINETYPE_INVISIBLE);
  482.       for (i = 0; i < narcs; i++) {
  483.      arcs[i].y -= diff;
  484.      /*
  485.       * set the parameters
  486.       */
  487.      GpiSetArcParams(stdwin, &arcs[i].arcp);
  488.      a1 = arcs[i].angle1 * 1024;
  489.      a2 = arcs[i].angle2 * 1024;
  490.      if (a2 < MAKEFIXED(360, 0)) { /* partial arc */
  491.         /*
  492.          * draw the arc first so we know the ending point
  493.          */
  494.         GpiPartialArc(stdwin, (PPOINTL)(&arcs[i].x), MAKEFIXED(1, 0),
  495.               a1, a2);
  496.         /*
  497.          * start an area
  498.          */
  499.         GpiBeginArea(stdwin, BA_BOUNDARY);
  500.         GpiLine(stdwin,(PPOINTL)(&arcs[i].x));
  501.         GpiPartialArc(stdwin, (PPOINTL)(&arcs[i].x), MAKEFIXED(1, 0),
  502.               a1, a2);
  503.         GpiEndArea(stdwin);
  504.         }
  505.      else { /* full arc */
  506.         /*
  507.          * move the center of the ellipse, then draw it
  508.          */
  509.         GpiMove(stdwin, (PPOINTL)(&arcs[i].x));
  510.         GpiFullArc(stdwin, DRO_FILL, MAKEFIXED(1, 0));
  511.         }
  512.      }
  513.       /*
  514.        * put the line type back to what it was
  515.        */
  516.       if (ws->lineContext)
  517.      GpiSetLineType(stdwin, ws->lineContext->lineBundle.usType);
  518.       }
  519.    MutexOff(ws);
  520.    return;
  521.    }
  522.  
  523. /*
  524.  * fillrectangles
  525.  *  Parameters - the window binding for output, an array of rectangle
  526.  *         structures (assumed to be fixed up for the bitmap),
  527.  *         a count of the number of structures -> the number of
  528.  *         rectangles
  529.  */
  530. void fillrectangles(wbp wb, XRectangle *recs, int nrecs)
  531.    {
  532.    int i, diff, bheight;
  533.    STDLOCALS(wb);
  534.  
  535.    bheight = ws->pixheight;
  536.    MutexOn(ws);
  537.    /*
  538.     * make sure the area is loaded
  539.     */
  540.    SetAreaContext(wb, ws, wc);
  541.    /*
  542.     * loop through the rectangle array, drawing to bitmap
  543.     */
  544.    for (i = 0; i < nrecs; i++) {
  545.       recs[i].yTop = bheight - recs[i].yTop - 1;
  546.       recs[i].xRight += recs[i].xLeft - 1;
  547.       recs[i].yBottom = recs[i].yTop - recs[i].yBottom + 1;
  548.       GpiMove(stdbit, (PPOINTL)&recs[i]);
  549.       GpiBox(stdbit, DRO_FILL, (PPOINTL)&(recs[i].xRight), 0, 0);
  550.       }
  551.    /*
  552.     * if the window is there, draw to it as well
  553.     */
  554.    if (stdwin && !(ws->winState & WS_MIN)) {
  555.       diff = ws->pixheight - ws->height;
  556.       for (i = 0; i < nrecs; i++) {
  557.      recs[i].yTop -= diff;
  558.      recs[i].yBottom -= diff;
  559.      GpiMove(stdwin, (PPOINTL)&recs[i]);
  560.      GpiBox(stdwin, DRO_FILL, (PPOINTL)&(recs[i].xRight), 0, 0);
  561.      }
  562.       }
  563.    MutexOff(ws);
  564.    return;
  565.    }
  566.  
  567. /*
  568.  * drawrectangles
  569.  *  Parameters - the window binding for output, an array of rectangle
  570.  *         a count of the number of structures -> the number of
  571.  *         rectangles
  572.  */
  573. void drawrectangles(wbp wb, XRectangle *recs, int nrecs)
  574.    {
  575.    int i, diff, bheight;
  576.    STDLOCALS(wb);
  577.  
  578.    MutexOn(ws);
  579.    bheight = ws->pixheight;
  580.    /*
  581.     * do the fixup (flip y for PM origin)
  582.     */
  583.    for (i = 0; i < nrecs; i++) {
  584.       recs[i].yTop = bheight - recs[i].yTop - 1;
  585.       recs[i].xRight += recs[i].xLeft;
  586.       recs[i].yBottom = recs[i].yTop - recs[i].yBottom;
  587.       }
  588.    /*
  589.     * make sure the line context is loaded
  590.     */
  591.    SetLineContext(wb, ws, wc);
  592.    /*
  593.     * check for wide lines
  594.     */
  595.    if (wc->lineBundle.lGeomWidth > 0) {
  596.       /*
  597.        * load the area context to get the colors/mix right
  598.        */
  599.       SetAreaContext(wb, ws, wc);
  600.       /*
  601.        * knock it out
  602.        */
  603.       ws->areaContext = NULL;
  604.       /*
  605.        * load the corrects fills
  606.        */
  607.       GpiSetPatternSet(stdbit, LCID_DEFAULT);
  608.       GpiSetPattern(stdbit, PATSYM_DEFAULT);
  609.       /*
  610.        * loop through the rectangle array, drawing to bitmap
  611.        */
  612.       for (i = 0; i < nrecs; i++) {
  613.      GpiBeginPath(stdbit, 1);
  614.      GpiMove(stdbit, (PPOINTL)&recs[i]);
  615.      GpiBox(stdbit, DRO_OUTLINE, (PPOINTL)&(recs[i].xRight), 0, 0);
  616.      GpiEndPath(stdbit);
  617.      GpiStrokePath(stdbit, 1, 0);
  618.      } /* End of for - draw rectangles on the bitmap */
  619.       if (stdwin && !(ws->winState & WS_MIN)) {
  620.      GpiSetPatternSet(stdwin, LCID_DEFAULT);
  621.      GpiSetPattern(stdwin, PATSYM_DEFAULT);
  622.      diff = ws->pixheight - ws->height;
  623.      for (i = 0; i < nrecs; i++) {
  624.         recs[i].yTop -= diff;
  625.         recs[i].yBottom -= diff;
  626.         GpiBeginPath(stdwin, 1);
  627.         GpiMove(stdwin, (PPOINTL)&recs[i]);
  628.         GpiBox(stdwin, DRO_OUTLINE, (PPOINTL)&(recs[i].xRight), 0, 0);
  629.         GpiEndPath(stdwin);
  630.         GpiStrokePath(stdwin, 1, 0);
  631.         }
  632.      }
  633.       }
  634.    else {
  635.       /*
  636.        * loop through the rectangle array, drawing to bitmap
  637.        */
  638.       for (i = 0; i < nrecs; i++) {
  639.      GpiMove(stdbit, (PPOINTL)&recs[i]);
  640.      GpiBox(stdbit, DRO_OUTLINE, (PPOINTL)&(recs[i].xRight), 0, 0);
  641.      }
  642.       if (stdwin && !(ws->winState & WS_MIN)) {
  643.      diff = ws->pixheight - ws->height;
  644.      for (i = 0; i < nrecs; i++) {
  645.         recs[i].yTop -= diff;
  646.         recs[i].yBottom -= diff;
  647.         GpiMove(stdwin, (PPOINTL)&recs[i]);
  648.         GpiBox(stdwin, DRO_OUTLINE, (PPOINTL)&(recs[i].xRight), 0, 0);
  649.         }
  650.      }
  651.       }
  652.    MutexOff(ws);
  653.    return;
  654.    }
  655.  
  656. /*
  657.  * fillpolygon
  658.  */
  659. void fillpolygon(wbp wb, XPoint *pts, int npts)
  660.    {
  661.    int i, diff, bheight = wb->window->pixheight;
  662.    POLYGON poly;
  663.    STDLOCALS(wb);
  664.  
  665.    MutexOn(ws);
  666.    /*
  667.     * set the fill
  668.     */
  669.    SetAreaContext(wb, ws, wc);
  670.    poly.aPointl = &pts[1];
  671.    poly.ulPoints = npts - 1;
  672.  
  673.    /*
  674.     * Draw the polygon on the pixmap.
  675.     * First, fix up the points' y coordinates, then
  676.     * move to the first point, and do the polygon starting from there.
  677.     */
  678.    for (i = 0; i < npts; i++)
  679.       pts[i].y = bheight - pts[i].y - 1;
  680.    GpiMove(stdbit, pts);
  681.    GpiPolygons(stdbit, 1, &poly, POLYGON_NOBOUNDARY | POLYGON_ALTERNATE,
  682.            POLYGON_INCL);
  683.    /*
  684.     * If there is a window, draw the polygon on it.
  685.     * First, further fix up the points' y coordinates if necessary, then
  686.     * move to the first point, and do the polygon starting from there.
  687.     */
  688.    if (stdwin && !(ws->winState & WS_MIN)) {
  689.       if (diff = ws->pixheight - ws->height)
  690.      for (i = 0; i < npts; i++)
  691.         pts[i].y -= diff;
  692.       GpiMove(stdwin, pts);
  693.       GpiPolygons(stdwin, 1, &poly, POLYGON_NOBOUNDARY | POLYGON_ALTERNATE,
  694.           POLYGON_INCL);
  695.       }
  696.    MutexOff(ws);
  697.    return;
  698.    }
  699. #else                    /* Graphics */
  700.   static char aaa;
  701. #endif                    /* Graphics */
  702.