cell_height += Resrcs.grid + 6 +
Resrcs.label_bitmap * (font−>ascent + font−>descent);
cell_width += Resrcs.grid + 6;
/* if user didn't specify row/column layout figure it out ourselves.
* optimize layout by making it "square".
*/
if (!Resrcs.rows && !Resrcs.cols) {
Resrcs.cols = int_sqrt (total);
Resrcs.rows = (total + Resrcs.cols − 1) / Resrcs.cols;
}
else if (Resrcs.rows)
/* user specified rows −− figure out columns */
Resrcs.cols = (total + Resrcs.rows − 1) / Resrcs.rows;
else
/* user specified cols −− figure out rows */
Resrcs.rows = (total + Resrcs.cols − 1) / Resrcs.cols;
printf ("Creating pixmap area of size %dx%d (%d rows, %d cols)0,
Resrcs.cols * cell_width, Resrcs.rows * cell_height,
Resrcs.rows, Resrcs.cols);
if (!(pixmap = XCreatePixmap (dpy, DefaultRootWindow(dpy),
Resrcs.cols * cell_width, Resrcs.rows * cell_height,
DefaultDepthOfScreen (XtScreen (toplevel)))))
XtError ("Can't Create pixmap.");
if (!(gc = XCreateGC (dpy, pixmap, NULL, 0)))
XtError ("Can't create gc.");
XSetForeground (dpy, gc, Resrcs.bg); /* init GC's foreground to bg */
XFillRectangle (dpy, pixmap, gc, 0, 0,
Resrcs.cols * cell_width, Resrcs.rows * cell_height);
XSetForeground (dpy, gc, Resrcs.fg);
XSetBackground (dpy, gc, Resrcs.bg);
XSetFont (dpy, gc, font−>fid);
if (Resrcs.grid) {
if (Resrcs.grid != 1)
/* Line weight of 1 is faster when left as 0 (the default) */
XSetLineAttributes (dpy, gc, Resrcs.grid, 0, 0, 0);
for (j = 0; j <= Resrcs.rows * cell_height; j += cell_height)
XDrawLine (dpy, ...