Пример #1
0
static void motFontDlgInitFamilyList(Ihandle* ih)
{
  int i, j = 1, count = 0;
  char prev[1024]="", family[1024];
  Ihandle* list1 = IupGetDialogChild(ih, "LIST1");            /* this will reduce the initial number */
  char**font_list_str = XListFonts(iupmot_display, "-*-*-medium-r-*-*-0-0-*-*-*-*-*-*", 32767, &count);
  char*backup_list[32767];

  if (!font_list_str)
    return;

  memcpy(backup_list, font_list_str, count*sizeof(char*));
  qsort(font_list_str, count, sizeof(char*), motFontDlgCompareStr);

  for (i=0; i<count; i++)
  {
    motFontGetFamily(font_list_str[i], family);

    if (!iupStrEqual(family, prev))  /* avoid duplicates */
    {
      IupStoreAttributeId(list1, "", j, family);
      strcpy(prev, family);
      j++;
    }
  }
  IupSetAttributeId(list1, "", j, NULL);

  memcpy(font_list_str, backup_list, count*sizeof(char*));
  XFreeFontNames(font_list_str);
}
Пример #2
0
void IupSetfAttributeId(Ihandle *ih, const char* name, int id, const char* f, ...)
{
  static char value[SHRT_MAX];
  va_list arglist;
  va_start(arglist, f);
  vsprintf(value, f, arglist);
  va_end(arglist);
  IupStoreAttributeId(ih, name, id, value);
}
Пример #3
0
void IupTreeSetfAttribute(Ihandle* ih, const char* a, int id, const char* f, ...)
{
  int size;
  char* v = iupStrGetLargeMem(&size);
  va_list arglist;
  va_start(arglist, f);
  vsnprintf(v, size, f, arglist);
  va_end(arglist);
  IupStoreAttributeId(ih, a, id, v);
}
Пример #4
0
static int StoreAttributeId(lua_State *L)
{
  int store;
  Ihandle *ih = iuplua_checkihandle(L,1);
  const char *a = luaL_checkstring(L,2);
  int id = (int)luaL_checkinteger(L,3);
  const char* v = iuplua_checkvalue(L, 4, &store);
  if (store)
    IupStoreAttributeId(ih, a, id, v);
  else
    IupSetAttributeId(ih, a, id, v);
  return 0;
}
Пример #5
0
static int StoreAttributeId(lua_State *L)
{
  Ihandle *ih = iuplua_checkihandle(L,1);
  const char *a = luaL_checkstring(L,2);
  int id = luaL_checkint(L,3);

  if (lua_isnil(L,4)) 
    IupSetAttributeId(ih,a,id,NULL);
  else 
  {
    const char *v;
    if(lua_isuserdata(L,4)) 
    {
      v = lua_touserdata(L,4);
      IupSetAttributeId(ih,a,id,v);
    }
    else 
    {
      v = luaL_checkstring(L,4);
      IupStoreAttributeId(ih,a,id,v);
    }
  }
  return 0;
}
Пример #6
0
void IupTreeStoreAttribute(Ihandle* ih, const char* a, int id, const char* v)
{
  IupStoreAttributeId(ih, a, id, v);
}
Пример #7
0
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);
  }
}