static void naturalsize(statusbox *box, register int *w, register int *h) { int minw,minh; vdialogGetItemMinSize(&box->item, &minw, &minh); if (box->message) { vfont *fn = vdialogDetermineItemFont(&box->item); *w = 2*H_MARGIN + vfontStringWidthX(fn, box->message); *h = 2*V_MARGIN + vfontHeight(fn); if (*w<minw) *w = minw; if (*h<minh) *h = minh; } else if (box->gmode) { *w = 2*H_MARGIN + calcwidth(box, box->number); *h = minh; if (*w<minw) *w = minw; } else { *w = minw; *h = minh; } return; }
/* returns string representation of n in base 'base' */ char *getstring(unsigned int n, char *s, int base, int width) { unsigned int i,j,c,d = calcwidth(n,base); char *p = s; if(width && d<width) { for(i=d;i<width;i++) { *p = '0'; p++; } } for(i=d;i;i--) { j = pow(base,i-1); c = 0; while(n>=j) { n-=j; c++; } *p = c + ((c<10) ? 48 : 55); p++; } *p = 0; return s; }