int actualsize_action_cb(Ihandle* ih) { Ihandle* zoom_val = IupGetDialogChild(ih, "ZOOMVAL"); IupSetDouble(zoom_val, "VALUE", 0); zoom_update(ih, 0); return IUP_DEFAULT; }
int progressCb(long total, long now, double kBps){ double progress = (double)now/(double)total; IupSetDouble(pb, "VALUE", progress); IupSetStrf(status, "TITLE", "Total file size: %dKb, downloaded: %dKb\n(progress: %d%%, average speed: %dkBps)", total/1000, now/1000, (int)(progress*100), (int)kBps); IupRefresh(downloaderGui); IupLoopStep(); return stop; }
int zoomin_action_cb(Ihandle* ih) { Ihandle* zoom_val = IupGetDialogChild(ih, "ZOOMVAL"); double zoom_index = IupGetDouble(zoom_val, "VALUE"); zoom_index++; if (zoom_index > 6) zoom_index = 6; IupSetDouble(zoom_val, "VALUE", round(zoom_index)); /* fixed increments when using buttons */ zoom_update(ih, zoom_index); return IUP_DEFAULT; }
void set_new_image(Ihandle* canvas, imImage* image, const char* filename, int dirty) { imImage* old_image = (imImage*)IupGetAttribute(canvas, "IMAGE"); Ihandle* size_lbl = IupGetDialogChild(canvas, "SIZELABEL"); Ihandle* zoom_val = IupGetDialogChild(canvas, "ZOOMVAL"); if (filename) { IupSetStrAttribute(canvas, "FILENAME", filename); IupSetfAttribute(IupGetDialog(canvas), "TITLE", "%s - Simple Paint", str_filetitle(filename)); } else { IupSetAttribute(canvas, "FILENAME", NULL); IupSetAttribute(IupGetDialog(canvas), "TITLE", "Untitled - Simple Paint"); } /* 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; } /* default file format */ const char* format = imImageGetAttribString(image, "FileFormat"); if (!format) imImageSetAttribString(image, "FileFormat", "JPEG"); IupSetAttribute(canvas, "DIRTY", dirty? "Yes": "No"); IupSetAttribute(canvas, "IMAGE", (char*)image); IupSetfAttribute(size_lbl, "TITLE", "%d x %d px", image->width, image->height); if (old_image) imImageDestroy(old_image); IupSetDouble(zoom_val, "VALUE", 0); zoom_update(canvas, 0); }