#include <vcl.h>

class TDragAndDrop
{
  protected:
  Graphics::TBitmap *mpbmpBackgroundCopy; // Working copy of what will be displayed
  Graphics::TBitmap *mpbmpBlit;           // Image that is being moved around
  Graphics::TBitmap *mpbmpBackgroundSave; // Piece of background that is saved before blit operation

  TRect mrectBlitPos;      // bounds of where the blit currently is on the canvas
  TRect mrectBlitSize;     // Size of the current blit
  TForm *mpDestForm;       // Address of app's for to be dravn on
  TPoint mCursorDiff;
  bool mIsDragging;        // True if blit is currently being moved
  bool mPostingMessages;   // If true, does an Application->ProcessMessages() on each loop iteration.

  void SetBlit(Graphics::TBitmap *BlitToMove);

  
  public :
  TDragAndDrop(TForm *DestForm, Graphics::TBitmap *CleanBackground);
  ~TDragAndDrop();
  TPoint GetBlitPos();
  void StartDragging(int X,int Y, TPoint ptBlitPos, Graphics::TBitmap *bmpBlitToMove, bool CursorRelative=true, bool ShowBlit=false,  bool Transparent=true);
  bool Dragging() { return mIsDragging; };
  void EndDragging(bool ShowBlit=true);
  void MoveTo(TPoint Dest, bool CursorRelative=true);
  void SlideBlit(int SourceX, int SourceY,int DestX, int DestY, Graphics::TBitmap *bmpBlitToMove,int Speed=0, int Res=15);
  void SlideBlit(TPoint Source,TPoint Dest, Graphics::TBitmap *bmpBlitToMove,int Speed=0, int Res=15);
  void ProcessMessages( bool PostState=true ) { mPostingMessages=PostState; }
};
