Ejemplo n.º 1
0
int iupClassAttribIsRegistered(Iclass* ic, const char* name)
{
  IattribFunc* afunc = NULL;

  if (ic->has_attrib_id!=0)
  {
    const char* name_id = iClassFindId(name);
    if (name_id)
    {
      const char* partial_name = iClassCutNameId(name, name_id);
      if (!partial_name)
        partial_name = "IDVALUE";  /* pure numbers are used as attributes in IupList and IupMatrix, 
                                      translate them into IDVALUE. */
      afunc = (IattribFunc*)iupTableGet(ic->attrib_func, partial_name);
    }
  }

  if (!afunc)
    afunc = (IattribFunc*)iupTableGet(ic->attrib_func, name);

  if (afunc)
    return 1;

  return 0;
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
0
void iupClassObjectGetAttributeInfo(Ihandle* ih, const char* name, char* *def_value, int *inherit)
{
  IattribFunc* afunc;

  if (ih->iclass->has_attrib_id!=0)
  {
    const char* name_id = iClassFindId(name);
    if (name_id)
    {
      const char* partial_name = iClassCutNameId(name, name_id);
      if (!partial_name)
        partial_name = "IDVALUE";  /* pure numbers are used as attributes in IupList and IupMatrix, 
                                      translate them into IDVALUE. */
      afunc = (IattribFunc*)iupTableGet(ih->iclass->attrib_func, partial_name);
      if (afunc && afunc->flags & IUPAF_HAS_ID)
      {
        *def_value = NULL;  /* id numbered attributes have default value NULL always */
        *inherit = 0;       /* id numbered attributes are NON inheritable always */
         return;      /* if the function exists, then must return here */
      }
    }
  }

  /* if not has_attrib_id, or not found an ID, or not found the partial name, check using the full name */

  afunc = (IattribFunc*)iupTableGet(ih->iclass->attrib_func, name);
  *def_value = NULL;
  *inherit = 1; /* default is inheritable */
  if (afunc)
  {
    *def_value = iClassGetDefaultValue(afunc);
    *inherit = !(afunc->flags & IUPAF_NO_INHERIT) &&  /* is inheritable */
               !(afunc->flags & IUPAF_NO_STRING);     /* is a string */
  }
}
Ejemplo n.º 4
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;
}
Ejemplo n.º 5
0
void IupSetClassDefaultAttribute(const char* classname, const char *name, const char* default_value)
{
  Iclass* ic;
  IattribFunc* afunc;

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

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

  ic = iupRegisterFindClass(name);
  if (!ic)
    return;

  afunc = (IattribFunc*)iupTableGet(ic->attrib_func, name);
  if (afunc && !(afunc->flags & IUPAF_NO_DEFAULTVALUE) &&   /* can has default */
               !(afunc->flags & IUPAF_NO_STRING) &&     /* is a string */
               !(afunc->flags & IUPAF_HAS_ID))
  {
    if (default_value == IUPAF_SAMEASSYSTEM)
      afunc->default_value = afunc->system_default;
    else
      afunc->default_value = default_value;

    if (iupClassIsGlobalDefault(afunc->default_value, 0))
      afunc->call_global_default = 1;
    else
      afunc->call_global_default = 0;
  }
  else if (!afunc && default_value)
    iupClassRegisterAttribute(ic, name, NULL, NULL, default_value, NULL, IUPAF_DEFAULT);
}
Ejemplo n.º 6
0
char* iupClassCallbackGetFormat(Iclass* ic, const char* name)
{
  IattribFunc* afunc = (IattribFunc*)iupTableGet(ic->attrib_func, name);
  if (afunc)
    return (char*)afunc->default_value;
  return NULL;
}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
0
char *iupdrvGetDefault (Ihandle *n, const char *a)
{
   char *def;

   if (n == NULL || a == NULL)
      return NULL;
 
   if (iupStrEqual(a, IUP_FONT) || iupStrEqual(a, "_IUPMOT_FONT"))
   {
	  return iupmot_fontname; 
   }
   else if (iupStrEqual(a, "EXPAND"))
   {
     if(type(n) == FILL_  || type(n) == CANVAS_ ||
				type(n) == FRAME_ || type(n) == HBOX_   ||
				type(n) == RADIO_ || type(n) == VBOX_   ||
				type(n) == ZBOX_)
       return IUP_YES;
     else
       return IUP_NO;
   }  

   def = (char *)iupTableGet(attrDefEnv, a);

   return def;
}
Ejemplo n.º 9
0
void iupClassRegisterAttribute(Iclass* ic, const char* name, 
                               IattribGetFunc _get, IattribSetFunc _set, 
                               const char* _default_value, const char* _system_default, int _flags)
{
  IattribFunc* afunc = (IattribFunc*)iupTableGet(ic->attrib_func, name);
  if (afunc)
    free(afunc);  /* overwrite a previous registration */

  afunc = (IattribFunc*)malloc(sizeof(IattribFunc));
  afunc->get = _get;
  afunc->set = _set;
  if (_default_value == IUPAF_SAMEASSYSTEM)
    afunc->default_value = _system_default;
  else
    afunc->default_value = _default_value;
  afunc->system_default = _system_default;
  afunc->flags = _flags;

  if (iupClassIsGlobalDefault(afunc->default_value, 0))
    afunc->call_global_default = 1;
  else
    afunc->call_global_default = 0;

  iupTableSet(ic->attrib_func, name, (void*)afunc, IUPTABLE_POINTER);
}
Ejemplo n.º 10
0
int iupClassObjectAttribIsIhandle(Ihandle* ih, const char* name)
{
  IattribFunc* afunc = (IattribFunc*)iupTableGet(ih->iclass->attrib_func, name);
  if (afunc && (afunc->flags & IUPAF_IHANDLE))
    return 1;
  return 0;
}
Ejemplo n.º 11
0
int iupClassObjectAttribIsNotString(Ihandle* ih, const char* name)
{
  IattribFunc* afunc = (IattribFunc*)iupTableGet(ih->iclass->attrib_func, name);
  if (afunc && (afunc->flags & IUPAF_NO_STRING || afunc->flags & IUPAF_CALLBACK || afunc->flags & IUPAF_IHANDLE))
    return 1;
  return 0;
}
Ejemplo n.º 12
0
void iupAttribUpdateFromParent(Ihandle* ih)
{
  Iclass* ic = ih->iclass;
  char *name = iupTableFirst(ic->attrib_func);
  while (name)
  {
    /* if inheritable and NOT defined at the element */
    if (iupClassObjectCurAttribIsInherit(ic) && !iupAttribGet(ih, name))
    {
      /* check in the parent tree if the attribute is defined */
      Ihandle* parent = ih->parent;
      while (parent)
      {
        char* value = iupTableGet(parent->attrib, name);
        if (value)
        {
          int inherit;
          /* set on the class */
          iupClassObjectSetAttribute(ih, name, value, &inherit);
          break;
        }
        parent = parent->parent;
      }
    }

    name = iupTableNext(ic->attrib_func);
  }
}
Ejemplo n.º 13
0
char* iupClassObjectGetAttributeId(Ihandle* ih, const char* name, int id)
{
  IattribFunc* afunc;

  if (ih->iclass->has_attrib_id==0)
    return NULL;

  if (name[0]==0)
    name = "IDVALUE";  /* pure numbers are used as attributes in IupList and IupMatrix, 
                          translate them into IDVALUE. */
  afunc = (IattribFunc*)iupTableGet(ih->iclass->attrib_func, name);
  if (afunc && afunc->flags & IUPAF_HAS_ID)
  {
    if (afunc->flags & IUPAF_WRITEONLY)
      return NULL;

    if (afunc->get && 
        !(afunc->flags & IUPAF_HAS_ID2) &&
        (ih->handle || afunc->flags & IUPAF_NOT_MAPPED))
    {
      IattribGetIdFunc id_get = (IattribGetIdFunc)afunc->get;
      return id_get(ih, id);
    }
  }

  return NULL;
}
Ejemplo n.º 14
0
int iupClassObjectSetAttributeId(Ihandle* ih, const char* name, int id, const char * value)
{
  IattribFunc* afunc;

  if (ih->iclass->has_attrib_id==0)
    return 1;  /* function not found, default to string */

  if (name[0]==0)
    name = "IDVALUE";  /* pure numbers are used as attributes in IupList and IupMatrix, 
                          translate them into IDVALUE. */
  afunc = (IattribFunc*)iupTableGet(ih->iclass->attrib_func, name);
  if (afunc && afunc->flags & IUPAF_HAS_ID)
  {         
    if (afunc->flags & IUPAF_READONLY)
    {
      if (afunc->flags & IUPAF_NO_STRING)
        return -1;  /* value is NOT a string, can NOT call iupAttribSetStr */
      return 0;
    }

    if (afunc->set && 
        !(afunc->flags & IUPAF_HAS_ID2) &&
        (ih->handle || afunc->flags & IUPAF_NOT_MAPPED))
    {
      /* id numbered attributes have default value NULL always */
      IattribSetIdFunc id_set = (IattribSetIdFunc)afunc->set;
      return id_set(ih, id, value);
    }

    if (afunc->flags & IUPAF_NO_STRING)
      return -1; /* value is NOT a string, can NOT call iupAttribSetStr */
  }

  return 1;  /* function not found, default to string */
}
Ejemplo n.º 15
0
char* iupAttribGetStr(Ihandle* ih, const char* name)
{
  char* value;
  if (!ih || !name)
    return NULL;

  value = iupTableGet(ih->attrib, name);

  if (!value && !iupAttribIsInternal(name))
  {
    int inherit;
    char *def_value;
    iupClassObjectGetAttributeInfo(ih, name, &def_value, &inherit);

    if (inherit)
    {
      while (!value)
      {
        ih = ih->parent;
        if (!ih)
          break;

        value = iupAttribGet(ih, name);
      }
    }

    if (!value)
      value = def_value;
  }

  return value;
}
Ejemplo n.º 16
0
char* IupGetName(Ihandle* ih)
{
    iupASSERT(iupObjectCheck(ih));
    if (!iupObjectCheck(ih))
        return NULL;
    return iupTableGet(inames_ihtable, (char*)ih);
}
Ejemplo n.º 17
0
int iupGetWidth (Itable* e)
{
 int i=0;
 char *v = iupTableGet (e, IUP_WIDTH);
 if (v)
  sscanf (v, "%d", &i);
 return i;
}
Ejemplo n.º 18
0
int iupGetHeight (Itable* e)
{
 int i=0;
 char *v = iupTableGet (e, IUP_HEIGHT);
 if (v)
  sscanf (v, "%d", &i);
 return i;
}
Ejemplo n.º 19
0
void iupRegisterClass(Iclass* ic)
{
  Iclass* old_ic = (Iclass*)iupTableGet(iregister_table, ic->name);
  if (old_ic)
    iupClassRelease(old_ic);

  iupTableSet(iregister_table, ic->name, (void*)ic, IUPTABLE_POINTER);
}
Ejemplo n.º 20
0
void iupClassRegisterReplaceAttribFunc(Iclass* ic, const char* name, IattribGetFunc _get, IattribSetFunc _set)
{
  IattribFunc* afunc = (IattribFunc*)iupTableGet(ic->attrib_func, name);
  if (afunc)
  {
    if (_get) afunc->get = _get;
    if (_set) afunc->set = _set;
  }
}
Ejemplo n.º 21
0
Ihandle * iupmotGetZboxValue( Ihandle* n )
{
   if (type(n) == ZBOX_)
   {
      Ihandle *z, *c=IupGetHandle ((char*)iupTableGet(env(n),IUP_VALUE));
      if (c)
         foreachchild( z, n ) if (c==z) return c;
      return child(n);
   }
Ejemplo n.º 22
0
void iupClassGetAttribNameInfo(Iclass* ic, const char* name, char* *def_value, int *flags)
{
  IattribFunc* afunc = (IattribFunc*)iupTableGet(ic->attrib_func, name);
  *def_value = NULL;
  *flags = 0;
  if (afunc)
  {
    *flags = afunc->flags;
    *def_value = iClassGetDefaultValue(afunc);
  }
}
Ejemplo n.º 23
0
char *IupGetGlobal(const char *name)
{
  char* v;
  assert(name);
  if (!name) return NULL;

  v = iupdrvGetGlobal(name);
  if (!v) v = (char*)iupTableGet(iglobalenv, name);

  return v;
}
Ejemplo n.º 24
0
char* iupGetEnv (Ihandle* n, const char* a)
{
 char *v;
 if (n == NULL)
  return NULL;
 v = iupTableGet (env(n), a);
 if (v == NULL)
   if(iupIsInheritable(a))
     v = iupGetEnv (parent(n), a);
 return v;
}
Ejemplo n.º 25
0
void iupClassRegisterReplaceAttribDef(Iclass* ic, const char* name, const char* _default_value, const char* _system_default)
{
  IattribFunc* afunc = (IattribFunc*)iupTableGet(ic->attrib_func, name);
  if (afunc)
  {
    if (_default_value == IUPAF_SAMEASSYSTEM)
      afunc->default_value = _system_default;
    else
      afunc->default_value = _default_value;
    afunc->system_default = _system_default;
  }
}
Ejemplo n.º 26
0
void iupImageStockSet(const char *name, iupImageStockCreateFunc func, const char* native_name)
{
  IimageStock* istock = (IimageStock*)iupTableGet(istock_table, name);
  if (istock)
    free(istock);  /* overwrite a previous registration */

  istock = (IimageStock*)malloc(sizeof(IimageStock));
  istock->func = func;
  istock->image = NULL;
  istock->native_name = native_name;

  iupTableSet(istock_table, name, (void*)istock, IUPTABLE_POINTER);
}
Ejemplo n.º 27
0
char *iupdrvGetAttribute (Ihandle *n, const char *a)
{
   get_fn getfunc;
 
   if (n == NULL || handle(n) == NULL || a == NULL)
      return NULL;
 
   getfunc = (get_fn)iupTableGet(attrEnv, a);
 
   if (getfunc != NULL)
      return (getfunc)(n);
   return NULL;
}
Ejemplo n.º 28
0
void iupClassRegisterGetAttribute(Iclass* ic, const char* name, 
                                  IattribGetFunc *_get, IattribSetFunc *_set, 
                                  const char* *_default_value, const char* *_system_default, int *_flags)
{
  IattribFunc* afunc = (IattribFunc*)iupTableGet(ic->attrib_func, name);
  if (afunc)
  {
    if (_get) *_get = afunc->get;
    if (_set) *_set = afunc->set;
    if (_default_value) *_default_value = afunc->default_value;
    if (_system_default) *_system_default = afunc->system_default;
    if (_flags) *_flags = afunc->flags;
  }
}
Ejemplo n.º 29
0
void iupAttribUpdateChildren(Ihandle* ih)
{
  char *name = iupTableFirst(ih->attrib);
  while (name)
  {
    if (!iupAttribIsInternal(name) && iAttribIsInherit(ih, name))
    {
      /* retrieve from the table */
      char* value = iupTableGet(ih->attrib, name);
      iAttribNotifyChildren(ih, name, value);
    }

    name = iupTableNext(ih->attrib);
  }
}
Ejemplo n.º 30
0
static void iImageStockGet(const char* name, Ihandle* *ih, const char* *native_name)
{
  IimageStock* istock = (IimageStock*)iupTableGet(istock_table, name);
  if (istock)
  {
    if (istock->image)
      *ih = istock->image;
    else if (istock->native_name)
        *native_name = istock->native_name;
    else if (istock->func)
    {
      istock->image = istock->func();
      *ih = istock->image;
    }
  }
}