June 1994
Intermediate to advanced
821 pages
24h 40m
English
This routine simply sets colors and draws the text in a pad. Example 14-13 shows the
drawButton routine.
Example 14-13. basecalc — the drawButton routine
/* Draw a single pad with its text */
drawButton (win, exposeEvent)
register int win;
{
register char *string;
register int x, y;
struct windata *winp;
char *Measure;
XSetWindowAttributes attributes;
unsigned long valuemask;
GC gc;
winp = &windata[win];
x = winp->x;
y = winp->y;
string = winp->text;
switch (windata[win].color) {
case WHITE:
gc = fgGC;
attributes.background_pixel = background;
attributes.border_pixel = foreground;
valuemask = CWBackPixel|CWBorderPixel;
break;
case BLACK:
gc = bgGC;
attributes.background_pixel = foreground;
attributes.border_pixel = background;
valuemask = CWBackPixel|CWBorderPixel;
break;
case LIGHTGRAY:
gc = bgGC;
attributes.background_pixmap = lgrayPixmap;
attributes.border_pixel = foreground;
valuemask = CWBackPixmap|CWBorderPixel;
break;
}
if (!exposeEvent){
XChangeWindowAttributes(display, Buttons[win].self,
valuemask, &attributes);
XClearWindow(display, Buttons[win].self);
}
XDrawString (display, Buttons[win].self, gc, x, y, string,
strlen (string));
if (win == 0) {
switch (Base) {
case 10:
case 8:
Measure = Octmeasure;
break;
default:
case 16:
case 2:
Measure = Hexmeasure;
break;
}
XDrawString (display, dispWin, gc, 7, 6, Measure, 31);
}
}