home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / intuition / pointinimage.c < prev    next >
C/C++ Source or Header  |  1997-01-27  |  3KB  |  109 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: pointinimage.c,v 1.4 1997/01/27 00:36:42 ldp Exp $
  4.     $Log: pointinimage.c,v $
  5.     Revision 1.4  1997/01/27 00:36:42  ldp
  6.     Polish
  7.  
  8.     Revision 1.3  1996/12/10 14:00:07  aros
  9.     Moved #include into first column to allow makedepend to see it.
  10.  
  11.     Revision 1.2  1996/10/24 15:51:23  aros
  12.     Use the official AROS macros over the __AROS versions.
  13.  
  14.     Revision 1.1  1996/10/23 15:33:52  aros
  15.     Three new functions: DrawImageState(), EraseImage() and PointInImage()
  16.     by C. Aldi.
  17.  
  18.     First version of IMAGECLASS by C. Aldi
  19.  
  20.  
  21.     Desc:
  22.     Lang: english
  23. */
  24. #include "intuition_intern.h"
  25. #include <intuition/classusr.h>
  26. #include <proto/alib.h>
  27.  
  28. /*****************************************************************************
  29.  
  30.     NAME */
  31. #include <intuition/intuition.h>
  32. #include <intuition/imageclass.h>
  33. #include <proto/intuition.h>
  34.  
  35.     AROS_LH2(BOOL, PointInImage,
  36.  
  37. /*  SYNOPSIS */
  38.     AROS_LHA(ULONG,          point, D0),
  39.     AROS_LHA(struct Image *, image, A0),
  40.  
  41. /*  LOCATION */
  42.     struct IntuitionBase *, IntuitionBase, 104, Intuition)
  43.  
  44. /*  FUNCTION
  45.     Check whether a point is inside an image.
  46.  
  47.     INPUTS
  48.     point - This are the packed point coordinates. The X coordinate
  49.         in in the upper 16 bits and the Y coordinate is in the
  50.         lower 16 bits. The coordinates are signed.
  51.     image - Check against this image.
  52.  
  53.     RESULT
  54.     TRUE is the point is inside the image, FALSE otherwise.
  55.  
  56.     NOTES
  57.  
  58.     EXAMPLE
  59.  
  60.     BUGS
  61.  
  62.     SEE ALSO
  63.  
  64.     INTERNALS
  65.  
  66.     HISTORY
  67.     29-10-95    digulla automatically created from
  68.                 intuition_lib.fd and clib/intuition_protos.h
  69.  
  70. *****************************************************************************/
  71. {
  72.     AROS_LIBFUNC_INIT
  73.     AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  74.     BOOL result;
  75.     WORD X = (point >> 16L);
  76.     WORD Y =  point & 0x0000FFFFL;
  77.  
  78.     if (image != NULL)
  79.     {
  80.     if (image->Depth == CUSTOMIMAGEDEPTH)
  81.     {
  82.         /* I'm making a possibly wrong assumption here regarding the
  83.          * X/Y point structure and the packed word order of the point.
  84.          */
  85.         result = (BOOL)DoMethod((Object *)image,
  86.         IM_HITTEST, (WORD)X, (WORD)Y
  87.         );
  88.     }
  89.     else
  90.     {
  91.  
  92.         if ((X >= image->LeftEdge && X <= image->LeftEdge + image->Width) &&
  93.         (Y >= image->TopEdge  && Y <= image->TopEdge  + image->Height)
  94.         )
  95.         {
  96.         result = TRUE;
  97.         }
  98.     }
  99.     }
  100.     else
  101.     {
  102.     /* NULL image returns TRUE per intuition autodoc! */
  103.     result = TRUE;
  104.     }
  105.  
  106.     return (result);
  107.     AROS_LIBFUNC_EXIT
  108. } /* PointInImage */
  109.