static int iGLExpanderGetBarSize(Ihandle* ih) { int bar_size; if (ih->data->barSize == -1) { iupGLFontGetCharSize(ih, NULL, &bar_size); /* define a minimum size only when estimating one from charsize */ if (bar_size < IEXPAND_HANDLE_SIZE) bar_size = IEXPAND_HANDLE_SIZE; if (ih->data->position == IEXPANDER_TOP) { char* title = iupAttribGetStr(ih, "TITLE"); char* image = iupAttribGetStr(ih, "IMAGE"); if (image) { int image_h = 0; iupGLImageGetInfo(image, NULL, &image_h, NULL); bar_size = iupMAX(bar_size, image_h); } if (title || image || ih->data->extra_buttons != 0) bar_size += 2 * IEXPAND_BACK_MARGIN; } } else bar_size = ih->data->barSize; return bar_size; }
static void iGLProgressBarComputeNaturalSizeMethod(Ihandle* ih, int *w, int *h, int *children_expand) { int natural_w = 0, natural_h = 0; int fit2backimage = iupAttribGetBoolean(ih, "FITTOBACKIMAGE"); char* bgimage = iupAttribGet(ih, "BACKIMAGE"); if (fit2backimage && bgimage) { iupAttribSet(ih, "BORDERWIDTH", "0"); iupGLImageGetInfo(bgimage, &natural_w, &natural_h, NULL); } else { iGLProgressBar* pb = (iGLProgressBar*)iupAttribGet(ih, "_IUP_GLPROGRESSBAR"); int charwidth, charheight; float bwidth = iupAttribGetFloat(ih, "BORDERWIDTH"); int border_width = (int)ceil(bwidth); int is_horizontal = iupStrEqualNoCase(iupAttribGetStr(ih, "ORIENTATION"), "HORIZONTAL"); iupGLFontGetCharSize(ih, &charwidth, &charheight); if (is_horizontal) { natural_h = charheight; if (ih->userwidth <= 0) natural_w = 15 * charwidth; } else { natural_w = charheight; if (ih->userheight <= 0) natural_h = 15 * charwidth; } natural_w += 2 * (pb->horiz_padding + border_width); natural_h += 2 * (pb->vert_padding + border_width); } *w = natural_w; *h = natural_h; (void)children_expand; /* unset if not a container */ }
static void iGLValComputeNaturalSizeMethod(Ihandle* ih, int *w, int *h, int *children_expand) { int natural_w = 0, natural_h = 0; int fit2backimage = iupAttribGetBoolean(ih, "FITTOBACKIMAGE"); char* bgimage = iupAttribGet(ih, "BACKIMAGE"); if (fit2backimage && bgimage) { iupAttribSet(ih, "BORDERWIDTH", "0"); iupGLImageGetInfo(bgimage, &natural_w, &natural_h, NULL); } else { int charwidth, charheight; int is_horizontal = iupStrEqualNoCase(iupAttribGetStr(ih, "ORIENTATION"), "HORIZONTAL"); iupGLFontGetCharSize(ih, &charwidth, &charheight); if (is_horizontal) { natural_h = charheight; if (ih->userwidth <= 0) natural_w = 15 * charwidth; } else { natural_w = charheight; if (ih->userheight <= 0) natural_h = 15 * charwidth; } } *w = natural_w; *h = natural_h; (void)children_expand; /* unset if not a container */ }