void iupMatrixScrollToVisible(Ihandle* ih, int lin, int col) { int old_lines_first = ih->data->lines.first; int old_columns_first = ih->data->columns.first; int old_lines_first_offset = ih->data->lines.first_offset; int old_columns_first_offset = ih->data->columns.first_offset; iMatrixScrollToVisible(&ih->data->columns, col); iMatrixScrollToVisible(&ih->data->lines, lin); if ((ih->data->lines.first != old_lines_first || ih->data->lines.first_offset != old_lines_first_offset) || (ih->data->columns.first != old_columns_first || ih->data->columns.first_offset != old_columns_first_offset)) { /* when "first" is changed must update scroll pos */ if (ih->data->columns.first != old_columns_first || ih->data->columns.first_offset != old_columns_first_offset) iupMatrixAuxUpdateScrollPos(ih, IMAT_PROCESS_COL); if (ih->data->lines.first != old_lines_first || ih->data->lines.first_offset != old_lines_first_offset) iupMatrixAuxUpdateScrollPos(ih, IMAT_PROCESS_LIN); iMatrixScrollCallScrollTopCb(ih); iupMatrixDraw(ih, 1); } }
void iupMatrixScrollMove(iupMatrixScrollMoveFunc func, Ihandle* ih, int mode, float pos, int m) { int old_lines_first = ih->data->lines.first; int old_columns_first = ih->data->columns.first; int old_lines_first_offset = ih->data->lines.first_offset; int old_columns_first_offset = ih->data->columns.first_offset; iupMatrixEditForceHidden(ih); func(ih, mode, pos, m); if ((ih->data->lines.first != old_lines_first || ih->data->lines.first_offset != old_lines_first_offset) || (ih->data->columns.first != old_columns_first || ih->data->columns.first_offset != old_columns_first_offset)) { /* when "first" is changed must update scroll pos */ if (ih->data->columns.first != old_columns_first || ih->data->columns.first_offset != old_columns_first_offset) iupMatrixAuxUpdateScrollPos(ih, IMAT_PROCESS_COL); if (ih->data->lines.first != old_lines_first || ih->data->lines.first_offset != old_lines_first_offset) iupMatrixAuxUpdateScrollPos(ih, IMAT_PROCESS_LIN); iMatrixScrollCallScrollTopCb(ih); iupMatrixDraw(ih, 0); } }
void iupMatrixAuxCalcSizes(Ihandle* ih) { iMatrixAuxFillSizeVec(ih, IMAT_PROCESS_COL); iMatrixAuxFillSizeVec(ih, IMAT_PROCESS_LIN); iMatrixAuxUpdateVisibleSize(ih, IMAT_PROCESS_COL); iMatrixAuxUpdateVisibleSize(ih, IMAT_PROCESS_LIN); /* when removing lines the first can be positioned after the last line */ if (ih->data->lines.first > ih->data->lines.num-1) { ih->data->lines.first_offset = 0; if (ih->data->lines.num==ih->data->lines.num_noscroll) ih->data->lines.first = ih->data->lines.num_noscroll; else ih->data->lines.first = ih->data->lines.num-1; } if (ih->data->columns.first > ih->data->columns.num-1) { ih->data->columns.first_offset = 0; if (ih->data->columns.num==ih->data->columns.num_noscroll) ih->data->columns.first = ih->data->columns.num_noscroll; else ih->data->columns.first = ih->data->columns.num-1; } /* make sure scroll pos is consistent */ iupMatrixAuxUpdateScrollPos(ih, IMAT_PROCESS_COL); iupMatrixAuxUpdateScrollPos(ih, IMAT_PROCESS_LIN); ih->data->need_calcsize = 0; }
static int iMatrixSetOriginAttrib(Ihandle* ih, const char* value) { int lin = -1, col = -1; /* Get the parameters. The '*' indicates that want to keep the table in the same line or column */ if (iupStrToIntInt(value, &lin, &col, ':') != 2) { if (lin != -1) col = ih->data->columns.first; else if (col != -1) lin = ih->data->lines.first; else return 0; } /* Check if the cell exists */ if (!iupMatrixCheckCellPos(ih, lin, col)) return 0; /* Can not be a title */ if((lin < 1) || (col < 1)) return 0; ih->data->columns.first = col; ih->data->columns.first_offset = 0; ih->data->lines.first = lin; ih->data->lines.first_offset = 0; /* when "first" is changed must update scroll pos */ iupMatrixAuxUpdateScrollPos(ih, IMAT_PROCESS_COL); iupMatrixAuxUpdateScrollPos(ih, IMAT_PROCESS_LIN); iupMatrixDraw(ih, 1); return 0; }