static int iCellsCreateMethod(Ihandle* ih, void **params) { (void)params; /* free the data allocated by IupCanvas */ free(ih->data); ih->data = iupALLOCCTRLDATA(); /* change the IupCanvas default values */ iupAttribSet(ih, "SCROLLBAR", "YES"); iupAttribSet(ih, "BORDER", "NO"); /* default values */ ih->data->boxed = 1; ih->data->clipped = 1; /* IupCanvas callbacks */ IupSetCallback(ih, "RESIZE_CB", (Icallback)iCellsResize_CB); IupSetCallback(ih, "ACTION", (Icallback)iCellsRedraw_CB); IupSetCallback(ih, "BUTTON_CB", (Icallback)iCellsButton_CB); IupSetCallback(ih, "MOTION_CB", (Icallback)iCellsMotion_CB); IupSetCallback(ih, "SCROLL_CB", (Icallback)iCellsScroll_CB); return IUP_NOERROR; }
static int iGLValBUTTON_CB(Ihandle* ih, int button, int pressed, int x, int y, char* status) { if (button == IUP_BUTTON1) { if (pressed) { if (!iGLValIsInsideHandler(ih, x, y)) iupAttribSet(ih, "PRESSED", NULL); else { iupAttribSetInt(ih, "_IUP_START_X", x); iupAttribSetInt(ih, "_IUP_START_Y", y); } } else { if (iupAttribGet(ih, "_IUP_DRAG")) { IFni cb = (IFni)IupGetCallback(ih, "VALUECHANGING_CB"); if (cb) cb(ih, 0); iupAttribSet(ih, "_IUP_DRAG", NULL); } } iupGLSubCanvasRedraw(ih); } (void)status; return IUP_DEFAULT; }
static int winToggleImageFlatMsgProc(Ihandle* ih, UINT msg, WPARAM wp, LPARAM lp, LRESULT *result) { /* Called only when (ih->data->type==IUP_TOGGLE_IMAGE && ih->data->flat) */ switch (msg) { case WM_MOUSELEAVE: iupAttribSet(ih, "_IUPWINTOG_ENTERWIN", NULL); iupdrvRedrawNow(ih); break; case WM_MOUSEMOVE: if (!iupAttribGet(ih, "_IUPWINTOG_ENTERWIN")) { /* this will not affect the process in iupwinBaseMsgProc*/ /* must be called so WM_MOUSELEAVE will be called */ iupwinTrackMouseLeave(ih); iupAttribSet(ih, "_IUPWINTOG_ENTERWIN", "1"); iupdrvRedrawNow(ih); } break; } return iupwinBaseMsgProc(ih, msg, wp, lp, result); }
static int iMatrixExSetNumericUnitSymbolSearchAttrib(Ihandle* ih, const char* value) { int q, u; int utf8 = IupGetInt(NULL, "UTF8MODE"); iupAttribSet(ih, "NUMERICFOUNDQUANTITY", NULL); iupAttribSet(ih, "NUMERICFOUNDUNIT", NULL); iupAttribSet(ih, "NUMERICFOUNDUNITSYMBOL", NULL); for (q=0; q<imatex_quantity_count; q++) { ImatExUnit* units = (ImatExUnit*)(imatex_quantities[q].units); int units_count = imatex_quantities[q].units_count; for (u=0; u<units_count; u++) { const char* symbol; if (utf8 && units[u].symbol_utf8) symbol = units[u].symbol_utf8; else symbol = units[u].symbol; if (iupStrEqual(symbol, value)) { iupAttribSet(ih, "NUMERICFOUNDQUANTITY", imatex_quantities[q].q_name); iupAttribSet(ih, "NUMERICFOUNDUNIT", units[u].u_name); iupAttribSetStr(ih, "NUMERICFOUNDUNITSYMBOL", symbol); return 0; } } } (void)ih; return 0; }
static int winToggleSetActiveAttrib(Ihandle* ih, const char* value) { /* update the inactive image if necessary */ if (ih->data->type==IUP_TOGGLE_IMAGE) { if (iupwin_comctl32ver6 || ih->data->flat) { iupBaseSetActiveAttrib(ih, value); iupdrvRedrawNow(ih); return 0; } else { int active = iupStrBoolean(value); int check = SendMessage(ih->handle, BM_GETCHECK, 0, 0L); if (active) iupAttribSet(ih, "_IUPWIN_ACTIVE", "YES"); else iupAttribSet(ih, "_IUPWIN_ACTIVE", "NO"); winToggleUpdateImage(ih, active, check); return 0; } } return iupBaseSetActiveAttrib(ih, value); }
static void motDropTransferProc(Widget dropTransfer, Ihandle* ih, Atom *selType, Atom *typeAtom, XtPointer targetData, unsigned long *length, int format) { IFnsViii cbDropData; if(!targetData || !(*length)) return; cbDropData = (IFnsViii)IupGetCallback(ih, "DROPDATA_CB"); if(cbDropData) { /* TODO should we check for incompatible targets here? */ char* type = XGetAtomName(iupmot_display, *typeAtom); int x = iupAttribGetInt(ih, "_IUPMOT_DROP_X"); int y = iupAttribGetInt(ih, "_IUPMOT_DROP_Y"); cbDropData(ih, type, (void*)targetData, (int)*length, x, y); iupAttribSet(ih, "_IUPMOT_DROP_X", NULL); iupAttribSet(ih, "_IUPMOT_DROP_Y", NULL); } (void)dropTransfer; (void)format; (void)selType; }
static int iListSetMaskFloatAttrib(Ihandle* ih, const char* value) { if (!ih->data->has_editbox) return 0; if (!value) { if (ih->data->mask) iupMaskDestroy(ih->data->mask); iupAttribSet(ih, "MASK", NULL); } else { Imask* mask; float min, max; if (iupStrToFloatFloat(value, &min, &max, ':')!=2) return 0; mask = iupMaskCreateFloat(min,max); if (ih->data->mask) iupMaskDestroy(ih->data->mask); ih->data->mask = mask; if (min < 0) iupAttribSet(ih, "MASK", IUP_MASK_FLOAT); else iupAttribSet(ih, "MASK", IUP_MASK_UFLOAT); } return 0; }
static int iMatrixExSetCopyFileAttrib(Ihandle *ih, const char* value) { int num_lin, num_col, skip_lin, skip_col; char buffer[1024]; char* format; FILE *file = fopen(value, "wb"); if (!file) { iupAttribSet(ih, "LASTERROR", "IUP_ERRORFILEOPEN"); return 0; } /* reset error state */ iupAttribSet(ih, "LASTERROR", NULL); num_lin = IupGetInt(ih, "NUMLIN"); num_col = IupGetInt(ih, "NUMCOL"); skip_lin = iupAttribGetInt(ih, "SKIPLINES"); skip_col = iupAttribGetInt(ih, "SKIPCOLUMNS"); format = iupAttribGetStr(ih, "FILEFORMAT"); if (iupStrEqualNoCase(format, "HTML")) iMatrixExCopyHTML(ih, file, num_lin, num_col, buffer, skip_lin, skip_col); else if (iupStrEqualNoCase(format, "LaTeX")) iMatrixExCopyLaTeX(ih, file, num_lin, num_col, buffer, skip_lin, skip_col); else iMatrixExCopyTXT(ih, file, num_lin, num_col, skip_lin, skip_col); fclose(file); return 0; }
void IupGLMakeCurrent(Ihandle* ih) { IGlControlData* gldata; iupASSERT(iupObjectCheck(ih)); if (!iupObjectCheck(ih)) return; /* must be an IupGLCanvas */ if (ih->iclass->nativetype != IUP_TYPECANVAS || !IupClassMatch(ih, "glcanvas")) return; /* must be mapped */ gldata = (IGlControlData*)iupAttribGet(ih, "_IUP_GLCONTROLDATA"); if (!gldata->window) return; if (wglMakeCurrent(gldata->device, gldata->context)==FALSE) { iupAttribSet(ih, "ERROR", "Failed to set new current context."); iupAttribSetStr(ih, "LASTERROR", IupGetGlobal("LASTERROR")); } else { iupAttribSet(ih, "ERROR", NULL); iupAttribSet(ih, "LASTERROR", NULL); } }
static void gtkItemActivate(GtkWidget *widget, Ihandle* ih) { Icallback cb; if (GTK_IS_CHECK_MENU_ITEM(ih->handle) && !iupAttribGetBoolean(ih, "AUTOTOGGLE") && !iupAttribGetBoolean(ih->parent, "RADIO")) { /* GTK by default will do autotoggle */ g_signal_handlers_block_by_func(G_OBJECT(ih->handle), G_CALLBACK(gtkItemActivate), ih); gtk_check_menu_item_set_active((GtkCheckMenuItem*)ih->handle, !gtk_check_menu_item_get_active((GtkCheckMenuItem*)ih->handle)); g_signal_handlers_unblock_by_func(G_OBJECT(ih->handle), G_CALLBACK(gtkItemActivate), ih); } if (GTK_IS_IMAGE_MENU_ITEM(ih->handle)) { if (iupAttribGetBoolean(ih, "AUTOTOGGLE")) { if (iupAttribGetBoolean(ih, "VALUE")) iupAttribSet(ih, "VALUE", "OFF"); else iupAttribSet(ih, "VALUE", "ON"); gtkItemUpdateImage(ih, iupAttribGet(ih, "VALUE"), iupAttribGet(ih, "IMAGE"), iupAttribGet(ih, "IMPRESS")); } } cb = IupGetCallback(ih, "ACTION"); if (cb && cb(ih)==IUP_CLOSE) IupExitLoop(); (void)widget; }
static int iMatrixEditKillFocus_CB(Ihandle* ih_edit) { Ihandle* ih = ih_edit->parent; if (IupGetGlobal("MOTIFVERSION")) { if (iupAttribGet(ih, "_IUPMAT_DROPDOWN") || /* from iMatrixEditDropDown_CB, in Motif */ iupAttribGet(ih, "_IUPMAT_DOUBLECLICK")) /* from iMatrixMouseLeftPress, in Motif */ { iupAttribSet(ih, "_IUPMAT_DOUBLECLICK", NULL); iupAttribSet(ih, "_IUPMAT_DROPDOWN", NULL); return IUP_DEFAULT; } } if (iupAttribGet(ih, "_IUPMAT_IGNOREFOCUS")) return IUP_DEFAULT; if (ih->data->edit_hide_onfocus) { ih->data->edit_hidden_byfocus = 1; iupMatrixEditHide(ih); ih->data->edit_hidden_byfocus = 0; } else { IFn cb = (IFn)IupGetCallback(ih, "EDITKILLFOCUS_CB"); if (cb) cb(ih); } return IUP_DEFAULT; }
static int winButtonWmCommand(Ihandle* ih, WPARAM wp, LPARAM lp) { int cmd = HIWORD(wp); switch (cmd) { case BN_DOUBLECLICKED: case BN_CLICKED: { Icallback cb = IupGetCallback(ih, "ACTION"); if (cb) { /* to avoid double calls when pressing enter and a dialog is displayed */ if (!iupAttribGet(ih, "_IUPBUT_INSIDE_ACTION")) { int ret; iupAttribSet(ih, "_IUPBUT_INSIDE_ACTION", "1"); ret = cb(ih); if (ret == IUP_CLOSE) IupExitLoop(); if (ret!=IUP_IGNORE && iupObjectCheck(ih)) iupAttribSet(ih, "_IUPBUT_INSIDE_ACTION", NULL); } } } } (void)lp; return 0; /* not used */ }
static int iMatrixExSetNumericUnitSearchAttrib(Ihandle* ih, const char* value) { int q, u; iupAttribSet(ih, "NUMERICFOUNDQUANTITY", NULL); iupAttribSet(ih, "NUMERICFOUNDUNIT", NULL); iupAttribSet(ih, "NUMERICFOUNDUNITSYMBOL", NULL); for (q=0; q<imatex_quantity_count; q++) { ImatExUnit* units = (ImatExUnit*)(imatex_quantities[q].units); int units_count = imatex_quantities[q].units_count; for (u=0; u<units_count; u++) { if (iMatrixCompareUnity(units[u].u_name, value)) { iupAttribSet(ih, "NUMERICFOUNDQUANTITY", imatex_quantities[q].q_name); iupAttribSet(ih, "NUMERICFOUNDUNIT", units[u].u_name); iupAttribSetStr(ih, "NUMERICFOUNDUNITSYMBOL", iMatrixExReturnSymbol(units + u)); return 0; } } } (void)ih; return 0; }
static int winCanvasSetDYAttrib(Ihandle* ih, const char *value) { if (ih->data->sb & IUP_SB_VERT) { double posy, ymin, ymax; float dy; int iposy, ipagey; if (!iupStrToFloatDef(value, &dy, 0.1f)) return 1; ymin = iupAttribGetFloat(ih, "YMIN"); ymax = iupAttribGetFloat(ih, "YMAX"); posy = ih->data->posy; iupCanvasCalcScrollIntPos(ymin, ymax, dy, posy, IUP_SB_MIN, IUP_SB_MAX, &ipagey, &iposy); winCanvasSetScrollInfo(ih->handle, IUP_SB_MIN, IUP_SB_MAX, ipagey, SB_VERT, iupAttribGetBoolean(ih, "YAUTOHIDE")); if (dy >= (ymax-ymin)) { if (iupAttribGetBoolean(ih, "YAUTOHIDE")) { iupAttribSet(ih, "YHIDDEN", "YES"); ShowScrollBar(ih->handle, SB_VERT, FALSE); SetScrollPos(ih->handle, SB_VERT, IUP_SB_MIN, FALSE); } else { EnableScrollBar(ih->handle, SB_VERT, ESB_DISABLE_BOTH); SetScrollPos(ih->handle, SB_VERT, IUP_SB_MIN, TRUE); } ih->data->posy = (float)ymin; return 1; } else { if (iupAttribGetBoolean(ih, "YAUTOHIDE")) { iupAttribSet(ih, "YHIDDEN", "NO"); ShowScrollBar(ih->handle, SB_VERT, TRUE); } else EnableScrollBar(ih->handle, SB_VERT, ESB_ENABLE_BOTH); /* also update position because it could have being changed */ iupCanvasCalcScrollRealPos(ymin, ymax, &posy, IUP_SB_MIN, IUP_SB_MAX, ipagey, &iposy); SetScrollPos(ih->handle, SB_VERT, iposy, TRUE); ih->data->posy = (float)posy; } } return 1; }
static int iGLValENTERWINDOW_CB(Ihandle* ih, int x, int y) { /* special highlight processing for handler area */ if (iGLValIsInsideHandler(ih, x, y)) iupAttribSet(ih, "HIGHLIGHT", "1"); else iupAttribSet(ih, "HIGHLIGHT", NULL); return iupGLSubCanvasRedraw(ih); }
static int winCanvasSetDXAttrib(Ihandle* ih, const char *value) { if (ih->data->sb & IUP_SB_HORIZ) { double posx, xmin, xmax; float dx; int iposx, ipagex; if (!iupStrToFloatDef(value, &dx, 0.1f)) return 1; xmin = iupAttribGetFloat(ih, "XMIN"); xmax = iupAttribGetFloat(ih, "XMAX"); posx = ih->data->posx; iupCanvasCalcScrollIntPos(xmin, xmax, dx, posx, IUP_SB_MIN, IUP_SB_MAX, &ipagex, &iposx); winCanvasSetScrollInfo(ih->handle, IUP_SB_MIN, IUP_SB_MAX, ipagex, SB_HORZ, iupAttribGetBoolean(ih, "XAUTOHIDE")); if (dx >= (xmax-xmin)) { if (iupAttribGetBoolean(ih, "XAUTOHIDE")) { iupAttribSet(ih, "XHIDDEN", "YES"); ShowScrollBar(ih->handle, SB_HORZ, FALSE); SetScrollPos(ih->handle, SB_HORZ, IUP_SB_MIN, FALSE); } else { EnableScrollBar(ih->handle, SB_HORZ, ESB_DISABLE_BOTH); SetScrollPos(ih->handle, SB_HORZ, IUP_SB_MIN, TRUE); } ih->data->posx = (float)xmin; } else { if (iupAttribGetBoolean(ih, "XAUTOHIDE")) { iupAttribSet(ih, "XHIDDEN", "NO"); ShowScrollBar(ih->handle, SB_HORZ, TRUE); } else EnableScrollBar(ih->handle, SB_HORZ, ESB_ENABLE_BOTH); /* also update position because it could have being changed */ iupCanvasCalcScrollRealPos(xmin, xmax, &posx, IUP_SB_MIN, IUP_SB_MAX, ipagex, &iposx); SetScrollPos(ih->handle, SB_HORZ, iposx, TRUE); ih->data->posx = (float)posx; } } return 1; }
static void gtkTabsChildRemovedMethod(Ihandle* ih, Ihandle* child, int pos) { if (ih->handle) { GtkWidget* tab_page = (GtkWidget*)iupAttribGet(child, "_IUPTAB_PAGE"); if (tab_page) { if (iupdrvTabsGetCurrentTab(ih) == pos) iupAttribSet(ih, "_IUPGTK_IGNORE_SWITCHPAGE", "1"); iupTabsCheckCurrentTab(ih, pos, 1); iupAttribSet(ih, "_IUPGTK_IGNORE_CHANGE", "1"); gtk_notebook_remove_page((GtkNotebook*)ih->handle, pos); iupAttribSet(ih, "_IUPGTK_IGNORE_CHANGE", NULL); iupAttribSet(child, "_IUPGTK_TABCLOSE", NULL); iupAttribSet(child, "_IUPGTK_TABIMAGE", NULL); iupAttribSet(child, "_IUPGTK_TABLABEL", NULL); iupAttribSet(child, "_IUPTAB_CONTAINER", NULL); iupAttribSet(child, "_IUPTAB_PAGE", NULL); if (iupAttribGet(ih, "_IUPGTK_IGNORE_SWITCHPAGE")) { gtkTabsSwitchManual(ih, child, pos); iupAttribSet(ih, "_IUPGTK_IGNORE_SWITCHPAGE", NULL); } } } }
static int iGLValMOTION_CB(Ihandle* ih, int x, int y, char* status) { int redraw = 0; int pressed = iupAttribGetInt(ih, "PRESSED"); /* special highlight processing for handler area */ if (iGLValIsInsideHandler(ih, x, y)) { if (!iupAttribGet(ih, "HIGHLIGHT")) { redraw = 1; iupAttribSet(ih, "HIGHLIGHT", "1"); } } else { if (iupAttribGet(ih, "HIGHLIGHT")) { redraw = 1; iupAttribSet(ih, "HIGHLIGHT", NULL); } } if (pressed) { int start_x = iupAttribGetInt(ih, "_IUP_START_X"); int start_y = iupAttribGetInt(ih, "_IUP_START_Y"); if (iGLValMoveHandler(ih, x - start_x, y - start_y)) { iupGLSubCanvasRedraw(ih); redraw = 0; if (!iupAttribGet(ih, "_IUP_DRAG")) { IFni cb = (IFni)IupGetCallback(ih, "VALUECHANGING_CB"); if (cb) cb(ih, 1); } iupBaseCallValueChangedCb(ih); iupAttribSet(ih, "_IUP_DRAG", "1"); } iupAttribSetInt(ih, "_IUP_START_X", x); iupAttribSetInt(ih, "_IUP_START_Y", y); } if (redraw) iupGLSubCanvasRedraw(ih); (void)status; return IUP_DEFAULT; }
static int winColorDlgPopup(Ihandle* ih, int x, int y) { InativeHandle* parent = iupDialogGetNativeParent(ih); CHOOSECOLOR choosecolor; unsigned char r, g, b; COLORREF lpCustColors[16]; char* value; iupAttribSetInt(ih, "_IUPDLG_X", x); /* used in iupDialogUpdatePosition */ iupAttribSetInt(ih, "_IUPDLG_Y", y); /* if NOT set will NOT be Modal */ /* anyway it will be modal only relative to its parent */ if (!parent) parent = GetActiveWindow(); iupStrToRGB(iupAttribGet(ih, "VALUE"), &r, &g, &b); ZeroMemory(lpCustColors, 16*sizeof(COLORREF)); value = iupAttribGetStr(ih, "COLORTABLE"); if (value) winColorDlgStringToColors(value, lpCustColors); ZeroMemory(&choosecolor, sizeof(CHOOSECOLOR)); choosecolor.lStructSize = sizeof(CHOOSECOLOR); choosecolor.hwndOwner = parent; choosecolor.rgbResult = RGB(r, g, b); choosecolor.lpCustColors = lpCustColors; choosecolor.lCustData = (LPARAM)ih; choosecolor.Flags = CC_RGBINIT|CC_FULLOPEN; if (IupGetCallback(ih, "HELP_CB")) choosecolor.Flags |= CC_SHOWHELP; choosecolor.Flags |= CC_ENABLEHOOK; choosecolor.lpfnHook = (LPCCHOOKPROC)winColorDlgHookProc; if (!ChooseColor(&choosecolor)) { iupAttribSet(ih, "VALUE", NULL); iupAttribSet(ih, "COLORTABLE", NULL); iupAttribSet(ih, "STATUS", NULL); return IUP_NOERROR; } iupAttribSetStrf(ih, "VALUE", "%d %d %d", GetRValue(choosecolor.rgbResult), GetGValue(choosecolor.rgbResult), GetBValue(choosecolor.rgbResult)); iupAttribSet(ih, "COLORTABLE", winColorDlgColorsToString(lpCustColors)); iupAttribSet(ih, "STATUS", "1"); return IUP_NOERROR; }
static void iSpinRunTimer(Ihandle* ih, char* status, char* dir) { Ihandle* spin_timer = IupGetHandle("IupSpinTimer"); iupAttribSet(spin_timer, "_IUPSPIN_BUTTON", (char*)ih); iupAttribSetStr(spin_timer, "_IUPSPIN_STATUS", status); iupAttribSetStr(spin_timer, "_IUPSPIN_DIR", dir); iupAttribSet(spin_timer, "_IUPSPIN_COUNT", "0"); IupSetAttribute(spin_timer, "TIME", "400"); IupSetAttribute(spin_timer, "RUN", "YES"); }
static void winToggleSetCheck(Ihandle* ih, int check) { if (ih->data->type==IUP_TOGGLE_IMAGE && !iupwin_comctl32ver6 && ih->data->flat) { if (check == BST_CHECKED) iupAttribSet(ih, "_IUPWIN_TOGGLE_CHECK", "1"); else iupAttribSet(ih, "_IUPWIN_TOGGLE_CHECK", NULL); iupdrvRedrawNow(ih); } else SendMessage(ih->handle, BM_SETCHECK, check, 0L); }
static int motListSetAppendAttrib(Ihandle* ih, const char* value) { if (value && ih->data->has_editbox) { XmTextPosition pos; Widget cbedit; XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL); pos = XmTextFieldGetLastPosition(cbedit); iupAttribSet(ih, "_IUPMOT_DISABLE_TEXT_CB", "1"); /* disable callbacks */ XmTextFieldInsert(cbedit, pos+1, (char*)value); iupAttribSet(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL); } return 0; }
static int gtkToggleSetValueAttrib(Ihandle* ih, const char* value) { if (iupStrEqualNoCase(value,"NOTDEF")) gtk_toggle_button_set_inconsistent((GtkToggleButton*)ih->handle, TRUE); else { int check; Ihandle* last_ih = NULL; Ihandle* radio = iupRadioFindToggleParent(ih); gtk_toggle_button_set_inconsistent((GtkToggleButton*)ih->handle, FALSE); /* This action causes the toggled signal to be emitted. */ iupAttribSet(ih, "_IUPGTK_IGNORE_TOGGLE", "1"); if (radio) { last_ih = (Ihandle*)IupGetAttribute(radio, "VALUE_HANDLE"); if (last_ih) iupAttribSet(last_ih, "_IUPGTK_IGNORE_TOGGLE", "1"); } if (iupStrEqualNoCase(value,"TOGGLE")) { if (gtk_toggle_button_get_active((GtkToggleButton*)ih->handle)) check = 0; else check = 1; } else check = iupStrBoolean(value); if (check) gtk_toggle_button_set_active((GtkToggleButton*)ih->handle, TRUE); else { gtk_toggle_button_set_active((GtkToggleButton*)ih->handle, FALSE); if (ih->data->type == IUP_TOGGLE_IMAGE && ih->data->flat) gtk_button_set_relief((GtkButton*)ih->handle, GTK_RELIEF_NONE); } if (ih->data->type == IUP_TOGGLE_IMAGE) gtkToggleUpdateImage(ih, iupdrvIsActive(ih), gtkToggleGetCheck(ih)); iupAttribSet(ih, "_IUPGTK_IGNORE_TOGGLE", NULL); if (last_ih) iupAttribSet(last_ih, "_IUPGTK_IGNORE_TOGGLE", NULL); } return 0; }
static int iScrollBoxButton_CB(Ihandle *ih, int but, int pressed, int x, int y, char* status) { if (but==IUP_BUTTON1 && pressed) { iupAttribSetInt(ih, "_IUP_START_X", x); iupAttribSetInt(ih, "_IUP_START_Y", y); iupAttribSetInt(ih, "_IUP_START_POSX", IupGetInt(ih, "POSX")); iupAttribSetInt(ih, "_IUP_START_POSY", IupGetInt(ih, "POSY")); iupAttribSet(ih, "_IUP_DRAG_SB", "1"); } if (but==IUP_BUTTON1 && !pressed) iupAttribSet(ih, "_IUP_DRAG_SB", NULL); (void)status; return IUP_DEFAULT; }
static int iFlatButtonSetValueAttrib(Ihandle* ih, const char* value) { if (iupAttribGetBoolean(ih, "TOGGLE")) { Ihandle* radio = iupRadioFindToggleParent(ih); if (radio) { /* can only set Radio to ON */ if (iupStrEqualNoCase(value, "TOGGLE") || iupStrBoolean(value)) { Ihandle* last_tg = (Ihandle*)iupAttribGet(radio, "_IUP_FLATBUTTON_LASTRADIO"); if (iupObjectCheck(last_tg) && last_tg != ih) { iupAttribSet(last_tg, "VALUE", "OFF"); if (last_tg->handle) iupdrvRedrawNow(last_tg); } iupAttribSet(radio, "_IUP_FLATBUTTON_LASTRADIO", (char*)ih); } else return 0; } else { if (iupStrEqualNoCase(value, "TOGGLE")) { int oldcheck = iupAttribGetBoolean(ih, "VALUE"); if (oldcheck) iupAttribSet(ih, "VALUE", "OFF"); else iupAttribSet(ih, "VALUE", "ON"); if (ih->handle) iupdrvRedrawNow(ih); return 0; } } if (ih->handle) iupdrvPostRedraw(ih); return 1; } else return 0; }
static void motListDragStart(Widget w, XButtonEvent* evt, String* params, Cardinal* num_params) { Atom atomListItem = XInternAtom(iupmot_display, "LIST_ITEM", False); Atom exportList[1]; Widget drop_context; int idDrag, num_args = 0; Arg args[40]; Ihandle *ih = NULL; XtVaGetValues(w, XmNuserData, &ih, NULL); if(!ih->handle) return; exportList[0] = atomListItem; idDrag = motListConvertXYToPos(ih, evt->x, evt->y); /* starts at 1 */ /* specify resources for DragContext for the transfer */ num_args = 0; iupMOT_SETARG(args, num_args, XmNexportTargets, exportList); iupMOT_SETARG(args, num_args, XmNnumExportTargets, 1); iupMOT_SETARG(args, num_args, XmNdragOperations, XmDROP_MOVE|XmDROP_COPY); iupMOT_SETARG(args, num_args, XmNconvertProc, motListConvertProc); iupMOT_SETARG(args, num_args, XmNclientData, idDrag); /* start the drag and register a callback to clean up when done */ drop_context = XmDragStart(w, (XEvent*)evt, args, num_args); XtAddCallback(drop_context, XmNdragDropFinishCallback, (XtCallbackProc)motListDragDropFinishCallback, NULL); XtAddCallback(drop_context, XmNdragMotionCallback, (XtCallbackProc)motListDragMotionCallback, (XtPointer)ih); iupAttribSet(ih, "_IUPLIST_DROPITEM", NULL); (void)params; (void)num_params; }
void iupListUpdateOldValue(Ihandle* ih, int pos, int removed) { if (!ih->data->has_editbox) { char* old_value = iupAttribGet(ih, "_IUPLIST_OLDVALUE"); if (old_value) { int old_pos = atoi(old_value)-1; /* was in IUP reference, starting at 1 */ if (ih->data->is_dropdown || !ih->data->is_multiple) { if (old_pos >= pos) { if (removed && old_pos == pos) { /* when the current item is removed nothing remains selected */ iupAttribSet(ih, "_IUPLIST_OLDVALUE", NULL); } else iupAttribSetInt(ih, "_IUPLIST_OLDVALUE", removed? old_pos-1: old_pos+1); } } else { /* multiple selection on a non drop-down list. */ char* value = IupGetAttribute(ih, "VALUE"); iupAttribSetStr(ih, "_IUPLIST_OLDVALUE", value); } } } }
static int CB_dblclick(Ihandle *ih, int item, char *text) { (void)text; iupAttribSetInt(IupGetDialog(ih), "_IUP_LIST_NUMBER", item-1); iupAttribSet(IupGetDialog(ih), "STATUS", "1"); return IUP_CLOSE; }
static void gtkDialogUnMapMethod(Ihandle* ih) { GtkWidget* inner_parent; #if GTK_CHECK_VERSION(2, 10, 0) GtkStatusIcon* status_icon; #endif if (ih->data->menu) { ih->data->menu->handle = NULL; /* the dialog will destroy the native menu */ IupDestroy(ih->data->menu); } #if GTK_CHECK_VERSION(2, 10, 0) status_icon = (GtkStatusIcon*)iupAttribGet(ih, "_IUPDLG_STATUSICON"); if (status_icon) { g_object_unref(status_icon); iupAttribSet(ih, "_IUPDLG_STATUSICON", NULL); } #endif inner_parent = gtk_bin_get_child((GtkBin*)ih->handle); gtk_widget_unrealize(inner_parent); gtk_widget_destroy(inner_parent); gtk_widget_unrealize(ih->handle); /* To match the call to gtk_widget_realize */ gtk_widget_destroy(ih->handle); /* To match the call to gtk_window_new */ }
static int iMatrixExSetPasteFileAttrib(Ihandle *ih, const char* value) { size_t size; char* data; FILE *file = fopen(value, "rb"); if (!file) { iupAttribSet(ih, "LASTERROR", "IUP_ERRORFILEOPEN"); return 0; } fseek(file, 0, SEEK_END); size = (size_t)ftell(file); fseek(file, 0, SEEK_SET); data = (char*)malloc(size+1); fread(data, size, 1, file); data[size] = 0; fclose(file); iMatrixExPasteData(ih, data, 0, 0, "PASTEFILE"); free(data); return 0; }