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

  1. #ifndef _IDRGTGTH_
  2.   #define _IDRGTGTH_
  3. /*--------------------------------------------------------------*/
  4. /* CLASS NAMES:   IDragTargetHandler                            */
  5. /*                                                              */
  6. /* DESCRIPTION  : Target drag handler.                          */
  7. /*                Handles: IDragOverEvent                       */
  8. /*                         IDropOnEvent                         */
  9. /*                                                              */
  10. /* CHANGE ACTIVITY:                                             */
  11. /* ---------------                                              */
  12. /*   DATE:     INITIAL:       DESCRIPTION:                      */
  13. /* --/--/91/92 RDL & Co       IDRGMAN.?PP                       */
  14. /* 08/19/92    PHG            Created from IDrgMan stuff        */
  15. /*                                                              */
  16. /*--------------------------------------------------------------*/
  17. /* Copyright (c) IBM Corporation 1991                           */
  18. /*--------------------------------------------------------------*/
  19.  
  20. // classes forward definitions
  21. class IDragTargetHandler;
  22. class IDropCatcher;
  23. class IDropCatcherSet;
  24. class IDxferAssoc;
  25. class IDxferAssocSet;
  26.  
  27. // include ICLUI base definitions
  28. #ifndef _IBASETYP_
  29.   #include <ibasetyp.hpp>
  30. #endif
  31. #ifndef _ISTRING_
  32.   #include <istring.hpp>
  33. #endif
  34. #ifdef _USEBB_
  35.   #ifndef _ISET_H
  36.     #include <iset.h>
  37.   #endif
  38. #else
  39.   #ifndef _ISET_
  40.     #include <iset.hpp>
  41.   #endif
  42.   declare(IGSet1, IDropCatcher);
  43.   declare(IGSet1, IDxferAssoc)
  44. #endif
  45.  
  46. #ifndef _IWINDOW_
  47.   #include <iwindow.hpp>
  48. #endif
  49. #ifndef _IHANDLER_
  50.   #include <ihandler.hpp>
  51. #endif
  52.  
  53. // include Drag&Drop specific definitions
  54. #ifndef _IDRGEVT_
  55.   #include <idrgevt.hpp>
  56. #endif
  57. #ifndef _IDRGITM_
  58.   #include <idrgitm.hpp>
  59. #endif
  60. #ifndef _IDRPCTCH_
  61.   #include <idrpctch.hpp>
  62. #endif
  63.  
  64. ////////////////////////////////////////////////////////////////////
  65. // !PHG!               --- TO DO --                   !PHG!
  66. // Implement messages:
  67. //   - DM_DROPHELP
  68. //   - DM_DRAGLEAVE
  69. //
  70. // droptype: accept or not partial drops
  71. ////////////////////////////////////////////////////////////////////
  72.  
  73. class IDxferAssoc : public IBase {
  74. /**************************************************************************
  75. *  Class for association of a pdxfer, a hwndSource and a dropcatcher      *
  76. *  NOTE: This will be a nested private class when migrated to Boeblingen's*
  77. *        KeySet later on                                                  *
  78. *        This is a class for private use by IDragTargetHandler            *
  79. **************************************************************************/
  80.   friend class IDragTargetHandler;
  81.   friend class IDxferAssocSet;
  82.  
  83. private:
  84.   IDxferAssoc(const void* pdragtransfer,
  85.               IWindowHandle wndhSource,
  86.               const IDropCatcher* pdrpctch) :
  87.     pdragtransferCl(pdragtransfer),
  88.     wndhClSource(wndhSource),
  89.     pdrpctchCl(pdrpctch)
  90.     { };
  91.  
  92. // required == operator for IGSet1
  93. Boolean
  94.   operator==(IDxferAssoc& dxas) const
  95.     { return(dxas.pdragtransferCl==pdragtransferCl); }
  96.  
  97.   // associated data
  98.   const void*         pdragtransferCl;
  99.   IWindowHandle       wndhClSource;
  100.   const IDropCatcher* pdrpctchCl;
  101. };
  102.  
  103. class IDragTargetHandler : public IHandler {
  104. /**************************************************************************
  105. *  Handler to intercept Drag&Drop messages on the target side and process *
  106. *  them.                                                                  *
  107. *  This handler has a collection of IDropCather instances, which are      *
  108. *  used to catch drops and perform whatever action id required by the     *
  109. *  RMFs implemented by the catcher.                                       *
  110. *                                                                         *
  111. * EXAMPLE:                                                                *
  112. *  {IDragTargetHandler* ptgth=new IDragTargetHandler();                   *
  113. *   IDropCatcher* pctch=new IDropCatcher(...);                            *
  114. *   IWindow* pwnd=new IWindow(...);                                       *
  115. *                                                                         *
  116. *    ptgth->dropCatcherList().add(pctch);                                 *
  117. *    pwnd->addHandler(ptgth);                                             *
  118. *  }                                                                      *
  119. **************************************************************************/
  120.   public:
  121. #ifdef _USEBB_
  122.     typedef ISet<IDropCatcher*> IDropCatcherSet;
  123.     typedef ISet<IDxferAssoc*> IDxferAssocSet;
  124. #else
  125.     typedef IGSet1(IDropCatcher) IDropCatcherSet;
  126.     typedef IGSet1(IDxferAssoc) IDxferAssocSet;
  127. #endif
  128.  
  129. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
  130. | There is one default way to construct instances of this class:          |
  131. |   1. Specify wether partial drops are enabled or not                    |
  132. |      Note: *not* enabled so far                                         |
  133. +------------------------------------------------------------------------*/
  134.   IDragTargetHandler(Boolean bPartialDrop=false);
  135.  
  136. virtual
  137.   ~IDragTargetHandler();
  138.  
  139.     // give access to the drop catcher collection
  140. /*-------------------------------- ACCESSORS -----------------------------+
  141. | These function provide means of getting and setting the accessible      |
  142. | attributes of instances of this class:                                  |
  143. |   dropCatcherList - give access to the drop catcher collection          |
  144. +------------------------------------------------------------------------*/
  145. IDropCatcherSet&
  146.   dropCatcherList() { return(drpcthsetCl); };
  147.  
  148.     // ask to render this item in specified RMF
  149. /*-------------------------------- UTILITY -------------------------------+
  150. | These functions are utility functions used to implement most of the     |
  151. | handler's behavior.                                                     |
  152. |  askRender - ask to render this item in specified RMF, called by catcher|
  153. +------------------------------------------------------------------------*/
  154. void
  155.   askRender(const IWindow* pwndRenderWindow,
  156.             const IWindowHandle& wndhSource,
  157.             const IDropCatcher* pdrpctch,
  158.             const IDragItem& drgitm,
  159.             const IRMFsString& strRMFs,
  160.             const IString& strRenderToName,
  161.             const IDragOperationEvent::Operations& opCurrent,
  162.             unsigned long ulTargetInfo=0) const;
  163.  
  164. protected:
  165. /*-------------------------------- OVERRIDES -----------------------------+
  166. | This class overrides the following inherited functions:                 |
  167. |   dispatchHandlerEvent - event dispatcher overload                      |
  168. +------------------------------------------------------------------------*/
  169. virtual Boolean
  170.   dispatchHandlerEvent(IEvent& evt);
  171.  
  172.     // event processing
  173. /*------------------------- EVENT PROCESSING -----------------------------+
  174. | Functions used to process events. Used either internally or by          |
  175. | subclasses which implement different sets of Drag&Drop events           |
  176. |  isDropAccepted - check wether a drop is accepted or not                |
  177. |  processDrop - process a drop event                                     |
  178. |  processRenderComplete - process a render_complete event                |
  179. +------------------------------------------------------------------------*/
  180. IEDropFlag
  181.   isDropAccepted(const IDragOverEvent& drgovevt);
  182.  
  183. void
  184.   processDrop(IDropOnEvent& drponevt),
  185.   processRenderComplete(IRenderCompleteEvent& rendcompevt);
  186.  
  187.  
  188. /*-------------------------------- CALLBACKS -----------------------------+
  189. | These functions are intended to be overridden by the user to implement  |
  190. | his own specific behavior                                               |
  191. |  checkItem - check items for acceptance, returns a catcher ptr accepted |
  192. |  checkOperation - check that the current operation is supported an item |
  193. +------------------------------------------------------------------------*/
  194. virtual IDropCatcher*
  195.   checkItem(const IDragItem& drgitem,
  196.             const IDragOperationEvent& drgopevt,
  197.             IEDropFlag& drpflg);
  198.  
  199. virtual Boolean
  200.   checkOperation(const IDragItem& drgitm,
  201.                  const IDragOperationEvent& drgopevt);
  202.  
  203. private:
  204. /*------------------------------ UTILITY ---------------------------------+
  205. | Private utility functions                                               |
  206. |  doRender - send the actual DM_RENDER message                           |
  207. |  transferComplete - process error from DM_RENDER or DM_RENDERCOMPLETE   |
  208. +------------------------------------------------------------------------*/
  209. Boolean
  210.   doRender(const IUDragDropRender& udrgdrpevt);
  211. void
  212.   transferComplete(void* pdragtransfer,
  213.                    Boolean bRenderOK,
  214.                    const IRenderCompleteEvent& rendcompevt);
  215.  
  216. /*------------------------------ DATA MEMBERS ----------------------------+
  217. |  bClPartialDrop - true if partial drop enabled                          |
  218. |  drpcthsetCl    - set of drop catchers for this handler                 |
  219. |  dxassetCl      - set of associations between dragtransfers and items   |
  220. +------------------------------------------------------------------------*/
  221.   Boolean         bClPartialDrop;
  222.   IDropCatcherSet drpcthsetCl;
  223.   IDxferAssocSet  dxassetCl;
  224.  
  225. /*---------------------- ASSOC SET MANAGEMENT ----------------------------+
  226. | Private utility functions to deal with the set of assoc                 |
  227. | The set and functions will be deported in an outside class later        |
  228. +------------------------------------------------------------------------*/
  229. IDxferAssoc*
  230.   findXfer(const void* pdragtransfer,
  231.            IDxferAssocSet::Cursor& dxascurs) const;
  232.  
  233. void
  234.   associateXfer(const void* pdragtransfer,
  235.                 IWindowHandle wndhSource,
  236.                 const IDropCatcher* pdrpctch) const;
  237.  
  238. IWindowHandle
  239.   sourceWindowXfer(const void* pdragtransfer) const;
  240.  
  241. IDropCatcher*
  242.   catcherXfer(const void* pdragtransfer) const;
  243.  
  244. Boolean
  245.   removeXfer(const void* pdragtransfer) const;
  246.  
  247. }; // IDragTargetHandler
  248.  
  249. #endif /* def _IDRGTGTH_ */
  250.