Ejemplo n.º 1
0
static int iListSetAppendItemAttrib(Ihandle* ih, const char* value)
{
  if (!ih->handle)  /* do not do the action before map */
    return 0;
  if (value)
    iupdrvListAppendItem(ih, value);
  return 0;
}
Ejemplo n.º 2
0
void iupListSetInitialItems(Ihandle* ih)
{
  char *value;
  int i = 1;
  while ((value = iupAttribGetId(ih, "", i))!=NULL)
  {
    iupdrvListAppendItem(ih, value);
    iupAttribSetId(ih, "", i, NULL);

    i++;
  }
}
Ejemplo n.º 3
0
static void motListDragTransferProc(Widget drop_context, Ihandle* ih, Atom *seltype, Atom *type, XtPointer value, unsigned long *length, int format)
{
  Atom atomListItem = XInternAtom(iupmot_display, "LIST_ITEM", False);
  int idDrag = (int)value;  /* starts at 1 */
  int idDrop = iupAttribGetInt(ih, "_IUPLIST_DROPITEM");  /* starts at 1 */

  if (idDrop==0)
    return;

  /* shift to start at 0 */
  idDrag--;
  idDrop--;

  if (*type == atomListItem)
  {
    int is_ctrl;

    if (iupListCallDragDropCb(ih, idDrag, idDrop, &is_ctrl) == IUP_CONTINUE)  /* starts at 0 */
    {
      char* text = motListGetIdValueAttrib(ih, idDrag+1); /* starts at 1 */
      int count = iupdrvListGetCount(ih);
        
      /* Copy the item to the idDrop position */
      if (idDrop >= 0 && idDrop < count) /* starts at 0 */
      {
        iupdrvListInsertItem(ih, idDrop, text);   /* starts at 0, insert before */
        if (idDrag > idDrop)
          idDrag++;
      }
      else  /* idDrop = -1 */
      {
        iupdrvListAppendItem(ih, text);
        idDrop = count;  /* new item is the previous count */
      }

      /* Selects the drop item */
      XmListSelectPos(ih->handle, idDrop+1, FALSE);    /* starts at 1 */
      iupAttribSetInt(ih, "_IUPLIST_OLDVALUE", idDrop+1);  /* starts at 1 */

      /* Remove the Drag item if moving */
      if (!is_ctrl)
        iupdrvListRemoveItem(ih, idDrag);   /* starts at 0 */
    }
  }

  iupAttribSet(ih, "_IUPLIST_DROPITEM", NULL);

  (void)drop_context;
  (void)seltype;
  (void)format;
  (void)length;
}
Ejemplo n.º 4
0
static int iListSetInsertItemAttrib(Ihandle* ih, int id, const char* value)
{
  if (!ih->handle)  /* do not do the action before map */
    return 0;
  if (value)
  {
    int pos = iupListGetPosAttrib(ih, id);
    if (pos >= 0)
      iupdrvListInsertItem(ih, pos, value);
    else if (pos == -2)
      iupdrvListAppendItem(ih, value);
  }
  return 0;
}
Ejemplo n.º 5
0
void iupListSetInitialItems(Ihandle* ih)
{
  char str[20], *value;
  int i = 1;
  sprintf(str, "%d", i);
  while ((value = iupAttribGet(ih, str))!=NULL)
  {
    iupdrvListAppendItem(ih, value);
    iupAttribSetStr(ih, str, NULL);

    i++;
    sprintf(str, "%d", i);
  }
}
Ejemplo n.º 6
0
int iupListSetIdValueAttrib(Ihandle* ih, const char* name_id, const char* value)
{
  int pos;
  if (iupStrToInt(name_id, &pos))
  {
    int count = iupdrvListGetCount(ih);

    pos--; /* IUP starts at 1 */

    if (!value)
    {
      if (pos >= 0 && pos <= count-1)
      {
        if (pos == 0)
          iupdrvListRemoveAllItems(ih);
        else
        {
          int i = pos;
          while (i < count)
          {
            iupdrvListRemoveItem(ih, pos);
            i++;
          }
        }
      }
    }
    else
    {
      if (pos >= 0 && pos <= count-1)
      {
        iupdrvListRemoveItem(ih, pos);
        iupdrvListInsertItem(ih, pos, value);
      }
      else if (pos == count)
        iupdrvListAppendItem(ih, value);
    }
  }
  return 1;
}
Ejemplo n.º 7
0
int iupListSetIdValueAttrib(Ihandle* ih, int pos, const char* value)
{
  int count = iupdrvListGetCount(ih);

  pos--; /* IUP starts at 1 */

  if (!value)
  {
    if (pos >= 0 && pos <= count-1)
    {
      if (pos == 0)
      {
        iupdrvListRemoveAllItems(ih);
        iupAttribSet(ih, "_IUPLIST_OLDVALUE", NULL);
      }
      else
      {
        int i = pos;
        while (i < count)
        {
          iupdrvListRemoveItem(ih, pos);
          i++;
        }
      }
    }
  }
  else
  {
    if (pos >= 0 && pos <= count-1)
    {
      iupdrvListRemoveItem(ih, pos);
      iupdrvListInsertItem(ih, pos, value);
    }
    else if (pos == count)
      iupdrvListAppendItem(ih, value);
  }
  return 0;
}