static int iMatrixSetSizeAttrib(Ihandle* ih, int pos, const char* value) { (void)pos; (void)value; ih->data->need_calcsize = 1; IupUpdate(ih); /* post a redraw */ return 1; }
int scroll_cb(Ihandle *ih, int op, float posx, float posy) { char* op2str[12] = {"SBUP", "SBDN", "SBPGUP", "SBPGDN", "SBPOSV", "SBDRAGV", "SBLEFT", "SBRIGHT", "SBPGLEFT", "SBPGRIGHT", "SBPOSH", "SBDRAGH"}; printf("SCROLL_CB(%s, posx=%.2f, posy=%.2f)\n", op2str[op], posx, posy); IupUpdate(ih); return IUP_DEFAULT; }
static void iLayoutDisplayUpdateChildren(Ihandle *ih) { Ihandle* child; for (child = ih->firstchild; child; child = child->brother) { iLayoutDisplayUpdateChildren(child); IupUpdate(child); } }
void iupMatrixDrawUpdate(Ihandle* ih) { cdCanvasFlush(ih->data->cd_canvas); if (ih->data->has_focus) iMatrixDrawFocus(ih); if (!ih->data->edit_hide_onfocus && ih->data->editing) IupUpdate(ih->data->datah); }
/*****************************************\ * Sets the RGB color in the Color Canvas * \*****************************************/ static void iColorDlgColor_Update(IcolorDlgData* colordlg_data) { colordlg_data->color = iupDrawColor(colordlg_data->red, colordlg_data->green, colordlg_data->blue, colordlg_data->alpha); IupUpdate(colordlg_data->color_cnv); { Ihandle* ih = IupGetDialog(colordlg_data->color_browser); Icallback cb = IupGetCallback(ih, "COLORUPDATE_CB"); if (cb) cb(ih); } }
static int iMatrixSetWidthAttrib(Ihandle* ih, const char* name_id, const char* value) { int col = 0; if (iupStrToInt(name_id, &col)) { (void)value; ih->data->need_calcsize = 1; IupUpdate(ih); } return 1; }
static int iMatrixSetRasterHeightAttrib(Ihandle* ih, const char* name_id, const char* value) { int lin = 0; if (iupStrToInt(name_id, &lin)) { (void)value; ih->data->need_calcsize = 1; IupUpdate(ih); } return 1; }
static int iColorDlgAlphaSpin_CB(Ihandle* ih, int vi) { IcolorDlgData* colordlg_data = (IcolorDlgData*)iupAttribGetInherit(ih, "_IUP_GC_DATA"); colordlg_data->alpha = (unsigned char)vi; IupSetInt(colordlg_data->alpha_val, "VALUE", (int)colordlg_data->alpha); colordlg_data->color = iupDrawColor(colordlg_data->red, colordlg_data->green, colordlg_data->blue, colordlg_data->alpha); IupUpdate(colordlg_data->color_cnv); return IUP_DEFAULT; }
static int iExpanderEnterWindow_cb(Ihandle* bar) { Ihandle* ih = bar->parent; if (!ih->data->highlight) { ih->data->highlight = 1; IupUpdate(ih->firstchild); if (ih->data->auto_show && ih->firstchild->brother && ih->data->state==IEXPANDER_CLOSE) IupSetAttribute(ih->data->timer, "RUN", "Yes"); } return IUP_DEFAULT; }
static int iExpanderLeaveWindow_cb(Ihandle* bar) { Ihandle* ih = bar->parent; if (ih->data->highlight) { ih->data->highlight = 0; IupUpdate(ih->firstchild); if (ih->data->auto_show) { if (IupGetInt(ih->data->timer, "RUN")) IupSetAttribute(ih->data->timer, "RUN", "No"); } } return IUP_DEFAULT; }
static int iColorDlgAlphaAction_CB(Ihandle* ih, int c, char* value) { IcolorDlgData* colordlg_data = (IcolorDlgData*)iupAttribGetInherit(ih, "_IUP_GC_DATA"); int vi; if (iupStrToInt(value, &vi)) { colordlg_data->alpha = (unsigned char)vi; IupSetInt(colordlg_data->alpha_val, "VALUE", (int)colordlg_data->alpha); colordlg_data->color = iupDrawColor(colordlg_data->red, colordlg_data->green, colordlg_data->blue, colordlg_data->alpha); IupUpdate(colordlg_data->color_cnv); } (void)c; return IUP_DEFAULT; }
static void iExpanderOpenCloseChild(Ihandle* ih, int refresh) { Ihandle *child = ih->firstchild->brother; IupUpdate(ih->firstchild); if (!child) return; if (ih->data->state == IEXPANDER_CLOSE) IupSetAttribute(child, "VISIBLE", "NO"); else IupSetAttribute(child, "VISIBLE", "YES"); if (refresh) IupRefresh(child); /* this will recompute the layout of the hole dialog */ }
int item_paste_action_cb(Ihandle* item_paste) { if (save_check(item_paste)) { Ihandle* canvas = IupGetDialogChild(item_paste, "CANVAS"); imImage* old_image = (imImage*)IupGetAttribute(canvas, "IMAGE"); Ihandle *clipboard = IupClipboard(); imImage* image = IupGetNativeHandleImage(IupGetAttribute(clipboard, "NATIVEIMAGE")); IupDestroy(clipboard); if (!image) { show_error("Invalid Clipboard Data", 1); return IUP_DEFAULT; } /* we are going to support only RGB images with no alpha */ imImageRemoveAlpha(image); if (image->color_space != IM_RGB) { imImage* new_image = imImageCreateBased(image, -1, -1, IM_RGB, -1); imConvertColorSpace(image, new_image); imImageDestroy(image); image = new_image; } /* create OpenGL compatible data */ imImageGetOpenGLData(image, NULL); imImageSetAttribString(image, "FileFormat", "JPEG"); IupSetAttribute(canvas, "DIRTY", "Yes"); IupSetAttribute(canvas, "IMAGE", (char*)image); IupSetAttribute(canvas, "FILENAME", NULL); IupSetAttribute(IupGetDialog(canvas), "TITLE", "Untitled - Simple Paint"); IupUpdate(canvas); if (old_image) imImageDestroy(old_image); } return IUP_DEFAULT; }
int canvas_wheel_cb(Ihandle* canvas, float delta) { if (IupGetInt(NULL, "CONTROLKEY")) { if (delta < 0) zoomout_action_cb(canvas); else zoomin_action_cb(canvas); } else { float posy = IupGetFloat(canvas, "POSY"); posy -= delta * IupGetFloat(canvas, "DY") / 10.0f; IupSetFloat(canvas, "POSY", posy); IupUpdate(canvas); } return IUP_DEFAULT; }
static int iColorDlgColorSelDrag_CB(Ihandle* ih, unsigned char r, unsigned char g, unsigned char b) { IcolorDlgData* colordlg_data = (IcolorDlgData*)iupAttribGetInherit(ih, "_IUP_GC_DATA"); colordlg_data->red = r; colordlg_data->green = g; colordlg_data->blue = b; iColorDlgRGB2HSI(colordlg_data); iColorDlgHex_TXT_Update(colordlg_data); iColorDlgHSI_TXT_Update(colordlg_data); iColorDlgRGB_TXT_Update(colordlg_data); colordlg_data->color = iupDrawColor(colordlg_data->red, colordlg_data->green, colordlg_data->blue, colordlg_data->alpha); IupUpdate(colordlg_data->color_cnv); return IUP_DEFAULT; }
static int motion_cb(Ihandle *self,int x,int y,char *r) { int dx, dy, posx, posy, w, h; int maxwidth = 0, maxheight = 0; IupSetAttribute(self, "CURSOR", "ARROW"); /* move all the controls except the CBOX itself */ if (iupStrEqual("cbox", IupGetClassName(self))) return IUP_DEFAULT; IupSetAttribute(self, "CURSOR", "HAND"); if (!isbutton1(r)) return IUP_DEFAULT; if (!moving) return IUP_DEFAULT; dx = x - start_x; dy = y - start_y; posx = iupGetPosX(self); posy = iupGetPosY(self); posx += dx; posy += dy; if (posx < 0) posx = 0; if (posy < 0) posy = 0; iupGetSize(self, &w, &h); iupGetSize(getCBox(self), &maxwidth, &maxheight); if (posx+w > maxwidth) posx = maxwidth-1 - w; if (posy+h > maxheight) posy = maxheight-1 - h; updateCXY(self, posx, posy); iupCpiSetPosition(self, posx, posy); iupdrvResizeObjects(self); IupUpdate(IupGetDialog(self)); return IUP_DEFAULT; }
static int iColorDlgSetAlphaAttrib(Ihandle* ih, const char* value) { IcolorDlgData* colordlg_data = (IcolorDlgData*)iupAttribGetInherit(ih, "_IUP_GC_DATA"); int alpha; if (iupStrToInt(value, &alpha)) { colordlg_data->alpha = (unsigned char)alpha; IupSetInt(colordlg_data->alpha_txt, "VALUE", (int)colordlg_data->alpha); IupSetInt(colordlg_data->alpha_val, "VALUE", (int)colordlg_data->alpha); colordlg_data->color = iupDrawColor(colordlg_data->red, colordlg_data->green, colordlg_data->blue, colordlg_data->alpha); colordlg_data->previous_color = iupDrawColor(iupDrawRed(colordlg_data->previous_color), iupDrawGreen(colordlg_data->previous_color), iupDrawBlue(colordlg_data->previous_color), colordlg_data->alpha); IupUpdate(colordlg_data->color_cnv); if (!ih->handle) /* do it only before map */ IupSetAttribute(ih, "SHOWALPHA", "YES"); } return 1; }
void new_file(Ihandle* ih, imImage* image) { Ihandle* dlg = IupGetDialog(ih); Ihandle* canvas = IupGetDialogChild(dlg, "CANVAS"); imImage* old_image = (imImage*)IupGetAttribute(canvas, "IMAGE"); IupSetAttribute(dlg, "TITLE", "Untitled - Simple Paint"); IupSetAttribute(canvas, "FILENAME", NULL); IupSetAttribute(canvas, "DIRTY", "NO"); IupSetAttribute(canvas, "IMAGE", (char*)image); /* create OpenGL compatible data */ imImageGetOpenGLData(image, NULL); IupUpdate(canvas); if (old_image) imImageDestroy(old_image); }
void zoom_update(Ihandle* ih, double zoom_index) { Ihandle* zoom_lbl = IupGetDialogChild(ih, "ZOOMLABEL"); Ihandle* canvas = IupGetDialogChild(ih, "CANVAS"); imImage* image = (imImage*)IupGetAttribute(canvas, "IMAGE"); double zoom_factor = pow(2, zoom_index); IupSetStrf(zoom_lbl, "TITLE", "%.0f%%", floor(zoom_factor * 100)); if (image) { float old_center_x, old_center_y; int view_width = (int)(zoom_factor * image->width); int view_height = (int)(zoom_factor * image->height); scroll_calc_center(canvas, &old_center_x, &old_center_y); scrollbar_update(canvas, view_width, view_height); scroll_center(canvas, old_center_x, old_center_y); } IupUpdate(canvas); }
int item_background_action_cb(Ihandle* item_background) { Ihandle* canvas = IupGetDialogChild(item_background, "CANVAS"); Ihandle* config = (Ihandle*)IupGetAttribute(canvas, "CONFIG"); Ihandle* colordlg = IupColorDlg(); const char* background = IupConfigGetVariableStrDef(config, "MainWindow", "Background", "255 255 255"); IupSetStrAttribute(colordlg, "VALUE", background); IupSetAttributeHandle(colordlg, "PARENTDIALOG", IupGetDialog(item_background)); IupPopup(colordlg, IUP_CENTERPARENT, IUP_CENTERPARENT); if (IupGetInt(colordlg, "STATUS") == 1) { background = IupGetAttribute(colordlg, "VALUE"); IupConfigSetVariableStr(config, "MainWindow", "Background", background); IupUpdate(canvas); } IupDestroy(colordlg); return IUP_DEFAULT; }
void open_file(Ihandle* ih, const char* filename) { imImage* image = read_file(filename); if (image) { Ihandle* dlg = IupGetDialog(ih); Ihandle* canvas = IupGetDialogChild(dlg, "CANVAS"); Ihandle* config = (Ihandle*)IupGetAttribute(canvas, "CONFIG"); imImage* old_image = (imImage*)IupGetAttribute(canvas, "IMAGE"); IupSetfAttribute(dlg, "TITLE", "%s - Simple Paint", str_filetitle(filename)); IupSetStrAttribute(canvas, "FILENAME", filename); IupSetAttribute(canvas, "DIRTY", "NO"); IupSetAttribute(canvas, "IMAGE", (char*)image); IupUpdate(canvas); if (old_image) imImageDestroy(old_image); IupConfigRecentUpdate(config, filename); } }
int main(int argc, char** argv) { IupOpen(&argc, &argv); #ifdef USE_CONTEXTPLUS cdInitContextPlus(); #endif #ifdef USE_OPENGL IupGLCanvasOpen(); #endif simple_loadled(); #ifdef USE_OPENGL { Ihandle* dialog = IupGetHandle("SimpleDialog"); Ihandle* canvas = IupGetHandle("SimpleCanvas"); IupDestroy(canvas); canvas = IupGLCanvas("SimpleRepaint"); IupSetAttribute(canvas, "BUFFER", "DOUBLE"); IupSetHandle("SimpleCanvas", canvas); IupAppend(dialog, canvas); } #endif IupSetAttribute(IupGetHandle("SimpleDialog"), "SIZE", "HALFxHALF"); IupSetAttribute(IupGetHandle("SimpleDialog"), "PLACEMENT", "MAXIMIZED"); IupShow(IupGetHandle("SimpleDialog")); IupSetAttribute(IupGetHandle("SimpleDialog"), "SIZE", NULL); SimpleCreateCanvas((char*)IupGetHandle("SimpleCanvas")); IupSetFunction("cmdExit", (Icallback) cmdExit); IupSetFunction("SimplePlayClipboard", (Icallback) SimplePlayClipboard); IupSetFunction("SimplePlayCGMText", (Icallback) SimplePlayCGMText); IupSetFunction("SimplePlayCGMBin", (Icallback) SimplePlayCGMBin); IupSetFunction("SimplePlayMetafile", (Icallback) SimplePlayMetafile); IupSetFunction("SimplePlayWMF", (Icallback) SimplePlayWMF); IupSetFunction("SimplePlayEMF", (Icallback) SimplePlayEMF); IupSetFunction("SimpleDrawDebug", (Icallback) SimpleDrawDebug); IupSetFunction("SimpleDrawWindow", (Icallback) SimpleDrawWindow); IupSetFunction("SimpleDrawCGMText", (Icallback) SimpleDrawCGMText); IupSetFunction("SimpleDrawCGMBin", (Icallback) SimpleDrawCGMBin); IupSetFunction("SimpleDrawDXF", (Icallback) SimpleDrawDXF); IupSetFunction("SimpleDrawDGN", (Icallback) SimpleDrawDGN); IupSetFunction("SimpleDrawEMF", (Icallback) SimpleDrawEMF); IupSetFunction("SimpleDrawMetafile", (Icallback) SimpleDrawMetafile); IupSetFunction("SimpleDrawPDF", (Icallback) SimpleDrawPDF); IupSetFunction("SimpleDrawPS", (Icallback) SimpleDrawPS); IupSetFunction("SimpleDrawEPS", (Icallback) SimpleDrawEPS); IupSetFunction("SimpleDrawSVG", (Icallback) SimpleDrawSVG); IupSetFunction("SimpleDrawWMF", (Icallback)SimpleDrawWMF); IupSetFunction("SimpleDrawPPTX", (Icallback)SimpleDrawPPTX); IupSetFunction("SimpleDrawPrint", (Icallback)SimpleDrawPrint); IupSetFunction("SimpleDrawPrintDialog", (Icallback) SimpleDrawPrintDialog); IupSetFunction("SimpleDrawClipboardBitmap", (Icallback) SimpleDrawClipboardBitmap); IupSetFunction("SimpleDrawClipboardMetafile", (Icallback) SimpleDrawClipboardMetafile); IupSetFunction("SimpleDrawClipboardEMF", (Icallback) SimpleDrawClipboardEMF); IupSetFunction("SimpleDrawImage", (Icallback) SimpleDrawImage); IupSetFunction("SimpleDrawImageRGB", (Icallback) SimpleDrawImageRGB); IupSetFunction("SimpleDrawSimulate", (Icallback) SimpleDrawSimulate); #ifdef USE_OPENGL IupSetFunction("SimpleDrawGL", (Icallback) SimpleDrawGL); #endif IupSetFunction("SimpleNotXor", (Icallback) SimpleNotXor); IupSetFunction("SimpleXor", (Icallback) SimpleXor); IupSetFunction("SimpleReplace", (Icallback) SimpleReplace); IupSetFunction("SimpleClippingOff", (Icallback) SimpleClippingOff); IupSetFunction("SimpleClippingArea", (Icallback) SimpleClippingArea); IupSetFunction("SimpleClippingPolygon", (Icallback) SimpleClippingPolygon); IupSetFunction("SimpleClippingRegion", (Icallback) SimpleClippingRegion); IupSetFunction("SimpleContextPlus", (Icallback) SimpleContextPlus); IupSetFunction("SimpleTransform", (Icallback) SimpleTransform); IupSetFunction("SimpleAll", (Icallback) SimpleAll); IupSetFunction("SimpleTextAlign", (Icallback)SimpleTextAlign); IupSetFunction("SimpleTextFonts", (Icallback)SimpleTextFonts); IupSetFunction("SimpleTest", (Icallback) SimpleTest); IupSetFunction("SimpleRepaint", (Icallback) SimpleRepaint); SimpleDrawWindow(); #ifdef USE_OPENGL SimpleUpdateSize(NULL); IupUpdate(IupGetHandle("SimpleCanvas")); #endif IupMainLoop(); SimpleKillCanvas(); #ifdef USE_CONTEXTPLUS cdFinishContextPlus(); #endif IupClose(); return EXIT_SUCCESS; }
static void Update(void) { IupUpdate(iuplua_checkihandle(1)); }
static int iExpanderSetUpdateAttrib(Ihandle* ih, const char* value) { (void)value; IupUpdate(ih->firstchild); return 1; /* store value in hash table */ }
static int iDetachBoxSetColorAttrib(Ihandle* ih, const char* value) { (void)value; IupUpdate(ih->firstchild); /* only updates the bar */ return 1; /* store value in hash table */ }
static int Update (lua_State *L) { IupUpdate(iuplua_checkihandle(L,1)); return 0; }