home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / BlobMgr / Library Folder / TrackMouse.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-21  |  700 b   |  36 lines  |  [TEXT/KAHL]

  1. # include    "BlobMgr.h"
  2.  
  3.  
  4. /*
  5.  * Track the mouse while the button is held down.  Invert the given
  6.  * blob region whenever the mouse is in the region.  Return true if
  7.  * the mouse is released inside of the region, false otherwise.
  8.  */
  9.  
  10. pascal Boolean
  11. BTrackMouse (BlobHandle b, Point startPt, short partCode)
  12. {
  13. Boolean        inBlob;
  14. RgnHandle    rgn;
  15. Point        pt;
  16.  
  17.     rgn = BCalcRegion (b, partCode);
  18.     pt = startPt;
  19.     inBlob = false;
  20.     for (;;)
  21.     {
  22.         if (PtInRgn (pt, rgn) != inBlob)    /* invert on change of state */
  23.         {
  24.             InvertRgn (rgn);
  25.             inBlob = !inBlob;
  26.         }
  27.         if (!StillDown ())
  28.             break;
  29.         GetMouse (&pt);
  30.     }
  31.     if (inBlob)        /* leave region uninverted */
  32.         InvertRgn (rgn);
  33.     DisposeRgn (rgn);
  34.     return (inBlob);
  35. }
  36.