home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / uicldd.zip / IDMRENDR.HPP < prev    next >
Text File  |  1993-09-03  |  20KB  |  420 lines

  1. #ifndef _IDMRENDR_
  2. #define _IDMRENDR_
  3. /*******************************************************************************
  4. * FILE NAME: idmrendr.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   This file contains the declaration(s) of the class(es):                    *
  8. *     IDMRenderer          - Direct manipulation renderer common base 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. * $Log:   S:/ibmclass/idrag/vcs/idmrendr.hpv  $
  19. //
  20. //   Rev 1.23   03 Sep 1993 11:19:32   HAGGAR
  21. //Added drag image support and made assorted fixes
  22. //
  23. //   Rev 1.22   02 Sep 1993 13:21:24   banzai
  24. //Interface changes per container
  25. //
  26. //   Rev 1.21   01 Sep 1993 10:36:54   banzai
  27. //Massage per container integration
  28. //
  29. //   Rev 1.20   28 Aug 1993 15:53:12   banzai
  30. //Move part of rendering/drop logic into IDMItem
  31. //
  32. //   Rev 1.19   23 Aug 1993 15:35:06   banzai
  33. //Target rendering bug revealed by DMSAMP2
  34. //
  35. //   Rev 1.18   16 Aug 1993 20:20:44   banzai
  36. //Make IDMCOMM stuff into IDM struct
  37. //
  38. //   Rev 1.17   16 Aug 1993 13:59:18   banzai
  39. //Move setSupportedXxx to public
  40. //
  41. //   Rev 1.16   16 Aug 1993 09:21:28   banzai
  42. //Make subclass of IVBase
  43. //
  44. //   Rev 1.15   14 Aug 1993 08:48:06   banzai
  45. //Rename checkOperation to selectOperation
  46. //
  47. //   Rev 1.14   12 Aug 1993 13:53:14   banzai
  48. //Merge source and target item into one
  49. //
  50. //   Rev 1.13   09 Aug 1993 12:45:12   HAGGAR
  51. //rendering
  52. //
  53. //   Rev 1.12   02 Aug 1993 15:27:58   HAGGAR
  54. //more rendering changes
  55. //
  56. //   Rev 1.11   17 Jul 1993 14:04:50   banzai
  57. //Fix trap on exit
  58. //
  59. //   Rev 1.10   14 Jul 1993 17:29:32   banzai
  60. //Testing changes
  61. //
  62. //   Rev 1.9   13 Jul 1993 18:01:04   banzai
  63. //It works
  64. //
  65. //   Rev 1.8   13 Jul 1993 15:57:42   banzai
  66. //Add assignment operator for handles
  67. //
  68. //   Rev 1.7   12 Jul 1993 11:31:40   banzai
  69. //Rendering changes
  70. //
  71. //   Rev 1.6   01 Jul 1993 12:23:12   HAGGAR
  72. //rendering changes
  73. //
  74. //   Rev 1.5   09 Jun 1993 16:09:08   banzai
  75. //More changes
  76. //
  77. //   Rev 1.4   07 Jun 1993 16:29:18   unknown
  78. //Same oh sam oh
  79. //
  80. //   Rev 1.3   04 Jun 1993 16:39:46   unknown
  81. //Control Enablement
  82. //
  83. //   Rev 1.2   05 May 1993 16:36:00   unknown
  84. //Source Render Prepare changes
  85. //
  86. //   Rev 1.1   30 Apr 1993 11:45:40   HAGGAR
  87. //No change.
  88. //
  89. //   Rev 1.0   22 Apr 1993 10:44:08   HAGGAR
  90. //Initial revision.
  91. *******************************************************************************/
  92. #ifndef _IVBASE_
  93.   #include <ivbase.hpp>
  94. #endif
  95.  
  96.  
  97. #ifndef _ISTRING_
  98.   #include <istring.hpp>
  99. #endif
  100.  
  101. #ifndef _IDMCOMM_
  102.   #include <idmcomm.hpp>
  103. #endif
  104.  
  105. typedef IDM::DropIndicator DropIndicator;
  106.  
  107. /* Forward Declarations */
  108. struct _DRAGTRANSFER;
  109. class IDMSourceRenderEvent;
  110. class IDMSourcePrepareEvent;
  111. class IDMSourceNotifyEvent;
  112. class IDMSourceEndEvent;
  113. class IDMTargetDropEvent;
  114. class IDMTargetEndEvent;
  115. class IDMItemHandle;
  116. class IDMTgtOperationHandle;
  117.  
  118.  
  119. class IDMRenderer : public IVBase {
  120. typedef IVBase
  121.   Inherited;
  122. /*******************************************************************************
  123. * This is the common base class for the source and target direct               *
  124. * manipulation renderer classes.                                               *
  125. *                                                                              *
  126. * Objects of this class perform the "rendering" of items during direct         *
  127. * manipulation.  Such "rendering" is essentially the transfer of the dragged   *
  128. * object from the source to the target window.                                 *
  129. *                                                                              *
  130. * This class is an abstract base class that defines the common protocol of     *
  131. * source and target renderers.  The derived classes IDMSourceRenderer and      *
  132. * IDMTargetRenderer, declared below, define the specific protocol for source   *
  133. * and target renderers.                                                        *
  134. *                                                                              *
  135. * A generic renderer possesses the following attributes:                       *
  136. *   o A set of supported types.  These are the types of dragged items that     *
  137. *     this renderer can work with.                                             *
  138. *   o A set of supported rendering mechanisms and rendering formats (RMFs).    *
  139. *     These describe the various means by which this renderer can transfer     *
  140. *     the dragged object.                                                      *
  141. *                                                                              *
  142. * The operations that can be performed on objects of this class fall into      *
  143. * two basic categories:                                                        *
  144. *   o Queries as to whether the renderer can render a given item.              *
  145. *   o Requests to perform one of the basic rendering processes.                *
  146. *******************************************************************************/
  147. public:
  148.  
  149. /*------------------------ Constructor/Destructor ------------------------------
  150. | Generic objects of this class are constructed without formal parameters.     |
  151. ------------------------------------------------------------------------------*/
  152.   IDMRenderer     ( );
  153.  
  154. virtual
  155.   ~IDMRenderer    ( );
  156.  
  157. /*------------------------- Supported Types and RMFs ---------------------------
  158.   These functions return the types and renderering mechanisms/formats
  159.   supported by an IDMRenderer object:
  160.     supportedTypes           - Returns the types of items supported by the
  161.                                renderer.
  162.     supportedRMFs            - Returns the rendering mechanisms and formats
  163.                                supported by this renderer.
  164.     setSupportedTypes        - Sets the types of items supported by the
  165.                                renderer.
  166.     setSupportedRMFs         - Sets the rendering mechanisms and formats
  167.                                supported by this renderer.
  168.     informRenderingCompleted - Returns flag which indicates whether source
  169.                                should post and target should expect to receive
  170.                                an IDMTargetEndEvent.  Default is false.
  171.     setRenderingCompleted    - Sets flag which indicates whether source
  172.                                should post and target should expect to receive
  173.                                an IDMTargetEndEvent.
  174. ------------------------------------------------------------------------------*/
  175. virtual IString
  176.   supportedTypes              ( ) const,
  177.   supportedRMFs               ( ) const;
  178.  
  179. virtual Boolean
  180.   informRenderingCompleted    ( ) const;
  181.  
  182. virtual IDMRenderer
  183.  &setSupportedTypes           ( const IString &aType ),
  184.  &setSupportedRMFs            ( const IString &aRMF ),
  185.  &setRenderingCompleted       ( Boolean       completed );
  186.  
  187. protected:
  188. /*------------------------------ Implementation --------------------------------
  189. | These functions provide utilities used to implement this class:              |
  190. |   setProcessInfo - sets the process information.                             |
  191. |   sourcePID      - returns the PID for the source window.                    |
  192. |   targetPID      - returns the PID for the target window.                    |
  193. ------------------------------------------------------------------------------*/
  194. IDMRenderer
  195.  &setProcessInfo    ( const IDMItemHandle  &dragItem ),
  196.  &setProcessInfo    ( IDMSourceRenderEvent &event );
  197.  
  198. unsigned long
  199.   sourcePID         ( ) const,
  200.   targetPID         ( ) const;
  201.  
  202. private: /*------------------------ PRIVATE ----------------------------------*/
  203.  
  204. IString
  205.   strTypes,
  206.   strRMFs;
  207.  
  208. unsigned long
  209.   srcPID,
  210.   tgtPID;
  211.  
  212. Boolean
  213.   bInformTgtRndrCompleted;
  214. }; // class IDMRenderer
  215.  
  216.  
  217. class IDMSourceRenderer : public IDMRenderer {
  218. /*******************************************************************************
  219. * Objects of this class provide source rendering when a direct manipulation    *
  220. * operation is performed.  Instances of this class are "registered" with the   *
  221. * source handler.  The handler selects a renderer for a given drag item and    *
  222. * invokes rendering functions of the renderer when source rendering events     *
  223. * occur.                                                                       *
  224. *******************************************************************************/
  225. public:
  226. /*------------------------ Constructor/Destructor ------------------------------
  227. | Generic objects of this class are constructed without formal parameters.     |
  228. ------------------------------------------------------------------------------*/
  229. IDMSourceRenderer ();
  230.  
  231. virtual
  232.   ~IDMSourceRenderer ();
  233.  
  234. /*--------------------------------- Testing ------------------------------------
  235. | These functions are used to test whether a given item can be rendered:       |
  236. |   canRender - Returns true if the renderer can render items with the         |
  237. |               argument attribute(s).                                         |
  238. ------------------------------------------------------------------------------*/
  239. virtual Boolean
  240.   canRender    ( const IString  &types ),
  241.   canRender    ( const IString  &selectedType,
  242.                  const IString  &selectedRMF,
  243.                  unsigned short selectedOp );
  244.  
  245. /*-------------------------------- Rendering -----------------------------------
  246. | These functions are called to perform rendering operations:                  |
  247. |   sourceRender             - Called when the target renderer requests that a |
  248. |                              source renderer render an item.                 |
  249. |   sourceRenderPrepare      - Called when an item indicates that it requires  |
  250. |                              preparation.                                    |
  251. |   sourceRenderEnd          - Called when the target informs the source that  |
  252. |                              it has finished processing the data that was    |
  253. |                              associated with the dropped item.               |
  254. |   informTargetOfCompletion - Informs target that source renderering on the   |
  255. |                              item has completed.                             |
  256. ------------------------------------------------------------------------------*/
  257. virtual IDMSourceRenderer
  258.  &sourceRender                ( IDMSourceRenderEvent  &event ),
  259.  &sourceRenderPrepare         ( IDMSourcePrepareEvent &event ),
  260. // &sourceRenderEnd             ( IDMSourceEndEvent     &event ),
  261.  &informTargetOfCompletion    ( IDMSourceRenderEvent  &event );
  262.  
  263. protected:
  264. /*------------------------------ Implementation --------------------------------
  265. | These functions provide utilities used to implement this class:              |
  266. |   renderPrepare  - Called when a "render prepare" event occurs for a drag    |
  267. |                    item to be rendered by this renderer.                     |
  268. |   render         - Called when a "render" event occurs for a drag item to    |
  269. |   render         - Called when a "render" event occurs for a drag item to    |
  270. |                    be rendered by this renderer.                             |
  271. |   renderEnd      - Called when an "end" event occurs on a drag item being    |
  272. |                    rendered by this renderer.                                |
  273. ------------------------------------------------------------------------------*/
  274. virtual Boolean
  275.   renderPrepare     ( IDMSourcePrepareEvent &event ),
  276.   render            ( IDMSourceRenderEvent  &event );
  277. //renderEnd         ( IDMSourceEndEvent     &event );
  278.  
  279. private: /*------------------------ PRIVATE ----------------------------------*/
  280.  
  281. _DRAGTRANSFER
  282.  *pPMDragTransfer;
  283.  
  284. }; // class IDMSourceRenderer
  285.  
  286.  
  287. class IDMTargetRenderer : public IDMRenderer {
  288. /*******************************************************************************
  289.   Objects of this class provide target rendering when a direct manipulation
  290.   operation is performed.  Instances of this class are "registered" with the
  291.   target handler.  The handler selects a renderer for a given drag item and
  292.   invokes rendering functions of the renderer when target rendering events
  293.   occur.
  294. *******************************************************************************/
  295. public:
  296.  
  297. /*------------------------ Constructor/Destructor ------------------------------
  298. | Generic objects of this class are constructed without formal parameters.     |
  299. ------------------------------------------------------------------------------*/
  300.   IDMTargetRenderer     ( );
  301.  
  302. virtual
  303.   ~IDMTargetRenderer    ( );
  304.  
  305.  
  306. /*-------------------------------- Accessors -----------------------------------
  307. | The following function provides access to the accessible attributes of       |
  308. | instances of this class:                                                     |
  309. |   targetInfo        - Returns the target-defined information.                |
  310. |   refreshTargetInfo - Refreshes and returns the target-defined information   |
  311. |                       with source preparation modifications (if any).        |
  312. ------------------------------------------------------------------------------*/
  313. unsigned long
  314.   targetInfo           ( ) const,
  315.   refreshTargetInfo    ( );
  316.  
  317. /*--------------------------------- Testing ------------------------------------
  318. | These functions are used to test whether a given item can be rendered:       |
  319. |   canRender       - Returns drop indicator per the renderers ability to      |
  320. |                     render the item with the argument attributes.            |
  321. |   selectOperation - Returns true if the default operation (i.e. move, copy   |
  322. |                     or link) is supported by the item.  If the operation set |
  323. |                     by the source is IDMOperation::drag, we will need        |
  324. |                     to indicate which operation we support (i.e. copy,       |
  325. |                     move, or link) here in the target.  If the operation     |
  326. |                     value defined by the source is > IDMOperation::unknown,  |
  327. |                     it will be up to the application to define the           |
  328. |                     operation it supports.  Otherwise, we'll use the         |
  329. |                     operation the source indicated if the item supports it.  |
  330. ------------------------------------------------------------------------------*/
  331. virtual DropIndicator
  332.   canRender         ( const IString               &types ),
  333.   canRender         ( const IDMTgtOperationHandle targetOperation,
  334.                       const IString               &aType,
  335.                       const IString               &sourceRMFs,
  336.                       unsigned short              supportedOps );
  337.  
  338. virtual Boolean
  339.   selectOperation    ( const IDMTgtOperationHandle targetOperation,
  340.                        unsigned short              supportedOps );
  341.  
  342. /*-------------------------------- Rendering -----------------------------------
  343. | These functions are called to perform rendering operations:                  |
  344. |   targetRender             - Called when a "drop" event occurs for a drag    |
  345. |                              item to be rendered by this renderer.           |
  346. |   targetRenderPrepare      - Called when the source requests the target to   |
  347. |                              generate a "preparation" event.                 |
  348. |   targetRenderComplete     - Called when a "completion" event occurs for a   |
  349. |                              drag item to be rendered by this renderer.      |
  350. |   informSourceOfCompletion - Inform the source that the target has finished  |
  351. |                              processing the data that was associated with    |
  352. |                              the dropped item.  Source is informed           |
  353. |                              irregardless of source or target rendering.     |
  354. ------------------------------------------------------------------------------*/
  355. virtual IDMTargetRenderer
  356.  &targetRender                ( IDMTargetDropEvent  &event,
  357.                                 const IDMItemHandle &dragItem ),
  358.  
  359.  &targetRenderPrepare         ( IDMTargetDropEvent  &event,
  360.                                 const IDMItemHandle &dragItem ),
  361.  
  362.  &targetRenderComplete        ( IDMTargetEndEvent   &event ),
  363.  &informSourceOfCompletion    ( const IDMItemHandle &dragItem );
  364.  
  365. protected:
  366. /*------------------------------ Implementation --------------------------------
  367. | These functions provide utilities used to implement this class:              |
  368. |   renderAtSource      - Send "render" event to source window to request      |
  369. |                         source rendering for the argument item.              |
  370. |   prepareAtSource     - Send "prepare" event to source window to request     |
  371. |                         source preparation for the argument item.            |
  372. |   renderComplete      - Called to process a "completion" event for a drag    |
  373. |                         item.                                                |
  374. |   renderToName        - Called to provide the name to render the data        |
  375. |                         to.  This could be a filename, shared memory         |
  376. |                         name, etc.                                           |
  377. ------------------------------------------------------------------------------*/
  378. virtual Boolean
  379.   renderAtSource     ( IDMTargetDropEvent  &event ),
  380.   prepareAtSource    ( IDMTargetDropEvent  &event ),
  381. //renderComplete     ( IDMTargetEndEvent   &event );
  382.   renderComplete     ( const IDMItemHandle &dragItem );
  383.  
  384. virtual IString
  385.   renderToName       ( const IDMItemHandle &dragItem );
  386.  
  387. /*-------------------------------- Accessors -----------------------------------
  388. | The following function provides writeable access to the accessible           |
  389. | attributes of instances of this class:                                       |
  390. |   setTargetInfo - Can be used to pass information to the target              |
  391. ------------------------------------------------------------------------------*/
  392. virtual IDMTargetRenderer
  393.  &setTargetInfo     ( unsigned long info );
  394.  
  395. private: /*------------------------ PRIVATE ----------------------------------*/
  396.  
  397. unsigned long
  398.   ulTgtInfo;
  399.  
  400. _DRAGTRANSFER
  401.   *allocDragTransfer (IDMTargetDropEvent &dropEvent,
  402.                       const IDMItemHandle pDI);
  403.  
  404. _DRAGTRANSFER
  405.   *dragTransfer ();
  406.  
  407. _DRAGTRANSFER
  408.  *pPMDragTransfer;
  409.  
  410. unsigned long
  411.   TgtEndConversationCount;
  412. }; // class IDMTargetRenderer
  413.  
  414.  
  415. #ifndef I_NO_INLINES
  416.   #include <idmrendr.inl>
  417. #endif
  418.  
  419. #endif // _IDMRENDR_
  420.