home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / lemming / part02 / lemselect.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-08-05  |  916 b   |  51 lines

  1. /*
  2.  * lemselect.c - object selection and proximity testing
  3.  *
  4.  * copyright (c) by Alan W. Paeth, 1987. All rights reserved.
  5.  */
  6.  
  7. #include "lem.h"
  8.  
  9. cycleselect()
  10.     {
  11.     if (markobj)
  12.     {
  13.     if (objs[markobj]->stat == UNDEL) any(markobj, SELECT);
  14.     else if (objs[markobj]->stat == SEL) any(markobj, DESELECT);
  15.     }
  16.     }
  17.  
  18. rectselect(x0, y0, x1, y1)
  19.     {
  20.     int i, mode, xl, yl, xh, yh;
  21.     xl = MIN(x0, x1);
  22.     yl = MIN(y0, y1);
  23.     xh = MAX(x0, x1);
  24.     yh = MAX(y0, y1);
  25.     mode = (y0 < y1) ? DESELECT : SELECT;
  26.     forobjects
  27.     {
  28.     if (objinrect(i, xl, yl, xh, yh)) any(i, mode);
  29.     }
  30.     }
  31.  
  32. objnearany(x, y)
  33.     {
  34.     int i;
  35.     if (i = objnear(x, y, UNDEL)) return(i);
  36.     return(objnear(x, y, SEL));
  37.     }
  38.  
  39. objnear(x, y, stat)
  40.     {
  41.     int i;
  42.     forobjsrev        /* reverse order search - most recent appears first */
  43.     {
  44.     if (Ostat == stat)
  45.         {
  46.         if (objnearpt(i, x, y)) return(i);
  47.         }
  48.     }
  49.     return(0);
  50.     }
  51.