Example #1
0
Ihandle* IupSetHandle(const char *name, Ihandle *ih)
{
    Ihandle *old_ih;

    iupASSERT(name!=NULL);
    if (!name)
        return NULL;

    old_ih = iupTableGet(inames_strtable, name);
    if (ih != NULL)
    {
        iupTableSet(inames_strtable, name, ih, IUPTABLE_POINTER);
        iupTableSet(inames_ihtable, (char*)ih, (char*)name, IUPTABLE_STRING);  /* keep only the last name set */
    }
    else
    {
        ih = iupTableGet(inames_strtable, name);
        iupTableRemove(inames_strtable, name);
        if (ih)
        {
            char* cur_name = iupTableGet(inames_ihtable, (char*)ih);
            if (iupStrEqualNoCase(cur_name, name))
                iupTableRemove(inames_ihtable, (char*)ih);
        }
    }
    return old_ih;
}
Example #2
0
void iupAttribStoreStr(Ihandle* ih, const char* name, const char* value)
{
  if (!value)
    iupTableRemove(ih->attrib, name);
  else
    iupTableSet(ih->attrib, name, (void*)value, IUPTABLE_STRING);
}
Example #3
0
void iupRemoveNames(Ihandle* ih)
{
  char *name;

  /* clear the cache */
  name = iupAttribGet(ih, "_IUP_LASTHANDLENAME");
  if (name)
    iupTableRemove(inames_strtable, name);

  /* check for an internal name */
  name = iupAttribGetHandleName(ih);
  if (name)
    iupTableRemove(inames_strtable, name);

  /* Do NOT search for other names */
}
Example #4
0
Ihandle* IupSetHandle(const char *name, Ihandle *ih)
{
  Ihandle *old_ih;

  iupASSERT(name!=NULL);
  if (!name)
    return NULL;

  old_ih = iupTableGet(inames_strtable, name);

  if (ih != NULL)
  {
    iupTableSet(inames_strtable, name, ih, IUPTABLE_POINTER);

    /* save the name in the cache if it is a valid handle */
    if (iupObjectCheck(ih))
      iupAttribStoreStr(ih, "_IUP_LASTHANDLENAME", name);
  }
  else
  {
    iupTableRemove(inames_strtable, name);

    /* clear the name from the cache if it is a valid handle */
    if (iupObjectCheck(old_ih))
      iupAttribSetStr(old_ih, "_IUP_LASTHANDLENAME", NULL);
  }

  return old_ih;
}
Example #5
0
Ihandle* IupSetHandle(const char *name, Ihandle *h)
{
  Ihandle *oe = iupTableGet (inames_strtable, name);
  if (h != NULL)
  {
    iupTableSet(inames_strtable, name, h, IUP_POINTER);
    iupTableSet(inames_ihtable, (char*) h, (char*)name, IUP_STRING);
  }
  else
  {
    h = iupTableGet(inames_strtable, name);
    iupTableRemove(inames_strtable, name);
    if (h) iupTableRemove(inames_ihtable, (char*)h);
  }
  return oe;
}
Example #6
0
void iupStoreEnv (Ihandle* n, const char* a, const char* v)
{
 if (n == NULL)
  return;
 if (v==NULL)
  iupTableRemove (env(n), a);
 else
  iupTableSet(env(n), a, (void*)v, IUP_STRING);
}
Example #7
0
static void iGlobalTableSet(const char *name, const char *value, int store)
{
  if (!value)
    iupTableRemove(iglobal_table, name);
  else if (store)
    iupTableSet(iglobal_table, name, (void*)value, IUPTABLE_STRING);
  else
    iupTableSet(iglobal_table, name, (void*)value, IUPTABLE_POINTER);
}
Example #8
0
void IupStoreGlobal(const char *name, const char *value)
{
  assert(name);
  if (!name) return;

  if (!iupdrvSetGlobal(name, value))
  {
    if (!value)
      iupTableRemove(iglobalenv, name);
    else
      iupTableSet(iglobalenv, name, (void*)value, IUP_STRING);
  }
}
Example #9
0
void iupRemoveAllNames(Ihandle* ih)
{
    char *name;
    Ihandle *cur_ih;

    name = iupTableFirst(inames_strtable);
    while (name)
    {
        cur_ih = (Ihandle*)iupTableGetCurr(inames_strtable);
        if (iupObjectCheck(cur_ih) && cur_ih == ih)
            iupTableRemoveCurr(inames_strtable);

        name = iupTableNext(inames_strtable);
    }

    iupTableRemove(inames_ihtable, (char*)ih);
}
Example #10
0
void iupRemoveNames(Ihandle* ih)
{
  /* called from IupDestroy */
  char *name;

  /* ih here is an Ihandle* */

  /* check for at least one name (the last one set) */
  name = iupAttribGetHandleName(ih);
  if (name)
    iupTableRemove(inames_strtable, name);

  /* clear also the NAME attribute */
  iupBaseSetNameAttrib(ih, NULL);

  /* Do NOT search for other names, this would implying in checking in all store names.
     So, some names may have left invalid on the handle names database. */
}
Example #11
0
Ihandle* IupSetHandle(const char *name, Ihandle *ih)
{
  Ihandle *old_ih;

  iupASSERT(name!=NULL);
  if (!name)
    return NULL;

  /* ih here can be also an user pointer, not just an Ihandle* */

  /* we do not check if the handle already has names, it may has many different names */

  old_ih = iupTableGet(inames_strtable, name);

  if (ih != NULL)
  {
    iupTableSet(inames_strtable, name, ih, IUPTABLE_POINTER);

    /* save the name in the cache if it is a valid handle */
    if (iupObjectCheck(ih))
      iupAttribSetStr(ih, "HANDLENAME", name);
  }
  else
  {
    iupTableRemove(inames_strtable, name);

    /* clear the name from the cache if it is a valid handle */
    if (iupObjectCheck(old_ih))
    {
      char* last_name = iupAttribGet(old_ih, "HANDLENAME");
      if (last_name && iupStrEqual(last_name, name))
      {
        iupAttribSet(old_ih, "HANDLENAME", NULL);  /* remove also from the cache */

        last_name = iNameFindHandle(old_ih);
        if (last_name)
          iupAttribSetStr(old_ih, "HANDLENAME", last_name);  /* if found another name save it in the cache */
      }
    }
  }

  return old_ih;
}
Example #12
0
void iupAttribUpdate(Ihandle* ih)
{
  char** name_array;
  char *name, *value;
  int count, i = 0, inherit, store;

  count = iupTableCount(ih->attrib);
  if (!count)
    return;

  name_array = (char**)malloc(count * sizeof(char*));

  /* store the names before updating so we can add or remove attributes during the update */
  name = iupTableFirst(ih->attrib);
  while (name)
  {
    name_array[i] = name;
    name = iupTableNext(ih->attrib);
    i++;
  }

  /* for all defined attributes updates the native system */
  for (i = 0; i < count; i++)
  {
    name = name_array[i];
    if (!iupAttribIsInternal(name))
    {
      /* retrieve from the table */
      value = iupTableGet(ih->attrib, name);

      /* set on the class */
      store = iupClassObjectSetAttribute(ih, name, value, &inherit);

      if (inherit)
        iAttribNotifyChildren(ih, name, value);

      if (store == 0)
        iupTableRemove(ih->attrib, name); /* remove from the table acording to the class SetAttribute */
    }
  }

  free(name_array);
}
Example #13
0
void IupStoreGlobal(const char *name, const char *value)
{
  iupASSERT(name!=NULL);
  if (!name) return;

  if (iupStrEqual(name, "DEFAULTFONTSIZE"))
  {
    iupSetDefaultFontSizeGlobalAttrib(value);
    return;
  }

  if (iupdrvSetGlobal(name, value))
  {
    if (!value)
      iupTableRemove(iglobal_table, name);
    else
      iupTableSet(iglobal_table, name, (void*)value, IUPTABLE_STRING);
  }
}
Example #14
0
Icallback IupSetFunction(const char *name, Icallback func)
{
  void* value;
  Icallback old_func;

  iupASSERT(name!=NULL);
  if (!name)
    return NULL;

  old_func = (Icallback)iupTableGetFunc(ifunc_table, name, &value);

  if (!func)
    iupTableRemove(ifunc_table, name);
  else
    iupTableSetFunc(ifunc_table, name, (Ifunc)func);

  /* notifies the driver if changing the Idle */
  if (iupStrEqual(name, "IDLE_ACTION"))
    iupdrvSetIdleFunction(func);

  return old_func;
}