Example #1
0
static int Reparent(lua_State *L)
{
  lua_pushinteger(L, IupReparent(iuplua_checkihandle(L,1),
                                 iuplua_checkihandle(L,2),
                                 iuplua_checkihandleornil(L,3)));
  return 1;
}
Example #2
0
static int iDetachBoxSetRestoreAttrib(Ihandle* ih, const char* value)
{
  Ihandle *dlg = IupGetDialog(ih);
  Ihandle* new_parent = IupGetHandle(value);
  Ihandle* new_brother = NULL;

  if (!new_parent)
  {
    new_parent = ih->data->old_parent;
    new_brother = ih->data->old_brother;

    if (IupGetChildPos(new_parent, new_brother) == -1)  /* not a child of new_parent */
      new_brother = NULL;
  }

  /* Sets the new parent */
  IupReparent(ih, new_parent, new_brother);

  /* Show handler */
  if (ih->data->barsize)
    IupSetAttribute(ih->firstchild, "VISIBLE", "Yes");

  /* Updates/redraws the layout of the dialog */
  IupRefresh(new_parent);

  /* Reset previous parent and brother */
  ih->data->old_parent = NULL;
  ih->data->old_brother = NULL;

  IupDestroy(dlg);
  return 0;
}
Example #3
0
static int iDetachBoxSetDetachAttrib(Ihandle* ih, const char* value)
{
  int cur_x, cur_y;
  IFnnii detachedCB = (IFnnii)IupGetCallback(ih, "DETACHED_CB");

  /* Create new dialog */
  Ihandle *new_parent = IupDialog(NULL);
  Ihandle *old_dialog = IupGetDialog(ih);

  /* Set new dialog as child of the current application */
  IupSetAttributeHandle(new_parent, "PARENTDIALOG", old_dialog);

  iupStrToIntInt(IupGetGlobal("CURSORPOS"), &cur_x, &cur_y, 'x');

  if (detachedCB)
  {
    int ret = detachedCB(ih, new_parent, cur_x, cur_y);
    if (ret == IUP_IGNORE)
    {
      IupDestroy(new_parent);
      return IUP_DEFAULT;
    }
  }

  /* set user size of the detachbox as the current size of the child */
  IupSetStrAttribute(ih, "RASTERSIZE", IupGetAttribute(ih->firstchild->brother, "RASTERSIZE"));

  /* Save current parent and reference child */
  ih->data->old_parent = ih->parent;
  ih->data->old_brother = ih->brother;

  IupMap(new_parent);

  /* Sets the new parent */
  IupReparent(ih, new_parent, NULL);

  /* Hide handler */
  IupSetAttribute(ih->firstchild, "VISIBLE", "No");

  /* force a dialog resize since IupMap already computed the dialog size */
  IupSetAttribute(new_parent, "RASTERSIZE", NULL);

  /* Maps and shows the new dialog */
  IupShowXY(new_parent, cur_x, cur_y);

  /* reset user size of the detachbox */
  IupSetAttribute(ih, "USERSIZE", NULL);

  /* Updates/redraws the layout of the old dialog */
  IupRefresh(old_dialog);

  (void)value;
  return 0;
}
static int iDetachBoxSetDetachAttrib(Ihandle* ih, const char* value)
{
  IFnnii detachedCB = (IFnnii)IupGetCallback(ih, "DETACHED_CB");

  /* Create new dialog */
  Ihandle *new_parent = IupDialog(NULL);
  Ihandle *old_dialog = IupGetDialog(ih);

  /* Set new dialog as child of the current application */
  IupSetAttributeHandle(new_parent, "PARENTDIALOG", old_dialog);

  if (detachedCB)
    detachedCB(ih, new_parent, 0, 0);

  /* Save current parent and reference child */
  ih->data->old_parent = ih->parent;
  ih->data->old_brother = ih->brother;

  IupMap(new_parent);

  /* Sets the new parent */
  IupReparent(ih, new_parent, NULL);

  /* Hide canvas bar */
  ih->data->barsize = 0;
  IupHide(ih->firstchild);

  /* Restores the cursor */
  IupSetAttribute(ih->firstchild, "CURSOR", "MOVE");

  /* Updates/redraws the layout of the dialog application */
  IupRefresh(old_dialog);

  IupSetAttribute(new_parent, "RASTERSIZE", NULL);
  IupRefresh(new_parent);

  /* Maps and shows the new dialog */
  IupShow(new_parent);

  (void)value;
  return 0;
}
Example #5
0
static int btn_restore_cb(Ihandle *bt)
{
  Ihandle *dbox = IupGetHandle("dbox");

#if 0
  Ihandle *dlg = IupGetDialog(dbox);
  Ihandle *old_parent = (Ihandle*)IupGetAttribute(dbox, "OLDPARENT_HANDLE");
  Ihandle *ref_child = (Ihandle*)IupGetAttribute(dbox, "OLDBROTHER_HANDLE");
  IupReparent(dbox, old_parent, ref_child);
  IupRefresh(old_parent);
  IupDestroy(dlg);
#else
  IupSetAttribute(dbox, "RESTORE", NULL);
#endif
  
  IupSetAttribute(bt, "ACTIVE", "NO");
  IupSetAttribute(IupGetHandle("detach"), "ACTIVE", "Yes");

  return IUP_DEFAULT;
}
static int iDetachBoxSetRestoreAttrib(Ihandle* ih, const char* value)
{
  Ihandle *dlg = IupGetDialog(ih);

  IupReparent(ih, ih->data->old_parent, ih->data->old_brother);

  /* Restores and shows the bar handler when the element returns to its previous parent */
  ih->data->barsize = 10;  /* default size */
  IupShow(ih->firstchild);

  /* Restores the cursor */
  IupSetAttribute(ih->firstchild, "CURSOR", "MOVE");

  IupRefresh(ih->data->old_parent);

  /* Reset previous parent and brother */
  ih->data->old_parent = NULL;
  ih->data->old_brother = NULL;

  IupDestroy(dlg);
  (void)value;
  return 0;
}
static int iDetachBoxButton_CB(Ihandle* bar, int button, int pressed, int x, int y, char* status)
{
  Ihandle* ih = bar->parent;
  Ihandle* mainDlg = IupGetDialog(ih);

  if (button != IUP_BUTTON1)
    return IUP_DEFAULT;

  if (!ih->data->is_holding && pressed)  /* DRAG BEGIN */
  {
    ih->data->is_holding = 1;
    
    /* Change cursor */
    IupSetAttribute(bar, "CURSOR", "IupDetachBoxCursor");
  }
  else if (ih->data->is_holding && !pressed)  /* DRAG END */
  {
    Ihandle *new_parent;
    IFnnii detachedCB = (IFnnii)IupGetCallback(ih, "DETACHED_CB");
    int cur_x, cur_y;

    ih->data->is_holding = 0;

    iupStrToIntInt(IupGetGlobal("CURSORPOS"), &cur_x, &cur_y, 'x');

    /* Create new dialog */
    new_parent = IupDialog(NULL);

    /* Set new dialog as child of the current application */
    IupSetAttributeHandle(new_parent, "PARENTDIALOG", mainDlg);

    if (detachedCB)
    {
      int ret = detachedCB(ih, new_parent, cur_x, cur_y);
      if (ret == IUP_IGNORE)
      {
        IupDestroy(new_parent);
        return IUP_DEFAULT;
      }
    }

    /* Save current parent and reference child */
    ih->data->old_parent = ih->parent;
    ih->data->old_brother = ih->brother;

    IupMap(new_parent);

    /* Sets the new parent */
    IupReparent(ih, new_parent, NULL);

    /* Restores the cursor */
    IupSetAttribute(bar, "CURSOR", "MOVE");

    /* Hide canvas bar */
    ih->data->barsize = 0;
    IupHide(bar);

    /* Updates/redraws the layout of the dialog application */
    IupRefresh(mainDlg);

    IupSetAttribute(new_parent, "RASTERSIZE", NULL);
    IupRefresh(new_parent);

    /* Maps and shows the new dialog */
    IupShowXY(new_parent, cur_x, cur_y);
  }

  (void)x;
  (void)y;
  (void)status;
  return IUP_DEFAULT;
}
Example #8
0
static void Reparent(void)
{
  lua_pushnumber(IupReparent(iuplua_checkihandle(1),
                             iuplua_checkihandle(2)));
}