#ifndef GTDRAG_H
#define GTDRAG_H 1
/*
**  $VER: gtdrag.h 1.3 (2.10.96)
**  Includes Release 1.4
**
**  Drag&Drop with GadTools
**
**  (C) Copyright 1996 Axel Dörfler
**  All rights Reserved
*/

#include <exec/nodes.h>
#include <utility/hooks.h>

/* The ImageNode structure is used to have both text and images in a listview.
 * A render hook for this type is provided (in future releases). It is not a must!
 */

struct ImageNode
{
  struct Node *in_Succ;
  struct Node *in_Pred;
  UBYTE  in_Type;
  BYTE   in_Pri;
  STRPTR in_Name;
  struct Image *in_Image;
};

/* The DragGadget structure manages the gadgets which support dragging.
 * Remember that these fields are read-only!
 */

#define DGF_IMAGES 1       /* Images only, if possible */
#define DGF_NODRAG 2       /* can't be the source of a drag */

struct DragGadget
{
  struct MinNode dg_Node;
  struct Gadget *dg_Gadget;
  ULONG  dg_Type;
  struct Window *dg_Window;
  struct List *dg_List;
  struct Hook *dg_Render;
  short  dg_ItemHeight;
  short  dg_Width;
  short  dg_Height;
  UWORD  dg_Flags;
};

/* You receive the DragMsg structure if someone has dragged an item.
 * And again, all fields are read-only!
 */

#define DMT_GADGET 1    /* target is a window */
#define DMT_WINDOW 2    /* target is a gadget */
#define DMT_UNKNOWN 4   /* target doesn't support drag&drop */

struct DragMsg
{
  struct MinNode dm_Node;
  int    dm_Type;
  struct ImageNode *dm_Object;  /* dragged object */
  struct DragGadget *dm_Source;
  APTR   dm_Target;             /* pointer to a DragGadget or Window */
  int    dm_SourceEntry;        /* the list position of the entry */
  int    dm_TargetEntry;        /* dto. - may be higher than the number of entries */
  int    dm_X,dm_Y;             /* exact co-ordinates */
};

/* The flags for the IDCMP-MsgPort of your Window */

#define DRAGIDCMP (LISTVIEWIDCMP | IDCMP_MOUSEBUTTONS)

/* Tags to pass to GTD_AddGadget() */

#define GTDA_TagBase    (TAG_USER + 0x90000)
#define GTDA_ItemHeight GTDA_TagBase + 1      /* height of a listview entry */
#define GTDA_RenderHook GTDA_TagBase + 2      /* render hook for listview */
#define GTDA_Images     GTDA_TagBase + 3      /* drags only images (listview MUST contain ImageNodes) */
#define GTDA_Width      GTDA_TagBase + 4      /* width of icon (only for GTDA_RenderHook & GTDA_Images) */
#define GTDA_Height     GTDA_TagBase + 5      /* height of a icon ("") */
#define GTDA_NoDrag     GTDA_TagBase + 6      /* do not drag from this gadget */
#define GTDA_Object     GTDA_TagBase + 7      /* drag node from a non-listview */

/* Tags to pass to GTD_Init() */

#define GTDA_GTMsgsOnly  GTDA_TagBase + 10     /* get only gadtools msgs */
#define GTDA_LVDragPixel GTDA_TagBase + 11     /* pixel until drag (listview) */
#define GTDA_DragPixel   GTDA_TagBase + 12     /* pixel until drag (other) */

/* The public function prototypes of gtdrag */

extern void GTD_Free(void);
extern void GTD_Init(ULONG tag1,...);
extern void GTD_AddGadget(ULONG type,struct Gadget *gad,struct Window *win,ULONG tag1,...);
extern void GTD_RemoveGadget(struct Gadget *);
extern void GTD_AddWindow(struct Window *win,ULONG tag1,...);
extern void GTD_RemoveWindow(struct Window *);
extern void GTD_ReplyDragMsg(struct DragMsg *dm);
extern void GTD_ReplyIMsg(struct IntuiMessage *msg);
extern struct DragMsg *GTD_GetDragMsg(void);
extern struct IntuiMessage *GTD_GetIMsg(struct MsgPort *mp);

#endif
