home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / ibmcli / idrgsrch.hp_ / IDRGSRCH.HPP
Encoding:
C/C++ Source or Header  |  1992-10-26  |  8.4 KB  |  215 lines

  1. #ifndef _IDRGSRCH_
  2.   #define _IDRGSRCH_
  3. /*--------------------------------------------------------------*/
  4. /* CLASS NAMES:   IDragSourceHandler                            */
  5. /*                                                              */
  6. /* DESCRIPTION  : Source drag handler.                          */
  7. /*                Handles: IBeginDragEvent                      */
  8. /*                         IDragOverNotifyEvent                 */
  9. /*                         IEndDragEvent                        */
  10. /*                                                              */
  11. /* CHANGE ACTIVITY:                                             */
  12. /* ---------------                                              */
  13. /*   DATE:     INITIAL:       DESCRIPTION:                      */
  14. /* 19/08/92    PHG            Created from IDrgMan stuff        */
  15. /* 06/10/92    PHG            Moved to BBXX Sets                */
  16. /*                                                              */
  17. /*--------------------------------------------------------------*/
  18. /* Copyright (c) IBM Corporation 1991                           */
  19. /*--------------------------------------------------------------*/
  20.  
  21. // Forward class references
  22. class IDragSourceHandler;
  23. class IDragItem;
  24.  
  25. // ICLUI definitions
  26. #ifndef _IBASETYP_
  27.   #include <ibasetyp.hpp>
  28. #endif
  29.  
  30. #ifndef _ISTRING_
  31.   #include <istring.hpp>
  32. #endif
  33.  
  34. #ifndef _IHANDLER_
  35.   #include <ihandler.hpp>
  36. #endif
  37.  
  38. #ifdef _USEBB_
  39.   #ifndef _ISET_H
  40.     #include <iset.h>
  41.   #endif
  42. #else
  43.   #ifndef _ISET_
  44.     #include <iset.hpp>
  45.   #endif
  46.   declare(IGSet1, IDragItem);
  47. #endif
  48.  
  49. // This header's specific definitions
  50. #ifndef _IDRGEVT_
  51.   #include <idrgevt.hpp>
  52. #endif
  53. #ifndef _IDRGITM_
  54.   #include <idrgitm.hpp>
  55. #endif
  56.  
  57. ////////////////////////////////////////////////////////////////////
  58. // !PHG!               --- TO DO --                   !PHG!
  59. // Implement messages:
  60. //   - DM_PRINTOBJECT      -> used for DRM_PRINT mechanism
  61. //   - DM_DISCARDOBJECT    -> used for DRM_DISCARD mechanism
  62. //
  63. //   - DM_DRAGOVERNOTIFY
  64. ////////////////////////////////////////////////////////////////////
  65.  
  66. class IDragSourceHandler : public IHandler {
  67. /**************************************************************************
  68. * Handler for Drag&drop events on source side                             *
  69. *                                                                         *
  70. *   This class is intended to be used as follows:                         *
  71. *     Create a IDragSourceHandler for each window that has to             *
  72. *     implement drag&drop source behavior.                                *
  73. *                                                                         *
  74. *     Add IDragItems to the manager, either once for all                  *
  75. *     initially, or dynamically using the dragSetup()                     *
  76. *     callback or directly accessing the collection.                      *
  77. *                                                                         *
  78. **************************************************************************/
  79. public:
  80.  
  81. #ifdef _USEBB_
  82.   typedef ISet<IDragItem*> IDragItemSet;
  83. #else
  84.   typedef IGSet1(IDragItem) IDragItemSet;
  85. #endif
  86.  
  87. // Icons dragging styles
  88. enum dragStyle {stack3AndFade = 1,
  89.                 systemIcons = 2,
  90.                 allAtPos = 3,
  91.                 allStacked = 4};
  92.  
  93. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
  94. | There is one default way to construct instances of this class:          |
  95. |   Construct giving the style of dragging to occur                       |
  96. +------------------------------------------------------------------------*/
  97.   IDragSourceHandler(dragStyle drgstyl = stack3AndFade);
  98.  
  99. virtual
  100.   ~IDragSourceHandler();
  101.  
  102. /*-------------------------------- ACCESSORS -----------------------------+
  103. | These function provide means of getting and setting the accessible      |
  104. | attributes of instances of this class:                                  |
  105. |  dragItemList   - give access to the IDragItems collection              |
  106. |  removeItem     - removes an item or all items from collection          |
  107. |  findDraginfo   - returns the PDRAGINFO holding a given PDRAGITEM       |
  108. |  renderComplete - must be called by an item after it is rendered        |
  109. |  setStyle       - sets the drag style                                   |
  110. +------------------------------------------------------------------------*/
  111. IDragItemSet
  112.   &dragItemList();
  113.  
  114. void
  115.   removeItem(IDragItem* pdrgitm=0,
  116.              Boolean bDelete=true);
  117.  
  118. void*
  119.   findDraginfo(void* pdragitem);
  120.  
  121. void
  122.   renderComplete(const IRenderEvent& rendevt,
  123.                  Boolean bRenderOK) const;
  124.  
  125. IDragSourceHandler&
  126.   setStyle(dragStyle drgstyl);
  127.  
  128. protected:
  129. /*-------------------------------- OVERRIDES -----------------------------+
  130. | This class overrides the following inherited functions:                 |
  131. |   dispatchHandlerEvent - event dispatcher overload                      |
  132. +------------------------------------------------------------------------*/
  133. virtual Boolean
  134.   dispatchHandlerEvent(IEvent& evt);
  135.  
  136. /*-------------------------------- CALLBACKS -----------------------------+
  137. | The following functions should be implemented in derived classes to     |
  138. | define behavior                                                         |
  139. |  dragSetup     - Called to set-up the drag                              |
  140. |  dragCompleted - Called after the dragging has completed                |
  141. |  dragEnded     - Called on the WM_ENDDRAG message                       |
  142. |  itemFromId    - used to correlate an item ID to a DragItem             |
  143. +------------------------------------------------------------------------*/
  144. virtual Boolean
  145.   dragSetup(const IBeginDragEvent& begdrgevt);
  146.  
  147. virtual void
  148.   dragCompleted(const IWindowHandle& wndhTarget,
  149.                 unsigned long ulOperation,
  150.                 const IPoint& ptDrop);
  151.  
  152. virtual void
  153.   dragEnded(const IEvent& evt);
  154.  
  155. virtual IDragItem
  156.   *itemFromId(unsigned long ulItemId, const IEvent& evt);
  157.  
  158. /*---------------------------- EVENT PROCESSING --------------------------+
  159. | These functions are used to process D&D events                          |
  160. | processBeginDrag - start the drag after calling dragSetup()             |
  161. | processEndDrag   - calls dragEnded()                                    |
  162. | processRender    - renders item to required RMF                         |
  163. | processEndConversation - cleans up resources for item                   |
  164. +------------------------------------------------------------------------*/
  165. IWindowHandle
  166.   processBeginDrag(const IBeginDragEvent& begdrgevt);
  167.  
  168. void
  169.   processEndDrag(IEvent& evt);
  170.  
  171. Boolean
  172.   processRender(IRenderEvent& rendevt);
  173.  
  174. Boolean
  175.   processEndConversation(const IEndConversationEvent& endcvevt);
  176.  
  177. private:
  178. /*------------------------------ DATA MEMBERS ----------------------------+
  179. | Private helper functions                                                |
  180. | draginfoInvalid - to be called when the draginfo becomes invalid        |
  181. +------------------------------------------------------------------------*/
  182. void
  183.   draginfoInvalid(void* pdraginfo);
  184.  
  185. /*------------------------------ DATA MEMBERS ----------------------------+
  186. |  drgstylCl   - drag style                                               |
  187. |  drgitmsetCl - drag item set                                            |
  188. +------------------------------------------------------------------------*/
  189.   dragStyle       drgstylCl;
  190.   IDragItemSet    drgitmsetCl;
  191.  
  192. }; // IDragSourceHandler
  193.  
  194. /*=========================================================================
  195. | Inlines for IDragSourceHandler                                PHG 21/10 |
  196. =========================================================================*/
  197. inline IDragSourceHandler::IDragItemSet& IDragSourceHandler :: dragItemList()
  198. { return(drgitmsetCl); }
  199.  
  200. inline Boolean IDragSourceHandler :: dragSetup(const IBeginDragEvent& begdrgevt)
  201. { return (drgitmsetCl.numberOfElements()>0); }
  202.  
  203. inline void IDragSourceHandler :: dragCompleted(const IWindowHandle& wndhTarget,
  204.                                                 unsigned long ulOperation,
  205.                                                 const IPoint& ptDrop)
  206. { }
  207.  
  208. inline void IDragSourceHandler :: dragEnded(const IEvent& evt)
  209. { }
  210.  
  211. inline IDragSourceHandler& IDragSourceHandler :: setStyle(dragStyle drgstyl)
  212. { drgstylCl=drgstyl; return(*this); }
  213.  
  214. #endif /* def _IDRGSRCH_ */
  215.