int IupGetAllAttributes(Ihandle* ih, char** names, int n) { char *name; int i = 0; iupASSERT(iupObjectCheck(ih)); if (!iupObjectCheck(ih)) return 0; if (!names || !n) return iupTableCount(ih->attrib); name = iupTableFirst(ih->attrib); while (name) { names[i] = name; i++; if (i == n) break; name = iupTableNext(ih->attrib); } return i; }
void iupNamesDestroyHandles(void) { char *name; Ihandle** ih_array, *ih; int count, i = 0; count = iupTableCount(inames_strtable); if (!count) return; ih_array = (Ihandle**)malloc(count * sizeof(Ihandle*)); /* store the names before updating so we can remove elements in the loop */ name = iupTableFirst(inames_strtable); while (name) { ih = (Ihandle*)iupTableGetCurr(inames_strtable); if (iupObjectCheck(ih)) { ih_array[i] = ih; i++; } name = iupTableNext(inames_strtable); } count = i; for (i = 0; i < count; i++) { if (iupObjectCheck(ih_array[i])) IupDestroy(ih_array[i]); } free(ih_array); }
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); }
void iupNamesDestroyHandles(void) { char *name; Ihandle** ih_array, *ih; int count, i = 0; count = iupTableCount(inames_strtable); if (!count) return; ih_array = (Ihandle**)malloc(count * sizeof(Ihandle*)); memset(ih_array, 0, count * sizeof(Ihandle*)); /* store the handles before updating so we can remove elements in the loop */ name = iupTableFirst(inames_strtable); while (name) { ih = (Ihandle*)iupTableGetCurr(inames_strtable); if (iupObjectCheck(ih)) /* here must be a handle */ { /* only need to destroy the top parent handle */ ih = iNameGetTopParent(ih); /* check if already in the array */ if (iNameCheckArray(ih_array, i, ih)) { ih_array[i] = ih; i++; } } name = iupTableNext(inames_strtable); } count = i; for (i = 0; i < count; i++) { if (iupObjectCheck(ih_array[i])) /* here must be a handle */ IupDestroy(ih_array[i]); } free(ih_array); }
int iupRegisterGetClasses(char *list[], int n) { int i = 0; char* name = iupTableFirst(iregister_table); if (!list || !n) return iupTableCount(iregister_table); while (name) { list[i] = name; i++; if (i == n) break; name = iupTableNext(iregister_table); } return i; }
int IupGetAllNames(char** names, int n) { int i = 0; char* name; if (!names || !n) return iupTableCount(inames_strtable); name = iupTableFirst(inames_strtable); while (name) { names[i] = name; i++; if (i == n) break; name = iupTableNext(inames_strtable); } return i; }
int IupGetClassCallbacks(const char* classname, char** names, int n) { Iclass* ic; int i = 0; char* name; IattribFunc* afunc; iupASSERT(classname!=NULL); if (!classname) return 0; ic = iupRegisterFindClass(classname); if (!ic) return -1; if (!names || !n) return iupTableCount(ic->attrib_func); name = iupTableFirst(ic->attrib_func); while (name) { afunc = (IattribFunc*)iupTableGetCurr(ic->attrib_func); if (afunc->flags&IUPAF_CALLBACK) { names[i] = name; i++; if (i == n) break; } name = iupTableNext(ic->attrib_func); } return i; }