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

  1. #ifndef _IDMCNRHD_
  2. #define _IDMCNRHD_
  3. /*******************************************************************************
  4. * FILE NAME: idmcnrhd.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   This file contains the interface for the container Drag and Drop           *
  8. *   source and target handlers.                                                *
  9. *                                                                              *
  10. *   Declaration of the classes:                                                *
  11. *     IDMCnrSourceHandler                                                      *
  12. *     IDMCnrTargetHandler                                                      *
  13. *                                                                              *
  14. *                                                                              *
  15. * COPYRIGHT:                                                                   *
  16. *   Licensed Materials - Property of IBM                                       *
  17. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  18. *   All Rights Reserved                                                        *
  19. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  20. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  21. *                                                                              *
  22. * $Log:   S:/ibmclass/idrag/vcs/idmcnrhd.hpv  $                         *
  23. //
  24. //   Rev 1.2   03 Sep 1993 13:41:58   HAGGAR
  25. //added drag image support
  26. //
  27. //   Rev 1.1   03 Sep 1993 10:44:06   banzai
  28. //Add renderer/provider support to constructor
  29. //
  30. //   Rev 1.0   02 Sep 1993 20:29:44   banzai
  31. //Initial Drop
  32. *                                                                              *
  33. *******************************************************************************/
  34. #ifndef _IDMCOMM_
  35.   #include <idmcomm.hpp>
  36. #endif
  37.  
  38. #ifndef _IDMSRCH_
  39.   #include <idmsrch.hpp>
  40. #endif
  41.  
  42. #ifndef _IDMTGTH_
  43.   #include <idmtgth.hpp>
  44. #endif
  45.  
  46. #ifndef _ICNRCTL_
  47.   #include <icnrctl.hpp>
  48. #endif
  49.  
  50.  
  51. /* Forward Declarations */
  52. class IDMCnrInitEvent;
  53. class IDMCnrOverAfterEvent;
  54. class IDMCnrDropEvent;
  55. class IDMCnrItemHandle;
  56. class IDMCnrTargetHandler;
  57.  
  58.  
  59. class IDMCnrSourceHandler : public IDMSourceHandler {
  60. typedef IDMSourceHandler
  61.   Inherited;
  62. /*******************************************************************************
  63. * Objects of this class handle events occuring at source containers in direct  *
  64. * manipulation operations.  An instance of this class (or a derived class)     *
  65. * must be added to any container that will support direct manipulation from    *
  66. * that container.                                                              *
  67. *                                                                              *
  68. * Example:                                                                     *
  69. * // Create frame window object ...                                            *
  70. * IFrameWindow                                                                 *
  71. *   frame( "ICLUI Direct Manipulation Sample" );                               *
  72. *                                                                              *
  73. * // Create containers ...                                                     *
  74. * IContainerControl                                                            *
  75. *   container1(),                                                              *
  76. *   container2();                                                              *
  77. *                                                                              *
  78. * // Define source handler for the container ...                               *
  79. * IDMCnrSourceHandler                                                          *
  80. *   source( &container1 );                                                     *
  81. *                                                                              *
  82. * // Reuse source item provider in container2 that was instantiated            *
  83. * // for container1 and configure container2 as a source handler               *
  84. * container2.setItemProvider(container1.itemProvider());                       *
  85. * source.handleEventsFor( &container2 );                                       *
  86. *                                                                              *
  87. * Note:  Direct Manipulation support for the container is built into the       *
  88. *        class library.                                                        *
  89. *******************************************************************************/
  90. public:
  91. /*-------------------------- Constructors/Destructors -------------------------+
  92. | Objects of this class are constructed as follows:                            |
  93. |                                                                              |
  94. | Note:  A Constructor is provided that will construct a container source      |
  95. |        handler designed specifically for the container.                      |
  96. +-----------------------------------------------------------------------------*/
  97.   IDMCnrSourceHandler  ( IContainerControl *container,
  98.                          IDM::DragImageStyle = IDM::systemImages );
  99.  
  100.   IDMCnrSourceHandler  ( IDM::DragImageStyle = IDM::systemImages );
  101.  
  102. virtual
  103.   ~IDMCnrSourceHandler ( );
  104.  
  105.  
  106. protected:
  107. /*---------------------------------- Overrides --------------------------------+
  108. | This class overrides the following inherited methods:                        |
  109. |   dispatchHandlerEvent  - The event dispatcher.                              |
  110. +-----------------------------------------------------------------------------*/
  111. virtual Boolean
  112.   dispatchHandlerEvent    ( IEvent  &event );
  113.  
  114. /*------------------------------ Event Handling --------------------------------
  115. | These functions are dispatched in response to specific direct manipulation   |
  116. | source events:                                                               |
  117. |   containerSetup -  Called to process the container begin drag notification. |
  118. |                     The initial processing of this function is to invoke the |
  119. |                     allocIDMSrcOper() function.  Then the                    |
  120. |                     provideSourceItems() function of the IDMSourceProvider   |
  121. |                     class is invoked to retrieve the objects that are to be  |
  122. |                     dragged.  Then the user begin drag event is sent to      |
  123. |                     all container source handlers.  If there are items to    |
  124. |                     be dragged, the function IDMSourceOperation::begin()     |
  125. |                     is called to commence the drag operation.                |
  126. ------------------------------------------------------------------------------*/
  127. virtual Boolean
  128.   containerSetup    ( IDMCnrInitEvent &event );
  129.  
  130. private: /*------------------------ PRIVATE ----------------------------------*/
  131.  
  132. }; // IDMCnrSourceHandler
  133.  
  134.  
  135. class IDMCnrTargetHandler : public IDMTargetHandler {
  136. typedef IDMTargetHandler
  137.   Inherited;
  138. /*******************************************************************************
  139. * Objects of this class handle events occuring at target containers in direct  *
  140. * manipulation operations.  An instance of this class (or a derived class)     *
  141. * must be added to any container that will support direct manipulation from       *
  142. * that container.                                                              *
  143. *                                                                              *
  144. * Example:                                                                     *
  145. * // Create frame window object ...                                            *
  146. * IFrameWindow                                                                 *
  147. *   frame( "ICLUI Direct Manipulation Sample" );                               *
  148. *                                                                              *
  149. * // Create containers ...                                                     *
  150. * IContainerControl                                                            *
  151. *   container1(),                                                              *
  152. *   container2();                                                              *
  153. *                                                                              *
  154. * // Define source handler for the container ...                               *
  155. * IDMCnrTargetHandler                                                          *
  156. *   target( &container1 );                                                     *
  157. *                                                                              *
  158. * // Reuse source item provider in container2 that was instantiated            *
  159. * // for container1 and configure container2 as a source handler               *
  160. * container2.setItemProvider(container1.itemProvider());                       *
  161. * target.handleEventsFor( &container2 );                                       *
  162. *                                                                              *
  163. * Note:  Direct Manipulation support for the container is built into the       *
  164. *        class library.                                                        *
  165. *******************************************************************************/
  166. public:
  167.  
  168. /*-------------------------------- DropStyle ----------------------------------+
  169. | The following functions provide a means to set and query container drop      |
  170. | styles:                                                                      |
  171. |                                                                              |
  172. |   DropStyle - Nested class that provides static members that define the      |
  173. |               behavior that occurs when an object is dropped in a            |
  174. |               container.  For example, you could define an instance of the   |
  175. |               IDMCnrTargetHandler::DropStyle class and initialize it like:   |
  176. |                  IDMCnrTargetHandler::DropStyle                              |
  177. |                    dropStyle = dropAtPosition | alignVertical;               |
  178. |               Once these drop styles have been defined, ICnrDrgTgtHandler    |
  179. |               member functions can be used to set or query them.             |
  180. |                                                                              |
  181. |               The declaration of the IDMCnrTargetHandler::DropStyle nested   |
  182. |               class is generated by the INESTEDBITFLAGCLASSDEF0 macro.       |
  183. |                                                                              |
  184. | The valid container drop styles are:                                         |
  185. |   dropAtPosition  - Drops items at the position they were in the list.       |
  186. |   alignVertical   - Alignment is along the vertical axis.                    |
  187. |   alignFlow       - Alignment flows along the window.                        |
  188. |   flowBeside      - Alignment flows beside the window.                       |
  189. +-----------------------------------------------------------------------------*/
  190. INESTEDBITFLAGCLASSDEF0(DropStyle, IDMCnrTargetHandler);
  191. static const DropStyle
  192.   dropAtPosition,
  193.   alignVertical,
  194.   alignFlow,
  195.   flowBeside;
  196.  
  197. /*-------------------------- Constructor/Destructor ---------------------------+
  198. | Objects of this class are constructed as follows:                            |
  199. |                                                                              |
  200. | Note:  A Constructor is provided that will construct a container target      |
  201. |        handler designed specifically for the container.                      |
  202. +-----------------------------------------------------------------------------*/
  203.   IDMCnrTargetHandler  ( IContainerControl *container,
  204.                          const DropStyle   &style = alignFlow );
  205.  
  206.   IDMCnrTargetHandler  ( const DropStyle &style = alignFlow );
  207.  
  208. virtual
  209.   ~IDMCnrTargetHandler ( );
  210.  
  211. /*--------------------------------- Accessors ---------------------------------+
  212. | These functions provide a means of getting and setting the accessible        |
  213. | attributes of instances of this class:                                       |
  214. |   wasDragAfter            - Returns the state of the latest DRAGOVER or      |
  215. |                             DRAGAFTER.                                       |
  216. |   isStyle                 - Queries whether a specified style flag is set.   |
  217. |   setCurrentDropOffset    - Sets the current drop offset.                    |
  218. |   setContainerNoRefresh   - Sets the given container to no-refresh.          |
  219. |                             When the process-drop returns, refresh is turned |
  220. |                             on again.                                        |
  221. |   setContainerRefresh     - Forces the no-refresh containers to refresh.     |
  222. |   setStyle                - Sets the drop style.                             |
  223. |   currentDropOffset       - Queries the current drop offset.                 |
  224. |   style                   - Returns the drop style.                          |
  225. +-----------------------------------------------------------------------------*/
  226. Boolean
  227.   wasDragAfter              ( ) const,
  228.   isStyle                   ( const DropStyle   &dropStyle );
  229.  
  230. IDMCnrTargetHandler
  231.   &setCurrentDropOffset     ( const ISize       &newPointerOffset ),
  232.   &setContainerNoRefresh    ( IContainerControl *noRefresh ),
  233.   &setContainerRefresh      ( ),
  234.   &setStyle                 ( const DropStyle   &dropStyle );
  235.  
  236. ISize
  237.   currentDropOffset         ( ) const;
  238.  
  239. DropStyle
  240.   style                     ( ) const;
  241.  
  242. /*------------------------------- Utility Methods -----------------------------+
  243. | The following is a utility method to handle a drop's positioning:            |
  244. |   dropPosition  - Computes the drop position for this item, in container     |
  245. |                   workspace coordinates, and sets the offset for the next    |
  246. |                   item, according to the handler's drop style.               |
  247. |   position     - Returns a drag item's position relative to the target       |
  248. +-----------------------------------------------------------------------------*/
  249. IPoint
  250.   dropPosition    ( const IDMCnrItemHandle &dragItem,
  251.                     IDMCnrDropEvent        &event );
  252.  
  253. protected:
  254. /*------------------------------ Event Handling --------------------------------
  255. | These functions are dispatched in response to specific direct manipulation   |
  256. | target events:                                                               |
  257. |   cnrTargetDrop - Called when the dragged objects are dropped on the         |
  258. |                   container target window.                                   |
  259. ------------------------------------------------------------------------------*/
  260. //virtual Boolean
  261. //  cnrTargetDrop    ( IDMCnrDropEvent   &event );
  262.  
  263. /*---------------------------------- Overrides --------------------------------+
  264. | This class overrides the following inherited method:                         |
  265. |   dispatchHandlerEvent - Dispatching function; handles drag target events.   |
  266. +-----------------------------------------------------------------------------*/
  267. virtual Boolean
  268.   dispatchHandlerEvent    ( IEvent& event );
  269.  
  270. private: /*------------------------ PRIVATE ----------------------------------*/
  271. friend class IDMCnrItem;
  272.  
  273. static IDMCnrTargetHandler
  274.  *cnrTgtHandler() { return(pTgtHnd); }
  275.  
  276. void
  277.   initDropVars    ();
  278.  
  279. Boolean
  280.   bWasDragAfter;
  281.  
  282. ISize
  283.   sizeDropCurrent;
  284.  
  285. DropStyle
  286.   dropStyle;
  287.  
  288. IContainerControl
  289.  *pCnrNoRefresh1,
  290.  *pCnrNoRefresh2;
  291.  
  292. static IDMCnrTargetHandler
  293.  *pTgtHnd;
  294.  
  295. }; // IDMCnrTargetHandler
  296.  
  297. /*--------------------------------- INLINES ----------------------------------*/
  298. #ifndef I_NO_INLINES
  299.   #include <idmcnrhd.inl>
  300. #endif
  301.  
  302.  
  303. #endif // _IDMCNRHD_
  304.