Skip to Content
XLIB Programming Manual, Rel. 5, Third Edition
book

XLIB Programming Manual, Rel. 5, Third Edition

by Adrian Nye
June 1994
Intermediate to advanced
821 pages
24h 40m
English
O'Reilly Media, Inc.
Content preview from XLIB Programming Manual, Rel. 5, Third Edition

14.10 Drawing a Pad

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);
    }
}
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Xlib Reference Manual for Version 11 of the X Window System

Xlib Reference Manual for Version 11 of the X Window System

Adrian Nye

Publisher Resources

ISBN: 9780596806187Supplemental ContentCatalog PageErrata