home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /*
- * Author: Terry Weissman
- * weissman@sgi.com
- */
-
- #include "seahaven.h"
-
- #include <string.h>
-
-
-
- unsigned long GetColor(char *name, char *gname, unsigned long def) {
- XColor col1, col2;
- if (hascolor && XAllocNamedColor(dpy, cmap, name, &col1, &col2)) {
- return col2.pixel;
- }
- else if (hasgrey && XAllocNamedColor(dpy, cmap, gname, &col1, &col2)) {
- return col2.pixel;
- }
- else {
- return def;
- }
- }
-
-
- void GetInterestingEvent(XEvent *event) {
- XNextEvent(dpy, event);
- while (event->type == Expose) {
- if (event->xexpose.count == 0) score->repaint();
- XNextEvent(dpy, event);
- }
- }
-
-
- Window CreateButtonWindow(char *label, int x, int y, int gravity, int *width) {
- static GC textgc = NULL, cleargc = NULL;
- int w = XTextWidth(font, label, strlen(label)) + 4;
- int h = font->ascent + font->descent + 4;
- if (width) *width = w;
- Pixmap pixmap = XCreatePixmap(dpy, toplevel, w, h,
- DefaultDepth(dpy, screen));
- if (textgc == NULL) {
- textgc = XCreateGC(dpy, toplevel, 0, NULL);
- XSetForeground(dpy, textgc, GetColor("black", "black",
- BlackPixel(dpy, screen)));
- XSetFont(dpy, textgc, font->fid);
- cleargc = XCreateGC(dpy, toplevel, 0, NULL);
- XSetForeground(dpy, cleargc, backpixel);
- }
- XFillRectangle(dpy, pixmap, cleargc, 0, 0, w, h);
- XDrawString(dpy, pixmap, textgc, 2, 2 + font->ascent,
- label, strlen(label));
-
- XSetWindowAttributes attributes;
- long valuemask = CWEventMask | CWBackPixmap | CWWinGravity;
- attributes.event_mask = ButtonPressMask;
- attributes.background_pixmap = pixmap;
- attributes.win_gravity = gravity;
- Window window = XCreateWindow(dpy, toplevel, x, y,
- w, h, 1, (int) CopyFromParent,
- InputOutput, (Visual *) CopyFromParent,
- valuemask, &attributes);
- XMapWindow(dpy, window);
- return window;
- }
-
-