CopyAvailableTypesOfDocument is called when the user selects and begins to drag an item to which this drag source is attached. This function should place each possible data type for the dragged item into the provided sequence object. Possible types include those that indicate a printable document, a model, a piece of text, or a custom type. Note that more than one drag source can be attached to one document, with each drag source contributing a different set of types.
CopyAvailableTypesOfDocument takes the following parameters:
Once the type negotiation between the drag source and the drag acceptor is complete, CreateItemOfDocumentMatchingDescription is called to provide the scrap item that matches the type chosen by the acceptor. This scrap item transfers information from the drag source to the drop acceptor.
CreateItemOfDocumentMatchingDescription takes the following parameters:
Overriding CopyAvailableTypesof
Document
virtual void CopyAvailableTypesOfDocument(
const TDocumentReference& representedDocument,
const TPlaceReference& placeContext,
const TScrapInteractionModifier& modifier,
TSequenceOf<TTypeDescription>& result,
TMemoryHeap* whichHeap = NIL) const = 0;
Overriding CreateItemOfDocument
MatchingDescription
virtual TScrapItem* CreateItemOfDocumentMatchingDescription(
const TDocumentReference& representedDocument,
const TPlaceReference& placeContext,
const TScrapInteractionModifier& modifier,
const TTypeDescription& requestedType,
TMemoryHeap* whichHeap = NIL) const = 0;
CreateItemOfDocumentMatchingDescription is only called with a TTypeDescription value that the drag source instance has published as available in the previous call to CopyAvailableTypesOfDocument. It is not called at all if the negotiation doesn't ask for any of the published types.
Instances of classes derived from TDocumentScrapItemSource are copied and stored with a document's attribute set. When deriving a new class from TDocumentScrapItemSource, you also have to properly define streaming operators, a default constructor, and a copy constructor.
Classes derived from TDocumentScrapItemSource also need to support dynamic casting. See OS Services for more information about the dynamic casting mechanism supported by the CommonPoint runtime system.
Once you have an object of the appropriate type available in the Workspace, attach your drag source to it using the utility program AddWorkspaceDragSource:
NOTE
You can also use this technique to propagate other attributes. For example, if you attach an icon to a particular document instance, and then create a stationery from that instance, all documents created from the stationery will carry the icon of the original document.
You can attach multiple drag sources to a Workspace entity with AddWorkspaceDragSource. It attaches a new instance of a scrap item source every time you run it. During the type negotiation that occurs during a drag and drop interaction, the scrap item sources are processed in the order that they were added to the document. The system iterates through the list until the type negotiation succeeds.
Supporting streaming
and dynamic casting
Attaching a TDocumentScrap-
ItemSource to a
Workspace entity
Once you've written a document scrap item source, you attach it to a Workspace entity. To do this, the Workspace must be running, and a document instance of the appropriate type must be available. You can use the RunDocument utility to create a document instance from a stationery. (See Taligent Tools for AIX for more information about using RunDocument.)
Note that you must be in $TaligentRoot/SharedLibs to run AddWorkspaceDragSource. This utility program takes the following parameters: % cd $TaligentRoot/SharedLibs
% AddWorkspaceDragSource entityName -c dragSourceClassName dragSourceSharedLib
This operation only affects the specified document instance. If you use the Workspace user command to create a stationery from the specified instance, the drag sourcing behavior is inherited by all documents created from the stationery. Removing a scrap
item source from a Workspace entity
To remove a drag source, use the utility program RemoveWorkspaceDragSource:
This tool iterates backward through the list of scrap item sources and removes the first one that supplies the specified scrap type. The third parameter, % cd $TaligentRoot/SharedLibs
% RemoveWorkspaceDragSource entityName scrapType sharedLib
sharedLib
, indicates the name of the shared library where scrapType
is defined. Viewing the current
drag sources
If you want to see what drag sources are currently attached to a Workspace entity, you can use the utility program WorkspaceDragAndDropInfo. To list the current drag sources for an entity:
This prints a list of the drag sources that are attached to the specified entity to the standard output. % cd $TaligentRoot/SharedLibs
% WorkspaceDragAndDropInfo entityName
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Generated with WebMaker