static void iSplitSetBarPosition(Ihandle* ih, int cur_x, int cur_y, int update) { if (ih->data->orientation == ISPLIT_VERT) { ih->firstchild->x = ih->data->start_bar + (cur_x - ih->data->start_pos); if (ih->firstchild->x < ih->x) ih->firstchild->x = ih->x; if (ih->firstchild->x > ih->x+ih->currentwidth) ih->firstchild->x = ih->x+ih->currentwidth; } else /* ISPLIT_HORIZ */ { ih->firstchild->y = ih->data->start_bar + (cur_y - ih->data->start_pos); if (ih->firstchild->y < ih->y) ih->firstchild->y = ih->y; if (ih->firstchild->y > ih->y+ih->currentheight) ih->firstchild->y = ih->y+ih->currentheight; } if (update) { IupSetAttribute(ih->firstchild, "ZORDER", "TOP"); iupClassObjectLayoutUpdate(ih->firstchild); } }
void iupLayoutUpdate(Ihandle* ih) { Ihandle* child; /* update size and position of the native control */ iupClassObjectLayoutUpdate(ih); /* update its children */ for (child = ih->firstchild; child; child = child->brother) { if (child->handle) iupLayoutUpdate(child); } }
static int iMatrixEditTextAction_CB(Ihandle* ih_text, int c, char* after) { Ihandle* ih = ih_text->parent; IFniiiis cb = (IFniiiis) IupGetCallback(ih, "ACTION_CB"); if (iupAttribGetBoolean(ih, "EDITFITVALUE")) { int value_w, value_h, resize = 0; value_w = iupdrvFontGetStringWidth(ih_text, after); iupdrvFontGetCharSize(ih_text, NULL, &value_h); if (iupAttribGetBoolean(ih_text, "BORDER")) { value_w += 2 * 4; value_h += 2 * 4; } if (value_w > ih_text->currentwidth) { ih_text->currentwidth = value_w; resize = 1; } if (value_h > ih_text->currentheight) { ih_text->currentheight = value_h; resize = 1; } if (resize) iupClassObjectLayoutUpdate(ih_text); } if (cb && iup_isprint(c)) /* only for keys that ARE ASCii characters */ { int oldc = c; c = cb(ih, c, ih->data->edit_lin, ih->data->edit_col, 1, after); if (c == IUP_IGNORE || c == IUP_CLOSE || c == IUP_CONTINUE) return c; else if(c == IUP_DEFAULT) c = oldc; return c; } return IUP_DEFAULT; }
void iupMatrixEditUpdatePos(Ihandle* ih) { int w, h, x, y, visible; visible = iupMatrixGetVisibleCellDim(ih, ih->data->edit_lin, ih->data->edit_col, &x, &y, &w, &h); if (!visible && !ih->data->edit_hide_onfocus) IupSetAttribute(ih->data->datah, "VISIBLE", "NO"); ih->data->datah->x = x; ih->data->datah->y = y; ih->data->datah->currentwidth = w; ih->data->datah->currentheight = h; if (ih->data->datah==ih->data->texth && iupAttribGetBoolean(ih, "EDITFITVALUE")) { char* value = IupGetAttribute(ih->data->texth, "VALUE"); int value_w, value_h; value_w = iupdrvFontGetStringWidth(ih->data->texth, value); iupdrvFontGetCharSize(ih->data->texth, NULL, &value_h); if (iupAttribGetBoolean(ih->data->texth, "BORDER")) { value_w += 2*4; value_h += 2*4; } if (value_w > ih->data->datah->currentwidth) ih->data->datah->currentwidth = value_w; if (value_h > ih->data->datah->currentheight) ih->data->datah->currentheight = value_h; } iupClassObjectLayoutUpdate(ih->data->datah); if (visible && !ih->data->edit_hide_onfocus) IupSetAttribute(ih->data->datah, "VISIBLE", "YES"); }
int iupMatrixEditShow(Ihandle* ih) { char* mask; int w, h, x, y; /* work around for Windows when using Multiline */ if (iupAttribGet(ih, "_IUPMAT_IGNORE_SHOW")) { iupAttribSetStr(ih, "_IUPMAT_IGNORE_SHOW", NULL); return 0; } /* there are no cells that can be edited */ if (ih->data->columns.num <= 1 || ih->data->lines.num <= 1) return 0; /* not active */ if(!IupGetInt(ih, "ACTIVE")) return 0; /* already visible */ if(IupGetInt(ih->data->datah, "VISIBLE")) return 0; /* notify application */ if (iMatrixEditCallEditionCb(ih, 1, 0) == IUP_IGNORE) return 0; if (iMatrixEditCallMenuDropCb(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell)) return 0; /* select edit control */ iMatrixEditChooseElement(ih); /* position the cell to make it visible */ /* If the focus is not visible, a scroll is done for that the focus to be visible */ if (!iupMatrixAuxIsCellStartVisible(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell)) iupMatrixScrollToVisible(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell); /* set attributes */ iupMatrixPrepareDrawData(ih); IupStoreAttribute(ih->data->datah, "BGCOLOR", iupMatrixGetBgColor(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell)); IupStoreAttribute(ih->data->datah, "FGCOLOR", iupMatrixGetFgColor(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell)); IupSetAttribute(ih->data->datah, "FONT", iupMatrixGetFont(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell)); mask = IupMatGetAttribute(ih,"MASK", ih->data->lines.focus_cell, ih->data->columns.focus_cell); if (mask) { IupSetAttribute(ih->data->datah, "MASKCASEI", IupMatGetAttribute(ih,"MASKCASEI", ih->data->lines.focus_cell, ih->data->columns.focus_cell)); IupSetAttribute(ih->data->datah, "MASK", mask); } else { mask = IupMatGetAttribute(ih,"MASKINT", ih->data->lines.focus_cell, ih->data->columns.focus_cell); if (mask) IupSetAttribute(ih->data->datah, "MASKINT", mask); else { mask = IupMatGetAttribute(ih,"MASKFLOAT", ih->data->lines.focus_cell, ih->data->columns.focus_cell); if (mask) IupSetAttribute(ih->data->datah, "MASKFLOAT", mask); else IupSetAttribute(ih->data->datah, "MASK", NULL); } } /* calc size */ iupMatrixGetVisibleCellDim(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell, &x, &y, &w, &h); ih->data->datah->x = x; ih->data->datah->y = y; ih->data->datah->currentwidth = w; ih->data->datah->currentheight = h; iupClassObjectLayoutUpdate(ih->data->datah); /* activate and show */ IupSetAttribute(ih->data->datah, "ACTIVE", "YES"); IupSetAttribute(ih->data->datah, "VISIBLE", "YES"); IupSetFocus(ih->data->datah); return 1; }