home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IDMSRCH.HPP < prev    next >
C/C++ Source or Header  |  1993-10-22  |  14KB  |  241 lines

  1. #ifndef _IDMSRCH_
  2. #define _IDMSRCH_
  3. /*******************************************************************************
  4. * FILE NAME: idmsrch.hpp                                                       *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IDMSourceHandler - Direct manipulation source window handler.            *
  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 disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *******************************************************************************/
  18. #ifndef _IDMCOMM_
  19.   #include <idmcomm.hpp>
  20. #endif
  21.  
  22. #ifndef _IDMHNDLR_
  23.   #include <idmhndlr.hpp>
  24. #endif
  25.  
  26. #ifndef _IDMSRCOP_
  27.   #include <idmsrcop.hpp>
  28. #endif
  29.  
  30. #ifndef _IDMSRCRN_
  31.   #include <idmsrcrn.hpp>
  32. #endif
  33.  
  34. #ifndef _IDMITEM_
  35.   #include <idmitem.hpp>
  36. #endif
  37.  
  38. /*----------------------------------------------------------------------------*/
  39. /* Align classes on four byte boundary.                                       */
  40. /*----------------------------------------------------------------------------*/
  41. #pragma pack(4)
  42.  
  43. /* Forward Declarations */
  44. class IWindow;
  45. class IEntryField;
  46. class IMultiLineEdit;
  47. class IContainerControl;
  48. class IDMSourceBeginEvent;
  49. class IDMSourcePrepareEvent;
  50. class IDMSourceRenderEvent;
  51. class IDMSourceEndEvent;
  52. class IDMSourceDiscardEvent;
  53. class IDMSourcePrintEvent;
  54.  
  55.  
  56. class IDMSourceHandler : public IDMHandler {
  57. typedef IDMHandler
  58.   Inherited;
  59. typedef IDM::DragImageStyle
  60.   DragImageStyle;
  61. /*******************************************************************************
  62. * Objects of the IDMSourceHandler class handle events that occur in the source *
  63. * window during a direct manipulation operation.  An instance of this class    *
  64. * must be added to a window so that it can support the dragging of object(s).  *
  65. * It does not  allow objects to be dropped on a window.  See the               *
  66. * IDMTargetHandler class for information about dropping objects on a window.   *
  67. *------------------------------------------------------------------------------*
  68. *                                                                              *
  69. * Two examples are provided.  Note that both achieve the same goal:            *
  70. *                                                                              *
  71. * Example 1:                                                                   *
  72. * // Create frame window object ...                                            *
  73. * IFrameWindow                                                                 *
  74. *   frame( "ICLUI Direct Manipulation Sample" );                               *
  75. *                                                                              *
  76. * // Create client entry field and entry field extension objects ...           *
  77. * IEntryField                                                                  *
  78. *   client( 0, &frame, &frame ),                                               *
  79. *   ext   ( 0, &frame, &frame );                                               *
  80. *                                                                              *
  81. * // Define source handler for the entry field ...                             *
  82. * IDMSourceHandler                                                             *
  83. *   source( &client );                                                         *
  84. *                                                                              *
  85. * // Reuse drag item provider in the extension that was instantiated           *
  86. * // for the client and configure the extension as a source handler            *
  87. * ext.setItemProvider(client.itemProvider());                                  *
  88. * source.handleEventsFor( &ext );                                              *
  89. *------------------------------------------------------------------------------*
  90. *                                                                              *
  91. * Example 2:                                                                   *
  92. * // Create frame window object ...                                            *
  93. * IFrameWindow                                                                 *
  94. *   frame( "ICLUI Direct Manipulation Sample" );                               *
  95. *                                                                              *
  96. * // Create client entry field and entry field extension objects ...           *
  97. * IEntryField                                                                  *
  98. *   client( 0, &frame, &frame ),                                               *
  99. *   ext   ( 0, &frame, &frame );                                               *
  100. *                                                                              *
  101. * // Enable both entry fields to allow dragging of text ...                    *
  102. * IDMHandler::enableDragFrom( &client );                                       *
  103. * IDMHandler::enableDragFrom( &ext );                                          *
  104. *                                                                              *
  105. *******************************************************************************/
  106. public:
  107.  
  108. /*----------------------- Constructor/Destructor -------------------------------
  109. | You can construct objects of this class by providing one of the following    |
  110. | items:                                                                       |
  111. |   o A pointer to an IWindow object                                           |
  112. |   o A pointer to an entry field                                              |
  113. |   o A pointer to an MLE                                                      |
  114. |   o A pointer to an container control                                        |
  115. |   o No arguments                                                             |
  116. |                                                                              |
  117. | Note:  If any of the first 4 constructors are used, this handler will        |
  118. |        automatically be attached to the specified window.                    |
  119. ------------------------------------------------------------------------------*/
  120.   IDMSourceHandler  ( IWindow           *window );
  121.  
  122.   IDMSourceHandler  ( IEntryField       *entryField );
  123.  
  124.   IDMSourceHandler  ( IMultiLineEdit    *multiLineEdit );
  125.  
  126.   IDMSourceHandler  ( IContainerControl *containerControl );
  127.  
  128.   IDMSourceHandler  ( );
  129.  
  130. virtual
  131.   ~IDMSourceHandler ( );
  132.  
  133. /*--------------------------------- Overrides ----------------------------------
  134. | The following functions override the rendering functions defined in the      |
  135. | base IDMHandler class.  They provide a means of accessing the                |
  136. | IDMSourceRenderer objects involved in the direct manipulation operation      |
  137. | described by instances of this class.  These objects will be used to handle  |
  138. | the rendering of dragged objects that are compatible with the supported      |
  139. | renderering mechanisms and formats:                                          |
  140. |   numberOfRenderers - Returns the number of renderers                        |
  141. |   renderer          - Returns the renderer with the given position           |
  142. |   replaceRenderer   - Replaces a given IDMSourceRenderer with another        |
  143. |   addRenderer       - Adds another IDMSourceRenderer to this source          |
  144. |                       operation                                              |
  145. |   removeRenderer    - Removes an IDMSourceRenderer from this source          |
  146. |                       operation                                              |
  147. |   setRenderer       - Sets the renderer for this source operation  Removes   |
  148. |                       any existing renderers.                                |
  149. |                                                                              |
  150. | Note: Renderers are maintained positionally, which is 1-based.               |
  151. ------------------------------------------------------------------------------*/
  152. virtual unsigned
  153.   numberOfRenderers  ( );
  154.  
  155. virtual IDMSourceRenderer
  156.  *renderer           ( unsigned                position );
  157.  
  158. virtual IDMSourceHandler
  159.  &replaceRenderer    ( unsigned                position,
  160.                        const IDMSourceRenderer &replacement ),
  161.  &addRenderer        ( const IDMSourceRenderer &newRenderer ),
  162.  &removeRenderer     ( const IDMSourceRenderer &rendererToRemove ),
  163.  &setRenderer        ( const IDMSourceRenderer &newRenderer );
  164.  
  165. protected:
  166. /*------------------------------ Event Handling --------------------------------
  167. | The following functions are dispatched in response to specific direct        |
  168. | manipulation source events:                                                  |
  169. |   sourceBegin       - Called to process the initiation of a drag operation   |
  170. |                       and subsequently start a drag operation in response    |
  171. |                       to a system begin drag event.                          |
  172. |   sourcePrepare     - Called to indicate to the source window that rendering |
  173. |                       is about to start.                                     |
  174. |   sourceRender      - Called to initiate the rendering of a given drag item  |
  175. |                       by the source renderer.                                |
  176. |   sourceEnd         - Called to indicate that a given item has been          |
  177. |                       processed by the target renderer.                      |
  178. |   sourceDiscard     - Called to indicate that an item or items have been     |
  179. |                       dropped on a shredder object.                          |
  180. |   sourcePrint       - Called to indicate that an item or items have been     |
  181. |                       dropped on a printer object.                           |
  182. ------------------------------------------------------------------------------*/
  183. virtual Boolean
  184.   sourceBegin        ( IDMSourceBeginEvent              &event ),
  185.   sourcePrepare      ( IDMSourcePrepareEvent            &event ),
  186.   sourceRender       ( IDMSourceRenderEvent             &event ),
  187.   sourceEnd          ( IDMSourceEndEvent                &event ),
  188.   sourceDiscard      ( IDMSourceDiscardEvent            &event ),
  189.   sourcePrint        ( IDMSourcePrintEvent              &event );
  190.  
  191. /*------------------------------ Implementation --------------------------------
  192. | The following utility functions are used to implement the behavior of        |
  193. | this class:                                                                  |
  194. |   allocateOperation - Creates an instance of the IDMSourceOperation class    |
  195. |                       and returns a pointer to it.                           |
  196. |   findRenderersFor  - Called to find the appropriate source renderers        |
  197. |                       for the operation.                                     |
  198. |   findRendererFor   - Called to find the appropriate source renderer         |
  199. |                       for the item.  Returns the position of the renderer,   |
  200. |                       0 if none found.                                       |
  201. ------------------------------------------------------------------------------*/
  202. virtual IDMSourceOperation::Handle
  203.   allocateOperation  ( IDMSourceBeginEvent              &event,
  204.                        DragImageStyle                   dragItemStyle) const;
  205.  
  206. virtual Boolean
  207.   findRenderersFor   ( const IDMSourceOperation::Handle &sourceOperation );
  208.  
  209. virtual unsigned
  210.   findRendererFor    ( const IDMItem::Handle            &item );
  211.  
  212. /*-------------------------------- Overrides -----------------------------------
  213. | This class overrides the inherited dispatchHandlerEvent function, which      |
  214. | handles source drag events.                                                  |
  215. ------------------------------------------------------------------------------*/
  216. virtual Boolean
  217.   dispatchHandlerEvent ( IEvent &event );
  218.  
  219. private: /*------------------------ PRIVATE ----------------------------------*/
  220.  
  221. virtual IDMHandler
  222.  &replaceRenderer ( unsigned          position,
  223.                     const IDMRenderer &replacement ),
  224.  &addRenderer     ( const IDMRenderer &newRenderer ),
  225.  &removeRenderer  ( unsigned          position ),
  226.  &removeRenderer  ( const IDMRenderer &rendererToRemove ),
  227.  &setRenderer     ( const IDMRenderer &newRenderer );
  228.  
  229. void
  230.   resolveRMFConflict (IDMItem::Handle &item,
  231.                       IDMSourceRenderer* pIDMSrcRenderer);
  232.  
  233. }; //IDMSourceHandler
  234.  
  235. /*----------------------------------------------------------------------------*/
  236. /* Resume compiler default packing.                                           */
  237. /*----------------------------------------------------------------------------*/
  238. #pragma pack()
  239.  
  240. #endif //_IDMSRCH_
  241.