Пример #1
0
void iupTabsCheckCurrentTab(Ihandle* ih, int pos, int removed)
{
  int cur_pos = iupdrvTabsGetCurrentTab(ih);
  if (cur_pos == pos)
  {
    int p;

    /* if given tab is the current tab, 
       then the current tab must be changed to a visible tab */
    Ihandle* child;

    /* this function is called after the child has being removed from the hierarchy,
       but before the system tab being removed. */

    p = 0;
    if (removed && p == pos)
      p++;

    for (child = ih->firstchild; child; child = child->brother)
    {
      if (p != pos && iupdrvTabsIsTabVisible(child, p))
      {
        iupdrvTabsSetCurrentTab(ih, p);
        return;
      }

      p++;
      if (removed && p == pos)
        p++;  /* increment twice to compensate for child already removed */
    }
  }
}
Пример #2
0
static void motTabsChildRemovedMethod(Ihandle* ih, Ihandle* child)
{
  if (ih->handle)
  {
    Widget child_manager = (Widget)iupAttribGet(child, "_IUPTAB_CONTAINER");
    if (child_manager)
    {
      int cur_pos, pos;
      Widget tab_button = (Widget)iupAttribGet(child, "_IUPMOT_TABBUTTON");

      cur_pos = iupdrvTabsGetCurrentTab(ih);
      pos = iupAttribGetInt(child, "_IUPMOT_TABNUMBER");  /* did not work when using XtVaGetValues(child_manager, XmNpageNumber) */
      if (cur_pos == pos)
      {
        if (cur_pos == 0)
          cur_pos = 1;
        else
          cur_pos--;

        iupdrvTabsSetCurrentTab(ih, cur_pos);
      }

      XtDestroyWidget(tab_button);
      XtDestroyWidget(child_manager);

      /* compact the tab number usage */
      motTabsUpdatePageNumber(ih);

      iupAttribSetStr(child, "_IUPTAB_CONTAINER", NULL);
      iupAttribSetStr(child, "_IUPMOT_TABBUTTON", NULL);
      iupAttribSetStr(child, "_IUPMOT_TABNUMBER", NULL);
    }
  }
}
Пример #3
0
static void iTabsSetTab(Ihandle* ih, Ihandle* child, int pos)
{
  if (ih->handle)
  {
    int cur_pos = iupdrvTabsGetCurrentTab(ih);
    if (cur_pos != pos && iupdrvTabsIsTabVisible(child, pos))
      iupdrvTabsSetCurrentTab(ih, pos);
  }
  else
    iupAttribSet(ih, "_IUPTABS_VALUE_HANDLE", (char*)child);
}
Пример #4
0
void iupTabsCheckCurrentTab(Ihandle* ih, int pos)
{
  int cur_pos = iupdrvTabsGetCurrentTab(ih);
  if (cur_pos == pos)
  {
    Ihandle* child;

    for (pos = 0, child = ih->firstchild; child; child = child->brother, pos++)
    {
      if (pos != cur_pos && iupdrvTabsIsTabVisible(child))
      {
        iupdrvTabsSetCurrentTab(ih, pos);
        return;
      }
    }
  }
}
Пример #5
0
static int iTabsSetValuePosAttrib(Ihandle* ih, const char* value)
{
  Ihandle* child;
  int pos;

  if (!iupStrToInt(value, &pos))
    return 0;

  child = IupGetChild(ih, pos);
  if (child) /* found child */
  {
    if (ih->handle)
      iupdrvTabsSetCurrentTab(ih, pos);
    else
      iupAttribSetStr(ih, "_IUPTABS_VALUE_HANDLE", (char*)child);
  }
 
  return 0;
}
Пример #6
0
void iupTabsTestRemoveTab(Ihandle* ih, int pos)
{
    int cur_pos = iupdrvTabsGetCurrentTab(ih);
    if (cur_pos == pos)
    {
        if (cur_pos == 0)
        {
            Ihandle* child = IupGetChild(ih, 1);
            if (!child) /* not found child, means only one child, do nothing */
                return;

            cur_pos = 1;
        }
        else
            cur_pos--;

        iupdrvTabsSetCurrentTab(ih, cur_pos);
    }
}
Пример #7
0
static int iTabsSetValueHandleAttrib(Ihandle* ih, const char* value)
{
  int pos;
  Ihandle *child;

  child = (Ihandle*)value;
  if (!iupObjectCheck(child))
    return 0;

  pos = IupGetChildPos(ih, child);
  if (pos != -1) /* found child */
  {
    if (ih->handle)
      iupdrvTabsSetCurrentTab(ih, pos);
    else
      iupAttribSetStr(ih, "_IUPTABS_VALUE_HANDLE", (char*)child);
  }
 
  return 0;
}