static int iGLProgressBarACTION_CB(Ihandle* ih) { iGLProgressBar* pb = (iGLProgressBar*)iupAttribGet(ih, "_IUP_GLPROGRESSBAR"); float bwidth = iupAttribGetFloat(ih, "BORDERWIDTH"); char* bordercolor = iupAttribGetStr(ih, "BORDERCOLOR"); int active = iupAttribGetInt(ih, "ACTIVE"); char* bgcolor = iupAttribGetStr(ih, "BGCOLOR"); int border_width = (int)ceil(bwidth); char* bgimage = iupAttribGet(ih, "BACKIMAGE"); /* draw background */ if (bgimage) iupGLDrawImageZoom(ih, border_width, ih->currentwidth - 1 - border_width, border_width, ih->currentheight - 1 - border_width, "BACKIMAGE", bgimage, active); else { iupGLDrawBox(ih, border_width, ih->currentwidth - 1 - border_width, border_width, ih->currentheight - 1 - border_width, bgcolor, 1); /* always active */ /* draw border - can be disabled setting bwidth=0 after the background because of the round rect */ iupGLDrawRect(ih, 0, ih->currentwidth - 1, 0, ih->currentheight - 1, bwidth, bordercolor, active, 1); } if (pb->show_text || pb->value != pb->vmin) { int xmin = pb->horiz_padding + border_width; int ymin = pb->vert_padding + border_width; int xmax = ih->currentwidth - 1 - (pb->horiz_padding + border_width); int ymax = ih->currentheight - 1 - (pb->vert_padding + border_width); double percent = (pb->value - pb->vmin) / (pb->vmax - pb->vmin); int is_horizontal = iupStrEqualNoCase(iupAttribGetStr(ih, "ORIENTATION"), "HORIZONTAL"); if (pb->value != pb->vmin) { char* fgcolor = iupAttribGetStr(ih, "FGCOLOR"); if (is_horizontal) { int xmid = xmin + iupRound((xmax - xmin + 1) * percent); iupGLDrawBox(ih, xmin, xmid, ymin, ymax, fgcolor, 1); } else { int ymid = ymin + iupRound((ymax - ymin + 1) * (1.0 - percent)); iupGLDrawBox(ih, xmin, xmax, ymid, ymax, fgcolor, 1); } } if (pb->show_text && is_horizontal) iGLProgressBarDrawText(ih, percent, xmin, ymin, xmax - xmin + 1, ymax - ymin + 1, active); } return IUP_DEFAULT; }
static int iGLValIsInsideHandler(Ihandle* ih, int x, int y) { iGLVal* val = (iGLVal*)iupAttribGet(ih, "_IUP_GLVAL"); int is_horizontal = iupStrEqualNoCase(iupAttribGetStr(ih, "ORIENTATION"), "HORIZONTAL"); double percent; int p, p1, p2, pmid, handler_op_size; int handler_size = iGLValGetSliderInfo(ih, x, y, is_horizontal, &p, &p1, &p2, &handler_op_size); percent = (val->value - val->vmin) / (val->vmax - val->vmin); if (!is_horizontal) percent = 1.0 - percent; pmid = p1 + iupRound((p2 - p1) * percent); p1 = pmid - handler_size / 2; p2 = pmid + handler_size / 2; if (p >= p1 && p <= p2) { int q, q1, q2, qmid, op_size; iGLValGetSliderOpositeInfo(ih, x, y, is_horizontal, &q, &op_size); qmid = op_size / 2; q1 = qmid - handler_op_size / 2; q2 = qmid + handler_op_size / 2; if (q >= q1 && q <= q2) return 1; else return 0; } else return 0; }
void iupdrvDrawArc(IdrawCanvas* dc, int x1, int y1, int x2, int y2, double a1, double a2, long color, int style, int line_width) { GdkColor c; iupgdkColorSet(&c, color); gdk_gc_set_rgb_fg_color(dc->pixmap_gc, &c); iupDrawCheckSwapCoord(x1, x2); iupDrawCheckSwapCoord(y1, y2); if (style != IUP_DRAW_FILL) { iDrawSetLineWidth(dc, line_width); iDrawSetLineStyle(dc, style); } /* using x2-x1+1 was resulting in a pixel larger arc */ gdk_draw_arc(dc->pixmap, dc->pixmap_gc, style == IUP_DRAW_FILL, x1, y1, x2 - x1, y2 - y1, iupRound(a1 * 64), iupRound((a2 - a1) * 64)); /* angle = 1/64ths of a degree */ }
void iupdrvDrawArc(IdrawCanvas* dc, int x1, int y1, int x2, int y2, double a1, double a2, unsigned char r, unsigned char g, unsigned char b, int style) { GdkColor color; iupgdkColorSet(&color, r, g, b); gdk_gc_set_rgb_fg_color(dc->pixmap_gc, &color); if (style!=IUP_DRAW_FILL) iDrawSetLineStyle(dc, style); gdk_draw_arc(dc->pixmap, dc->pixmap_gc, style == IUP_DRAW_FILL, x1, y1, x2 - x1 + 1, y2 - y1 + 1, iupRound(a1 * 64), iupRound((a2 - a1) * 64)); }
static int iGLValACTION_CB(Ihandle* ih) { iGLVal* val = (iGLVal*)iupAttribGet(ih, "_IUP_GLVAL"); float bwidth = iupAttribGetFloat(ih, "BORDERWIDTH"); char* bordercolor = iupAttribGetStr(ih, "BORDERCOLOR"); int active = iupAttribGetInt(ih, "ACTIVE"); char* bgcolor = iupAttribGetStr(ih, "BGCOLOR"); int slider_size = iupAttribGetInt(ih, "SLIDERSIZE"); int border_width = (int)ceil(bwidth); int is_horizontal = iupStrEqualNoCase(iupAttribGetStr(ih, "ORIENTATION"), "HORIZONTAL"); int handler_width, handler_height; char *image = iupAttribGet(ih, "IMAGE"); char* bgimage = iupAttribGet(ih, "BACKIMAGE"); double percent = (val->value - val->vmin) / (val->vmax - val->vmin); int x1, y1, x2, y2; iGLValGetHandlerSize(ih, is_horizontal, &handler_width, &handler_height); if (is_horizontal) { x1 = handler_width / 2; x2 = ih->currentwidth - 1 - handler_width / 2; y1 = (ih->currentheight - slider_size) / 2; y2 = y1 + slider_size; } else { y1 = handler_height / 2; y2 = ih->currentheight - 1 - handler_height / 2; x1 = (ih->currentwidth - slider_size) / 2; x2 = x1 + slider_size; } /* draw slider background */ if (bgimage) iupGLDrawIconImageZoom(ih, border_width, border_width, border_width, border_width, "BACKIMAGE", bgimage, active); else { iupGLDrawBox(ih, x1 + border_width, x2 - border_width, y1 + border_width, y2 - border_width, bgcolor, 1); /* always active */ /* draw slider border - can be disabled setting bwidth=0 */ iupGLDrawRect(ih, x1, x2, y1, y2, bwidth, bordercolor, active, 0); } if (is_horizontal) { int xmid = x1 + iupRound((x2 - x1) * percent); x1 = xmid - handler_width / 2; if (x1 < 0) x1 = 0; x2 = xmid + handler_width / 2; if (x2 > ih->currentwidth - 1) x2 = ih->currentwidth - 1; y1 = 0; y2 = ih->currentheight - 1; } else { int ymid = y1 + iupRound((y2 - y1) * (1.0 - percent)); y1 = ymid - handler_height / 2; if (y1 < 0) y1 = 0; y2 = ymid + handler_height / 2; if (y2 > ih->currentheight - 1) y2 = ih->currentheight - 1; x1 = 0; x2 = ih->currentwidth - 1; } if (image) { int x, y, width, height; iupGLImageGetInfo(image, &width, &height, NULL); /* always center the image */ x = (x2 - x1 + 1 - width) / 2; y = (y2 - y1 + 1 - height) / 2; if (x1 + x < 0) x = 0; if (y1 + y < 0) y = 0; if (x1 + x + width > ih->currentwidth - 1) x = ih->currentwidth - 1 - width - x1; if (y1 + y + height > ih->currentheight - 1) y = ih->currentheight - 1 - height - y1; iupGLDrawIconImage(ih, x1 + x, y1 + y, "IMAGE", image, active); } else { int pressed = iupAttribGetInt(ih, "PRESSED"); int highlight = iupAttribGetInt(ih, "HIGHLIGHT"); char* fgcolor = iupAttribGetStr(ih, "FGCOLOR"); if (pressed) { char* presscolor = iupAttribGetStr(ih, "PSCOLOR"); if (presscolor) fgcolor = presscolor; } else if (highlight) { char* hlcolor = iupAttribGetStr(ih, "HLCOLOR"); if (hlcolor) fgcolor = hlcolor; } /* draw handler foreground */ iupGLDrawBox(ih, x1 + border_width, x2 - border_width, y1 + border_width, y2 - border_width, fgcolor, active); /* draw handler border - can still be disabled setting bwidth=0 after the background because of the round rect */ iupGLDrawRect(ih, x1, x2, y1, y2, bwidth, bordercolor, active, 1); } return IUP_DEFAULT; }
/*************************************************\ * Updates text fields with the current HSI values * \*************************************************/ static void iColorDlgHSI_TXT_Update(IcolorDlgData* colordlg_data) { IupSetInt(colordlg_data->hue_txt, "VALUE", iupROUND(colordlg_data->hue)); IupSetInt(colordlg_data->saturation_txt, "VALUE", iupRound(colordlg_data->saturation * 100)); IupSetInt(colordlg_data->intensity_txt, "VALUE", iupRound(colordlg_data->intensity * 100)); }
void iupDrawArc(IdrawCanvas* dc, int x1, int y1, int x2, int y2, double a1, double a2, unsigned char r, unsigned char g, unsigned char b, int style) { XSetForeground(iupmot_display, dc->pixmap_gc, iupmotColorGetPixel(r, g, b)); if (style==IUP_DRAW_FILL) { XSetArcMode(iupmot_display, dc->pixmap_gc, ArcPieSlice); XFillArc(iupmot_display, dc->pixmap, dc->pixmap_gc, x1, y1, x2 - x1 + 1, y2 - y1 + 1, iupRound(a1 * 64), iupRound((a2 - a1) * 64)); } else { XGCValues gcval; if (style==IUP_DRAW_STROKE_DASH) gcval.line_style = LineOnOffDash; else gcval.line_style = LineSolid; XChangeGC(iupmot_display, dc->pixmap_gc, GCLineStyle, &gcval); XDrawArc(iupmot_display, dc->pixmap, dc->pixmap_gc, x1, y1, x2 - x1 + 1, y2 - y1 + 1, iupRound(a1 * 64), iupRound((a2 - a1) * 64)); } }