static void iTextComputeNaturalSizeMethod(Ihandle* ih, int *w, int *h, int *expand) { int natural_w = 0, natural_h = 0, visiblecolumns = iupAttribGetInt(ih, "VISIBLECOLUMNS"), visiblelines = iupAttribGetInt(ih, "VISIBLELINES"); (void)expand; /* unset if not a container */ /* Since the contents can be changed by the user, the size can not be dependent on it. */ if (ih->data->is_multiline) { iupdrvFontGetCharSize(ih, NULL, &natural_h); /* one line height */ natural_w = iupdrvFontGetStringWidth(ih, "WWWWWWWWWW"); natural_w = (visiblecolumns*natural_w)/10; natural_h = visiblelines*natural_h; } else { iupdrvFontGetCharSize(ih, NULL, &natural_h); /* one line height */ natural_w = iupdrvFontGetStringWidth(ih, "WWWWWWWWWW"); natural_w = (visiblecolumns*natural_w)/10; } /* compute the borders space */ if (iupAttribGetBoolean(ih, "BORDER")) iupdrvTextAddBorders(&natural_w, &natural_h); if (iupAttribGetBoolean(ih, "SPIN")) iupdrvTextAddSpin(&natural_w, natural_h); natural_w += 2*ih->data->horiz_padding; natural_h += 2*ih->data->vert_padding; /* add scrollbar */ if (ih->data->is_multiline && ih->data->sb) { int sb_size = iupdrvGetScrollbarSize(); if (ih->data->sb & IUP_SB_HORIZ) natural_w += sb_size; if (ih->data->sb & IUP_SB_VERT) natural_h += sb_size; } *w = natural_w; *h = natural_h; }
static void winDatePickComputeNaturalSizeMethod(Ihandle* ih, int *w, int *h, int *children_expand) { (void)children_expand; /* unset if not a container */ if (ih->handle && iupwinIsVistaOrNew() && iupwin_comctl32ver6) { SIZE size; SendMessage(ih->handle, DTM_GETIDEALSIZE, 0, (LPARAM)&size); *w = size.cx; *h = size.cy; } else { iupdrvFontGetMultiLineStringSize(ih, "WW/WW/WWWW", w, h); iupdrvTextAddBorders(w, h); *w += iupdrvGetScrollbarSize(); } }
static void winCalendarComputeNaturalSizeMethod(Ihandle* ih, int *w, int *h, int *children_expand) { (void)children_expand; /* unset if not a container */ if (ih->handle) { RECT rect; SendMessage(ih->handle, MCM_GETMINREQRECT, 0, (LPARAM)&rect); *w = rect.right - rect.left; *h = rect.bottom - rect.top; } else { iupdrvFontGetMultiLineStringSize(ih, "W8W", w, h); (*w) *= 7; /* 7 columns */ (*h) *= 8; /* 9 lines */ iupdrvTextAddBorders(w, h); } }