home *** CD-ROM | disk | FTP | other *** search
- #ifndef _IDRGITM_
- #define _IDRGITM_
- /*--------------------------------------------------------------*/
- /* CLASSES NAMES: IDragItem */
- /* ITextDragItem */
- /* IObjectDragItem */
- /* IFileDragItem */
- /* */
- /* DESCRIPTION : */
- /* */
- /* */
- /* CHANGE ACTIVITY: */
- /* --------------- */
- /* DATE: INITIAL: DESCRIPTION: */
- /* */
- /* 03/01/91 KKL Design & architecture */
- /* 05/30/91 PHG Original Implementation */
- /* 11/19/91 DH Start Re-design */
- /* 12/23/91 RDL Complete Re-design and implement */
- /* 08/13/92 PHG Modified for Giverny */
- /*--------------------------------------------------------------*/
- /* Copyright (c) IBM Corporation 1991 */
- /*--------------------------------------------------------------*/
-
- // forward class references
- class IDragSourceHandler;
- class IBeginDragEvent;
-
-
- // include library's common stuff
- #ifndef _IBASETYP_
- #include <ibasetyp.hpp>
- #endif
-
- #ifndef _ISTRING_
- #include <istring.hpp>
- #endif
-
- #ifndef _IPOINT_
- #include <ipoint.hpp>
- #endif
-
- #ifndef _IRESLIB_
- #include <ireslib.hpp>
- #endif
-
- #ifndef _IWINDOW_
- #include <iwindow.hpp>
- #endif
-
- // include our own stuff
- #ifndef _IDRGSTYL_
- #include <idrgstyl.hpp>
- #endif
- #ifndef _IDRGEVT_
- #include <idrgevt.hpp>
- #endif
- #ifndef _IDRGIMG_
- #include <idrgimg.hpp>
- #endif
- #ifndef _IDRGSTR_
- #include <idrgstr.hpp>
- #endif
-
- class IDragItem : public IVBase {
- /**************************************************************************
- * This is an encapsulation of a PM DRAGITEM structure *
- * *
- * It can be constructed either: *
- * - from C++ objects (IStrings and such), when used from *
- * the source (drag) side. *
- * - from a PM PDRAGITEM passed in a IDragOperation event, *
- * for instanciation from the target (drop) side *
- * HUngarian is 'drgitm' *
- **************************************************************************/
- public:
-
- INESTEDBITFLAGCLASSDEF0(SupportedOps,IDragItem);
- static const SupportedOps
- nosupop,
- copyable,
- moveable,
- linkable;
-
- INESTEDBITFLAGCLASSDEF0(Control,IDragItem);
- static const Control
- nocontrol,
- open,
- ref,
- group,
- container,
- prepare,
- removeablemedia;
-
- /*-------------------- FLAGS & HELPER FUNCTIONS --------------------------+
- | These are the declaration of nested flags classes and their tester |
- | helper functions |
- | SupportedOps - Emulate the PM item supported operations flags |
- | isCopyable - Test if item is copyable |
- | isMoveable - Test if item is moveable |
- | isLinkable - Test if item is linkable |
- | Control - Emulate the PM source control flags |
- | isOpen - Test if item is opened |
- | isReference - Test if item is a reference |
- | isGroup - Test if item represents a group of objects |
- | isContainer - Test if item is a container |
- | requiresDMPrepare - Test if item requires a renderprepare message |
- | isRemovableMedia - Test if item represents a removeable media |
- +------------------------------------------------------------------------*/
- Boolean
- isCopyable() const,
- isMoveable() const,
- isLinkable() const;
-
- Boolean
- isOpen() const,
- isReference() const,
- isGroup() const,
- isContainer() const,
- requiresDMPrepare() const,
- isRemovableMedia() const;
-
- /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
- | There are 3 ways to construct instances of this class: |
- | 1. Construction from scratch specifying drag items's characteristics |
- | 2. Instantiation from a IDragOperation event's dragged items list |
- | 3. Instantiation from a PDRAGITEM pointer |
- +------------------------------------------------------------------------*/
- IDragItem(IWindow* pwndItem,
- unsigned long ulItemId,
- const ITypesString& strTypes,
- const IRMFsString& strRMFs,
- const SupportedOps& drgsupops,
- const Control& drgctrl=nocontrol);
-
- IDragItem(const IDragOperationEvent& drgopevt,
- unsigned long ulItem);
-
- IDragItem(void* pdragitem);
-
- virtual
- ~IDragItem();
-
- /*-------------------------------- ACCESSORS -----------------------------+
- | These function provide means of getting and setting the accessible |
- | attributes of instances of this class: |
- | id - retunrs the item ID |
- | setId - sets the item ID |
- | window - returns the item's IWindow pointer if any |
- | windowHandle - returns the window handle |
- | setWindow - set the IWindow pointer (and handle, as side effect) |
- | types - return the types supported by the item |
- | setTypes - set the types supported by the item |
- | RMFs - return the RMFs supported by the item |
- | setRMFs - set the RMFs supported by the item |
- | containerName - return the container name for item |
- | setContainerName - set the container name for item |
- | sourceName - return the source name for item |
- | setSourceName - set the source name for item |
- | targetName - return the target name for item |
- | setTargetName - set the target name for item |
- | dragImage - return the IDragImage pointer for item, or 0 if none |
- | setDragImage - set or remove the item's IDragImage pointer |
- | dragControl - return the control flags for item |
- | setDragControl - set the control flags for item |
- | dragSupOps - return the operations supported by item |
- | setDragSupOps - set the operations supported by item |
- | origin - return the item's origin offset from mouse hotspot |
- | setOrigin - set the item's origin offset from mouse hotspot |
- +------------------------------------------------------------------------*/
- unsigned long
- id() const;
- IDragItem
- &setId(unsigned long ulId);
- const IWindow*
- window() const;
- IWindowHandle
- windowHandle() const;
- IDragItem
- &setWindow(IWindow* pwndItem);
- ITypesString
- types() const;
- IDragItem
- &setTypes(const ITypesString& strTypes);
- IRMFsString
- RMFs() const;
- IDragItem
- &setRMFs(const IRMFsString& strRMFs);
- IString
- containerName() const;
- IDragItem
- &setContainerName(const char* pszContainerName);
- IString
- sourceName() const;
- IDragItem
- &setSourceName(const char* pszSourceName);
- IString
- targetName() const;
- IDragItem
- &setTargetName(const char* pszTargetName);
- IDragImage*
- dragImage() const;
- IDragItem
- &setDragImage(IDragImage* pdrgimg, Boolean bAutoDelete=true);
- Control
- dragControl() const;
- IDragItem
- &setDragControl(Control& drgctrl);
- SupportedOps
- dragSupOps() const;
- IDragItem
- &setDragSupOps(SupportedOps& drgsupops);
- ISize
- origin() const;
- IDragItem
- &setOrigin(const ISize& sizOrigin);
-
-
- /*-------------------------------- OPERATORS -----------------------------+
- | Operators defined on DragItems |
- | operator== required for sets |
- +------------------------------------------------------------------------*/
- Boolean
- operator==(IDragItem& drgit);
-
- /*-------------------------------- UTILITY -------------------------------+
- | Utility functions to access and handle PM-specific data |
- | dragitemPtr - returns the external PDRAGITEM pointer if exists |
- | dragitemStruct - fills-in a dragitem structure with item's data |
- | dragitemPtrInvalid - sets the DragItemPtr to 0 when freed from outside |
- +------------------------------------------------------------------------*/
- void*
- dragitemPtr() const;
- void
- dragitemStruct(void* pdragitem, unsigned long ulSize) const;
- Boolean
- dragitemPtrInvalid(void* pdragitem);
-
-
- /*-------------------------------- CALLBACKS -----------------------------+
- | These functions are intended to be overridden by the user to implement |
- | his own specific behavior |
- | setupForDrag - Called on an item so that it can be set to be dragged |
- | render - Called on an item for it to render itself |
- | conversationEnded - Called when conversation for this item has ended |
- +------------------------------------------------------------------------*/
- virtual Boolean
- setupForDrag(const IBeginDragEvent& begdrgevt) { return(false); };
-
- virtual Boolean
- render(const IDragSourceHandler* pdrgsrch,
- IRenderEvent& rendevt);
-
- virtual Boolean
- conversationEnded(const IDragSourceHandler* pdrgsrch,
- const IEndConversationEvent& endcvevt);
-
- /*-------------------------------- UTILITY -------------------------------+
- | Utility functions to convert to/from string handles |
- | handleFromString - create a string handle from an IString |
- | stringFromHandle - returns the string represented by a string handle |
- +------------------------------------------------------------------------*/
- IStringHandle
- handleFromString(const char* pszIn) const;
- IString
- stringFromHandle(IStringHandle strhIn) const;
-
- private:
- /*------------------------------ DATA MEMBERS ----------------------------+
- | These are instance variables for the item |
- | pdragitemCl - set when constructed from an outside pointer |
- | pwndClItem - item's IWindow*, 0 if constructed from an outside pointer|
- | wndhClItem - item's window handle |
- | ulClItemId - item's ID |
- | sizClOrigin - item's position from mouse hotspot |
- | drgctrlCl - drag control flags |
- | drgsupopsCl - supported operations flags |
- | pdrgimageCl - item's drag image, 0 if none |
- | bClAutoDelImage - autodelete image pointer if set |
- | strClTypes - Item's types ! |
- | strClRMFs - Item's supported RMFs ! These are not set |
- | strClContainerName - Item's container name ! if constructed from |
- | strClSourceName - Item's source name ! an outside pointer |
- | strClTargetName - Item's target name ! |
- +------------------------------------------------------------------------*/
- void* pdragitemCl;
- IWindow* pwndClItem;
-
- IWindowHandle wndhClItem;
- unsigned long ulClItemId;
- ISize sizClOrigin;
- Control drgctrlCl;
- SupportedOps drgsupopsCl;
- IDragImage* pdrgimageCl;
- Boolean bClAutoDelImage;
-
- ITypesString strClTypes;
- IRMFsString strClRMFs;
- IString strClContainerName;
- IString strClSourceName;
- IString strClTargetName;
-
- }; // IDragItem
-
- /*=========================================================================
- | Inlines for IDragItem PHG 21/10 |
- =========================================================================*/
- inline IDragItem::Control IDragItem :: dragControl() const
- { return drgctrlCl; }
-
- inline IDragItem::SupportedOps IDragItem :: dragSupOps() const
- { return drgsupopsCl; }
-
- inline Boolean IDragItem :: isCopyable() const
- { return( (dragSupOps().asUnsignedLong() & copyable.asUnsignedLong())!=0 ); }
-
- inline Boolean IDragItem :: isMoveable() const
- { return( (dragSupOps().asUnsignedLong() & moveable.asUnsignedLong())!=0 ); }
-
- inline Boolean IDragItem :: isLinkable() const
- { return( (dragSupOps().asUnsignedLong() & linkable.asUnsignedLong())!=0 ); }
-
- inline Boolean IDragItem :: isOpen() const
- { return( (dragControl().asUnsignedLong() & open.asUnsignedLong())!=0 ); }
-
- inline Boolean IDragItem :: isReference() const
- { return( (dragControl().asUnsignedLong() & ref.asUnsignedLong())!=0 ); }
-
- inline Boolean IDragItem :: isGroup() const
- { return( (dragControl().asUnsignedLong() & group.asUnsignedLong())!=0 ); }
-
- inline Boolean IDragItem :: isContainer() const
- { return( (dragControl().asUnsignedLong() & container.asUnsignedLong())!=0 ); }
-
- inline Boolean IDragItem :: requiresDMPrepare() const
- { return( (dragControl().asUnsignedLong() & prepare.asUnsignedLong())!=0 ); }
-
- inline Boolean IDragItem :: isRemovableMedia() const
- { return( (dragControl().asUnsignedLong() & removeablemedia.asUnsignedLong())!=0 ); }
-
- inline unsigned long IDragItem :: id() const
- { return ulClItemId; }
-
- inline const IWindow* IDragItem :: window() const
- { return pwndClItem; }
-
- inline IWindowHandle IDragItem :: windowHandle() const
- { return wndhClItem; }
-
- inline ISize IDragItem :: origin() const
- { return sizClOrigin; }
-
- inline IDragImage* IDragItem :: dragImage() const
- { return pdrgimageCl; }
-
- inline Boolean IDragItem :: operator==(IDragItem& drgit)
- { return &drgit == this; }
-
- #endif /* ndef _IDRGITM_ */