static int iSplitSetValueAttrib(Ihandle* ih, const char* value) { if (!value) { ih->data->val = -1; /* reset to calculate in Natural size */ if (ih->data->autohide) iSplitAutoHideVal(ih); if (ih->handle) IupRefreshChildren(ih); } else { int val; if (iupStrToInt(value, &val)) { ih->data->val = val; iSplitCropVal(ih); if (ih->data->autohide) iSplitAutoHideVal(ih); if (ih->handle) IupRefreshChildren(ih); } } return 0; /* do not store value in hash table */ }
static int iGridBoxSetFitToChildrenAttrib(Ihandle* ih, const char* value) { if (!value || value[0] == 0) return 0; if (value[0] == 'C') { int col; if (iupStrToInt(value + 1, &col)) { iGridBoxFitColChildren(ih, col); IupRefreshChildren(ih); } } else if (value[0] == 'L') { int line; if (iupStrToInt(value + 1, &line)) { iGridBoxFitLineChildren(ih, line); IupRefreshChildren(ih); } } return 0; }
static int iDetachBoxSetBarSizeAttrib(Ihandle* ih, const char* value) { if (iupStrToInt(value, &ih->data->barsize) && ih->handle) IupRefreshChildren(ih); return 0; /* do not store value in hash table */ }
static int iSplitSetBarSizeAttrib(Ihandle* ih, const char* value) { if (iupStrToInt(value, &ih->data->barsize)) { if (ih->data->autohide) iSplitAutoHideVal(ih); if (ih->handle) IupRefreshChildren(ih); } return 0; /* do not store value in hash table */ }
static int iSplitButton_CB(Ihandle* bar, int button, int pressed, int x, int y, char* status) { Ihandle* ih = bar->parent; if (button!=IUP_BUTTON1) return IUP_DEFAULT; if (!ih->data->is_holding && pressed) { int cur_x, cur_y; ih->data->is_holding = 1; iupStrToIntInt(IupGetGlobal("CURSORPOS"), &cur_x, &cur_y, 'x'); /* Save the cursor position and size */ if (ih->data->orientation == ISPLIT_VERT) { ih->data->start_bar = ih->firstchild->x; ih->data->start_pos = cur_x; ih->data->start_size = iSplitGetWidth1(ih); } else { ih->data->start_bar = ih->firstchild->y; ih->data->start_pos = cur_y; ih->data->start_size = iSplitGetHeight1(ih); } } else if (ih->data->is_holding && !pressed) { ih->data->is_holding = 0; if (!ih->data->layoutdrag) { if (ih->data->autohide) { int cur_x, cur_y; iupStrToIntInt(IupGetGlobal("CURSORPOS"), &cur_x, &cur_y, 'x'); iSplitSetBarPosition(ih, cur_x, cur_y, 0); iSplitAutoHideXY(ih); } IupRefreshChildren(ih); } } (void)x; (void)y; (void)status; return IUP_DEFAULT; }
static int iDetachBoxSetBarSizeAttrib(Ihandle* ih, const char* value) { if (iupStrToInt(value, &ih->data->barsize)) { if (ih->data->barsize == 0) IupSetAttribute(ih->firstchild, "VISIBLE", "No"); if (ih->handle) IupRefreshChildren(ih); } return 0; /* do not store value in hash table */ }
static int cbRemoveThisTab(Ihandle* ih) { Ihandle* tabs = (Ihandle*)IupGetAttribute(ih, "APP_TABS"); int pos = IupGetInt(ih, "APP_THISTAB"); Ihandle* child = IupGetChild(tabs, pos); if (child) { IupDestroy(child); IupRefreshChildren(tabs); /* update children layout */ } return IUP_DEFAULT; }
static int iSplitMotion_CB(Ihandle* bar, int x, int y, char *status) { Ihandle* ih = bar->parent; if (ih->data->is_holding) { if (iup_isbutton1(status)) { int cur_x, cur_y; iupStrToIntInt(IupGetGlobal("CURSORPOS"), &cur_x, &cur_y, 'x'); if (ih->data->orientation == ISPLIT_VERT) { int width1 = iSplitGetWidth1(ih); width1 = ih->data->start_size + (cur_x - ih->data->start_pos); ih->data->val = (width1*1000)/(ih->currentwidth-ih->data->barsize); } else { int height1 = iSplitGetHeight1(ih); height1 = ih->data->start_size + (cur_y - ih->data->start_pos); ih->data->val = (height1*1000)/(ih->currentheight-ih->data->barsize); } iSplitCropVal(ih); if (ih->data->layoutdrag) { if (ih->data->autohide) { iSplitSetBarPosition(ih, cur_x, cur_y, 0); iSplitAutoHideXY(ih); } IupRefreshChildren(ih); } else iSplitSetBarPosition(ih, cur_x, cur_y, 1); } else ih->data->is_holding = 0; } (void)x; (void)y; return IUP_DEFAULT; }
static int iExpanderTimer_cb(Ihandle* timer) { Ihandle* ih = (Ihandle*)iupAttribGet(timer, "_IUP_EXPANDER"); Ihandle *child = ih->firstchild->brother; /* run timer just once each time */ IupSetAttribute(timer, "RUN", "No"); /* just show child on top, that's why child must be a native container when using autoshow. */ ih->data->state = IEXPANDER_OPEN_FLOAT; iExpanderOpenCloseChild(ih, 0); IupRefreshChildren(ih); IupSetAttribute(child, "ZORDER", "TOP"); /* now monitor mouse move */ IupSetGlobal("INPUTCALLBACKS", "Yes"); IupSetFunction("_IUP_OLD_GLOBALMOTION_CB", IupGetFunction("GLOBALMOTION_CB")); IupSetGlobal("_IUP_EXPANDER_GLOBAL", (char*)ih); IupSetFunction("GLOBALMOTION_CB", (Icallback)iExpanderGlobalMotion_cb); return IUP_DEFAULT; }
static void iGLExpanderOpenCloseChild(Ihandle* ih, int refresh, int callcb, int state) { Ihandle* gl_parent = (Ihandle*)iupAttribGet(ih, "GL_CANVAS"); Ihandle *child = ih->firstchild; if (callcb) { IFni cb = (IFni)IupGetCallback(ih, "OPENCLOSE_CB"); if (cb) { int ret = cb(ih, state); if (ret == IUP_IGNORE) return; } } ih->data->state = state; if (child) { if (ih->data->state == IEXPANDER_CLOSE) IupSetAttribute(child, "VISIBLE", "NO"); else IupSetAttribute(child, "VISIBLE", "YES"); if (refresh) IupRefreshChildren(gl_parent); /* this will recompute the layout of the glcanvasbox only */ } IupSetAttribute(gl_parent, "REDRAW", NULL); /* redraw the whole box */ if (callcb) { IFn cb = IupGetCallback(ih, "ACTION"); if (cb) cb(ih); } }
static void gtkTabsCloseButtonClicked(GtkButton *widget, Ihandle* child) { /* Close tab child */ GtkWidget* tab_page = (GtkWidget*)iupAttribGet(child, "_IUPTAB_PAGE"); if (tab_page) { Ihandle* ih = IupGetParent(child); int pos = gtk_notebook_page_num((GtkNotebook*)ih->handle, tab_page); int ret = IUP_DEFAULT; IFni cb = (IFni)IupGetCallback(ih, "TABCLOSE_CB"); if (cb) ret = cb(ih, pos); if (ret == IUP_CONTINUE) /* destroy tab and children */ { IupDestroy(child); IupRefreshChildren(ih); } else if (ret == IUP_DEFAULT) /* hide tab and children */ gtk_widget_hide(tab_page); } (void)widget; }
static int iSplitSetMinMaxAttrib(Ihandle* ih, const char* value) { if (iupStrToIntInt(value, &ih->data->min, &ih->data->max, ':')) { if (ih->data->min > ih->data->max) { int t = ih->data->min; ih->data->min = ih->data->max; ih->data->max = t; } if (ih->data->min < 0) ih->data->min = 0; if (ih->data->max > 1000) ih->data->max = 1000; if (ih->data->val != -1) iSplitCropVal(ih); if (ih->data->autohide) iSplitAutoHideVal(ih); if (ih->handle) IupRefreshChildren(ih); } return 0; /* do not store value in hash table */ }
static int RefreshChildren (lua_State *L) { IupRefreshChildren(iuplua_checkihandle(L,1)); return 0; }