Esempio n. 1
0
static int MatStoreAttribute(lua_State *L)
{
  Ihandle *ih = iuplua_checkihandle(L,1);
  const char *a = luaL_checkstring(L,2);
  int lin = luaL_checkint(L,3);
  int col = luaL_checkint(L,4);

  if (lua_isnil(L,5)) 
    IupSetAttributeId2(ih,a,lin, col,NULL);
  else 
  {
    const char *v;
    if(lua_isuserdata(L,5)) 
    {
      v = lua_touserdata(L,5);
      IupSetAttributeId2(ih,a,lin, col,v);
    }
    else 
    {
      v = luaL_checkstring(L,5);
      IupStoreAttributeId2(ih,a,lin, col,v);
    }
  }
  return 0;
}
Esempio n. 2
0
void IupMatSetfAttribute(Ihandle* ih, const char* name, int lin, int col, const char* f, ...)
{
  static char value[SHRT_MAX];
  va_list arglist;
  va_start(arglist, f);
  vsprintf(value, f, arglist);
  va_end(arglist);
  IupStoreAttributeId2(ih, name, lin, col, value);
}
Esempio n. 3
0
static int StoreAttributeId2(lua_State *L)
{
  int store;
  Ihandle *ih = iuplua_checkihandle(L, 1);
  const char *a = luaL_checkstring(L,2);
  int lin = (int)luaL_checkinteger(L,3);
  int col = (int)luaL_checkinteger(L,4);
  const char* v = iuplua_checkvalue(L, 5, &store);
  if (store)
    IupStoreAttributeId2(ih, a, lin, col, v);
  else
    IupSetAttributeId2(ih, a, lin, col, v);
  return 0;
}
Esempio n. 4
0
void IupMatStoreAttribute(Ihandle* ih, const char* name, int lin, int col, const char* value)
{
  IupStoreAttributeId2(ih, name, lin, col, value);
}
void IupCopyClassAttributes(Ihandle* src_ih, Ihandle* dst_ih)
{
  int has_attrib_id, start_id = 0;
  Iclass* ic;
  char *name;

  iupASSERT(iupObjectCheck(src_ih));
  if (!iupObjectCheck(src_ih))
    return;

  iupASSERT(iupObjectCheck(dst_ih));
  if (!iupObjectCheck(dst_ih))
    return;

  if (!IupClassMatch(dst_ih, src_ih->iclass->name))
    return;

  ic = src_ih->iclass;

  has_attrib_id = ic->has_attrib_id;
  if (iupClassMatch(ic, "tree") || /* tree can only set id attributes after map, so they can not be saved */
      iupClassMatch(ic, "cells")) /* cells does not have any saveable id attributes */
    has_attrib_id = 0;  

  if (iupClassMatch(ic, "list"))
    start_id = 1;

  name = iupTableFirst(ic->attrib_func);
  while (name)
  {
    IattribFunc* afunc = (IattribFunc*)iupTableGet(ic->attrib_func, name);
    if (afunc && !(afunc->flags & IUPAF_NO_STRING) &&  /* is a string */
                 !(afunc->flags & IUPAF_READONLY) &&   /* not read-only */
                 !(afunc->flags & IUPAF_WRITEONLY) &&  /* not write-only */
                 !(afunc->flags & IUPAF_CALLBACK))     /* not a callback */
    {
      if ((afunc->flags&IUPAF_NO_SAVE) && iupBaseNoSaveCheck(src_ih, name))  /* can not be saved */
      {
        name = iupTableNext(ic->attrib_func);
        continue;
      }

      if (!(afunc->flags & IUPAF_HAS_ID))     /* no ID */
      {
        char *value = IupGetAttribute(src_ih, name);
        if (value && value[0])    /* NOT NULL and not empty */
        {
          if (!iupStrEqualNoCase(value, IupGetAttribute(dst_ih, name)))     /* NOT already equal */
            IupStoreAttribute(dst_ih, name, value);
        }
      }
      else if (has_attrib_id)
      {
        char *value;

        if (iupStrEqual(name, "IDVALUE"))
          name = "";

        if (afunc->flags&IUPAF_HAS_ID2)
        {
          int lin, col, 
              numcol = IupGetInt(src_ih, "NUMCOL")+1,
              numlin = IupGetInt(src_ih, "NUMLIN")+1;
          for (lin=0; lin<numlin; lin++)
          {
            for (col=0; col<numcol; col++)
            {
              value = IupGetAttributeId2(src_ih, name, lin, col);
              if (value && value[0])  /* NOT NULL and not empty */
              {
                if (!iupStrEqualNoCase(value, IupGetAttributeId2(dst_ih, name, lin, col)))     /* NOT already stored */
                  IupStoreAttributeId2(dst_ih, name, lin, col, value);
              }
            }
          }
        }
        else
        {
          int id, count = IupGetInt(src_ih, "COUNT");
          for (id=start_id; id<count+start_id; id++)
          {
            value = IupGetAttributeId(src_ih, name, id);
            if (value && value[0])  /* NOT NULL and not empty */
            {
              if (!iupStrEqualNoCase(value, IupGetAttributeId(dst_ih, name, id)))     /* NOT already stored */
                IupStoreAttributeId(dst_ih, name, id, value);
            }
          }
        }
      }
    }

    name = iupTableNext(ic->attrib_func);
  }



  name = iupTableFirst(ic->attrib_func);
  while (name)
  {
    IattribFunc* afunc = (IattribFunc*)iupTableGet(ic->attrib_func, name);
    if (afunc && !(afunc->flags & IUPAF_NO_STRING) &&   /* is a string */
                 !(afunc->flags & IUPAF_READONLY) &&
                 !(afunc->flags & IUPAF_WRITEONLY) &&
                 !(afunc->flags & IUPAF_HAS_ID) &&
                 !(afunc->flags & IUPAF_CALLBACK))
    {
      char *value = IupGetAttribute(src_ih, name);
      if (value &&     /* NOT NULL */
          !iupStrEqualNoCase(value, IupGetAttribute(dst_ih, name)))     /* NOT already stored */
        IupStoreAttribute(dst_ih, name, value);
    }

    name = iupTableNext(ic->attrib_func);
  }
}