static void iMatrixMarkCellSet(Ihandle* ih, int lin, int col, int mark, IFniii markedit_cb, IFnii mark_cb) { /* called only when MARKMODE=CELL */ if (mark == -1) mark = !iupMatrixMarkCellGet(ih, lin, col, mark_cb); if (ih->data->callback_mode) { if (markedit_cb && !ih->data->inside_markedit_cb) { ih->data->inside_markedit_cb = 1; markedit_cb(ih, lin, col, mark); ih->data->inside_markedit_cb = 0; } else { if (mark) iupAttribSetId2(ih, "MARK", lin, col, "1"); else iupAttribSetId2(ih, "MARK", lin, col, NULL); } } else { if (mark) ih->data->cells[lin][col].flags |= IMAT_IS_MARKED; else ih->data->cells[lin][col].flags &= ~IMAT_IS_MARKED; } }
static int iMatrixListSetTitleAttrib(Ihandle* ih, const char* value) { ImatrixListData* mtxList = (ImatrixListData*)iupAttribGet(ih, "_IUPMTXLIST_DATA"); if (!ih->handle) iupAttribSetId2(ih, "", 0, mtxList->label_col, value); else iupMatrixSetValue(ih, 0, mtxList->label_col, value, 0); 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); } } } }
int iupMatrixSetMarkAttrib(Ihandle* ih, int lin, int col, const char* value) { if (ih->data->mark_mode == IMAT_MARK_NO) return 0; if (lin >= 0 && col >= 0) /* both are specified */ { if (!iupMatrixCheckCellPos(ih, lin, col)) return 0; if (ih->data->mark_mode == IMAT_MARK_CELL) { int mark, ret = 0; if (lin == 0 || col == 0) /* title can NOT have a mark */ return 0; mark = iupStrBoolean(value); if (ih->data->callback_mode) { IFniii markedit_cb = (IFniii)IupGetCallback(ih, "MARKEDIT_CB"); if (markedit_cb && !ih->data->inside_markedit_cb) { ih->data->inside_markedit_cb = 1; markedit_cb(ih, lin, col, mark); ih->data->inside_markedit_cb = 0; } else { if (mark) { iupAttribSetId2(ih, "MARK", lin, col, "1"); ret = 1; } else iupAttribSetId2(ih, "MARK", lin, col, NULL); } } else { if (mark) ih->data->cells[lin][col].flags |= IMAT_IS_MARKED; else ih->data->cells[lin][col].flags &= ~IMAT_IS_MARKED; } if (ih->handle) { /* This assumes that the matrix has been draw completely previously */ iupMatrixPrepareDrawData(ih); iupMatrixDrawCells(ih, lin, col, lin, col); } return ret; } else { int mark = iupStrBoolean(value); if (ih->data->mark_mode & IMAT_MARK_LIN && lin>0) { if (mark) ih->data->lines.dt[lin].flags |= IMAT_IS_MARKED; else ih->data->lines.dt[lin].flags &= ~IMAT_IS_MARKED; } if (ih->data->mark_mode & IMAT_MARK_COL && col>0) { if (mark) ih->data->columns.dt[col].flags |= IMAT_IS_MARKED; else ih->data->columns.dt[col].flags &= ~IMAT_IS_MARKED; } if (ih->handle) { /* This assumes that the matrix has been drawn completely previously */ iupMatrixPrepareDrawData(ih); iupMatrixDrawCells(ih, lin, col, lin, col); } } } return 0; }