static char* iMatrixListGetTitleAttrib(Ihandle* ih) { ImatrixListData* mtxList = (ImatrixListData*)iupAttribGet(ih, "_IUPMTXLIST_DATA"); if (!ih->handle) return iupAttribGetId2(ih, "", 0, mtxList->label_col); else return iupMatrixGetValue(ih, 0, mtxList->label_col); }
static int iMatrixDrawGetFrameVertColor(Ihandle* ih, int lin, int col, long *framecolor) { if (ih->data->checkframecolor && (ih->data->callback_mode || ih->data->cells[lin][col].flags & IMAT_HAS_FRAMEVERTCOLOR || ih->data->columns.dt[col].flags & IMAT_HAS_FRAMEVERTCOLOR)) { char* color; unsigned char r,g,b; color = iupAttribGetId2(ih, "FRAMEVERTCOLOR", lin, col); if (!color) color = iupAttribGetId2(ih, "FRAMEVERTCOLOR", IUP_INVALID_ID, col); if (iupStrEqual(color, "BGCOLOR")) return 1; if (framecolor && iupStrToRGB(color, &r, &g, &b)) *framecolor = cdEncodeColor(r, g, b); } return 0; }
static char* iMatrixExGetCellAttrib(Ihandle* ih, const char* attrib, int lin, int col) { char* value = NULL; /* 1 - check for this cell */ value = iupAttribGetId2(ih, attrib, lin, col); if (!value) { /* 2 - check for this line, if not title col */ if (col != 0) value = iupAttribGetId2(ih, attrib, lin, IUP_INVALID_ID); if (!value) { /* 3 - check for this column, if not title line */ if (lin != 0) value = iupAttribGetId2(ih, attrib, IUP_INVALID_ID, col); } } return value; }
static int iMatrixExIsBoldLine(Ihandle* ih, int lin) { char* value; if (lin==0) return 0; value = iupAttribGetId2(ih, "FONT", lin, IUP_INVALID_ID); if (value) { if (strstr(value, "Bold")||strstr(value, "BOLD")) return 1; } return 0; }
static void iMatrixGetInitialValues(Ihandle* ih) { int lin, col; char* value; for (lin=0; lin<ih->data->lines.num; lin++) { for (col=0; col<ih->data->columns.num; col++) { value = iupAttribGetId2(ih, "", lin, col); if (value) { /* get the initial value and remove it from the hash table */ if (*value) ih->data->cells[lin][col].value = iupStrDup(value); iupAttribSetId2(ih, "", lin, col, NULL); } } } }
static void iMatrixGetCellAlign(Ihandle* ih, int lin, int col, int *col_alignment, int *lin_alignment) { char* align = iupAttribGetId2(ih, "ALIGN", lin, col); if (align) { char col_align[30], lin_align[30]; if (iupStrToStrStr(align, lin_align, col_align, ':')) { if (iupStrEqualNoCase(col_align, "ARIGHT")) *col_alignment = IMAT_ALIGN_END; else if (iupStrEqualNoCase(col_align, "ACENTER")) *col_alignment = IMAT_ALIGN_CENTER; else if (iupStrEqualNoCase(col_align, "ALEFT")) *col_alignment = IMAT_ALIGN_START; if (iupStrEqualNoCase(col_align, "ABOTTOM")) *lin_alignment = IMAT_ALIGN_END; else if (iupStrEqualNoCase(col_align, "ACENTER")) *lin_alignment = IMAT_ALIGN_CENTER; else if (iupStrEqualNoCase(col_align, "ATOP")) *lin_alignment = IMAT_ALIGN_START; } } }
void IupSaveClassAttributes(Ihandle* ih) { int has_attrib_id, start_id = 0; Iclass* ic; char *name; iupASSERT(iupObjectCheck(ih)); if (!iupObjectCheck(ih)) return; ic = 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(ih, name)) /* can not be saved */ { name = iupTableNext(ic->attrib_func); continue; } if (!(afunc->flags & IUPAF_HAS_ID)) /* no ID */ { int inherit; char *def_value; char *value = iupClassObjectGetAttribute(ih, name, &def_value, &inherit); if (value && value[0]) /* NOT NULL and not empty */ { if ((def_value && iupStrEqualNoCase(def_value, value)) || /* equal to the default value */ (!def_value && iupStrFalse(value))) /* default=NULL and value=NO */ { name = iupTableNext(ic->attrib_func); continue; } if (!iupStrEqualNoCase(value, iupAttribGet(ih, name))) /* NOT already stored */ iupAttribSetStr(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(ih, "NUMCOL")+1, numlin = IupGetInt(ih, "NUMLIN")+1; for (lin=0; lin<numlin; lin++) { for (col=0; col<numcol; col++) { value = iupClassObjectGetAttributeId2(ih, name, lin, col); if (value && value[0]) /* NOT NULL and not empty */ { if (!iupStrEqualNoCase(value, iupAttribGetId2(ih, name, lin, col))) /* NOT already stored */ iupAttribSetStrId2(ih, name, lin, col, value); } } } } else { int id, count = IupGetInt(ih, "COUNT"); for (id=start_id; id<count+start_id; id++) { value = iupClassObjectGetAttributeId(ih, name, id); if (value && value[0]) /* NOT NULL and not empty */ { if (!iupStrEqualNoCase(value, iupAttribGetId(ih, name, id))) /* NOT already stored */ iupAttribSetStrId(ih, name, id, value); } } } } } name = iupTableNext(ic->attrib_func); } }