Beispiel #1
0
/*++++++++++++++++++++++++++++ transfer_data() ++++++++++++++++++++++++++*/
static void
transfer_data(Widget        w,
              XtPointer     client_data,
              Atom          *selection,
              Atom          *type,
              XtPointer     value,
              unsigned long *length,
              int           *format)
{
   if ((*type == compound_text) && (y != -1))
   {
      int           i,
                    no_selected,
                    *select_list,
                    pos = XmListYToPos(host_list_w, y);
      char          *ptr;
      XmString      str;
      XmStringTable xmsel;

      /* Retrieve the selected items from the list. */
      XtVaGetValues(host_list_w,
                    XmNselectedItemCount, &no_selected,
                    XmNselectedItems,     &xmsel,
                    NULL);

      for (i = 0; i < no_selected; i++)
      {
         ptr = XmCvtXmStringToCT(xmsel[i]);
         str = XmStringCreateLocalized(ptr);
         if (pos == 0) /* Last position! */
         {
            XmListAddItemUnselected(host_list_w, str, 0);
         }
         else
         {
            XmListAddItemUnselected(host_list_w, str, pos + i);
         }
         XmStringFree(str);
      }
      if (XmListGetSelectedPos(host_list_w, &select_list, &no_selected) == True)
      {
         XmListDeletePositions(host_list_w, select_list, no_selected);
      }

      /* Select the host that was selected last. */
      str = XmStringCreateLocalized(last_selected_host);
      last_selected = -1;
      XmListSelectItem(host_list_w, str, True);
      XmStringFree(str);

      XtFree((char *)select_list);

      host_alias_order_change = YES;
   }

   return;
}
Beispiel #2
0
static int motListConvertXYToPos(Ihandle* ih, int x, int y)
{
  int count, pos;
  (void)x;

  if (ih->data->is_dropdown)
    return -1;

  if (ih->data->has_editbox)
  {
    Widget cblist;
    XtVaGetValues(ih->handle, XmNlist, &cblist, NULL);
    pos = XmListYToPos(cblist, (Position)y);   /* XmListYToPos returns start at 1 */
  }
  else
    pos = XmListYToPos(ih->handle, (Position)y);

  XtVaGetValues(ih->handle, XmNitemCount, &count, NULL);
  if (pos <= 0 || pos >= count)
    return -1;
  else
    return pos;
}
Beispiel #3
0
void
DtcmProcessPress(
        Widget          w,
        XEvent          *event,
	String		*params,
	Cardinal	*num_params)
{
   int i, action, cur_item;
   int *selected_positions, nselected_positions;

   /*
    *  This action happens when Button1 is pressed and the Selection
    *  and Transfer are integrated on Button1.  It is passed two
    *  parameters: the action to call when the event is a selection,
    *  and the action to call when the event is a transfer.
    */

    if (*num_params != 2 || !XmIsList(w))
      return;

    action = SELECTION_ACTION;
    cur_item = XmListYToPos(w, event->xbutton.y);

    if (cur_item > 0)
    {
        XtVaGetValues(w,
		XmNselectedPositions, &selected_positions,
		XmNselectedPositionCount, &nselected_positions,
		NULL);

	for (i=0; i<nselected_positions; i++)
	{
	    if (cur_item == selected_positions[i])
	    {
		/*
		 * The determination of whether this is a transfer drag
		 * cannot be made until a Motion event comes in.  It is
		 * not a drag as soon as a ButtonUp event happens.
		 */
		XEvent new_event;

		XPeekIfEvent(
			XtDisplay(w),
			&new_event,
			lookForButton,
			(XPointer)event);
                switch (new_event.type)
                {
                    case MotionNotify:
      	               action = TRANSFER_ACTION;
                       break;
                    case ButtonRelease:
        	       action = SELECTION_ACTION;
                       break;
                }
		break;
	    }
	}
    }

    XtCallActionProc(w, params[action], event, params, *num_params);
}