static int iMatrixSetMarkMultipleAttrib(Ihandle* ih, const char* value) { if (iupStrBoolean(value)) ih->data->mark_multiple = 1; else ih->data->mark_multiple = 0; if (ih->handle) { iupMatrixMarkClearAll(ih, 0); iupMatrixDraw(ih, 1); } return 0; }
static int iMatrixSetMarkAreaAttrib(Ihandle* ih, const char* value) { if (iupStrEqualNoCase(value, "NOT_CONTINUOUS")) ih->data->mark_continuous = 0; else ih->data->mark_continuous = 1; if (ih->handle) { iupMatrixMarkClearAll(ih, 0); iupMatrixDraw(ih, 1); } return 0; }
static int iMatrixSetMarkModeAttrib(Ihandle* ih, const char* value) { if (iupStrEqualNoCase(value, "CELL")) ih->data->mark_mode = IMAT_MARK_CELL; else if (iupStrEqualNoCase(value, "LIN")) ih->data->mark_mode = IMAT_MARK_LIN; else if (iupStrEqualNoCase(value, "COL")) ih->data->mark_mode = IMAT_MARK_COL; else if(iupStrEqualNoCase(value, "LINCOL")) ih->data->mark_mode = IMAT_MARK_LINCOL; else ih->data->mark_mode = IMAT_MARK_NO; if (ih->handle) { iupMatrixMarkClearAll(ih, 0); iupMatrixDraw(ih, 1); } return 0; }
int iupMatrixSetMarkedAttrib(Ihandle* ih, const char* value) { int lin, col, mark; IFniii markedit_cb; if (ih->data->mark_mode == IMAT_MARK_NO) return 0; if (!value) iupMatrixMarkClearAll(ih, 1); else if (*value == 'C' || *value == 'c') /* columns */ { if (ih->data->mark_mode == IMAT_MARK_LIN) return 0; value++; /* skip C mark */ if ((int)strlen(value) != ih->data->columns.num-1) return 0; markedit_cb = (IFniii)IupGetCallback(ih, "MARKEDIT_CB"); for(col = 1; col < ih->data->columns.num; col++) { if (*value++ == '1') mark = 1; else mark = 0; /* mark all the cells for that column */ if (ih->data->mark_mode == IMAT_MARK_CELL) { for(lin = 1; lin < ih->data->lines.num; lin++) iMatrixMarkCellSet(ih, lin, col, mark, markedit_cb, NULL); } else iMatrixMarkColSet(ih, col, mark); } if (ih->data->mark_mode & IMAT_MARK_LIN) iMatrixMarkAllLinCol(&(ih->data->lines), 0); } else if (*value == 'L' || *value == 'l') /* lines */ { if (ih->data->mark_mode == IMAT_MARK_COL) return 0; value++; /* skip L mark */ if ((int)strlen(value) != ih->data->lines.num-1) return 0; markedit_cb = (IFniii)IupGetCallback(ih, "MARKEDIT_CB"); for(lin = 1; lin < ih->data->lines.num; lin++) { if (*value++ == '1') mark = 1; else mark = 0; /* Mark all the cells for that line */ if (ih->data->mark_mode == IMAT_MARK_CELL) { for(col = 1; col < ih->data->columns.num; col++) iMatrixMarkCellSet(ih, lin, col, mark, markedit_cb, NULL); } else iMatrixMarkLinSet(ih, lin, mark); } if (ih->data->mark_mode & IMAT_MARK_COL) iMatrixMarkAllLinCol(&(ih->data->columns), 0); } else if (ih->data->mark_mode == IMAT_MARK_CELL) /* cells */ { if ((int)strlen(value) != (ih->data->lines.num-1)*(ih->data->columns.num-1)) return 0; markedit_cb = (IFniii)IupGetCallback(ih, "MARKEDIT_CB"); for(lin = 1; lin < ih->data->lines.num; lin++) { for(col = 1; col < ih->data->columns.num; col++) { if (*value++ == '1') mark = 1; else mark = 0; iMatrixMarkCellSet(ih, lin, col, mark, markedit_cb, NULL); } } } if (ih->handle) iupMatrixDraw(ih, 1); return 0; }
void iupMatrixMarkBlockSet(Ihandle* ih, int ctrl, int lin1, int col1) { int mark = 1, mark_full_all, lin, col; IFniii markedit_cb = NULL; IFnii mark_cb = NULL; iupMatrixMarkBlockReset(ih); iupMatrixPrepareDrawData(ih); if (!ih->data->mark_multiple || ih->data->mark_continuous || !ctrl) { iupMatrixMarkClearAll(ih, 1); iupMatrixDraw(ih, 0); } else mark = -1; /* toggle mark state */ ih->data->mark_full1 = 0; mark_full_all = 0; if (lin1 == 0 && col1 == 0) { if ((ih->data->mark_mode == IMAT_MARK_CELL && ih->data->mark_multiple) || ih->data->mark_mode == IMAT_MARK_COL || ih->data->mark_mode == IMAT_MARK_LIN) mark_full_all = 1; } /* If it was pointing for a column title... */ else if (lin1 == 0) { if ((ih->data->mark_mode == IMAT_MARK_CELL && ih->data->mark_multiple) || ih->data->mark_mode & IMAT_MARK_COL) ih->data->mark_full1 = IMAT_PROCESS_COL; } /* If it was pointing for a line title... */ else if (col1 == 0) { if ((ih->data->mark_mode == IMAT_MARK_CELL && ih->data->mark_multiple) || ih->data->mark_mode & IMAT_MARK_LIN) ih->data->mark_full1 = IMAT_PROCESS_LIN; } if (ih->data->mark_mode == IMAT_MARK_CELL && ih->data->callback_mode) { markedit_cb = (IFniii)IupGetCallback(ih, "MARKEDIT_CB"); mark_cb = (IFnii)IupGetCallback(ih, "MARK_CB"); } if (mark_full_all) { if (ih->data->mark_mode == IMAT_MARK_CELL) { for (col = 1; col < ih->data->columns.num; col++) { for(lin = 1; lin < ih->data->lines.num; lin++) iMatrixMarkCellSet(ih, lin, col, mark, markedit_cb, mark_cb); } } else if (ih->data->mark_mode == IMAT_MARK_LIN) { for(lin = 1; lin < ih->data->lines.num; lin++) iMatrixMarkLinSet(ih, lin, mark); iupMatrixDrawTitleLines(ih, 1, ih->data->lines.num-1); } else if (ih->data->mark_mode == IMAT_MARK_COL) { for (col = 1; col < ih->data->columns.num; col++) iMatrixMarkColSet(ih, col, mark); iupMatrixDrawTitleColumns(ih, 1, ih->data->columns.num-1); } iupMatrixDrawCells(ih, 1, 1, ih->data->lines.num-1, ih->data->columns.num-1); } else iMatrixMarkItem(ih, lin1, col1, mark, markedit_cb, mark_cb); ih->data->mark_lin1 = lin1; ih->data->mark_col1 = col1; ih->data->mark_block = 1; }
int iupMatrixProcessKeyPress(Ihandle* ih, int c) { /* This function is also called from inside the keyboard callbacks of the Text and Dropdown list when in edition mode */ int ret = IUP_IGNORE; /* default for processed keys */ /* Hide (off) the marked cells if the key is not tab/del */ if (c != K_TAB && c != K_sTAB && c != K_DEL && c != K_sDEL) iupMatrixMarkClearAll(ih, 1); /* If the focus is not visible, a scroll is done for that the focus to be visible */ if (!iupMatrixAuxIsCellFullVisible(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell)) iupMatrixScrollToVisible(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell); switch (c) { case K_CR+2000: /* used by the iMatrixEditTextKeyAny_CB and iMatrixEditDropDownKeyAny_CB */ if (iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE) break; iupMatrixScrollKeyCr(ih); iupMatrixAuxCallEnterCellCb(ih); break; case K_cHOME: case K_sHOME: case K_HOME: if(iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE) break; iupMatrixScrollKeyHome(ih); ih->data->homekeycount++; iupMatrixAuxCallEnterCellCb(ih); break; case K_cEND: case K_sEND: case K_END: if(iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE) break; iupMatrixScrollKeyEnd(ih); ih->data->endkeycount++; iupMatrixAuxCallEnterCellCb(ih); break; case K_sTAB: case K_TAB: return IUP_CONTINUE; /* do not redraw */ case K_cLEFT: case K_sLEFT: case K_LEFT: if (iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE) break; iupMatrixScrollKeyLeft(ih); iupMatrixAuxCallEnterCellCb(ih); break; case K_cRIGHT: case K_sRIGHT: case K_RIGHT: if(iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE) break; iupMatrixScrollKeyRight(ih); iupMatrixAuxCallEnterCellCb(ih); break; case K_cUP: case K_sUP: case K_UP: if(iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE) break; iupMatrixScrollKeyUp(ih); iupMatrixAuxCallEnterCellCb(ih); break ; case K_cDOWN: case K_sDOWN: case K_DOWN: if(iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE) break; iupMatrixScrollKeyDown(ih); iupMatrixAuxCallEnterCellCb(ih); break; case K_sPGUP: case K_PGUP: if(iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE) break; iupMatrixScrollKeyPgUp(ih); iupMatrixAuxCallEnterCellCb(ih); break; case K_sPGDN: case K_PGDN: if(iupMatrixAuxCallLeaveCellCb(ih) == IUP_IGNORE) break; iupMatrixScrollKeyPgDown(ih); iupMatrixAuxCallEnterCellCb(ih); break; case K_SP: case K_CR: case K_sCR: if (iupMatrixEditShow(ih)) return IUP_IGNORE; /* do not redraw */ break; case K_sDEL: case K_DEL: { int lin, col; char str[100]; IFnii mark_cb = (IFnii)IupGetCallback(ih, "MARK_CB"); iupMatrixPrepareDrawData(ih); for(lin = 1; lin < ih->data->lines.num; lin++) { for(col = 1; col < ih->data->columns.num; col++) { if (iupMatrixMarkCellGet(ih, lin, col, mark_cb, str)) { if (iupMatrixAuxCallEditionCbLinCol(ih, lin, col, 1) != IUP_IGNORE) { IFniis value_edit_cb; iupMatrixCellSetValue(ih, lin, col, NULL); value_edit_cb = (IFniis)IupGetCallback(ih, "VALUE_EDIT_CB"); if (value_edit_cb) value_edit_cb(ih, lin, col, NULL); iupMatrixDrawCells(ih, lin, col, lin, col); } } } } break; } default: /* if a valid character is pressed enter edition mode */ if (iup_isprint(c)) { if (iupMatrixEditShow(ih)) { if (ih->data->datah == ih->data->texth) { char value[2] = {0,0}; value[0] = (char)c; IupStoreAttribute(ih->data->datah, "VALUE", value); IupSetAttribute(ih->data->datah, "CARET", "2"); } return IUP_IGNORE; /* do not redraw */ } } ret = IUP_DEFAULT; /* unprocessed keys */ break; } iupMatrixDrawUpdate(ih); return ret; }