/* Calculate the size, in pixels, of the invisible columns/lines, the left/above of the first column/line. In fact the start position of the visible area. Depends on the first visible column/line. -> m : choose will operate on lines or columns [IMAT_PROCESS_LIN|IMAT_PROCESS_COL] */ void iupMatrixAuxUpdateVisiblePos(Ihandle* ih, int m) { char* POS; int i, sb, visible_pos; ImatLinColData *p; if (m == IMAT_PROCESS_LIN) { p = &(ih->data->lines); sb = IUP_SB_VERT; POS = "POSY"; } else { p = &(ih->data->columns); sb = IUP_SB_HORIZ; POS = "POSX"; } visible_pos = 0; for(i = 1; i < p->first; i++) visible_pos += p->sizes[i]; if (ih->data->canvas.sb & sb) { float pos; if (p->total_size) { while ((visible_pos + p->visible_size > p->total_size) && p->first>1) { /* invalid position, must recalculate first */ p->first--; visible_pos -= p->sizes[p->first]; } pos = (float)visible_pos/(float)p->total_size; } else pos = 0; iupMatrixAuxUpdateLast(p); IupSetfAttribute(ih, POS, "%.5f", (double)pos); } else iupMatrixAuxUpdateLast(p); }
/* Calculate the size, in pixels, of the invisible columns/lines, the left/above of the first column/line. In fact the start position of the visible area. Depends on the first visible column/line. -> m : choose will operate on lines or columns [IMAT_PROCESS_LIN|IMAT_PROCESS_COL] */ void iupMatrixAuxUpdateScrollPos(Ihandle* ih, int m) { float pos; int i, sb, scroll_pos; char* POS; ImatLinColData *p; if (m == IMAT_PROCESS_LIN) { p = &(ih->data->lines); sb = IUP_SB_VERT; POS = "POSY"; } else { p = &(ih->data->columns); sb = IUP_SB_HORIZ; POS = "POSX"; } /* "first" was changed, so update "last" and the scroll pos */ if (p->total_visible_size <= p->current_visible_size) { /* the matrix is fully visible */ p->first = p->num_noscroll; p->first_offset = 0; p->last = p->num==p->num_noscroll? p->num_noscroll: p->num-1; if (ih->data->canvas.sb & sb) IupSetAttribute(ih, POS, "0"); return; } /* must check if it is a valid position */ scroll_pos = 0; for(i = p->num_noscroll; i < p->first; i++) scroll_pos += p->dt[i].size; scroll_pos += p->first_offset; if (scroll_pos + p->current_visible_size > p->total_visible_size) { /* invalid condition, must recalculate so it is valid */ scroll_pos = p->total_visible_size - p->current_visible_size; /* position first and first_offset, according to scroll pos */ iupMatrixAuxAdjustFirstFromScrollPos(p, scroll_pos); } pos = (float)scroll_pos/(float)p->total_visible_size; /* update last */ iupMatrixAuxUpdateLast(p); /* update scroll pos */ if (ih->data->canvas.sb & sb) IupSetFloat(ih, POS, pos); }