home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / runnable / ibmc / ibmclass / idrgimg.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-26  |  6.0 KB  |  144 lines

  1. #ifndef _IDRGIMG_
  2.   #define _IDRGIMG_
  3. /*--------------------------------------------------------------*/
  4. /* CLASS NAME:    IDragImage                                    */
  5. /*                                                              */
  6. /* DESCRIPTION :  Drag image encapsulation                      */
  7. /*                                                              */
  8. /* CHANGE ACTIVITY:                                             */
  9. /* ---------------                                              */
  10. /*   DATE:     INITIAL:       DESCRIPTION:                      */
  11. /* 08/22/92    PHG            Created from IDRGITM.HPP          */
  12. /*--------------------------------------------------------------*/
  13. /* Copyright (c) IBM Corporation 1991                           */
  14. /*--------------------------------------------------------------*/
  15.  
  16. #ifndef _IBASETYP_
  17.   #include <ibasetyp.hpp>
  18. #endif
  19. #ifndef _IPOINT_
  20.   #include <ipoint.hpp>
  21. #endif
  22. #ifndef _IRESLIB_
  23.   #include <ireslib.hpp>
  24. #endif
  25.  
  26. class IDragImage : public IBase {
  27. /**************************************************************************
  28. *  This class encapsulates the PM DRAGIMAGE structure                     *
  29. *  Hungarian is 'drgimg'                                                  *
  30. **************************************************************************/
  31. public:
  32. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
  33. | There are 3 ways to construct instances of this class:                  |
  34. |   1. default, from resource icon or bitmap                              |
  35. |   2. from pointer handle                                                |
  36. |   2. from bitmap handle                                                 |
  37. +------------------------------------------------------------------------*/
  38.   IDragImage(const IResourceId& resid,
  39.              const ISize& sizOffset,
  40.              const ISize& sizStretch=ISize(0,0),
  41.              Boolean bIconResource=true);
  42.  
  43.   IDragImage(const IPointerHandle& ptrhIcon,
  44.              const ISize& sizOffset,
  45.              const ISize& sizStretch=ISize(0,0));
  46.  
  47.   IDragImage(const IBitmapHandle& bmphBitmap,
  48.              const ISize& sizOffset,
  49.              const ISize& sizStretch=ISize(0,0));
  50.  
  51.   ~IDragImage();
  52.  
  53. /*-------------------------------- ACCESSORS -----------------------------+
  54. | These function provide means of getting and setting the accessible      |
  55. | attributes of instances of this class:                                  |
  56. |  dragimageStruct - Fills-in a DRAGIMAGE structure                       |
  57. |  pointerOffset - return the image's offset from mouse pointer           |
  58. |  stretchSize - return the stretch size                                  |
  59. |  dragPointer - return the pointer to the internal pointer handle if any |
  60. |  dragBitmap - return the pointer to the internal bitmap handle if any   |
  61. |  isIcon - test whether the image is an icon (otherwise, it's a bitmap)  |
  62. |  isTransparent - test wether the 'transparent' bit is set               |
  63. |  setPointerOffset - set the pointer's offset from mouse hotspot         |
  64. |  setStretchSize - set the strech size, ISize(0,0) for no stretch        |
  65. |  setTransparent - set the transparent flag                              |
  66. +------------------------------------------------------------------------*/
  67. void
  68.   dragimageStruct(void* pdragimage,
  69.                   unsigned long uldimgSize) const;
  70. ISize
  71.   pointerOffset() const,
  72.   stretchSize() const;
  73.  
  74. IPointerHandle*
  75.   dragPointer() const;
  76. IBitmapHandle*
  77.   dragBitmap() const;
  78. Boolean
  79.   isIcon() const,
  80.   isTransparent() const;
  81.  
  82. IDragImage
  83.   &setPointerOffset(const ISize& sizPointerOffset),
  84.   &setStretchSize(const ISize& sizStretch=ISize()),
  85.   &setTransparent(Boolean bTransparent=true);
  86.  
  87. // helper functions
  88. /*-------------------------------- HELPER --------------------------------+
  89. | These are helper functions                                              |
  90. |   iconSize - returns the size of the icons for this system              |
  91. +------------------------------------------------------------------------*/
  92. static ISize
  93.   iconSize();
  94.  
  95. private:
  96. /*------------------------------ DATA MEMBERS ----------------------------+
  97. | Private data members                                                    |
  98. |  sizClOffset       - Offset                                             |
  99. |  sizClStretch      - stretch size, (0,0) for no stretch                 |
  100. |  pptrhClDragIcon   - pointer to icon handle if this is an icon          |
  101. |  pbmphClDragBitmap - pointer to bitmap handle if this is a bitmap       |
  102. |  bClTransparent    - Transparent bit flag                               |
  103. +------------------------------------------------------------------------*/
  104.   /* instance vars */
  105.   ISize            sizClOffset;
  106.   ISize            sizClStretch;
  107.   IPointerHandle*  pptrhClDragIcon;
  108.   IBitmapHandle*   pbmphClDragBitmap;
  109.   Boolean          bClTransparent;
  110.  
  111. }; // IDragImage
  112.  
  113. /*=========================================================================
  114. | Inlines for IDragImage                                        PHG 24/10 |
  115. =========================================================================*/
  116. inline ISize IDragImage :: pointerOffset() const
  117. { return(sizClOffset); }
  118.  
  119. inline ISize IDragImage :: stretchSize() const
  120. { return(sizClStretch); }
  121.  
  122. inline IPointerHandle* IDragImage :: dragPointer() const
  123. { return(pptrhClDragIcon); }
  124.  
  125. inline IBitmapHandle*  IDragImage :: dragBitmap() const
  126. { return(pbmphClDragBitmap); }
  127.  
  128. inline Boolean IDragImage :: isIcon() const
  129. { return(pptrhClDragIcon!=0); }
  130.  
  131. inline Boolean IDragImage :: isTransparent() const
  132. { return(bClTransparent); }
  133.  
  134. inline IDragImage& IDragImage :: setPointerOffset(const ISize& sizOffset)
  135. { sizClOffset=sizOffset; return(*this); }
  136.  
  137. inline IDragImage& IDragImage :: setStretchSize(const ISize& sizStretch)
  138. { sizClStretch=sizStretch; return(*this); }
  139.  
  140. inline IDragImage& IDragImage :: setTransparent(Boolean bTransparent)
  141. { bClTransparent=bTransparent; return(*this); }
  142.  
  143. #endif /* ndef _IDRGIMG_ */
  144.