home *** CD-ROM | disk | FTP | other *** search
- #ifndef _IDRGSRCH_
- #define _IDRGSRCH_
- /*--------------------------------------------------------------*/
- /* CLASS NAMES: IDragSourceHandler */
- /* */
- /* DESCRIPTION : Source drag handler. */
- /* Handles: IBeginDragEvent */
- /* IDragOverNotifyEvent */
- /* IEndDragEvent */
- /* */
- /* CHANGE ACTIVITY: */
- /* --------------- */
- /* DATE: INITIAL: DESCRIPTION: */
- /* 19/08/92 PHG Created from IDrgMan stuff */
- /* 06/10/92 PHG Moved to BBXX Sets */
- /* */
- /*--------------------------------------------------------------*/
- /* Copyright (c) IBM Corporation 1991 */
- /*--------------------------------------------------------------*/
-
- // Forward class references
- class IDragSourceHandler;
- class IDragItem;
-
- // ICLUI definitions
- #ifndef _IBASETYP_
- #include <ibasetyp.hpp>
- #endif
-
- #ifndef _ISTRING_
- #include <istring.hpp>
- #endif
-
- #ifndef _IHANDLER_
- #include <ihandler.hpp>
- #endif
-
- #ifdef _USEBB_
- #ifndef _ISET_H
- #include <iset.h>
- #endif
- #else
- #ifndef _ISET_
- #include <iset.hpp>
- #endif
- declare(IGSet1, IDragItem);
- #endif
-
- // This header's specific definitions
- #ifndef _IDRGEVT_
- #include <idrgevt.hpp>
- #endif
- #ifndef _IDRGITM_
- #include <idrgitm.hpp>
- #endif
-
- ////////////////////////////////////////////////////////////////////
- // !PHG! --- TO DO -- !PHG!
- // Implement messages:
- // - DM_PRINTOBJECT -> used for DRM_PRINT mechanism
- // - DM_DISCARDOBJECT -> used for DRM_DISCARD mechanism
- //
- // - DM_DRAGOVERNOTIFY
- ////////////////////////////////////////////////////////////////////
-
- class IDragSourceHandler : public IHandler {
- /**************************************************************************
- * Handler for Drag&drop events on source side *
- * *
- * This class is intended to be used as follows: *
- * Create a IDragSourceHandler for each window that has to *
- * implement drag&drop source behavior. *
- * *
- * Add IDragItems to the manager, either once for all *
- * initially, or dynamically using the dragSetup() *
- * callback or directly accessing the collection. *
- * *
- **************************************************************************/
- public:
-
- #ifdef _USEBB_
- typedef ISet<IDragItem*> IDragItemSet;
- #else
- typedef IGSet1(IDragItem) IDragItemSet;
- #endif
-
- // Icons dragging styles
- enum dragStyle {stack3AndFade = 1,
- systemIcons = 2,
- allAtPos = 3,
- allStacked = 4};
-
- /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
- | There is one default way to construct instances of this class: |
- | Construct giving the style of dragging to occur |
- +------------------------------------------------------------------------*/
- IDragSourceHandler(dragStyle drgstyl = stack3AndFade);
-
- virtual
- ~IDragSourceHandler();
-
- /*-------------------------------- ACCESSORS -----------------------------+
- | These function provide means of getting and setting the accessible |
- | attributes of instances of this class: |
- | dragItemList - give access to the IDragItems collection |
- | removeItem - removes an item or all items from collection |
- | findDraginfo - returns the PDRAGINFO holding a given PDRAGITEM |
- | renderComplete - must be called by an item after it is rendered |
- | setStyle - sets the drag style |
- +------------------------------------------------------------------------*/
- IDragItemSet
- &dragItemList();
-
- void
- removeItem(IDragItem* pdrgitm=0,
- Boolean bDelete=true);
-
- void*
- findDraginfo(void* pdragitem);
-
- void
- renderComplete(const IRenderEvent& rendevt,
- Boolean bRenderOK) const;
-
- IDragSourceHandler&
- setStyle(dragStyle drgstyl);
-
- protected:
- /*-------------------------------- OVERRIDES -----------------------------+
- | This class overrides the following inherited functions: |
- | dispatchHandlerEvent - event dispatcher overload |
- +------------------------------------------------------------------------*/
- virtual Boolean
- dispatchHandlerEvent(IEvent& evt);
-
- /*-------------------------------- CALLBACKS -----------------------------+
- | The following functions should be implemented in derived classes to |
- | define behavior |
- | dragSetup - Called to set-up the drag |
- | dragCompleted - Called after the dragging has completed |
- | dragEnded - Called on the WM_ENDDRAG message |
- | itemFromId - used to correlate an item ID to a DragItem |
- +------------------------------------------------------------------------*/
- virtual Boolean
- dragSetup(const IBeginDragEvent& begdrgevt);
-
- virtual void
- dragCompleted(const IWindowHandle& wndhTarget,
- unsigned long ulOperation,
- const IPoint& ptDrop);
-
- virtual void
- dragEnded(const IEvent& evt);
-
- virtual IDragItem
- *itemFromId(unsigned long ulItemId, const IEvent& evt);
-
- /*---------------------------- EVENT PROCESSING --------------------------+
- | These functions are used to process D&D events |
- | processBeginDrag - start the drag after calling dragSetup() |
- | processEndDrag - calls dragEnded() |
- | processRender - renders item to required RMF |
- | processEndConversation - cleans up resources for item |
- +------------------------------------------------------------------------*/
- IWindowHandle
- processBeginDrag(const IBeginDragEvent& begdrgevt);
-
- void
- processEndDrag(IEvent& evt);
-
- Boolean
- processRender(IRenderEvent& rendevt);
-
- Boolean
- processEndConversation(const IEndConversationEvent& endcvevt);
-
- private:
- /*------------------------------ DATA MEMBERS ----------------------------+
- | Private helper functions |
- | draginfoInvalid - to be called when the draginfo becomes invalid |
- +------------------------------------------------------------------------*/
- void
- draginfoInvalid(void* pdraginfo);
-
- /*------------------------------ DATA MEMBERS ----------------------------+
- | drgstylCl - drag style |
- | drgitmsetCl - drag item set |
- +------------------------------------------------------------------------*/
- dragStyle drgstylCl;
- IDragItemSet drgitmsetCl;
-
- }; // IDragSourceHandler
-
- /*=========================================================================
- | Inlines for IDragSourceHandler PHG 21/10 |
- =========================================================================*/
- inline IDragSourceHandler::IDragItemSet& IDragSourceHandler :: dragItemList()
- { return(drgitmsetCl); }
-
- inline Boolean IDragSourceHandler :: dragSetup(const IBeginDragEvent& begdrgevt)
- { return (drgitmsetCl.numberOfElements()>0); }
-
- inline void IDragSourceHandler :: dragCompleted(const IWindowHandle& wndhTarget,
- unsigned long ulOperation,
- const IPoint& ptDrop)
- { }
-
- inline void IDragSourceHandler :: dragEnded(const IEvent& evt)
- { }
-
- inline IDragSourceHandler& IDragSourceHandler :: setStyle(dragStyle drgstyl)
- { drgstylCl=drgstyl; return(*this); }
-
- #endif /* def _IDRGSRCH_ */