home *** CD-ROM | disk | FTP | other *** search
- #ifndef _IDRGTXT_
- #define _IDRGTXT_
- /*--------------------------------------------------------------*/
- /* CLASS NAMES: IDragTextItem */
- /* IDragWinTextItem */
- /* IDragEFItem */
- /* IDropTextCatcher */
- /* IDropWinTextCatcher */
- /* IDragDropEFHandler */
- /* */
- /* DESCRIPTION : Drag by text classes. */
- /* */
- /* */
- /* CHANGE ACTIVITY: */
- /* --------------- */
- /* DATE: INITIAL: DESCRIPTION: */
- /* 09/11/92 PHG Created */
- /*--------------------------------------------------------------*/
- /* Copyright (c) IBM Corporation 1991 */
- /*--------------------------------------------------------------*/
-
- #ifndef _ITEXTCTL_
- #include <itextctl.hpp>
- #endif
-
- #ifndef _IENTRYFD_
- #include <ientryfd.hpp>
- #endif
-
- #ifndef _IDRGSRCH_
- #include <idrgsrch.hpp>
- #endif
-
- #ifndef _IDRGTGTH_
- #include <idrgtgth.hpp>
- #endif
-
- #ifndef _IDRGITM_
- #include <idrgitm.hpp>
- #endif
-
- #ifndef _IDRPCTCH_
- #include <idrpctch.hpp>
- #endif
-
-
- class IDragTextItem : public IDragItem {
- /**************************************************************************
- * These classes are subclasses of the base drag&drop classes tailored *
- * to support Drag&Drop of text either within the same process or across *
- * processes. *
- * To this effect, two new RMFs are defined: *
- * <DRM_BUFFERpid,DRF_ZSTRING> used as native RMF to drag a string *
- * pointer valid within process 'pid'. The string pointer is held *
- * in the itemId. *
- * <DRM_SHRBUFFER,DRF_ZSTRING> used as alternative RMF to drag a string *
- * from one process to another. This mechanism requires rendering in *
- * order allow the copy of the string to a shared buffer *
- * *
- * EXAMPLE: *
- * {IDragTextItem* ptxtitm=new IDragTextItem("Text to Drag"); *
- * IDragSourceHandler psrch=new IDragSourceHandler(); *
- * IWindow* pwnd=new IWindow(...); *
- * *
- * psrch->dragItemList().add(ptxtitm); *
- * pwnd->addHandler(psrch); *
- * } *
- **************************************************************************/
- public:
-
- static const char* pszDefaultType;
-
- /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
- | There is one default way to construct instances of this class: |
- | 1. provide text string to drag, supported operations and type |
- +------------------------------------------------------------------------*/
- IDragTextItem(const char *pszDragText=0,
- const SupportedOps& drgsupops=copyable,
- const ITypesString& strTypes=pszDefaultType);
-
- /*-------------------------------- ACCESSORS -----------------------------+
- | These function provide means of setting the accessible attributes of |
- | instances of this lass: |
- | setDragString - sets the string to drag |
- +------------------------------------------------------------------------*/
- void
- setDragString(const IString& strDrag);
-
-
- protected:
- /*-------------------------------- CALLBACKS -----------------------------+
- | These functions are intended to be overridden by the user to implement |
- | his own specific behavior |
- | dragString - return the drag string, default returns the instance str |
- +------------------------------------------------------------------------*/
- virtual IString
- dragString(const IBeginDragEvent& begdrgevt) const;
-
- private:
- /*-------------------------------- OVERRIDES -----------------------------+
- | This class overrides the following inherited functions: |
- | setupForDrag - prepare to be dragged |
- | render - renders the string to shared buffer |
- | conversationEnded - clean-up once conversation is finished |
- +------------------------------------------------------------------------*/
- virtual Boolean
- setupForDrag(const IBeginDragEvent& begdrgevt);
-
- virtual Boolean
- render(const IDragSourceHandler* pdrgsrch,
- IRenderEvent& rendevt);
-
- virtual Boolean
- conversationEnded(const IDragSourceHandler* pdrgsrch,
- const IEndConversationEvent& endcvevt);
-
- private:
- /*------------------------------ DATA MEMBERS ----------------------------+
- | strClDrag - Local copy of string to drag |
- +------------------------------------------------------------------------*/
- IString strClDrag;
-
- }; // IDragTextItem
-
-
- class IDragWinTextItem : public IDragTextItem {
- /**************************************************************************
- * This class is specifically designed to drag a text control's text *
- * Whenever a drag operation is started, the cnotrol's text will be *
- * queried and used as drag string. *
- * *
- * EXAMPLE: *
- * {IStaticText ptxt=new IStaticText(...); *
- * IDragWinTextItem* pwintxtitm=new IDragWinTextItem(ptxt); *
- * IDragSourceHandler psrch=new IDragSourceHandler(); *
- * *
- * psrch->dragItemList().add(pwintxtitm); *
- * ptxt->addHandler(psrch); *
- * } *
- **************************************************************************/
- public:
- /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
- | There is one default way to construct instances of this class: |
- | 1. Supply the text control that is to be dragged, and optionally |
- | the operations and types |
- +------------------------------------------------------------------------*/
- IDragWinTextItem(ITextControl* pwndText,
- const SupportedOps& drgsupops=copyable,
- const ITypesString& strTypes=IDragTextItem::pszDefaultType);
-
- protected:
- /*-------------------------------- OVERRIDES -----------------------------+
- | This class overrides the following inherited functions: |
- | dragString - to get the drag string from the window text |
- +------------------------------------------------------------------------*/
- virtual IString
- dragString(const IBeginDragEvent& begdrgevt) const;
-
- private:
- /*------------------------------ DATA MEMBERS ----------------------------+
- | pwndClText - Text control on which we apply |
- +------------------------------------------------------------------------*/
- ITextControl* pwndClText;
- }; // IDragWinTextItem
-
-
- class IDragEFItem : public IDragTextItem {
- /**************************************************************************
- * This class is specifically designed to drag an entry field's text *
- * or marked text if any. *
- * *
- * NOTE: These items should be added *only* source handlers which are *
- * themselves added to instances of descendants of the IEntryField *
- * class. Failure to do so is a coding error and will result in *
- * unpredictable behavior *
- * *
- * EXAMPLE: *
- * {IEntryField pef=new IEntryField(...); *
- * IDragEFItem* pefitm=new IDragEFItem(); *
- * IDragSourceHandler psrch=new IDragSourceHandler(); *
- * *
- * psrch->dragItemList().add(pefitm); *
- * pef->addHandler(psrch); *
- * } *
- **************************************************************************/
- public:
- /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
- | There is one way to construct instances of this class: |
- | - Construct from an IEntryField pointer |
- +------------------------------------------------------------------------*/
- IDragEFItem(const SupportedOps& drgsupops=copyable,
- const ITypesString& strTypes=IDragTextItem::pszDefaultType);
-
- protected:
- /*-------------------------------- OVERRIDES -----------------------------+
- | This class overrides the following inherited functions: |
- | dragString - return the string to drag for this event |
- +------------------------------------------------------------------------*/
- virtual IString
- dragString(const IBeginDragEvent& begdrgevt) const;
-
- }; // IDragEFItem
-
-
- class IDropTextCatcher : public IDropCatcher {
- /**************************************************************************
- * This class is specifically designed to catch drops of text according *
- * to the protocol set forth by IDragTextItem *
- * This class is typically used through a subclass that overloads the *
- * 'textDropped' virtual function to use the dropped text. *
- * *
- * EXAMPLE: *
- **************************************************************************/
- public:
- static const char* pszDefaultType;
- /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
- | There is one default way to construct instances of this class: |
- | 1. Specifying the type of items |
- +------------------------------------------------------------------------*/
- IDropTextCatcher(const ITypesString& pszTypes=pszDefaultType);
-
- protected:
- /*-------------------------------- CALLBACKS -----------------------------+
- | These functions are intended to be overridden by the user to implement |
- | his own specific behavior |
- | textDropped - pure virtual called when text is dropped |
- +------------------------------------------------------------------------*/
- virtual void
- textDropped(const char *pszText,
- const IEvent& evt) = 0;
-
- private:
- /*-------------------------------- OVERRIDES -----------------------------+
- | This class overrides the following inherited functions: |
- | itemRendered - To handle same-process drops |
- | itemRendered - To handle cross-process drops |
- +------------------------------------------------------------------------*/
- /* call-back functions overloads */
- virtual Boolean
- itemRendered(const IDragItem& drgitm,
- const IDropOnEvent& drpevt);
- virtual Boolean
- itemRendered(const IDragItem& drgitm,
- const IRMFsString& strRMFs,
- const IString& strRenderToName,
- unsigned long ulTargetInfo,
- const IRenderCompleteEvent& rendcevt);
-
- }; // IDropTextCatcher
-
- class IDropWinTextCatcher : public IDropTextCatcher {
- /**************************************************************************
- * This class is specifically designed to catch drops of text on a text *
- * control. *
- * *
- * NOTE: This catchers should be added *only* target handlers which are *
- * themselves added to instances of descendants of the ITextControl *
- * class. Failure to do so is a coding error and will result in *
- * unpredictable behavior *
- * *
- * EXAMPLE: *
- * {IDragTargetHandler* ptgth=new IDragTargetHandler(); *
- * IDropWinTextCatcher* pwintxtctch= new IDropTextCatcher(); *
- * IStaticText* ptxt=new IStaticText(...); *
- * *
- * ptgth->dropCatcherList().add(pwintxtctch); *
- * ptxt->addHandler(ptgth); *
- * *
- * } *
- **************************************************************************/
- public:
- /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
- | There is one default way to construct instances of this class: |
- | 1. Optionally specify the acceptable type of items |
- +------------------------------------------------------------------------*/
- IDropWinTextCatcher(const ITypesString& strTypes=
- IDropTextCatcher::pszDefaultType);
-
- protected:
- /*-------------------------------- OVERRIDES -----------------------------+
- | This class overrides the following inherited functions: |
- | textDropped - set window text when dropped |
- +------------------------------------------------------------------------*/
- virtual void
- textDropped(const char * pszText,
- const IEvent& evt);
-
- }; // IDropWinTextCatcher
-
-
- class IDragDropEFHandler : public IDragSourceHandler, public IDragTargetHandler {
- /**************************************************************************
- * This class is a wrap-up of EntryField drag&drop for both source and *
- * target operations. *
- * An instance of this class can be used to handle more than one *
- * IEntryField, provided they all support the same types *
- * *
- * EXAMPLE: *
- * {IDragDropEFHandler* pddefh= new IDragDropEFHandler(); *
- * IEntryField pef1=new IEntryField(...); *
- * IEntryField pef2=new IEntryField(...); *
- * *
- * pddefh->startHandlingEFDragDrop(pef1); *
- * pddefh->startHandlingEFDragDrop(pef2); *
- * } *
- **************************************************************************/
- public:
- /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------+
- | There is one way to construct instances of this class: |
- | 1 - from an optional IEntryfield pointer |
- +------------------------------------------------------------------------*/
- IDragDropEFHandler(IEntryField* pef=0,
- const ITypesString& strTypes=IDragTextItem::pszDefaultType);
-
- /*------------------------ HANDLER ACTIVATION ----------------------------+
- | These functions start and stop handling drag&drop events for entryfields|
- | startHandlingEFDragDrop - start handling D&D |
- | stopHandlingEFDragDrop - stop handling D&D |
- +------------------------------------------------------------------------*/
- void
- startHandlingEFDragDrop(IEntryField* pef) const,
- stopHandlingEFDragDrop(IEntryField* pef) const;
-
- }; // IDragDropEFHandler
-
-
- /*=========================================================================
- | Inlines for IDragTextItem PHG 26/10 |
- =========================================================================*/
- inline void IDragTextItem :: setDragString(const IString& strDrag)
- { strClDrag=strDrag; }
-
- /*=========================================================================
- | Inlines for IDropWinTextCatcher PHG 26/10 |
- =========================================================================*/
- inline IDropWinTextCatcher :: IDropWinTextCatcher(const ITypesString& strTypes)
- : IDropTextCatcher(strTypes) { }
-
- #endif // def _IDRGTXT_