MFC Grid manual

CDragDrop Class Reference

Default implementation of the drag and drop interface. More...

#include <Dapfor/GUI/DragDrop.h>

Inheritance diagram for CDragDrop:

IDragDrop IObjectImporter IAutoDelete

List of all members.


Public Types

typedef std::vector
< IClipboardFormat * > 
Formats
 List of the clipboard formats.

Public Member Functions

 CDragDrop (bool bAutoDelete=false)
 Constructor.
virtual ~CDragDrop ()
 Virtual destructor.
virtual void RegisterFormat (IClipboardFormat *format)
 Registers a new clipboard format. The formats are applied in order of their registration.
virtual FormatsGetFormats () const
 Gets a list of all registered formats.
virtual DROPEFFECT DoDrag (CDragSource &dragSource)
 Called to perform a drag operation.
virtual DROPEFFECT OnDragEnter (const CDropTarget &dropTarget)
 Called by CGrid when the cursor is dragged into a window for the first time.
virtual DROPEFFECT OnDragOver (const CDropTarget &dropTarget)
 Called by CGrid when the cursor is dragged over a window.
virtual BOOL OnDrop (const CDropTarget &dropTarget, DROPEFFECT dropEffect)
 Called by CGrid when a drop operation is about to occur.
virtual void OnDragLeave (const CGrid &grid)
 Called by the framework when the cursor leaves a window during a dragging operation.
virtual bool CanDrop (const CDropTarget &dropTarget) const
 The function indicates whether data can be dropped to a specified location.
virtual DROPEFFECT DoCustomDrag (CDragSource &dragSource, Formats formats)
 Customization of a drag operation.
virtual BOOL DoCustomDrop (const CDropTarget &dropTarget, IClipboardFormat::RestoredInfo &restoredInfo, DROPEFFECT dropEffect)
 Customization of a drop operation.
virtual Common::CDataObjectImportObject (const TString &className) const
 Tries to create a new data object of the class specified in the className parameter.
virtual void GetImportedObjects (ImportedObjects &container) const
 Gets all imported objects.
virtual void RemoveImportedObjects (bool bDestroy)
 Removes all imported objects from the local cache.
virtual bool AutoDelete () const
 IAutoDelete implementation. Returns the value, passed in the constructor.

Detailed Description

Default implementation of the drag and drop interface.

An object of this class can import data objects from other applications. These objects are deserialized from binary presentation with help of Common::CTypeFactory and are stocked in the internal container. The restored objects can be obtained by calling GetImportedObjects(). When the application is stopped, all non-retrieved data objects are destroyed in the destructor of this class. If you want to prevent their destruction, after each drop operation it should call RemoveImportedObjects(false).

Version:
1.0.0.0 Initial version

Constructor & Destructor Documentation

CDragDrop ( bool  bAutoDelete = false  ) 

Constructor.

Parameters:
[in] bAutoDelete Indicates that this object can be destroyed in the destructor of CGrid


Member Function Documentation

void RegisterFormat ( IClipboardFormat format  )  [virtual]

Registers a new clipboard format. The formats are applied in order of their registration.

Parameters:
[in] format A new clipboard format.

CDragDrop::Formats & GetFormats (  )  const [virtual]

Gets a list of all registered formats.

Returns:
List of all formats.

DROPEFFECT DoDrag ( CDragSource dragSource  )  [virtual]

Called to perform a drag operation.

Parameters:
[in] dragSource Contains a header, list of item handles and the grid itself where these handles are taken.
Returns:
Drop effect generated by drag-and-drop operation if success. Otherwise DROPEFFECT_NONE.

Implements IDragDrop.

DROPEFFECT OnDragEnter ( const CDropTarget dropTarget  )  [virtual]

Called by CGrid when the cursor is dragged into a window for the first time.

Parameters:
[in] dropTarget Contains the drop position where a clipboard content should be placed.
Returns:
dropEffect The effect that the user chose for the drop operation. It can be one of the following:
DROPEFFECT_COPY A copy operation would be performed.
DROPEFFECT_MOVE A move operation would be performed.
DROPEFFECT_LINK A link to the original data would be established.

Implements IDragDrop.

DROPEFFECT OnDragOver ( const CDropTarget dropTarget  )  [virtual]

Called by CGrid when the cursor is dragged over a window.

Parameters:
[in] dropTarget Contains a drop position where the clipboard content should be placed.
Returns:
dropEffect The effect that the user chose for the drop operation. It can be one of the following:
DROPEFFECT_COPY A copy operation would be performed.
DROPEFFECT_MOVE A move operation would be performed.
DROPEFFECT_LINK A link to the original data would be established.

Implements IDragDrop.

BOOL OnDrop ( const CDropTarget dropTarget,
DROPEFFECT  dropEffect 
) [virtual]

Called by CGrid when a drop operation is about to occur.

Parameters:
[in] dropTarget Contains the drop position where a clipboard content should be placed.
Returns:
dropEffect The effect that the user chose for the drop operation. It can be one of the following:
DROPEFFECT_COPY A copy operation would be performed.
DROPEFFECT_MOVE A move operation would be performed.
DROPEFFECT_LINK A link to the original data would be established.

TRUE if the clipboard data have been successfully dropped. Otherwise FALSE.

Implements IDragDrop.

void OnDragLeave ( const CGrid grid  )  [virtual]

Called by the framework when the cursor leaves a window during a dragging operation.

Parameters:
[in] grid Reference to the grid the cursor is leaving.

Implements IDragDrop.

bool CanDrop ( const CDropTarget dropTarget  )  const [virtual]

The function indicates whether data can be dropped to a specified location.

Returns:
True If the clipboard content can be dropped. Otherwise false.

Implements IDragDrop.

DROPEFFECT DoCustomDrag ( CDragSource dragSource,
Formats  formats 
) [virtual]

Customization of a drag operation.

Puts a content of the grid into the clipboard with the specified formats

Parameters:
[in] dragSource Contains the header, list of item handles and the grid itself where these handles were taken.
[in] formats List of the clipboard formats, used to serialize data to the clipboard.
Returns:
dropEffect The effect that the user chose for the drop operation. It can be one of the following:
DROPEFFECT_COPY A copy operation would be performed.
DROPEFFECT_MOVE A move operation would be performed.
DROPEFFECT_LINK A link to the original data would be established.

BOOL DoCustomDrop ( const CDropTarget dropTarget,
IClipboardFormat::RestoredInfo restoredInfo,
DROPEFFECT  dropEffect 
) [virtual]

Customization of a drop operation.

Drops data from the clipboard to the grid.

Parameters:
[in] dropTarget Contains the drop position where the clipboard content should be placed.
[in] restoredInfo Deserialized clipboard data.
[in] dropEffect The effect that the user chose for the drop operation. It can be one of the following:
DROPEFFECT_COPY A copy operation would be performed.
DROPEFFECT_MOVE A move operation would be performed.
DROPEFFECT_LINK A link to the original data would be established.
Returns:
TRUE if the clipboard data has been successfully dropped. Otherwise FALSE.

Common::CDataObject * ImportObject ( const TString &  className  )  const [virtual]

Tries to create a new data object of the class specified in the className parameter.

Parameters:
[in] className Name of the class, an instance of which should be created. Usually the class can be registered with the macro DF_DECLARE_SERIALIZABLE_TYPE().
Returns:
An instance of the class that has been registered in Common::CTypeFactory. If the appropriate class can't be found, the function returns a new instance Common::CDynamicObject.

Implements IObjectImporter.

void GetImportedObjects ( ImportedObjects container  )  const [virtual]

Gets all imported objects.

Parameters:
[in,out] container Container where all imported objects are copied to.

void RemoveImportedObjects ( bool  bDestroy  )  [virtual]

Removes all imported objects from the local cache.

Parameters:
[in] bDestroy Indicates whether it should destroy data objects. If the flag is set, the data objects will be physically destroyed and all the handles associated with will be automatically removed from all grids.

Implements IObjectImporter.

bool AutoDelete (  )  const [virtual]

IAutoDelete implementation. Returns the value, passed in the constructor.

Returns:
The value, passed in the constructor.

Implements IAutoDelete.