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

  1. #ifndef _IDRGEVT_
  2.   #define _IDRGEVT_
  3. /**************************************************************/
  4. /* CLASSES NAMES:   IBeginDragEvent                           */
  5. /*                  IDragOperationEvent                       */
  6. /*                    IDragOverEvent                          */
  7. /*                    IDropOnEvent                            */
  8. /*                    IDragOverNotificationEvent              */
  9. /*                  IRenderEvent                              */
  10. /*                  IRenderCompleteEvent                      */
  11. /*                  IEndConversationEvent                     */
  12. /*                                                            */
  13. /* DESCRIPTION  : This file defines a series of event classes */
  14. /*                for direct manipulation operations.         */
  15. /*                                                            */
  16. /* SYNOPSIS:    #include <idrgevt.hpp>                        */
  17. /*                                                            */
  18. /* CHANGE ACTIVITY:                                           */
  19. /*   DATE:     INITIAL:        DESCRIPTION                    */
  20. /*                                                            */
  21. /*   050191    PG & KKL        Initiate code & design         */
  22. /*   100191    KKL             Update per R2.0 spec.          */
  23. /*   111991    KKL             Update for new Manipulation cls*/
  24. /*   170892    PHG             Giverny update - redesign      */
  25. /*   071092    PHG             Major update                   */
  26. /*                                                            */
  27. /**************************************************************/
  28. /* Copyright (c) IBM Corporation 1991                         */
  29. /**************************************************************/
  30.  
  31. #ifndef _IBASETYP_
  32.   #include <ibasetyp.hpp>
  33. #endif
  34. #ifndef _IRESLIB_
  35.   #include <ireslib.hpp>
  36. #endif
  37. #ifndef _IPOINT_
  38.   #include <ipoint.hpp>
  39. #endif
  40. #ifndef _IWINDOW_
  41.   #include <iwindow.hpp>
  42. #endif
  43. #ifndef _IEVENT_
  44.   #include <ievent.hpp>
  45. #endif
  46. #ifndef _IBITFLAG_
  47.   #include <ibitflag.hpp>
  48. #endif
  49.  
  50. // forward define classes
  51. class IDragOperationEvent;
  52. class IRenderEvent;
  53. class IEndConversationEvent;
  54.  
  55. // include D&D related headers
  56. #ifndef _IDRGSTYL_
  57.   #include <idrgstyl.hpp>
  58. #endif
  59. #ifndef _IDRGITM_
  60.   #include <idrgitm.hpp>
  61. #endif
  62.  
  63.  
  64. class IBeginDragEvent : public IEvent {
  65. /**************************************************************************
  66. * Constructed on WM_BEGINDRAG message                                     *
  67. *   Hungarian is 'idevt'                                                  *
  68. **************************************************************************/
  69. public:
  70. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
  71. | There is one way to construct instances of this class:                  |
  72. |   1 - From an untyped generic IEvent                                    |
  73. +------------------------------------------------------------------------*/
  74.   IBeginDragEvent(const IEvent& evt);
  75. virtual
  76.   ~IBeginDragEvent();
  77.  
  78. /*-------------------------------- ACCESSORS -----------------------------+
  79. | These function provide means of getting and setting the accessible      |
  80. | attributes of instances of this class:                                  |
  81. |   isPointerEvent - returns wether the event results from pointer action |
  82. |   pointerPos - returns the pointer position relative to this window     |
  83. +------------------------------------------------------------------------*/
  84. virtual Boolean
  85.   isPointerEvent() const;
  86. virtual IPoint
  87.   pointerPos() const;
  88.  
  89. }; // IBeginDragEvent
  90.  
  91.  
  92. class IDragOperationEvent : public IEvent {
  93. /**************************************************************************
  94. * General base class for target drag operation events                     *
  95. *  Encapsulates the operations to extract data from a DRAGITEM structure  *
  96. *  whose pointer is stored in mp1 (can be overloaded to get pointer       *
  97. *  differently)                                                           *
  98. *  Provides methods to access the DRAGINFO elements.                      *
  99. *    Hungarian is 'dopevt'                                                *
  100. **************************************************************************/
  101. public:
  102. /*------------------------ DRAG OPERATION FLAGS --------------------------+
  103. | These flags are used to qualify a drag operation                        |
  104. +------------------------------------------------------------------------*/
  105. INESTEDBITFLAGCLASSDEF0(Operations, IDragOperationEvent);
  106. static const Operations
  107.   noop,
  108.   defop,
  109.   unknown,
  110.   copy,
  111.   move,
  112.   link,
  113.   create;
  114.  
  115. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
  116. | There is one way to construct instances of this class                   |
  117. |   1 - From an untyped generic IEvent                                    |
  118. +------------------------------------------------------------------------*/
  119.   IDragOperationEvent(const IEvent& evt);
  120. virtual
  121.   ~IDragOperationEvent();
  122.  
  123. /*------------------------ HELPER FUNCTIONS ------------------------------+
  124. | These functions are used to test the state of the Operations flags      |
  125. |   isDefault - Test if operation is default                              |
  126. |   isUnknown - Test if operation is unknown                              |
  127. |   isCopy    - Test if operation is a copy                               |
  128. |   isMove    - Test if operation is a move                               |
  129. |   isCreate  - Test if operation is creation                             |
  130. |   isLink    - Test if operation is a link                               |
  131. +------------------------------------------------------------------------*/
  132. Boolean
  133.   isDefault() const,
  134.   isUnknown() const,
  135.   isCopy() const,
  136.   isMove() const,
  137.   isCreate() const,
  138.   isLink() const;
  139.  
  140. /*------------------------ DRAGINFO ACCESSORS ----------------------------+
  141. | Functions to access the drag info information                           |
  142. |   dragItemsCount - returns count of items dragged                       |
  143. |   sourceHandle - returns the source window's handle                     |
  144. |   operations - returns the operations in progress                       |
  145. |   dropPosition - returns the position of the mouse ptr                  |
  146. +------------------------------------------------------------------------*/
  147. unsigned long
  148.   dragItemsCount() const;
  149. IWindowHandle
  150.   sourceHandle() const;
  151. Operations
  152.   operations() const;
  153. virtual IPoint
  154.   dropPosition() const;
  155.  
  156. /*------------------------ GENERAL FUNCTIONS -----------------------------+
  157. | Functions to get information pertaining to the drag in progress         |
  158. |   isSameProcess - tells if this the source is in the same process       |
  159. |   dragitemPtr - yields a pointer to a given drag item                   |
  160. +------------------------------------------------------------------------*/
  161. Boolean
  162.   isSameProcess() const;
  163. void*
  164.   dragitemPtr(unsigned long ulItem) const;
  165.  
  166. protected:
  167. /*-------------------------------- OVERRIDES -----------------------------+
  168. | This class defines the following overridable functions:                 |
  169. |  draginfoPtr        - returns the stored draginfo pointer               |
  170. |  extractDraginfoPtr - extracts the draginfo pointer from the evt        |
  171. +------------------------------------------------------------------------*/
  172. void*
  173.   draginfoPtr() const;
  174. virtual void*
  175.   extractDraginfoPtr() const;
  176.  
  177. /*-------------------------------- HELPER --------------------------------+
  178. | Helper utility functions                                                |
  179. |  asOperations - turn an ulOperation passed by PM to a IDragOperation    |
  180. +------------------------------------------------------------------------*/
  181. Operations
  182.   asOperations(unsigned long ulOperation) const;
  183.  
  184. private:
  185. /*-------------------------- PRIVATE FUNCTIONS ---------------------------+
  186. | Private functions                                                       |
  187. |  accessDragInfo - To access the DRAGINFO structure                      |
  188. |  freeDragInfo   - To free the DRAGINFO structure if different process   |
  189. +------------------------------------------------------------------------*/
  190. IDragOperationEvent
  191.   &accessDragInfo(),
  192.   &freeDragInfo();
  193.  
  194. /*----------------------------- PRIVATE DATA -----------------------------+
  195. | Private data members                                                    |
  196. |  pClDragInfo - Stored DRAGINFO pointer                                  |
  197. +------------------------------------------------------------------------*/
  198.   void* pClDragInfo;
  199.  
  200. }; // IDragOperationEvent
  201.  
  202.  
  203. class IDragOverEvent : public IDragOperationEvent {
  204. /**************************************************************************
  205. * Event to encapsulate the drag over messages                             *
  206. *   Hungarian is 'dovevt'                                                 *
  207. **************************************************************************/
  208. public:
  209. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
  210. | There is one default way to construct instances of this class           |
  211. |   1 - From an untyped generic IEvent                                    |
  212. +------------------------------------------------------------------------*/
  213.   IDragOverEvent(const IEvent& evt);
  214. virtual
  215.   ~IDragOverEvent();
  216.  
  217. /*-------------------------------- ACCESSORS -----------------------------+
  218. | These function provide means of getting and setting the accessible      |
  219. | attributes of instances of this class:                                  |
  220. |   dropPosition - returns the drop position from msg param 2             |
  221. |   setDragPointer - sets the drag pointer from resource or icon          |
  222. |   setDragSysPointer - sets the drag pointer from system icons           |
  223. |   defaultOperation - returns the default operation                      |
  224. |   setDefaultOperation - sets the default operation                      |
  225. +------------------------------------------------------------------------*/
  226. virtual IPoint
  227.   dropPosition() const;
  228.  
  229. IDragOverEvent
  230.   &setDragPointer(IResourceId& resid),
  231.   &setDragPointer(IPointerHandle ptrhDrag),
  232.   &setDragSysPointer(long lSysPtr);
  233.  
  234. Operations
  235.   defaultOperation();
  236. IDragOverEvent
  237.   &setDefaultOperation(const Operations& drgopDefault);
  238.  
  239.   //!PHG!: missing: functions to set the drag images - wait for BBXX Sets
  240.  
  241. private:
  242. /*----------------------------- PRIVATE DATA -----------------------------+
  243. | Private data members                                                    |
  244. |  drgopClDefault - current default operation for event                   |
  245. +------------------------------------------------------------------------*/
  246.   Operations drgopClDefault;
  247. }; // IDragOverEvent
  248.  
  249.  
  250. class IDropOnEvent : public IDragOperationEvent {
  251. /**************************************************************************
  252. * Event to encapsulate the drop on messages                               *
  253. *  Hungarian is 'donevt'                                                  *
  254. **************************************************************************/
  255. public:
  256. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
  257. | There is one default way to construct instances of this class:          |
  258. |   1 - From an untyped generic IEvent                                    |
  259. +------------------------------------------------------------------------*/
  260.   IDropOnEvent(const IEvent& evt);
  261. virtual
  262.   ~IDropOnEvent();
  263.  
  264. /*-------------------------------- ACCESSORS -----------------------------+
  265. | These function provide means of getting and setting the accessible      |
  266. | attributes of instances of this class:                                  |
  267. |   operation - returns the operation for the drop                        |
  268. +------------------------------------------------------------------------*/
  269. Operations
  270.   operation() const;
  271.  
  272. }; // IDropOnEvent
  273.  
  274.  
  275. class IRenderEvent : public IEvent {
  276. /**************************************************************************
  277. * This class encapsulates the DM_RENDER event used for rendering          *
  278. * in direct manipulation operations.                                      *
  279. *   Hungarian is 'rendevt'                                                *
  280. **************************************************************************/
  281. public:
  282.   INESTEDBITFLAGCLASSDEF0(Operation, IRenderEvent);
  283.   static const Operation
  284.     copy,
  285.     link,
  286.     move;
  287.  
  288. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
  289. | There is one default way to construct instances of this class:          |
  290. |   1 - From an untyped generic IEvent                                    |
  291. +------------------------------------------------------------------------*/
  292.   IRenderEvent(const IEvent& evt);
  293.  
  294. virtual
  295.   ~IRenderEvent();
  296.  
  297. /*-------------------------------- ACCESSORS -----------------------------+
  298. | These function provide means of getting information of the rendering    |
  299. | request, and set some of the attributes                                 |
  300. |   wndhClient   - handle of the render requester at target               |
  301. |   itemId       - ID of the item to render                               |
  302. |   selectedRMF  - RMF to render to                                       |
  303. |   nameToRender - name to render to                                      |
  304. |   targetInfo   - target-specific information                            |
  305. |   setTargetInfo- set the target-specific information                    |
  306. |   operation    - required operation to perform                          |
  307. +------------------------------------------------------------------------*/
  308. IWindowHandle
  309.   wndhClient() const;
  310. unsigned long
  311.   itemId() const;
  312. IString
  313.   selectedRMF() const,
  314.   nameToRender() const;
  315. unsigned long
  316.   targetInfo() const;
  317. void
  318.   setTargetInfo(unsigned long ulNewTargetInfo);
  319. Operation
  320.   operation() const;
  321.  
  322. /*-------------------------------- UTILITY -------------------------------+
  323. | Utility functions                                                       |
  324. |   dragtransferPtr - get to the dragtransfer pointer                     |
  325. |   isSameProcess   - find out if the target is in the same process       |
  326. +------------------------------------------------------------------------*/
  327. void*
  328.   dragtransferPtr() const;
  329. Boolean
  330.   isSameProcess() const;
  331.  
  332. /*----------------------------- IMPLEMENTATION ---------------------------+
  333. | Management of the DRAGTRANSFER structure                                |
  334. |  forceFreeXFer - force a free of the dragtransfer upon deletion         |
  335. +------------------------------------------------------------------------*/
  336. protected:
  337.   void
  338.     forceFreeXFer();
  339.  
  340. private:
  341. /*----------------------------- PRIVATE DATA MANAGEMENT ------------------+
  342. | Instance flag and function to control the freeing of the DRAGTRANSFER   |
  343. |  freeXFer       - free the structure                                    |
  344. |  bForceFreeXFer - flag to say if the structure has to be freed          |
  345. +------------------------------------------------------------------------*/
  346. void
  347.   freeXFer();
  348. Boolean
  349.   bForceFreeXFer;
  350.  
  351. };// IRenderEvent
  352.  
  353.  
  354. class IRenderCompleteEvent : public IRenderEvent {
  355. /**************************************************************************
  356. * Event to encapsulate the DM_RENDERCOMPLETE event                        *
  357. *   Hungarian is  'rendcompevt'                                           *
  358. **************************************************************************/
  359. public:
  360. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
  361. | There is one default way to construct instances of this class:          |
  362. |   1 - From an untyped generic IEvent                                    |
  363. +------------------------------------------------------------------------*/
  364.   IRenderCompleteEvent(const IEvent& evt);
  365. virtual
  366.   ~IRenderCompleteEvent();
  367.  
  368.     // test render flags
  369. /*-------------------------------- ACCESSORS -----------------------------+
  370. | These function provide means of testing the event's success flags       |
  371. |  isRenderOK    - Test if the rendering has completed successfully       |
  372. |  isRenderRetry - Test if the rendering has to be retryed                |
  373. +------------------------------------------------------------------------*/
  374. Boolean
  375.   isRenderOK() const,
  376.   isRenderRetry() const;
  377.  
  378. }; // IRenderCompleteEvent
  379.  
  380. class IEndConversationEvent : public IEvent {
  381. /**************************************************************************
  382. * Event to encapsulate the endconversation event                          *
  383. *   Hungarian is 'endconvevt'                                             *
  384. **************************************************************************/
  385. public:
  386. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
  387. | There is one default way to construct instances of this class:          |
  388. |   1 - From an untyped generic IEvent                                    |
  389. +------------------------------------------------------------------------*/
  390.   IEndConversationEvent(const IEvent& evt);
  391. virtual
  392.   ~IEndConversationEvent();
  393.  
  394. /*-------------------------------- ACCESSORS -----------------------------+
  395. | These function provide means of getting to the event's characteristics  |
  396. |   itemId          - ID of the item for which conversation ends          |
  397. |   isRenderSuccess - Test if the rendering has gone OK                   |
  398. +------------------------------------------------------------------------*/
  399. unsigned long
  400.   itemId() const;
  401. Boolean
  402.   isRenderSuccess() const;
  403.  
  404. };// IEndConversationEvent
  405.  
  406. class IUDragDropRender : public IEvent {
  407. /**************************************************************************
  408. * Class to encapsulate a private message used to trigger rendering of     *
  409. * a specific item                                                         *
  410. *  Note: This message's implementation may change, as there are pending   *
  411. *        problems if too many message are posted to a busy queue          *
  412. **************************************************************************/
  413. public:
  414. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
  415. | There is one default way to construct instances of this class:          |
  416. |   1 - From an untyped generic IEvent                                    |
  417. +------------------------------------------------------------------------*/
  418.   IUDragDropRender(const IEvent& evt);
  419. virtual
  420.   ~IUDragDropRender();
  421.  
  422. /*-------------------------------- ACCESSORS -----------------------------+
  423. | These function provide means of getting the accessible params for this  |
  424. | event.                                                                  |
  425. |  dragxferPtr - get to the dragtransfer pointer for item to render       |
  426. +------------------------------------------------------------------------*/
  427. void*
  428.   dragxferPtr() const;
  429. };// IUDragDropRender
  430.  
  431.  
  432. /*=========================================================================
  433. | Inlines for IBeginDragEvent                                   PHG 22/10 |
  434. =========================================================================*/
  435. inline IBeginDragEvent :: IBeginDragEvent(const IEvent& evt)
  436. : IEvent(evt) { }
  437. inline IBeginDragEvent :: ~IBeginDragEvent()
  438. { }
  439.  
  440. /*=========================================================================
  441. | Inlines for IDragOperationEvent                               PHG 22/10 |
  442. =========================================================================*/
  443. inline Boolean IDragOperationEvent :: isDefault() const
  444. { return( operations().asUnsignedLong() == defop.asUnsignedLong() ); }
  445.  
  446. inline Boolean IDragOperationEvent :: isUnknown() const
  447. { return( operations().asUnsignedLong() == unknown.asUnsignedLong() ); }
  448.  
  449. inline Boolean IDragOperationEvent :: isCopy() const
  450. { return( !(isDefault() || isUnknown()) && (operations().asUnsignedLong() & copy.asUnsignedLong()  )==copy.asUnsignedLong()  ); }
  451.  
  452. inline Boolean IDragOperationEvent :: isMove() const
  453. { return( !(isDefault() || isUnknown()) && (operations().asUnsignedLong() & move.asUnsignedLong()  )==move.asUnsignedLong()  ); }
  454.  
  455. inline Boolean IDragOperationEvent :: isCreate() const
  456. { return( !(isDefault() || isUnknown()) && (operations().asUnsignedLong() & create.asUnsignedLong())==create.asUnsignedLong()); }
  457.  
  458. inline Boolean IDragOperationEvent :: isLink() const
  459. { return( !(isDefault() || isUnknown()) && (operations().asUnsignedLong() & link.asUnsignedLong()  )==link.asUnsignedLong()  ); }
  460.  
  461. inline IDragOperationEvent::Operations IDragOperationEvent :: asOperations(unsigned long ulOperation) const
  462. { return(ulOperation); }
  463.  
  464.  
  465. /*=========================================================================
  466. | Inlines for IDragOverEvent                                    PHG 22/10 |
  467. =========================================================================*/
  468. inline IDragOperationEvent::Operations IDragOverEvent :: defaultOperation()
  469. { return(drgopClDefault); }
  470.  
  471. inline IDragOverEvent& IDragOverEvent :: setDefaultOperation(
  472.   const IDragOperationEvent::Operations& drgopDefault)
  473. { drgopClDefault=drgopDefault; return(*this); }
  474.  
  475. /*=========================================================================
  476. | Inlines for IDropOnEvent                                      PHG 22/10 |
  477. =========================================================================*/
  478. inline IDropOnEvent :: IDropOnEvent(const IEvent& evt)
  479. : IDragOperationEvent(evt) { }
  480. inline IDropOnEvent :: ~IDropOnEvent()
  481. { }
  482.  
  483. /*=========================================================================
  484. | Inlines for IRenderEvent                                      PHG 22/10 |
  485. =========================================================================*/
  486. inline IRenderEvent :: IRenderEvent(const IEvent& evt)
  487. : IEvent(evt) { bForceFreeXFer=false; }
  488.  
  489. inline IRenderEvent :: ~IRenderEvent()
  490. { freeXFer(); }
  491.  
  492. inline void IRenderEvent :: forceFreeXFer()
  493. { bForceFreeXFer=true; }
  494.  
  495.  
  496. /*=========================================================================
  497. | Inlines for IRenderCompleteEvent                              PHG 22/10 |
  498. =========================================================================*/
  499. inline IRenderCompleteEvent :: IRenderCompleteEvent(const IEvent& evt)
  500. :IRenderEvent(evt) { forceFreeXFer(); }
  501.  
  502. inline IRenderCompleteEvent :: ~IRenderCompleteEvent()
  503. { }
  504.  
  505.  
  506. /*=========================================================================
  507. | Inlines for IEndConversationEvent                             PHG 22/10 |
  508. =========================================================================*/
  509. inline IEndConversationEvent :: IEndConversationEvent(const IEvent& evt)
  510. :IEvent(evt) { }
  511.  
  512. inline IEndConversationEvent :: ~IEndConversationEvent()
  513. { }
  514.  
  515. /*=========================================================================
  516. | Inlines for IUDragDropRender                                  PHG 22/10 |
  517. =========================================================================*/
  518. inline IUDragDropRender :: IUDragDropRender(const IEvent& evt)
  519. : IEvent(evt) { }
  520. inline IUDragDropRender :: ~IUDragDropRender()
  521. { }
  522. inline void* IUDragDropRender :: dragxferPtr() const
  523. { return((void*)param1()); }
  524.  
  525. #endif /* ifndef _IDRGEVT_ */
  526.