Пример #1
0
/*############################# accept_drop() ###########################*/
void
accept_drop(Widget w, XtPointer client_data, XmDropProcCallback drop)
{
   int                    i;
   Cardinal               no_of_exports,
                          argcount;
   Arg                    args[MAXARGS];
   XmDropTransferEntryRec entries[1];
   Atom                   *exports;

   /* See what types of targets are available. */
   XtVaGetValues(drop->dragContext,
                 XmNexportTargets,    &exports,
                 XmNnumExportTargets, &no_of_exports,
                 NULL);

   for (i = 0; i < no_of_exports; i++)
   {
      if (exports[i] == compound_text)
      {
         break;
      }
   }

   if (i > no_of_exports)
   {
      return;
   }

   /* See whether the operation is a supported one. */
   argcount = 0;
   if ((drop->dropAction == XmDROP) &&
       (drop->operations == XmDROP_MOVE))
   {
      /* Set up transfer procedure. */
      entries[0].target = compound_text;
      XtSetArg(args[argcount], XmNdropTransfers,    entries);
      argcount++;
      XtSetArg(args[argcount], XmNnumDropTransfers, 1);
      argcount++;
      XtSetArg(args[argcount], XmNtransferProc,     transfer_data);
      argcount++;
      y = drop->y;
   }
   else
   {
      XtSetArg(args[argcount], XmNtransferStatus, XmTRANSFER_FAILURE);
      argcount++;
      XtSetArg(args[argcount], XmNdropTransfers,  0);
      argcount++;
      y = -1;
   }

   XmDropTransferStart(drop->dragContext, args, argcount);

   return;
}
Пример #2
0
static void motListDropProc(Widget w, XtPointer client_data, XmDropProcCallbackStruct* drop_data)
{
  Atom atomListItem = XInternAtom(iupmot_display, "LIST_ITEM", False);
  XmDropTransferEntryRec transferList[2];
  Arg args[10];
  int i, num_args = 0;
  Widget drop_context;
  Cardinal numExportTargets;
  Atom *exportTargets;
  Boolean found = False;
  Ihandle* ih = NULL;
  (void)client_data;

  drop_context = drop_data->dragContext;

  /* retrieve the data targets */
  XtVaGetValues(drop_context, XmNexportTargets, &exportTargets,
    XmNnumExportTargets, &numExportTargets, 
    NULL);

  for (i = 0; i < (int)numExportTargets; i++) 
  {
    if (exportTargets[i] == atomListItem) 
    {
      found = True;
      break;
    }
  }

  XtVaGetValues(w, XmNuserData, &ih, NULL);
  if(!ih->handle)
    found = False;

  num_args = 0;
  if ((!found) || (drop_data->dropAction != XmDROP) ||  (drop_data->operation != XmDROP_COPY && drop_data->operation != XmDROP_MOVE)) 
  {
    iupMOT_SETARG(args, num_args, XmNtransferStatus, XmTRANSFER_FAILURE);
    iupMOT_SETARG(args, num_args, XmNnumDropTransfers, 0);
  }
  else 
  {
    transferList[0].target = atomListItem;
    transferList[0].client_data = (XtPointer)ih;
    iupMOT_SETARG(args, num_args, XmNdropTransfers, transferList);
    iupMOT_SETARG(args, num_args, XmNnumDropTransfers, 1);
    iupMOT_SETARG(args, num_args, XmNtransferProc, motListDragTransferProc);
  }

  XmDropTransferStart(drop_context, args, num_args);
}
Пример #3
0
static void
DropProc(Widget w, XtPointer client_data, XtPointer call_data)
{
XmDropProcCallbackStruct *DropInfo = (XmDropProcCallbackStruct *)call_data;
XmDropTransferEntryRec transferEntries[2];
Arg args[10];
int n = 0;

    printf("DropProc %s\n", XtName(w));
    switch (DropInfo->dropAction)
    {
    case XmDROP:
    	break;
    case XmDROP_HELP:
    	break;
    default:
    	XtSetArg(args[n], XmNtransferStatus, XmTRANSFER_FAILURE); n++;
    	XtSetArg(args[n], XmNnumDropTransfers, 0); n++;
    	DropInfo->operation = XmDROP_NOOP;
    	DropInfo->dropSiteStatus = XmINVALID_DROP_SITE;
    	break;
    }
    XmDropTransferStart(DropInfo->dragContext, args, n);
}
Пример #4
0
static void motDropProc(Widget dropTarget, XtPointer clientData, XmDropProcCallbackStruct* dropData)
{
  XmDropTransferEntryRec transferList[2];
  Arg args[20];
  int i, j, num_args;
  Widget dragContext, dropTransfer;
  Cardinal numDragTypes, numDropTypes;
  Atom *dragTypesList, *dropTypesList;
  Atom atomItem;
  Boolean found = False;
  Ihandle *ih = NULL;

  /* this is called before drag data is processed */ 
  dragContext = dropData->dragContext;

  /* Getting drop types */
  num_args = 0;
  iupMOT_SETARG(args, num_args, XmNimportTargets, &dropTypesList);
  iupMOT_SETARG(args, num_args, XmNnumImportTargets, &numDropTypes);
  XmDropSiteRetrieve (dropTarget, args, num_args);
  if(!numDropTypes)  /* no type registered */
    return;

  /* Getting drag types */
  XtVaGetValues(dragContext, XmNexportTargets, &dragTypesList,
                             XmNnumExportTargets, &numDragTypes,
                             NULL);
  if(!numDragTypes)  /* no type registered */
    return;

  /* Checking the type compatibility */ 
  for (i = 0; i < (int)numDragTypes; i++) 
  {
    for (j = 0; j < (int)numDropTypes; j++) 
    {
      if(iupStrEqualNoCase(XGetAtomName(iupmot_display, dragTypesList[i]),
                           XGetAtomName(iupmot_display, dropTypesList[j])))
      {
        atomItem = dropTypesList[j];
        found = True;
        break;
      }
    }
    if(found == True)
      break;
  }

  num_args = 0;
  if ((!found) || 
      (dropData->dropAction != XmDROP) ||  
      (dropData->operation != XmDROP_COPY && dropData->operation != XmDROP_MOVE)) 
  {
    iupMOT_SETARG(args, num_args, XmNtransferStatus, XmTRANSFER_FAILURE);
    iupMOT_SETARG(args, num_args, XmNnumDropTransfers, 0);
  }
  else 
  {
    XtVaGetValues(dropTarget, XmNuserData, &ih, NULL);

    iupAttribSetInt(ih, "_IUPMOT_DROP_X", (int)dropData->x);
    iupAttribSetInt(ih, "_IUPMOT_DROP_Y", (int)dropData->y);

    /* set up transfer requests for drop site */
    transferList[0].target = atomItem;
    transferList[0].client_data = (XtPointer)ih;

    iupMOT_SETARG(args, num_args, XmNdropTransfers, transferList);
    iupMOT_SETARG(args, num_args, XmNnumDropTransfers, 1);
    iupMOT_SETARG(args, num_args, XmNtransferProc, motDropTransferProc);
  }

  /* creates a XmDropTransfer (not used here) */
  dropTransfer = XmDropTransferStart(dragContext, args, num_args);

  (void)dropTransfer;
  (void)clientData;
}