home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 594a.lha / maker_v0.1 / drag.c < prev    next >
C/C++ Source or Header  |  1991-10-18  |  16KB  |  722 lines

  1. #include "maker.h"
  2. #include "proto.h"
  3.  
  4. #include <graphics/gfxmacros.h>
  5.  
  6. #include <proto/intuition.h>
  7. #include <proto/graphics.h>
  8. #include <proto/exec.h>
  9.  
  10. #include <math.h>
  11. #include <string.h>
  12.  
  13.  
  14. BOOL PtinRect(Point *pt, Rect *rect)
  15. {
  16.         if (    (pt->x >= rect->minX) &&
  17.                 (pt->x <= rect->maxX) &&
  18.                 (pt->y >= rect->minY) &&
  19.                 (pt->y <= rect->maxY) )
  20.             return TRUE;
  21.         else
  22.             return FALSE;
  23. }
  24.  
  25. BOOL PtbyLine(Point *pt, Rect *rect, short tol)
  26. {
  27.     double    m, b;
  28.     short        xf, yf, dx, dy;
  29.     long        d2;
  30.  
  31. /*        Check for the infinite slope case    */
  32.  
  33.     if (rect->minX == rect->maxX)
  34.     {
  35.         dx = abs(pt->x - rect->minX);
  36.         if (dx < tol)
  37.             return TRUE;
  38.     }
  39.     else
  40.     {
  41.  
  42.         m = (double) (rect->minY - rect->maxY) /
  43.                 (double) (rect->minX - rect->maxX);
  44.         b = rect->minY - m * rect->minX;
  45.     
  46.         xf = (pt->x - m * b + m * pt->y) / (m * m + 1.0) + 0.5;
  47.     
  48.         if ( (rect->minX < rect->maxX && rect->minX <= xf &&
  49.                     xf <= rect->maxX) || 
  50.                 (rect->minX > rect->maxX && rect->minX >= xf &&
  51.                     xf >= rect->maxX))
  52.         {
  53.             yf = m * xf + b + 0.5;
  54.             dx = xf - pt->x;
  55.             dy = yf - pt->y;
  56.             d2 = (long) dx * dx + (long) dy * dy;
  57.             if (d2 < tol * tol)
  58.                 return TRUE;
  59.         }
  60.     }
  61.  
  62.     return FALSE;
  63. }
  64.  
  65. BOOL DragRect(register Window *window, register Point *mouse, register Rect *rect)
  66. {
  67.     short                 poly[8],x,y,dx,dy,lastx,lasty,code,xmin,xmax,ymin,ymax;
  68.     struct RastPort    *rp;
  69.     ULONG                    class, flags;
  70.     Rect                    tempRect;
  71.  
  72.     short bordleft, bordtop, bordright, bordbottom;
  73. /*
  74.     UBYTE    mask;
  75. */
  76.     struct IntuiMessage *message;
  77.  
  78.     bordleft = window->BorderLeft;
  79.     bordright = window->BorderRight;
  80.     bordtop = window->BorderTop;
  81.     bordbottom = window->BorderBottom;
  82.  
  83.     rp = window->RPort;
  84. /*
  85.     mask = rp->Mask;
  86.     rp->Mask = 0x01;
  87. */
  88.     xmin = rect->minX;
  89.     xmax = rect->maxX;
  90.     ymin = rect->minY;
  91.     ymax = rect->maxY;
  92.  
  93.     poly[0] = xmax;            poly[1] = ymin;
  94.     poly[2] = xmax;            poly[3] = ymax;
  95.     poly[4] = xmin;            poly[5] = ymax;
  96.     poly[6] = xmin;            poly[7] = ymin;    
  97.  
  98.     lastx = mouse->x;
  99.     lasty = mouse->y;
  100.  
  101.     flags = window->IDCMPFlags;
  102.     ModifyIDCMP(window, IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE /* IDCMP_INTUITICKS */ );
  103.  
  104.     SetDrMd(rp, COMPLEMENT);
  105.     SetDrPt(rp, DASH);
  106.     Move(rp, xmin, ymin);
  107.     PolyDraw(rp, 4L, poly);
  108.  
  109.     FOREVER
  110.     {
  111.         while (message = (struct IntuiMessage *) 
  112.                 GetMsg(window->UserPort))
  113.         {
  114.             class = message->Class;
  115.             code = message->Code;
  116.             x = message->MouseX;
  117.             y = message->MouseY;
  118.             ReplyMsg((struct Message *) message);
  119.             switch(class)
  120.             {
  121.                 case IDCMP_MOUSEBUTTONS:
  122.                     if (code == SELECTUP)
  123.                     {
  124.                         rect->minX = poly[6];
  125.                         rect->minY = poly[7];
  126.                         rect->maxX = poly[2];
  127.                         rect->maxY = poly[3];
  128.  
  129.                         Move(rp,poly[6],poly[7]);
  130.                         PolyDraw(rp,4,poly);
  131.  
  132.                         SetDrMd(rp, JAM1);
  133.                         SetDrPt(rp, SOLID);
  134.                         
  135.                         ModifyIDCMP(window, flags);
  136. /*
  137.                         rp->Mask = mask;
  138. */
  139.                         if (xmin == rect->minX && ymin == rect->minY)
  140.                             return FALSE;
  141.                         else
  142.                             return TRUE;
  143.                     }
  144.                     break;
  145.  
  146.         /*        case IDCMP_INTUITICKS:    */
  147.         
  148.                 case IDCMP_MOUSEMOVE:
  149.  
  150.                     if (x < mouse->x - xmin + bordleft)
  151.                         x = mouse->x - xmin + bordleft;     
  152.                     else if (window->Width - 1 - bordright - x <
  153.                                 xmax - mouse->x)
  154.                         x = window->Width - 1 - bordright - (xmax - mouse->x);        
  155.                     if (y < mouse->y - ymin + bordtop)
  156.                         y = mouse->y - ymin + bordtop;
  157.                     else if (window->Height - 1 - bordbottom - y <
  158.                                 ymax - mouse->y)
  159.                         y = window->Height - 1 - bordbottom - (ymax - mouse->y);
  160.  
  161.                     if (x != lastx || y != lasty)
  162.                     {      
  163.                         Move(rp,poly[6],poly[7]);
  164.                         PolyDraw(rp,4,poly);
  165.                         dx = x - lastx;
  166.                         dy = y - lasty;
  167.                         poly[0] += dx;
  168.                         poly[2] += dx;
  169.                         poly[4] += dx;
  170.                         poly[6] += dx;
  171.                         poly[1] += dy;
  172.                         poly[3] += dy;
  173.                         poly[5] += dy;
  174.                         poly[7] += dy;
  175.                         Move(rp,poly[6],poly[7]);
  176.                         Draw(rp,poly[0],poly[1]);
  177.                         Draw(rp,poly[2],poly[3]);
  178.                         Draw(rp,poly[4],poly[5]);
  179.                         Draw(rp,poly[6],poly[7]);
  180. /*
  181.                         PolyDraw(rp,4,poly);
  182. */
  183.                         lastx = x;
  184.                         lasty = y;
  185.                     
  186.                         // update the information window
  187.                     
  188.                         tempRect.minX = poly[6];
  189.                         tempRect.minY = poly[7];
  190.                         tempRect.maxX = poly[2];
  191.                         tempRect.maxY = poly[3];
  192.                         
  193.                         UpdateInfoWindow(&tempRect);
  194.                     }
  195.                     break;
  196.                 default:
  197.                     break;
  198.             }
  199.         }
  200. /*
  201.       wait only if the already available messages did not satisfy the request
  202. */
  203.         Wait(1<<window->UserPort->mp_SigBit);
  204.     }
  205. }
  206.  
  207. BOOL DragLine(register Window *window, register Point *mouse, register Rect *rect)
  208. {
  209.     short        cpx1, cpx2, cpy1, cpy2, x, y, dx, dy, lastx, lasty;
  210.     short        code,xmin,xmax,ymin,ymax;
  211.     struct RastPort    *rp;
  212.     ULONG        class,flags;
  213.     struct IntuiMessage *message;
  214.  
  215.     short bordleft, bordtop, bordright, bordbottom;
  216.     bordleft = window->BorderLeft;
  217.     bordright = window->BorderRight;
  218.     bordtop = window->BorderTop;
  219.     bordbottom = window->BorderBottom;
  220.  
  221.     rp = window->RPort;
  222.  
  223.     xmin = rect->minX;
  224.     xmax = rect->maxX;
  225.     ymin = rect->minY;
  226.     ymax = rect->maxY;
  227.  
  228.     cpx1 = xmin;
  229.     cpy1 = ymin;
  230.     cpx2 = xmax;
  231.     cpy2 = ymax;
  232.  
  233.     lastx = mouse->x;
  234.     lasty = mouse->y;
  235.  
  236.     flags = window->IDCMPFlags;
  237.     ModifyIDCMP(window, MOUSEBUTTONS | INTUITICKS);
  238.  
  239.     SetDrMd(rp, COMPLEMENT);
  240.     SetDrPt(rp, DASH);
  241.     Move(rp, xmin, ymin);
  242.     Draw(rp, xmax, ymax);
  243.  
  244.     FOREVER
  245.     {
  246.         while (message = (struct IntuiMessage *) 
  247.                 GetMsg(window->UserPort))
  248.         {
  249.             class = message->Class;
  250.             code = message->Code;
  251.             x = message->MouseX;
  252.             y = message->MouseY;
  253.             ReplyMsg((struct Message *) message);
  254.             switch(class)
  255.             {
  256.                 case MOUSEBUTTONS:
  257.                     if (code == SELECTUP)
  258.                     {
  259.                         rect->minX = cpx1;
  260.                         rect->minY = cpy1;
  261.                         rect->maxX = cpx2;
  262.                         rect->maxY = cpy2;
  263.  
  264.                         Move(rp, cpx1, cpy1);
  265.                         Draw(rp, cpx2, cpy2);
  266.  
  267.                         SetDrMd(rp, JAM1);
  268.                         SetDrPt(rp, SOLID);
  269.                         
  270.                         ModifyIDCMP(window, flags);
  271.  
  272.                         if (xmin == rect->minX && ymin == rect->minY)
  273.                             return FALSE;
  274.                         else
  275.                             return TRUE;
  276.                     }
  277.                     break;
  278.  
  279.                 case INTUITICKS:
  280.                if (xmin < xmax)
  281.                     {
  282.                         if (x < mouse->x - xmin + bordleft)
  283.                             x = mouse->x - xmin + bordleft;     
  284.                         else if (window->Width - 1 - bordright - x <
  285.                                     xmax - mouse->x)
  286.                             x = window->Width - 1 - bordright - (xmax - mouse->x);        
  287.                     }
  288.                else
  289.                     {
  290.                         if (x < mouse->x - xmax + bordleft)
  291.                             x = mouse->x - xmax + bordleft;     
  292.                         else if (window->Width - 1 - bordright - x <
  293.                                     xmin - mouse->x)
  294.                             x = window->Width - 1 - bordright -
  295.                                 (xmin - mouse->x);        
  296.                     }
  297.  
  298.                     if (ymin < ymax)
  299.                     {
  300.                         if (y < mouse->y - ymin + bordtop)
  301.                             y = mouse->y - ymin + bordtop;
  302.                         else if (window->Height - 1 - bordbottom - y <
  303.                                     ymax - mouse->y)
  304.                             y = window->Height - 1 - bordbottom - (ymax - mouse->y);
  305.                     }
  306.                     else
  307.                     {
  308.                         if (y < mouse->y - ymax + bordtop)
  309.                             y = mouse->y - ymax + bordtop;
  310.                         else if (window->Height - 1 - bordbottom - y <
  311.                                     ymin - mouse->y)
  312.                             y = window->Height - 1 - bordbottom -
  313.                                 (ymin - mouse->y);
  314.                     }
  315.  
  316.                     if (x != lastx || y != lasty)
  317.                     {      
  318.                         Move(rp, cpx1, cpy1);
  319.                         Draw(rp, cpx2, cpy2);
  320.                         dx = x - lastx;
  321.                         dy = y - lasty;
  322.                         cpx1 += dx;
  323.                         cpy1 += dy;
  324.                         cpx2 += dx;
  325.                         cpy2 += dy;
  326.         
  327.                         Move(rp, cpx1, cpy1);
  328.                         Draw(rp, cpx2, cpy2);
  329.  
  330.                         lastx = x;
  331.                         lasty = y;
  332.                     }
  333.                     break;
  334.                 default:
  335.                     break;
  336.             }
  337.         }
  338. /*
  339.       wait only if the already available messages did not satisfy the request
  340. */
  341.         Wait(1<<window->UserPort->mp_SigBit);
  342.     }
  343. }
  344.  
  345. BOOL SizeLine(register Window *window, register Point *mouse, Point *start, Point *anchor)
  346. {
  347.     short        cpx1, cpy1, x, y, dx, dy, lastx, lasty, code;
  348.     struct RastPort    *rp;
  349.     ULONG        class, flags;
  350.     struct IntuiMessage *message;
  351.  
  352.     short bordleft, bordtop, bordright, bordbottom;
  353.     bordleft = window->BorderLeft;
  354.     bordright = window->BorderRight;
  355.     bordtop = window->BorderTop;
  356.     bordbottom = window->BorderBottom;
  357.  
  358.     rp = window->RPort;
  359.  
  360.     cpx1 = start->x;
  361.     cpy1 = start->y;
  362.  
  363.     lastx = mouse->x;
  364.     lasty = mouse->y;
  365.  
  366.     flags = window->IDCMPFlags;
  367.     ModifyIDCMP(window, MOUSEBUTTONS | INTUITICKS);
  368.  
  369.     SetDrMd(rp, COMPLEMENT);
  370.     SetDrPt(rp, DASH);
  371.     Move(rp, start->x, start->y);
  372.     Draw(rp, anchor->x, anchor->y);
  373.  
  374.     FOREVER
  375.     {
  376.         while (message = (struct IntuiMessage *) 
  377.                 GetMsg(window->UserPort))
  378.         {
  379.             class = message->Class;
  380.             code = message->Code;
  381.             x = message->MouseX;
  382.             y = message->MouseY;
  383.             ReplyMsg((struct Message *) message);
  384.             switch(class)
  385.             {
  386.                 case MOUSEBUTTONS:
  387.                     if (code == SELECTUP)
  388.                     {
  389.                         start->x = cpx1;
  390.                         start->y = cpy1;
  391.  
  392.                         Move(rp, cpx1, cpy1);
  393.                         Draw(rp, anchor->x, anchor->y);
  394.  
  395.                         SetDrMd(rp, JAM1);
  396.                         SetDrPt(rp, SOLID);
  397.                         
  398.                         ModifyIDCMP(window, flags);
  399.  
  400.                         if (start->x == cpx1 && start->y == cpy1)
  401.                             return FALSE;
  402.                         else
  403.                             return TRUE;
  404.                     }
  405.                     break;
  406.  
  407.                 case INTUITICKS:
  408.  
  409.                     if (x < mouse->x - start->x + bordleft)
  410.                         x = mouse->x - start->x + bordleft;     
  411.                     else if (window->Width - 1 - bordright - x <
  412.                                 start->x - mouse->x)
  413.                         x = window->Width - 1 - bordright -
  414.                             (start->x - mouse->x);        
  415.                     if (y < mouse->y - start->y + bordtop)
  416.                         y = mouse->y - start->y + bordtop;
  417.                     else if (window->Height - 1 - bordbottom - y <
  418.                                 start->y - mouse->y)
  419.                         y = window->Height - 1 - bordbottom -
  420.                             (start->y - mouse->y);
  421.  
  422.                     if (x != lastx || y != lasty)
  423.                     {      
  424.                         Move(rp, cpx1, cpy1);
  425.                         Draw(rp, anchor->x, anchor->y);
  426.                         dx = x - lastx;
  427.                         dy = y - lasty;
  428.                         cpx1 += dx;
  429.                         cpy1 += dy;
  430.         
  431.                         Move(rp, cpx1, cpy1);
  432.                         Draw(rp, anchor->x, anchor->y);
  433.  
  434.                         lastx = x;
  435.                         lasty = y;
  436.                     }
  437.                     break;
  438.                 default:
  439.                     break;
  440.             }
  441.         }
  442. /*
  443.       wait only if the already available messages did not satisfy the request
  444. */
  445.         Wait(1<<window->UserPort->mp_SigBit);
  446.     }
  447. }
  448.  
  449. BOOL DragPoly(register Window *window, register Point *mouse, short npts, register short *points)
  450. {
  451.     short                    *poly, x, y, dx, dy, lastx, lasty, code,
  452.                             xmin, xmax, ymin, ymax, *temp, i;
  453.     struct RastPort    *rp;
  454.     ULONG                    class,flags;
  455.     BOOL                    flag;
  456. /*
  457.     UBYTE    mask;
  458. */
  459.     struct IntuiMessage *message;
  460.  
  461.     short bordleft, bordtop, bordright, bordbottom;
  462.     bordleft = window->BorderLeft;
  463.     bordright = window->BorderRight;
  464.     bordtop = window->BorderTop;
  465.     bordbottom = window->BorderBottom;
  466.  
  467.     if (!npts)
  468.         return FALSE;
  469.     if (!GetMem((void **) &poly, (long) npts * sizeof(short)))
  470.         return FALSE;
  471.  
  472.     memcpy((char *) poly, (char *) points, (int) npts * sizeof(short));
  473.  
  474.     rp = window->RPort;
  475. /*
  476.     mask = rp->Mask;
  477.     rp->Mask = 0x01;
  478. */
  479. /*
  480.         Find the minima and maxima of the vertices
  481. */
  482.     xmin = 30000;
  483.     xmax = 0;
  484.     ymin = 30000;
  485.     ymax = 0;
  486.     temp = poly;
  487.     for (i=0; i<npts; i++)
  488.     {
  489.         if (*temp < xmin)
  490.             xmin = *temp;
  491.         else if (*temp > xmax)
  492.             xmax = *temp;
  493.  
  494.         temp++;
  495.         if (*temp < ymin)
  496.             ymin = *temp;
  497.         else if (*temp > ymax)
  498.             ymax = *temp;
  499.  
  500.         temp++;
  501.     }
  502.  
  503.     lastx = mouse->x;
  504.     lasty = mouse->y;
  505.  
  506.     flags = window->IDCMPFlags;
  507.     ModifyIDCMP(window, MOUSEBUTTONS | INTUITICKS);
  508.  
  509.     SetDrMd(rp, COMPLEMENT);
  510.     SetDrPt(rp, DASH);
  511.     Move(rp, poly[0], poly[1]);
  512.     PolyDraw(rp, (long) npts, poly);
  513.  
  514.     FOREVER
  515.     {
  516.         while (message = (struct IntuiMessage *) 
  517.                 GetMsg(window->UserPort))
  518.         {
  519.             class = message->Class;
  520.             code = message->Code;
  521.             x = message->MouseX;
  522.             y = message->MouseY;
  523.             ReplyMsg((struct Message *) message);
  524.  
  525.             switch(class)
  526.             {
  527.                 case MOUSEBUTTONS:
  528.                     if (code == SELECTUP)
  529.                     {
  530.                         if (poly[0] == points[0] && poly[1] == points[1])
  531.                             flag = FALSE;
  532.                         else
  533.                             flag = TRUE;
  534.                         memcpy((char *) poly, (char *) points,
  535.                             (int) npts * sizeof(short));
  536.                         Move(rp, poly[0], poly[1]);
  537.                         PolyDraw(rp, (long) npts, poly);
  538.  
  539.                         SetDrMd(rp, JAM1);
  540.                         SetDrPt(rp, SOLID);
  541.                         
  542.                         ModifyIDCMP(window, flags);
  543. /*
  544.                         rp->Mask = mask;
  545. */
  546.                         DropMem( (void **) &poly, (long) npts * sizeof(short));
  547.                         
  548.                         return flag;
  549.                     }
  550.                     break;
  551.  
  552.                 case INTUITICKS:
  553.  
  554.                     if (x < mouse->x - xmin + bordleft)
  555.                         x = mouse->x - xmin + bordleft;     
  556.                     else if (window->Width - 1 - bordright - x <
  557.                                 xmax - mouse->x)
  558.                         x = window->Width - 1 - bordright - (xmax - mouse->x);        
  559.                     if (y < mouse->y - ymin + bordtop)
  560.                         y = mouse->y - ymin + bordtop;
  561.                     else if (window->Height - 1 - bordbottom - y <
  562.                                 ymax - mouse->y)
  563.                         y = window->Height - 1 - bordbottom - (ymax - mouse->y);
  564.  
  565.                     if (x != lastx || y != lasty)
  566.                     {      
  567.                         Move(rp, poly[0], poly[1]);
  568.                         PolyDraw(rp, (long) npts, poly);
  569.                         dx = x - lastx;
  570.                         dy = y - lasty;
  571.                         temp = poly;
  572.  
  573.                         for (i=0; i<npts; i++)
  574.                         {
  575.                             *temp++ += dx;
  576.                             *temp++ += dy;
  577.                         }
  578.                         Move(rp, poly[0], poly[1]);
  579.                         PolyDraw(rp, (long) npts, poly);
  580.  
  581.                         lastx = x;
  582.                         lasty = y;
  583.                     }
  584.                     break;
  585.                 default:
  586.                     break;
  587.             }
  588.         }
  589. /*
  590.       wait only if the already available messages did not satisfy the request
  591. */
  592.         Wait(1<<window->UserPort->mp_SigBit);
  593.     }
  594. }
  595.  
  596. /*******************************************************************************************/
  597.  
  598. BOOL SizeRect(register Window *window, register Point *mouse, register Rect *rect,
  599.                     Point *minsize, Point *maxsize)
  600. {
  601.     short                poly[8], x, y, dx, dy, lastx, lasty, code, xmin, xmax, ymin, ymax;
  602.     RastPort            *rp;
  603.     ULONG                class,flags;
  604.     IntuiMessage    *message;
  605.     Rect                tempRect;
  606.  
  607.     short                bordleft, bordtop, bordright, bordbottom;
  608.     
  609.     bordleft = window->BorderLeft;
  610.     bordright = window->BorderRight;
  611.     bordtop = window->BorderTop;
  612.     bordbottom = window->BorderBottom;
  613.  
  614.     rp = window->RPort;
  615.  
  616.     xmin = rect->minX;
  617.     xmax = rect->maxX;
  618.     ymin = rect->minY;
  619.     ymax = rect->maxY;
  620.  
  621.     poly[0] = xmax;            poly[1] = ymin;
  622.     poly[2] = xmax;            poly[3] = ymax;
  623.     poly[4] = xmin;            poly[5] = ymax;
  624.     poly[6] = xmin;            poly[7] = ymin;    
  625.  
  626.     lastx = mouse->x;
  627.     lasty = mouse->y;
  628.  
  629.     flags = window->IDCMPFlags;
  630.     ModifyIDCMP(window, IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE /* INTUITICKS */);
  631.  
  632.     SetDrMd(rp, COMPLEMENT);
  633.     SetDrPt(rp, DASH);
  634.     Move(rp, xmin, ymin);
  635.     PolyDraw(rp, 4, poly);
  636.  
  637.     FOREVER
  638.     {
  639.         while (message = (IntuiMessage *) GetMsg(window->UserPort))
  640.         {
  641.             class = message->Class;
  642.             code = message->Code;
  643.             x = message->MouseX;
  644.             y = message->MouseY;
  645.             ReplyMsg((Message *) message);
  646.             switch(class)
  647.             {
  648.                 case IDCMP_MOUSEBUTTONS:
  649.                     if (code == SELECTUP)
  650.                     {
  651.                         Move(rp, poly[6], poly[7]);
  652.                         PolyDraw(rp, 4, poly);
  653.  
  654.                         SetDrMd(rp, JAM1);
  655.                         SetDrPt(rp, SOLID);
  656.  
  657.                         ModifyIDCMP(window, flags);
  658.  
  659.                         if (poly[2] == xmax && poly[3] == ymax)
  660.                             return FALSE;
  661.  
  662.                         rect->maxX = poly[2];
  663.                         rect->maxY = poly[3];
  664.  
  665.                         return TRUE;
  666.                     }
  667.                     break;
  668.         /*        case IDCMP_INTUITICKS:    */
  669.                 case IDCMP_MOUSEMOVE:
  670.  
  671.                     if (x - xmin < minsize->x)
  672.                         x = xmin + minsize->x;
  673.                     else if (x - xmin > maxsize->x)
  674.                         x = xmin + maxsize->x;
  675.                     if (y - ymin < minsize->y)
  676.                         y = ymin + minsize->y;
  677.                     else if (y - ymin > maxsize->y)
  678.                         y = ymin + maxsize->y;
  679.  
  680.                     if (window->Width - 1 - bordright - x < xmax - mouse->x)
  681.                         x = window->Width - 1 - bordright - (xmax - mouse->x);        
  682.                     if (window->Height - 1 - bordbottom - y < ymax - mouse->y)
  683.                         y = window->Height - 1 - bordbottom - (ymax - mouse->y);
  684.  
  685.                     if (x != lastx || y != lasty)
  686.                     {      
  687.                         Move(rp, poly[6], poly[7]);
  688.                         PolyDraw(rp, 4, poly);
  689.                         dx = x - lastx;
  690.                         dy = y - lasty;
  691.                         poly[0] += dx;
  692.                         poly[2] += dx;
  693.                         poly[3] += dy;
  694.                         poly[5] += dy;
  695.                         Move(rp,poly[6],poly[7]);
  696.                         PolyDraw(rp,4,poly);
  697.                         lastx = x;
  698.                         lasty = y;
  699.                         
  700.                         // update the information window
  701.                     
  702.                         tempRect.minX = poly[6];
  703.                         tempRect.minY = poly[7];
  704.                         tempRect.maxX = poly[2];
  705.                         tempRect.maxY = poly[3];
  706.                         
  707.                         UpdateInfoWindow(&tempRect);
  708.                     }
  709.                     break;
  710.                 default:
  711.                     break;
  712.             }
  713.         }
  714. /*
  715.       wait only if the already available messages did not satisfy the request
  716. */
  717.         Wait(1<<window->UserPort->mp_SigBit);
  718.     }
  719. }
  720.  
  721.  
  722.