void iupClassObjectEnsureDefaultAttributes(Ihandle* ih) { Iclass* ic; char *name; ic = ih->iclass; name = iupTableFirst(ic->attrib_func); while (name) { IattribFunc* afunc = (IattribFunc*)iupTableGetCurr(ic->attrib_func); if (afunc && afunc->set && (afunc->default_value || afunc->system_default) && !(afunc->flags & IUPAF_NO_DEFAULTVALUE) && /* can has default */ !(afunc->flags & IUPAF_NO_STRING) && /* is a string */ !(afunc->flags & IUPAF_HAS_ID)) { if ((!iupStrEqualNoCase(afunc->default_value, afunc->system_default)) || (afunc->call_global_default && iupGlobalDefaultColorChanged(afunc->default_value))) { if ((!ih->handle && (afunc->flags & IUPAF_NOT_MAPPED)) || (ih->handle && !(afunc->flags & IUPAF_NOT_MAPPED))) { char* value = iupAttribGet(ih, name); if (!value) /* if set will be updated later */ afunc->set(ih, iClassGetDefaultValue(afunc)); } } } name = iupTableNext(ic->attrib_func); } }
char* IupGetName(Ihandle* ih) { char *name; if (!ih) /* no iupASSERT needed here */ return NULL; if (iupObjectCheck(ih)) { /* check the cache first, but must be a handle */ name = iupAttribGet(ih, "_IUP_LASTHANDLENAME"); if (name) return name; } /* check for an internal name */ name = iupAttribGetHandleName(ih); if (name) return name; /* search for the name */ name = iupTableFirst(inames_strtable); while (name) { if ((Ihandle*)iupTableGetCurr(inames_strtable) == ih) return name; name = iupTableNext(inames_strtable); } return NULL; }
static void iImageUnMapMethod(Ihandle* ih) { char *name; void* native_data; native_data = iupAttribGetStr(ih, "_IUPIMAGE_ICON"); if (native_data) { iupdrvImageDestroy(native_data, IUPIMAGE_ICON); iupAttribSetStr(ih, "_IUPIMAGE_ICON", NULL); } native_data = iupAttribGetStr(ih, "_IUPIMAGE_CURSOR"); if (native_data) { iupdrvImageDestroy(native_data, IUPIMAGE_CURSOR); iupAttribSetStr(ih, "_IUPIMAGE_CURSOR", NULL); } name = iupTableFirst(ih->attrib); while (name) { if (iupStrEqualPartial(name, "_IUPIMAGE_")) { native_data = iupTableGetCurr(ih->attrib); if (native_data) iupdrvImageDestroy(native_data, IUPIMAGE_IMAGE); } name = iupTableNext(ih->attrib); } }
int IupGetAllDialogs(char** names, int n) { int i = 0; char* name; if (!names || !n) return iNamesCountDialogs(); name = iupTableFirst(inames_strtable); while (name) { Ihandle* dlg = (Ihandle*)iupTableGetCurr(inames_strtable); if (iupObjectCheck(dlg) && /* here must be a handle */ dlg->iclass->nativetype == IUP_TYPEDIALOG) { names[i] = name; i++; if (i == n) break; } name = iupTableNext(inames_strtable); } return i; }
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 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); } }
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); }
char* IupGetAttributes (Ihandle *n) { static char *buffer=NULL; char *a, *v; char sb[128]; int first = 1; if ((n == NULL) || (env(n) == NULL)) return NULL; if (buffer == NULL) { buffer = (char *) malloc (sizeof(char)*10240); if (buffer == NULL) return NULL; } buffer[0]='\0'; a=iupTableFirst(env(n)); while (a) { if (!first) strcat(buffer,","); first=0; v = IupGetAttribute(n,a); if (iupIsPointer(a)) { sprintf(sb, "%p", (void*) v); v = sb; } strcat(buffer, a); strcat(buffer,"=\""); strcat(buffer, v); strcat(buffer,"\""); a=iupTableNext(env(n)); } return buffer; }
static int iMatrixExUndoDataSwap(ImatExData* matex_data, IundoData* undo_data) { char* id = iupTableFirst(undo_data->data_table); while (id) { char *value, *old_value; int lin=1, col=1; iupStrToIntInt(id, &lin, &col, ':'); value = (char*)iupTableGetCurr(undo_data->data_table); old_value = iupStrDup(iupMatrixExGetCellValue(matex_data->ih, lin, col, 0)); /* get internal value */ iupMatrixExSetCellValue(matex_data->ih, lin, col, value); if (!old_value) iupTableSetCurr(undo_data->data_table, (void*)"", IUPTABLE_POINTER); else { iupTableSetCurr(undo_data->data_table, (void*)old_value, IUPTABLE_STRING); free(old_value); } if (!iupMatrixExBusyInc(matex_data)) return 0; id = iupTableNext(undo_data->data_table); } return 1; }
static void iClassReleaseAttribFuncTable(Iclass* ic) { char* name = iupTableFirst(ic->attrib_func); while (name) { void* afunc = iupTableGetCurr(ic->attrib_func); free(afunc); name = iupTableNext(ic->attrib_func); } iupTableDestroy(ic->attrib_func); }
void iupRegisterFinish(void) { char* name = iupTableFirst(iregister_table); while (name) { Iclass* ic = (Iclass*)iupTableGetCurr(iregister_table); iupClassRelease(ic); name = iupTableNext(iregister_table); } iupTableDestroy(iregister_table); iregister_table = NULL; }
int IupGetAllNames(char *names[], int n) { int i = 0; names[i]=iupTableFirst(inames_strtable); while (names[i]) { i++; if (i == n) break; names[i]=iupTableNext(inames_strtable); } return i; }
static int iNamesCountDialogs(void) { int i = 0; char* name = iupTableFirst(inames_strtable); while (name) { Ihandle* dlg = (Ihandle*)iupTableGetCurr(inames_strtable); if (iupObjectCheck(dlg) && dlg->iclass->nativetype == IUP_TYPEDIALOG) i++; name = iupTableNext(inames_strtable); } return i; }
static char* iNameFindHandle(Ihandle *ih) { /* search for a name */ char* name = iupTableFirst(inames_strtable); while (name) { /* return the first one found */ if ((Ihandle*)iupTableGetCurr(inames_strtable) == ih) return name; name = iupTableNext(inames_strtable); } return NULL; }
void iupImageStockFinish(void) { char* name = iupTableFirst(istock_table); while (name) { IimageStock* istock = (IimageStock*)iupTableGetCurr(istock_table); if (iupObjectCheck(istock->image)) IupDestroy(istock->image); free(istock); name = iupTableNext(istock_table); } iupTableDestroy(istock_table); istock_table = NULL; }
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); } }
int IupGetAllDialogs(char *names[], int n) { int i = 0; names[i]=iupTableFirst(inames_strtable); while (names[i]) { Ihandle *d=(Ihandle*)iupTableGetCurr(inames_strtable); if (d && type(d)==DIALOG_) i++; if (i == n) break; names[i]=iupTableNext(inames_strtable); } return i; }
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); }
int IupGetAllAttributes(Ihandle* ih, char *names[], int n) { char *name; int i = 0; name = iupTableFirst(env(ih)); while (name) { strcpy(names[i], name); i++; if (i == n) break; name = iupTableNext(env(ih)); } return i; }
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 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 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; }
char* IupGetAttributes(Ihandle *ih) { char *buffer; char *name, *value; char sb[128]; iupASSERT(iupObjectCheck(ih)); if (!iupObjectCheck(ih)) return NULL; buffer = iupStrGetMemory(10240); buffer[0] = 0; name = iupTableFirst(ih->attrib); while (name) { if (!iupAttribIsInternal(name)) { if (buffer[0] != 0) strcat(buffer,","); value = iupTableGetCurr(ih->attrib); if (iupAttribIsPointer(ih, name)) { sprintf(sb, "%p", (void*) value); value = sb; } strcat(buffer, name); strcat(buffer,"=\""); strcat(buffer, value); strcat(buffer,"\""); } name = iupTableNext(ih->attrib); } return buffer; }
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; }
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); } }