static void calc_entry_dimens(WMenu *menu) { int i, n=extl_table_get_n(menu->tab); GrFontExtents fnte; GrBorderWidths bdw; int maxw=0; char *str; #if 0 if(extl_table_gets_s(menu->tab, title, &str)){ maxw=grbrush_get_text_width(title_brush, str, strlen(str)); free(str); } #endif for(i=1; i<=n; i++){ if(extl_table_getis(menu->tab, i, "name", 's', &str)){ int w=grbrush_get_text_width(menu->entry_brush, str, strlen(str)); if(w>maxw) maxw=w; free(str); } } grbrush_get_border_widths(menu->entry_brush, &bdw); grbrush_get_font_extents(menu->entry_brush, &fnte); menu->max_entry_w=maxw+bdw.left+bdw.right; menu->entry_h=fnte.max_height+bdw.top+bdw.bottom; menu->entry_spacing=bdw.spacing; }
static void infowin_resize(WInfoWin *p) { WRQGeomParams rq=RQGEOMPARAMS_INIT; const char *str=INFOWIN_BUFFER(p); GrBorderWidths bdw; GrFontExtents fnte; rq.flags=REGION_RQGEOM_WEAK_X|REGION_RQGEOM_WEAK_Y; rq.geom.x=REGION_GEOM(p).x; rq.geom.y=REGION_GEOM(p).y; grbrush_get_border_widths(p->brush, &bdw); grbrush_get_font_extents(p->brush, &fnte); rq.geom.w=bdw.left+bdw.right; rq.geom.w+=grbrush_get_text_width(p->brush, str, strlen(str)); rq.geom.h=fnte.max_height+bdw.top+bdw.bottom; if(rectangle_compare(&rq.geom, ®ION_GEOM(p))!=RECTANGLE_SAME) region_rqgeom((WRegion*)p, &rq, NULL); }
static WInfoWin *setup_moveres_display(WWindow *parent, int cx, int cy) { GrBorderWidths bdw; GrFontExtents fnte; WInfoWin *infowin; WFitParams fp; fp.mode=REGION_FIT_EXACT; fp.g.x=0; fp.g.y=0; fp.g.w=1; fp.g.h=1; infowin=create_infowin(parent, &fp, "moveres_display"); if(infowin==NULL) return NULL; grbrush_get_border_widths(INFOWIN_BRUSH(infowin), &bdw); grbrush_get_font_extents(INFOWIN_BRUSH(infowin), &fnte); /* Create move/resize position/size display window */ fp.g.w=3; fp.g.w+=chars_for_num(REGION_GEOM(parent).w); fp.g.w+=chars_for_num(REGION_GEOM(parent).h); fp.g.w*=max_width(INFOWIN_BRUSH(infowin), "0123456789x+"); fp.g.w+=bdw.left+bdw.right; fp.g.h=fnte.max_height+bdw.top+bdw.bottom;; fp.g.x=cx-fp.g.w/2; fp.g.y=cy-fp.g.h/2; region_fitrep((WRegion*)infowin, NULL, &fp); region_map((WRegion*)infowin); return infowin; }