home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IDMIMAGE.HPP < prev    next >
C/C++ Source or Header  |  1993-10-22  |  11KB  |  223 lines

  1. #ifndef _IDMIMAGE_
  2. #define _IDMIMAGE_
  3. /*******************************************************************************
  4. * FILE NAME: idmimage.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   This file contains the declaration(s) of the class(es):                    *
  8. *     IDMImage - Base direct manipulation "image" class.                       *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   Licensed Materials - Property of IBM                                       *
  12. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  13. *   All Rights Reserved                                                        *
  14. *   US Government Users Restricted Rights - Use, duplication, or               *
  15. *   disclosure                                                                 *
  16. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  17. *                                                                              *
  18. *******************************************************************************/
  19. #ifndef _IVBASE_
  20.   #include <ivbase.hpp>
  21. #endif
  22.  
  23. #ifndef _IPOINT_
  24.   #include <ipoint.hpp>
  25. #endif
  26.  
  27. #ifndef _IRESLIB_
  28.   #include <ireslib.hpp>
  29. #endif
  30.  
  31. #ifndef _IBITFLAG_
  32.   #include <ibitflag.hpp>
  33. #endif
  34.  
  35. /*----------------------------------------------------------------------------*/
  36. /* Align classes on four byte boundary.                                       */
  37. /*----------------------------------------------------------------------------*/
  38. #pragma pack(4)
  39.  
  40. /* Forward Declarations */
  41. struct _DRAGIMAGE;
  42.  
  43. class IDMImage : public IVBase {
  44. typedef IVBase
  45.   Inherited;
  46.  
  47. /*******************************************************************************
  48. * This is the common base class for the direct manipulation drag image         *
  49. * classes.  This base class provides the common support required to represent  *
  50. * the image of IDMItem objects that are dragged during a direct manipulation   *
  51. * operation.                                                                   *
  52. *                                                                              *
  53. * Objects of this class are created to provide an image to be displayed for    *
  54. * each IDMItem object being dragged.  As each IDMItem object is created, this  *
  55. * class can be created and attatched to it such that proper image              *
  56. * representation can be made during the direct manipulation operation.  If     *
  57. * this class is not attatched to IDMItem objects, default system icons will be *
  58. * used for images.                                                             *
  59. *                                                                              *
  60. * Objects of this class possess the following attributes (in addition to       *
  61. * those inherited from its base class):                                        *
  62. *   o image handle.                                                            *
  63. *   o stretch size for image.                                                  *
  64. *   o styles to determine type and shape of image.                             *
  65. *   o offset of image from the pointing device.                                *
  66. *   o number of points in a point arrary if certain styles are set.            *
  67. *                                                                              *
  68. * Ojbects of this class are not necessary to create if using IDM::systemImages *
  69. * for the images.  (See idmcomm.hpp) Use of IDM::systemImages will cause       *
  70. * system images to be generated and used, thus ignoring any images attatched   *
  71. * to IDMItem objects.                                                          *
  72. *******************************************************************************/
  73.  
  74. public:
  75. /*--------------------------------- Image Styles -------------------------------
  76. | The following static members provide the set of pre-defined image styles:    |
  77. |   ptr         - image is an IPointerHandle.                                  |
  78. |   bmp         - image is an IBitmapHandle.                                   |
  79. |   polygon     - image is a pointer to an array of points that will be        |
  80. |                 connected to form a polygon.  The first point of the array   |
  81. |                 should be (0,0), and the other points should be placed       |
  82. |                 relative to this position.                                   |
  83. |   stretch     - if the image is an IPointerHandle or an IBitmapHandle, the   |
  84. |                 image is stretched to the dimensions specified by            |
  85. |                 stretchSize.                                                 |
  86. |   transparent - if the image is an IPointerHandle, an outline of the image   |
  87. |                 is generated and displayed instead of the original image.    |
  88. |   closed      - if the image is a polygon, a closed polygon is formed by     |
  89. |                 moving the current position to the last point in the array   |
  90. |                 before drawing.                                              |
  91. ------------------------------------------------------------------------------*/
  92. INESTEDBITFLAGCLASSDEF0(Style, IDMImage);
  93. static const Style
  94.   ptr,
  95.   bmp,
  96.   polygon,
  97.   stretch,
  98.   transparent,
  99.   closed;
  100.  
  101. /*------------------------- Constructors/Destructor ----------------------------
  102. | Objects of this class are constructed in the following manner:               |
  103. |   o without parameters to create a generic object.                           |
  104. |   o by providing an icon or bitmap resource.                                 |
  105. |   o by providing a pointer handle.                                           |
  106. |   o by providing a bitmap handle.                                            |
  107. |   o by providing an array of points to draw a polygon.                       |
  108. ------------------------------------------------------------------------------*/
  109. IDMImage    ( );
  110. IDMImage    (const IResourceId     &resourceId,
  111.              const ISize           &pointerOffset = ISize(0,0),
  112.              const ISize           &stretchSize = ISize(0,0),
  113.              const IDMImage::Style style = 0,
  114.              Boolean               iconResource = true);
  115.  
  116. IDMImage    (const IPointerHandle  &icon,
  117.              const ISize           &pointerOffset = ISize(0,0),
  118.              const ISize           &stretchSize = ISize(0,0),
  119.              const IDMImage::Style style = 0);
  120.  
  121. IDMImage    (const IBitmapHandle   &bitmap,
  122.              const ISize           &pointerOffset = ISize(0,0),
  123.              const ISize           &stretchSize = ISize(0,0),
  124.              const IDMImage::Style style = 0);
  125.  
  126. IDMImage    (unsigned long         arrayOfPoints[],
  127.              const ISize           &pointerOffset = ISize(0,0),
  128.              const IDMImage::Style style = 0,
  129.              const unsigned long   points = 0);
  130.  
  131. virtual
  132.   ~IDMImage ( );
  133.  
  134. /*--------------------------------- Accessors ----------------------------------
  135. | These functions provide means of getting and setting the accessible          |
  136. | attributes of instances of this class:                                       |
  137. |   pointer           - returns the pointer image handle.                      |
  138. |   bitmap            - returns the bitmap image handle.                       |
  139. |   pointerOffset     - returns the offset of the image from the pointing      |
  140. |                       device.                                                |
  141. |   stretchSize       - returns the size of the image when stretched.          |
  142. |   style             - returns the styles used to describe the image.         |
  143. |   numberOfPoints    - returns the number of array points used to make up the |
  144. |                       image.                                                 |
  145. |   pointArray        - returns the array of points used to draw a polygon if  |
  146. |                       the image style is set to IDM::polygon.  If the image  |
  147. |                       isn't a drawn polygon, then it returns 0.              |
  148. |   setPointer        - sets the pointer image handle.                         |
  149. |   setBitmap         - sets the bitmap image handle.                          |
  150. |   setPointerOffset  - sets the offset of the image from the pointing device. |
  151. |   setStretchSize    - sets the size of the image when stretched.             |
  152. |   setStyle          - sets the styles used to describe the image.            |
  153. |   setNumberOfPoints - sets the number of array points field of the image.    |
  154. |   setPointArray     - sets the point array to be used to draw the image.     |
  155. ------------------------------------------------------------------------------*/
  156. IPointerHandle
  157.   pointer        ( );
  158.  
  159. IBitmapHandle
  160.   bitmap         ( );
  161.  
  162. ISize
  163.   pointerOffset  ( ),
  164.   stretchSize    ( );
  165.  
  166. IDMImage::Style
  167.   style          ( );
  168.  
  169. unsigned long
  170.   numberOfPoints ( );
  171.  
  172. unsigned long
  173.   *pointArray    ( );
  174.  
  175. IDMImage
  176.  &setPointer        ( IPointerHandle  &pointerImage ),
  177.  &setBitmap         ( IBitmapHandle   &bitmapImage ),
  178.  &setPointerOffset  ( ISize           &pointerOffset ),
  179.  &setStretchSize    ( ISize           &stretchSize ),
  180.  &setStyle          ( IDMImage::Style style ),
  181.  &setNumberOfPoints ( unsigned long   points ),
  182.  &setPointArray     ( unsigned long   arrayOfPoints[]);
  183.  
  184. protected:
  185. private: /*------------------------ PRIVATE ----------------------------------*/
  186. friend class IDMSourceOperation;
  187. IPointerHandle
  188.   pointerImage;
  189.  
  190. IBitmapHandle
  191.   bitmapImage;
  192.  
  193. unsigned long
  194.  *pointArr;
  195.  
  196. ISize
  197.   ptrOffset;
  198.  
  199. ISize
  200.   imageStretchSize;
  201.  
  202. IDMImage::Style
  203.   imgStyle;
  204.  
  205. unsigned long
  206.   points;
  207.  
  208. void
  209.   asPMDragImage (_DRAGIMAGE *pDragImage, Boolean useSystemIcons = false,
  210.                  Boolean fadeIcon = false);
  211. };
  212.  
  213. /*----------------------------------------------------------------------------*/
  214. /* Resume compiler default packing.                                           */
  215. /*----------------------------------------------------------------------------*/
  216. #pragma pack()
  217.  
  218. #ifndef I_NO_INLINES
  219.   #include <idmimage.inl>
  220. #endif
  221.  
  222. #endif //_IDMIMAGE_
  223.