static void iFlatButtonDrawBorder(IdrawCanvas* dc, int xmin, int xmax, int ymin, int ymax, int border_width, const char* color, char* bgcolor, int active) { unsigned char r = 0, g = 0, b = 0; if (!color || border_width == 0 || xmin == xmax || ymin == ymax) return; if (xmin > xmax) { int _t = xmin; xmin = xmax; xmax = _t; } if (ymin > ymax) { int _t = ymin; ymin = ymax; ymax = _t; } iupStrToRGB(color, &r, &g, &b); if (!active) { unsigned char bg_r = 0, bg_g = 0, bg_b = 0; iupStrToRGB(bgcolor, &bg_r, &bg_g, &bg_b); iupImageColorMakeInactive(&r, &g, &b, bg_r, bg_g, bg_b); } iupDrawRectangle(dc, xmin, ymin, xmax, ymax, r, g, b, IUP_DRAW_STROKE); while (border_width > 1) { border_width--; iupDrawRectangle(dc, xmin + border_width, ymin + border_width, xmax - border_width, ymax - border_width, r, g, b, IUP_DRAW_STROKE); } }
static int iSplitAction_CB(Ihandle* bar) { Ihandle* ih = bar->parent; IdrawCanvas* dc = iupDrawCreateCanvas(bar); iupDrawParentBackground(dc); if (ih->data->showgrip) { int i, w, h, x, y, count; unsigned char r = 160, g = 160, b = 160, bg_r, bg_g, bg_b; iupDrawGetSize(dc, &w, &h); iupStrToRGB(IupGetAttribute(ih, "COLOR"), &r, &g, &b); if (r+g+b > 3*190) { bg_r = 100; bg_g = 100; bg_b = 100; } else { bg_r = 255; bg_g = 255; bg_b = 255; } if (ih->data->orientation == ISPLIT_VERT) { x = ih->data->barsize/2-1; y = 2; count = (h-2)/5; } else { x = 2; y = ih->data->barsize/2-1; count = (w-2)/5; } for (i = 0; i < count; i++) { iupDrawRectangle(dc, x+1, y+1, x+2, y+2, bg_r, bg_g, bg_b, IUP_DRAW_FILL); iupDrawRectangle(dc, x, y, x+1, y+1, r, g, b, IUP_DRAW_FILL); if (ih->data->orientation == ISPLIT_VERT) y += 5; else x += 5; } } iupDrawFlush(dc); iupDrawKillCanvas(dc); return IUP_DEFAULT; }
void iupDrawParentBackground(IdrawCanvas* dc) { unsigned char r=0, g=0, b=0; char* color = iupBaseNativeParentGetBgColorAttrib(dc->ih); iupStrToRGB(color, &r, &g, &b); iupDrawRectangle(dc, 0, 0, dc->w-1, dc->h-1, r, g, b, IUP_DRAW_FILL); }
static void iFlatButtonDrawBox(IdrawCanvas* dc, int xmin, int xmax, int ymin, int ymax, const char* color, char* bgcolor, int active) { unsigned char r = 0, g = 0, b = 0; if (!color || xmin == xmax || ymin == ymax) return; if (xmin > xmax) { int _t = xmin; xmin = xmax; xmax = _t; } if (ymin > ymax) { int _t = ymin; ymin = ymax; ymax = _t; } iupStrToRGB(color, &r, &g, &b); if (!active) { unsigned char bg_r = 0, bg_g = 0, bg_b = 0; iupStrToRGB(bgcolor, &bg_r, &bg_g, &bg_b); iupImageColorMakeInactive(&r, &g, &b, bg_r, bg_g, bg_b); } iupDrawRectangle(dc, xmin, ymin, xmax, ymax, r, g, b, IUP_DRAW_FILL); }