static int iGlobalChangingDefaultColor(const char *name) { if (iupClassIsGlobalDefault(name, 1)) { char str[50] = "_IUP_USER_DEFAULT_"; strcat(str, name); iupTableSet(iglobal_table, str, (void*)"1", IUPTABLE_POINTER); /* mark as changed by the User */ return 1; } return 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); }
void IupStoreGlobal(const char *name, const char *value) { assert(name); if (!name) return; if (!iupdrvSetGlobal(name, value)) { if (!value) iupTableRemove(iglobalenv, name); else iupTableSet(iglobalenv, name, (void*)value, IUP_STRING); } }
static int iGlobalChangingDefaultColor(const char *name) { if (iupStrEqual(name, "DLGBGCOLOR") || iupStrEqual(name, "DLGFGCOLOR") || iupStrEqual(name, "MENUBGCOLOR") || iupStrEqual(name, "MENUFGCOLOR") || iupStrEqual(name, "TXTBGCOLOR") || iupStrEqual(name, "TXTFGCOLOR")) { char str[50] = "_IUP_USER_DEFAULT_"; strcat(str, name); iupTableSet(iglobal_table, str, (void*)"1", IUPTABLE_POINTER); /* mark as changed by the User */ return 1; } return 0; }
void iupClassRegisterAttributeId2(Iclass* ic, const char* name, IattribGetId2Func _get, IattribSetId2Func _set, 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 = (IattribGetFunc)_get; afunc->set = (IattribSetFunc)_set; afunc->default_value = NULL; afunc->system_default = NULL; afunc->flags = _flags|IUPAF_HAS_ID2|IUPAF_HAS_ID|IUPAF_NO_INHERIT|IUPAF_NO_DEFAULTVALUE; afunc->call_global_default = 0; iupTableSet(ic->attrib_func, name, (void*)afunc, IUPTABLE_POINTER); }
Ihandle* IupSetHandle(const char *name, Ihandle *ih) { Ihandle *old_ih; iupASSERT(name!=NULL); if (!name) return NULL; /* ih here can be also an user pointer, not just an Ihandle* */ /* we do not check if the handle already has names, it may has many different names */ 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)) iupAttribSetStr(ih, "HANDLENAME", name); } else { iupTableRemove(inames_strtable, name); /* clear the name from the cache if it is a valid handle */ if (iupObjectCheck(old_ih)) { char* last_name = iupAttribGet(old_ih, "HANDLENAME"); if (last_name && iupStrEqual(last_name, name)) { iupAttribSet(old_ih, "HANDLENAME", NULL); /* remove also from the cache */ last_name = iNameFindHandle(old_ih); if (last_name) iupAttribSetStr(old_ih, "HANDLENAME", last_name); /* if found another name save it in the cache */ } } } return old_ih; }
void IupStoreGlobal(const char *name, const char *value) { iupASSERT(name!=NULL); if (!name) return; if (iupStrEqual(name, "DEFAULTFONTSIZE")) { iupSetDefaultFontSizeGlobalAttrib(value); return; } if (iupdrvSetGlobal(name, value)) { if (!value) iupTableRemove(iglobal_table, name); else iupTableSet(iglobal_table, name, (void*)value, IUPTABLE_STRING); } }
static void iupEnvParse(Ihandle *n, const char* attr) { char env_buffer[256]; char* a=NULL; char* v=NULL; int state = 'a'; /* get attribute */ int end = 0; env_str = attr; for (;;) { switch (iupEnvToken(env_buffer)) { case TK_END: /* procedimento igual ao TK_COMMA */ end = 1; case TK_COMMA: if (a != NULL) { iupTableSet(env(n), a, v, IUP_STRING); iupCpiSetAttribute (n, a, v); free(a); } if (end) return; a=v=NULL; state = 'a'; break; case TK_SET: state = 'v'; /* get value */ break; case TK_NAME: if (state == 'a') a = iupStrDup(env_buffer); else v = env_buffer; break; } } }
void iupmotGetInitAttTable (void) { int i; if (attrEnv) return; store[0].attr = IUP_ACTIVE; store[0].type = WIDGET_; store[1].attr = IUP_FGCOLOR; store[1].type = WIDGET_; store[2].attr = IUP_BGCOLOR; store[2].type = WIDGET_; store[3].attr = IUP_WID; store[3].type = QUERY_; store[4].attr = IUP_X; store[4].type = QUERY_; store[5].attr = IUP_Y; store[5].type = QUERY_; store[6].attr = "XSCREEN"; store[6].type = QUERY_; store[7].attr = "XWINDOW"; store[7].type = QUERY_; store[8].attr = "XDISPLAY"; store[8].type = QUERY_; store[9].attr = "SELECTCOLOR"; store[9].type = TOGGLE_; store[10].attr = IUP_VALUE; store[10].type = TOGGLE_; store[11].attr = IUP_VALUE; store[11].type = MULTILINE_; store[12].attr = IUP_VALUE; store[12].type = TEXT_; store[13].attr = IUP_VALUE; store[13].type = ITEM_; store[14].attr = IUP_VALUE; store[14].type = LIST_; store[15].attr = IUP_VALUE; store[15].type = RADIO_; store[16].type = IUP_NC; store[16].attr = TEXT_; store[17].type = IUP_CARET; store[17].attr = TEXT_; store[18].type = IUP_CARET; store[18].attr = MULTILINE_; store[19].type = IUP_SELECTION; store[19].attr = TEXT_; store[20].type = IUP_SELECTION; store[20].attr = MULTILINE_; store[21].type = IUP_SELECTEDTEXT; store[21].attr = TEXT_; store[22].type = IUP_SELECTEDTEXT; store[22].attr = MULTILINE_; store[23].type = IUP_POSX; store[23].attr = CANVAS_; store[24].type = IUP_POSY; store[24].attr = CANVAS_; store[25].type = IUP_CONID; store[25].attr = CANVAS_; store[26].type = IUP_ALIGNMENT; store[26].attr = BUTTON_; store[27].type = IUP_MULTIPLE; store[27].attr = LIST_; store[28].type = IUP_ALIGNMENT; store[28].attr = LABEL_; store[29].type = IUP_ALIGNMENT; store[29].attr = TEXT_; store[30].type = IUP_ALIGNMENT; store[30].attr = MULTILINE_; attrEnv = iupTableCreate(IUPTABLE_STRINGINDEXED); attrDefEnv = iupTableCreate(IUPTABLE_STRINGINDEXED); for (i=0; i<NATTRIBUTES; i++) { iupTableSet(attrEnv, attributes[i].name, attributes[i].get, IUP_POINTER); iupTableSet(attrDefEnv, attributes[i].name, attributes[i].def, IUP_POINTER); } }
void iupTableSetFunc(Itable *it, const char *key, Ifunc func) { iupTableSet(it, key, (void*)func, IUPTABLE_FUNCPOINTER); /* type cast from function pointer to void* */ }