v10i022: xtrek, Part11/11
Dan A. Dickey
ddickey at aspen.cray.com
Wed Oct 24 18:34:47 AEST 1990
Submitted-by: ddickey at aspen.cray.com (Dan A. Dickey)
Posting-number: Volume 10, Issue 22
Archive-name: xtrek/part11
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# If this archive is complete, you will see the following message at the end:
# "End of archive 11 (of 11)."
#
# Contents:
# newwin.c
#
# Wrapped by ddickey at cray.com on Thu Oct 11 11:43:59 1990
#
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f newwin.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"newwin.c\"
else
echo shar: Extracting \"newwin.c\" \(37983 characters\)
sed "s/^X//" >newwin.c <<'END_OF_newwin.c'
Xstatic char sccsid[] = "@(#)newwin.c 3.1";
X/*
X
X Copyright (c) 1986 Chris Guthrie
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation. No representations are made about the
Xsuitability of this software for any purpose. It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X#include <X11/Xlib.h>
X#include <X11/cursorfont.h>
X#include <X11/Xutil.h>
X#include <stdio.h>
X#include <math.h>
X#include <signal.h>
X#include <errno.h>
X#if !defined(cray)
X#include <sys/types.h>
X#endif
X
X#ifdef hpux
X#include <time.h>
X#else /* hpux */
X#include <sys/time.h>
X#endif /* hpux */
X
X#include "defs.h"
X#include "data.h"
X#include "bitmaps.h"
X#include "clock.bitmap"
X
Xstatic char rvbuf[80];
Xstatic int xboxsize, yboxsize;
Xextern int debug;
X
X#define SIZEOF(a) (sizeof (a) / sizeof (*(a)))
X
X#define TILESIDE 32
X
Xstatic char solid[TILESIDE] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X};
X#define gray_width 16
X#define gray_height 16
X/* This can change depending on YAlertPattern */
Xstatic char gray[TILESIDE] = {
X 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
X 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
X 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
X 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
X};
X#define grey_width 16
X#define grey_height 16
X/* This stays the same */
Xstatic char grey[TILESIDE] = {
X 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
X 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
X 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
X 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
X};
Xstatic char striped[TILESIDE] = {
X 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
X 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f,
X 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00,
X 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0,
X};
X
X
Xchar *
Xnewwin(p)
Xregister struct player *p;
X{
X register int i;
X register char *str;
X register struct player *j;
X unsigned long mask;
X XSizeHints *wininfo;
X int uspec, rootX, rootY, dummy1, dummy2;
X XWMHints *wmhints;
X XClassHint *classhint;
X XIconSize *size_list_return;
X int count_return;
X int open_retries;
X
X#ifdef EXCLUDE
X for (i = 0, j = &players[0]; i < MAXPLAYER; i++, j++) {
X if (j->p_status != PFREE && (j != p) && (j->p_flags & PFROBOT) == 0 &&
X strcmp(j->p_monitor, p->p_monitor) == 0) {
X if (j->p_status == PALIVE)
X sprintf(rvbuf, "%s already playing on %s", j->p_login, p->p_monitor);
X else
X sprintf(rvbuf, "Someone already playing on %s", p->p_monitor);
X return rvbuf;
X }
X }
X#endif /* EXCLUDE */
X open_retries = 5;
X while (1) {
X if ((p->display = XOpenDisplay(p->p_monitor)) == NULL) {
X /* This seems to be fairly common for some reason. */
X if (open_retries-- > 0 && errno == EINTR)
X continue;
X perror(p->p_monitor);
X p->p_status = PFREE;
X p->p_warncount = 0;
X sprintf(rvbuf, "Cannot open display %s", p->p_monitor);
X return rvbuf;
X } else
X break;
X }
X
X p->screen = DefaultScreen(p->display);
X p->mono = XDisplayCells(p->display, p->screen) <= 2;
X p->xcn = XConnectionNumber(p->display);
X p->p_border = DEF_BORDER;
X p->p_messagesize = DEF_MESSAGESIZE;
X p->p_xwinsize = DEF_XWINSIZE;
X p->p_ywinsize = DEF_YWINSIZE;
X
X getColorDefs(p, PROGRAM_NAME);
X rootX = 0;
X rootY = 0;
X uspec = 0;
X if ((str = XGetDefault(p->display, PROGRAM_NAME, "geometry")) != NULL) {
X uspec = XParseGeometry(str, &rootX, &rootY, &dummy1, &dummy2);
X if ((uspec & (XValue|XNegative)) == (XValue|XNegative))
X rootX = -rootX;
X if ((uspec & (YValue|YNegative)) == (YValue|YNegative))
X rootY = -rootY;
X }
X
X p->baseWin = XCreateWindow(p->display, RootWindow(p->display, p->screen), rootX, rootY,
X (unsigned) p->p_xwinsize * 2 + 1 * p->p_border, (unsigned) p->p_ywinsize + 2 * p->p_border + 2 * p->p_messagesize,
X p->p_border, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X p->wm_change_state = XInternAtom(p->display, "WM_CHANGE_STATE", False);
X p->wm_delete_window = XInternAtom(p->display, "WM_DELETE_WINDOW", False);
X (void) XSetWMProtocols(p->display, p->baseWin, &p->wm_delete_window, 1);
X
X wininfo = XAllocSizeHints();
X wininfo->x = rootX;
X wininfo->y = rootY;
X wininfo->width = p->p_xwinsize * 2 + 1 * p->p_border;
X wininfo->height = p->p_ywinsize + 2 * p->p_border + 2 * p->p_messagesize;
X wininfo->min_width = clock_width * 5 + 1 * p->p_border;
X wininfo->min_height = clock_height;
X wininfo->min_height += 16 + 2 * p->p_border + 2 * p->p_messagesize;
X wininfo->max_width = DisplayWidth(p->display, p->screen);
X wininfo->max_height = DisplayHeight(p->display, p->screen);
X if (uspec & (XValue|YValue|XNegative|YNegative))
X wininfo->flags = USPosition | PSize | PMinSize | PMaxSize;
X else
X wininfo->flags = PPosition | PSize | PMinSize | PMaxSize;
X XSetWMNormalHints(p->display, p->baseWin, wininfo);
X XFree(wininfo);
X
X XSelectInput(p->display, p->baseWin, ExposureMask|StructureNotifyMask|VisibilityChangeMask);
X XSetWindowBackground(p->display, p->baseWin, p->backColor);
X p->ibm = XCreateBitmapFromData(p->display, p->baseWin, icon_bits, icon_width, icon_height);
X XStoreName(p->display, p->baseWin, PROGRAM_NAME);
X XSetIconName(p->display, p->baseWin, PROGRAM_NAME);
X
X rootX = 0;
X rootY = 0;
X uspec = 0;
X if ((str = XGetDefault(p->display, PROGRAM_NAME, "icon.geometry")) != NULL) {
X uspec = XParseGeometry(str, &rootX, &rootY, &dummy1, &dummy2);
X if ((uspec & (XValue|XNegative)) == (XValue|XNegative))
X rootX = -rootX;
X if ((uspec & (YValue|YNegative)) == (YValue|YNegative))
X rootY = -rootY;
X }
X p->iconWin = XCreateWindow(p->display, RootWindow(p->display, p->screen), rootX, rootY, (unsigned) icon_width,
X (unsigned) icon_height, p->p_border, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->iconWin, p->backColor);
X XSelectInput(p->display, p->iconWin, ExposureMask|StructureNotifyMask);
X
X if (debug > 0) {
X count_return = 0;
X i = XGetIconSizes(p->display, RootWindow(p->display, p->screen),
X &size_list_return, &count_return);
X fprintf(stderr, "Result of XGetIconSizes = %d\n", i);
X fprintf(stderr, "We have %d icon sizes, they are:\n", count_return);
X for (i = 0; i < count_return; i++) {
X fprintf(stderr, "\t%d> %d X %d -> %d X %d (inc: %d X %d)\n", i,
X size_list_return[i].min_width, size_list_return[i].min_height,
X size_list_return[i].max_width, size_list_return[i].max_height,
X size_list_return[i].width_inc, size_list_return[i].height_inc);
X }
X }
X
X wmhints = XAllocWMHints();
X /* NOTE: Should check for NULL return here. */
X wmhints->icon_window = p->iconWin;
X wmhints->icon_pixmap = p->ibm;
X wmhints->input = 1;
X wmhints->initial_state = NormalState;
X wmhints->flags = IconPixmapHint|IconWindowHint|InputHint|StateHint;
X XSetWMHints(p->display, p->baseWin, wmhints);
X XFree(wmhints);
X
X classhint = XAllocClassHint();
X /* NOTE: Should check for NULL return here. */
X classhint->res_name = PROGRAM_NAME;
X classhint->res_class = PROGRAM_NAME;
X XSetClassHint(p->display, p->baseWin, classhint);
X XFree(classhint);
X
X p->p_status = PMAP;
X return (char *) NULL;
X}
X
Xchar *
Xneww2(p)
Xregister struct player *p;
X{
X register int i;
X register char *str;
X register struct player *j;
X unsigned long mask;
X XGCValues values;
X XSizeHints *wininfo;
X int uspec, rootX, rootY, dummy1, dummy2;
X int x1, y1, w1, h1;
X
X values.graphics_exposures = 0;
X values.foreground = p->textColor;
X values.background = p->backColor;
X p->bmgc = XCreateGC(p->display, p->baseWin, GCForeground|GCBackground|GCGraphicsExposures, &values);
X p->gc = XCreateGC(p->display, p->baseWin, (unsigned long) 0, NULL);
X values.function = GXcopy;
X values.foreground = p->backColor;
X p->cleargc = XCreateGC(p->display, p->baseWin, GCFunction|GCForeground, &values);
X
X p->w = XCreateWindow(p->display, p->baseWin, -p->p_border, -p->p_border,
X (unsigned) (w1 = p->p_xwinsize), (unsigned) p->p_ywinsize,
X p->p_border, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->w, p->backColor);
X XSetWindowBorder(p->display, p->w, p->borderColor);
X
X if (getFonts(p, PROGRAM_NAME)) {
X XCloseDisplay(p->display);
X sprintf(rvbuf, "Not all fonts are available on %s\n", p->p_monitor);
X return rvbuf;
X }
X
X p->mapw = XCreateWindow(p->display, p->baseWin, p->p_xwinsize, -p->p_border,
X (unsigned) p->p_xwinsize, (unsigned) p->p_ywinsize, p->p_border,
X DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->mapw, p->backColor);
X XSetWindowBorder(p->display, p->mapw, p->borderColor);
X
X p->tstatw = XCreateWindow(p->display, p->baseWin, (x1 = -p->p_border), (y1 = p->p_xwinsize),
X w1, (unsigned) (h1 = (p->p_messagesize * 2 + p->p_border)), p->p_border,
X DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->tstatw, p->backColor);
X XSetWindowBorder(p->display, p->tstatw, p->borderColor);
X
X p->warnw = XCreateWindow(p->display, p->baseWin,
X (x1 = ((p->p_flags&PFNOMAPMODE) ? x1 : w1)),
X (y1 = ((p->p_flags&PFNOMAPMODE) ? (p->p_ywinsize+h1) : p->p_ywinsize)),
X w1, (unsigned) p->p_messagesize, p->p_border,
X DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->warnw, p->backColor);
X XSetWindowBorder(p->display, p->warnw, p->borderColor);
X
X p->messagew = XCreateWindow(p->display, p->baseWin,
X x1, y1 + p->p_border + p->p_messagesize,
X w1, (unsigned) p->p_messagesize, p->p_border,
X DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->messagew, p->backColor);
X XSetWindowBorder(p->display, p->messagew, p->borderColor);
X
X p->planetw = XCreateWindow(p->display, p->w, 3, 3, (unsigned) 60 * fontWidth(p->dfont),
X (unsigned) (MAXPLANETS + 3) * fontHeight(p->dfont), 2, DefaultDepth(p->display, p->screen), InputOutput,
X (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->planetw, p->backColor);
X XSetWindowBorder(p->display, p->planetw, p->borderColor);
X
X p->playerw = XCreateWindow(p->display, p->w, 3, 3, (unsigned) 66 * fontWidth(p->dfont),
X (unsigned) (MAXPLAYER + 3) * fontHeight(p->dfont), 2, DefaultDepth(p->display, p->screen), InputOutput,
X (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->playerw, p->backColor);
X XSetWindowBorder(p->display, p->playerw, p->borderColor);
X
X p->helpWin = XCreateWindow(p->display, RootWindow(p->display, p->screen),
X 0, p->p_ywinsize + 2 * p->p_border + 2 * p->p_messagesize,
X (unsigned) p->p_xwinsize * 2 + 1 * p->p_border, (unsigned) 10 * fontHeight(p->dfont), p->p_border,
X DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X (void) XSetWMProtocols(p->display, p->helpWin, &p->wm_delete_window, 1);
X
X wininfo = XAllocSizeHints();
X wininfo->x = 0;
X wininfo->y = p->p_ywinsize + 2 * p->p_border + 2 * p->p_messagesize;
X wininfo->width = p->p_xwinsize * 2 + 1 * p->p_border;
X wininfo->height = 10 * fontHeight(p->dfont);
X wininfo->min_width = p->p_xwinsize * 2 + 1 * p->p_border;
X wininfo->min_height = 10 * fontHeight(p->dfont);
X wininfo->max_width = p->p_xwinsize * 2 + 1 * p->p_border;
X wininfo->max_height = 20 * fontHeight(p->dfont);
X wininfo->flags = PPosition | PSize | PMinSize | PMaxSize;
X XSetWMNormalHints(p->display, p->helpWin, wininfo);
X XFree(wininfo);
X
X XStoreName(p->display, p->helpWin, "xtrek-help");
X XSetWindowBackground(p->display, p->helpWin, p->backColor);
X XSetWindowBorder(p->display, p->helpWin, p->borderColor);
X
X XDefineCursor(p->display, p->baseWin, (Cursor) XCreateFontCursor(p->display, XC_crosshair));
X XDefineCursor(p->display, p->iconWin, (Cursor) XCreateFontCursor(p->display, XC_crosshair));
X
X/* These windows will be used for setting one's warlike stats */
X
X#define WARHEIGHT (fontHeight(p->dfont) * 2)
X#define WARWIDTH (fontWidth(p->dfont) * 20)
X#define WARBORDER (p->p_border / 2)
X p->war = XCreateWindow(p->display, p->baseWin, p->p_xwinsize + 10, -p->p_border + 10, (unsigned) WARWIDTH,
X (unsigned) WARHEIGHT * 6, WARBORDER, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->war, p->backColor);
X XSetWindowBorder(p->display, p->war, p->borderColor);
X
X p->warf = XCreateWindow(p->display, p->war, 0, 0 * WARHEIGHT, (unsigned) WARWIDTH,
X (unsigned) WARHEIGHT, WARBORDER, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->warf, p->backColor);
X XSetWindowBorder(p->display, p->warf, p->borderColor);
X
X p->warr = XCreateWindow(p->display, p->war, 0, 1 * WARHEIGHT, (unsigned) WARWIDTH,
X (unsigned) WARHEIGHT, WARBORDER, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->warr, p->backColor);
X XSetWindowBorder(p->display, p->warr, p->borderColor);
X
X p->wark = XCreateWindow(p->display, p->war, 0, 2 * WARHEIGHT, (unsigned) WARWIDTH,
X (unsigned) WARHEIGHT, WARBORDER, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->wark, p->backColor);
X XSetWindowBorder(p->display, p->wark, p->borderColor);
X
X p->waro = XCreateWindow(p->display, p->war, 0, 3 * WARHEIGHT, (unsigned) WARWIDTH,
X (unsigned) WARHEIGHT, WARBORDER, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->waro, p->backColor);
X XSetWindowBorder(p->display, p->waro, p->borderColor);
X
X p->wargo = XCreateWindow(p->display, p->war, 0, 4 * WARHEIGHT, (unsigned) WARWIDTH,
X (unsigned) WARHEIGHT, WARBORDER, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->wargo, p->backColor);
X XSetWindowBorder(p->display, p->wargo, p->borderColor);
X
X p->warno = XCreateWindow(p->display, p->war, 0, 5 * WARHEIGHT, (unsigned) WARWIDTH,
X (unsigned) WARHEIGHT, WARBORDER, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->warno, p->backColor);
X XSetWindowBorder(p->display, p->warno, p->borderColor);
X
X
X XMapWindow(p->display, p->warf);
X XMapWindow(p->display, p->warr);
X XMapWindow(p->display, p->wark);
X XMapWindow(p->display, p->waro);
X XMapWindow(p->display, p->wargo);
X XMapWindow(p->display, p->warno);
X
X getResources(p, PROGRAM_NAME);
X mask = GCForeground | GCBackground;
X values.foreground = p->borderColor;
X values.background = p->backColor;
X XChangeGC(p->display, p->gc, mask, &values);
X XSetBackground(p->display, p->gc, (unsigned long) p->backColor);
X if (!p->mono) {
X XSetWindowBorder(p->display, p->baseWin, p->gColor);
X/*ICCCM 4.1.9 XSetWindowBorder(p->display, p->iconWin, p->gColor);*/
X } else {
X XSetWindowBorderPixmap(p->display, p->baseWin, p->gTile);
X/*ICCCM 4.1.9 XSetWindowBorder(p->display, p->iconWin, p->gTile);*/
X }
X p->p_status = POUTFIT;
X mapAll(p);
X return (char *) NULL;
X}
X
Xresizewins(p, cnf)
Xregister struct player *p;
XXConfigureEvent *cnf;
X{
X register int x1, y1, w1, h1;
X XWindowAttributes wa;
X
X XGetWindowAttributes(p->display, p->baseWin, &wa);
X
X /* We only handle baseWin resizes. */
X if (cnf->window != p->baseWin)
X return;
X
X if (cnf->width > (DisplayWidth(p->display, p->screen) - 15)) {
X cnf->width = DisplayWidth(p->display, p->screen) - 15;
X }
X if (cnf->height > (DisplayHeight(p->display, p->screen) - 15)) {
X cnf->height = DisplayHeight(p->display, p->screen) - 15;
X }
X
X /* NO! (not yet) */
X/* p->p_border = cnf->border_width;*/
X
X p->p_xwinsize = (cnf->width - p->p_border) / 2;
X p->p_ywinsize = (cnf->height - 2 * (p->p_border + p->p_messagesize));
X p->p_ts_offset = 0; /* Reset Status Line Offset */
X
X if (p->p_xwinsize < DEF_XWINSIZE || p->p_ywinsize < DEF_YWINSIZE) {
X p->p_flags |= PFNOMAPMODE;
X p->p_mapmode = 0;
X p->p_ywinsize -= 2 * (p->p_messagesize + p->p_border);
X p->p_xwinsize *= 2;
X if (p->mapw && ismapped(p, p->mapw))
X XUnmapWindow(p->display, p->mapw);
X } else {
X if (p->p_flags & PFNOMAPMODE)
X p->p_mapmode = 1;
X p->p_flags &= ~PFNOMAPMODE;
X if (p->mapw && (!ismapped(p, p->mapw)))
X XMapWindow(p->display, p->mapw);
X }
X y1 = clock_height + 4 * p->p_messagesize + 3 * p->p_border;
X if (p->p_ywinsize < y1)
X p->p_ywinsize = y1;
X
X#ifdef notdef /* This really screws up something...I suspect some */
X /* violation of ICCCM. */
X XResizeWindow(p->display, p->baseWin,
X (p->p_flags & PFNOMAPMODE) ? (p->p_xwinsize + p->p_border) : (p->p_xwinsize * 2 + p->p_border),
X (p->p_flags & PFNOMAPMODE) ? (p->p_ywinsize + 4 * (p->p_messagesize + p->p_border)) : (p->p_ywinsize + 2 * (p->p_border + p->p_messagesize)));
X#endif
X
X if (p->w)
X XMoveResizeWindow(p->display, p->w, -p->p_border, -p->p_border,
X (w1 = p->p_xwinsize), p->p_ywinsize);
X
X if (p->mapw)
X XMoveResizeWindow(p->display, p->mapw, p->p_xwinsize, -p->p_border, p->p_xwinsize, p->p_ywinsize);
X
X if (p->tstatw)
X XMoveResizeWindow(p->display, p->tstatw,
X (x1 = -p->p_border), (y1 = p->p_ywinsize),
X w1, (h1 = (p->p_border + 2 * p->p_messagesize)));
X
X if (p->warnw)
X XMoveResizeWindow(p->display, p->warnw,
X (x1 = ((p->p_flags & PFNOMAPMODE) ? x1 : w1)),
X (y1 = ((p->p_flags & PFNOMAPMODE) ? (p->p_ywinsize+h1) : p->p_ywinsize)),
X w1, p->p_messagesize);
X
X if (p->messagew)
X XMoveResizeWindow(p->display, p->messagew,
X x1,
X y1 + p->p_border + p->p_messagesize,
X w1, p->p_messagesize);
X
X XClearWindow(p->display, p->baseWin);
X p->p_redrawall = 1;
X}
X
Xchar *
Xwinmapped(p)
Xregister struct player *p;
X{
X return (neww2(p));
X}
X
X/*
X * this is separate from newwin. It should; be called *after*
X * openmem. If not, expose events will be eaten by the forked
X * process (daemon).
X */
XmapAll(p)
Xregister struct player *p;
X{
X initinput(p);
X XMapWindow(p->display, p->mapw);
X XMapWindow(p->display, p->tstatw);
X XMapWindow(p->display, p->warnw);
X XMapWindow(p->display, p->messagew);
X XMapWindow(p->display, p->w);
X}
X
XmapBase(p)
Xregister struct player *p;
X{
X XMapWindow(p->display, p->baseWin);
X}
X
X/* This routine throws up an entry window for the player. */
X
Xentrywindow(p)
Xregister struct player *p;
X{
X int boxy;
X
X xboxsize = p->p_xwinsize < 500 ? (p->p_xwinsize/5) : 100;
X yboxsize = p->p_ywinsize < 100 ? p->p_ywinsize : 100;
X boxy = p->p_ywinsize - yboxsize;
X if (boxy < 0)
X boxy = 0;
X
X /* Can we enter at other systems? */
X checksystems(p);
X
X /* The following allows quick choosing of teams */
X if ((p->p_pick & (1 << FED)) && !p->mustexit) {
X p->fwin = XCreateWindow(p->display, p->w, 0 * xboxsize, boxy, (unsigned) xboxsize, (unsigned) yboxsize,
X 1, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSelectInput(p->display, p->fwin, KeyPressMask|ButtonPressMask|ButtonReleaseMask|
X ExposureMask|SubstructureNotifyMask);
X XSetWindowBackground(p->display, p->fwin, p->backColor);
X XMapWindow(p->display, p->fwin);
X }
X else {
X p->fwin = XCreateWindow(p->display, p->w, 0 * xboxsize, boxy, (unsigned) xboxsize, (unsigned) yboxsize,
X 1, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSelectInput(p->display, p->fwin, ExposureMask|SubstructureNotifyMask);
X XSetWindowBackgroundPixmap(p->display, p->fwin, p->stippleTile);
X XMapWindow(p->display, p->fwin);
X }
X XSetWindowBorder(p->display, p->fwin, p->shipCol[FED]);
X
X if ((p->p_pick & (1 << ROM)) && !p->mustexit) {
X p->rwin = XCreateWindow(p->display, p->w, 1 * xboxsize, boxy, (unsigned) xboxsize, (unsigned) yboxsize, 1,
X DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSelectInput(p->display, p->rwin, KeyPressMask|ButtonPressMask|ButtonReleaseMask|
X ExposureMask|SubstructureNotifyMask);
X XSetWindowBackground(p->display, p->rwin, p->backColor);
X XMapWindow(p->display, p->rwin);
X }
X else {
X p->rwin = XCreateWindow(p->display, p->w, 1 * xboxsize, boxy, (unsigned) xboxsize, (unsigned) yboxsize,
X 1, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSelectInput(p->display, p->rwin, ExposureMask|SubstructureNotifyMask);
X XSetWindowBackgroundPixmap(p->display, p->rwin, p->stippleTile);
X XMapWindow(p->display, p->rwin);
X }
X XSetWindowBorder(p->display, p->rwin, p->shipCol[ROM]);
X
X if ((p->p_pick & (1 << KLI)) && !p->mustexit) {
X p->kwin = XCreateWindow(p->display, p->w, 2 * xboxsize, boxy, (unsigned) xboxsize, (unsigned) yboxsize,
X 1, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSelectInput(p->display, p->kwin, KeyPressMask|ButtonPressMask|ButtonReleaseMask|
X ExposureMask|SubstructureNotifyMask);
X XSetWindowBackground(p->display, p->kwin, p->backColor);
X XMapWindow(p->display, p->kwin);
X }
X else {
X p->kwin = XCreateWindow(p->display, p->w, 2 * xboxsize, boxy, (unsigned) xboxsize, (unsigned) yboxsize,
X 1, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSelectInput(p->display, p->kwin, ExposureMask|SubstructureNotifyMask);
X XSetWindowBackgroundPixmap(p->display, p->kwin, p->stippleTile);
X XMapWindow(p->display, p->kwin);
X }
X XSetWindowBorder(p->display, p->kwin, p->shipCol[KLI]);
X
X if ((p->p_pick & (1 << ORI)) && !p->mustexit) {
X p->owin = XCreateWindow(p->display, p->w, 3 * xboxsize, boxy, (unsigned) xboxsize, (unsigned) yboxsize,
X 1, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSelectInput(p->display, p->owin, KeyPressMask|ButtonPressMask|ButtonReleaseMask|
X ExposureMask|SubstructureNotifyMask);
X XSetWindowBackground(p->display, p->owin, p->backColor);
X XMapWindow(p->display, p->owin);
X }
X else {
X p->owin = XCreateWindow(p->display, p->w, 3 * xboxsize, boxy, (unsigned) xboxsize, (unsigned) yboxsize,
X 1, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSelectInput(p->display, p->owin, ExposureMask|SubstructureNotifyMask);
X XSetWindowBackgroundPixmap(p->display, p->owin, p->stippleTile);
X XMapWindow(p->display, p->owin);
X }
X XSetWindowBorder(p->display, p->owin, p->shipCol[ORI]);
X
X p->qwin = XCreateWindow(p->display, p->w, 4 * xboxsize, boxy, (unsigned) xboxsize, (unsigned) yboxsize, 1,
X DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->qwin, p->backColor);
X XSetWindowBorder(p->display, p->qwin, p->textColor);
X
X XSelectInput(p->display, p->qwin, KeyPressMask|ButtonPressMask|ExposureMask|SubstructureNotifyMask);
X XMapWindow(p->display, p->qwin);
X XClearWindow(p->display, p->qwin);
X
X p->startTime = time(0);
X makeClock(p, p->qwin);
X}
X
Xvoid
Xdel_entrywindow(p)
Xregister struct player *p;
X{
X destroyClock(p);
X XDestroyWindow(p->display, p->fwin);
X XDestroyWindow(p->display, p->rwin);
X XDestroyWindow(p->display, p->kwin);
X XDestroyWindow(p->display, p->owin);
X XDestroyWindow(p->display, p->qwin);
X p->fwin = p->rwin = p->kwin = p->owin = p->qwin = (Window) NULL;
X}
X
XnumShips(owner)
X{
X int i, num = 0;
X struct player *p;
X
X for (i = 0, p = players; i < MAXPLAYER; i++, p++)
X if (p->p_status == PALIVE && p->p_ship->s_team == owner)
X num++;
X return (num);
X}
X
Xstatic char *AUTHOR[] = {
X "",
X "--- XTREK Release Version 4.0 (D3.1) ---",
X "",
X "By Chris Guthrie (chris at ic.berkeley.edu)",
X "And Ed James (edjames at ic.berkeley.edu)",
X "",
X "Many more changes by Dan A. Dickey (ddickey at cray.com)"
X};
X
XshowMotd(p)
Xregister struct player *p;
X{
X char buf[BUFSIZ];
X FILE *motd, *fopen();
X int i, length, top, center;
X
X /* Author Gratification */
X XClearWindow(p->display, p->w);
X for (i = 0; i < SIZEOF(AUTHOR); i++) {
X length = strlen(AUTHOR[i]);
X center = p->p_xwinsize / 2 - (XTextWidth(p->dfont, AUTHOR[i], length)) / 2;
X XDrawImageString(p->display, p->w, p->dfgc, center, i * fontHeight(p->dfont) + p->dfont->ascent, AUTHOR[i],
X length);
X }
X top = SIZEOF(AUTHOR) + 2;
X
X /* the following will print a motd */
X if ((motd = fopen(MOTD, "r")) != NULL) {
X for (i = top; fgets(buf, sizeof (buf), motd) != NULL; i++) {
X length = strlen(buf);
X buf[length-1] = NULL;
X length = XTextWidth(p->dfont, buf, length);
X if (length > ((p->p_xwinsize/2)-20))
X length = ((p->p_xwinsize/2)-20);
X XDrawImageString(p->display, p->w, p->dfgc, 20, i * fontHeight(p->dfont) + p->dfont->ascent,
X buf, strlen(buf));
X }
X (void) fclose(motd);
X }
X}
X
XgetResources(p, prog)
Xregister struct player *p;
Xchar *prog;
X{
X getTiles(p, prog);
X initStats(p, prog);
X
X if (booleanDefault(p, prog, "showShields")) {
X p->p_flags |= PFSHOWSHIELDS;
X if (debug)
X fprintf(stderr, "pno %d PFSHOWSHIELDS\n", p->p_no);
X }
X if (booleanDefault(p, prog, "showStats")) {
X p->p_flags |= PFRSHOWSTATS;
X if (debug)
X fprintf(stderr, "pno %d PFRSHOWSTATS\n", p->p_no);
X }
X}
X
XgetTiles(p, prog)
Xregister struct player *p;
Xchar *prog;
X{
X register int i;
X char rPatt[TILESIDE], yPatt[TILESIDE], gPatt[TILESIDE];
X char tbPatt[TILESIDE];
X int rSize = sizeof (rPatt) / 2;
X int ySize = sizeof (yPatt) / 2;
X int gSize = sizeof (gPatt) / 2;
X int tbSize = sizeof (tbPatt) / 2;
X XImage *image;
X GC gc;
X XGCValues gcv;
X
X if (p->mono) {
X if (p->backColor == XWhitePixel(p->display, p->screen)) {
X /* Reverse video on, so reverse the bitmaps. */
X for (i = 0; i < TILESIDE; i++) solid[i] = ~solid[i];
X for (i = 0; i < TILESIDE; i++) gray[i] = ~gray[i];
X for (i = 0; i < TILESIDE; i++) striped[i] = ~striped[i];
X }
X if (arrayDefault(p, prog, "RalertPattern", &rSize, rPatt) < 0) {
X rSize = TILESIDE / 2;
X bcopy(striped, rPatt, sizeof (rPatt));
X }
X if (arrayDefault(p, prog, "YalertPattern", &ySize, yPatt) < 0) {
X ySize = TILESIDE / 2;
X bcopy(gray, yPatt, sizeof (yPatt));
X }
X if (arrayDefault(p, prog, "GalertPattern", &gSize, gPatt) < 0) {
X gSize = TILESIDE / 2;
X bcopy(solid, gPatt, sizeof (gPatt));
X }
X
X p->rTile = XCreateBitmapFromData(p->display, p->w, rPatt, rSize, rSize);
X p->yTile = XCreateBitmapFromData(p->display, p->w, yPatt, ySize, ySize);
X p->gTile = XCreateBitmapFromData(p->display, p->w, gPatt, gSize, gSize);
X }
X
X gcv.foreground = p->textColor;
X gcv.background = p->backColor;
X gcv.line_style = LineOnOffDash;
X p->tbgc = XCreateGC(p->display, p->baseWin, GCForeground|GCBackground|GCLineStyle, &gcv);
X
X p->stippleTile = XCreatePixmap(p->display, p->baseWin,
X stipple_width, stipple_height, DefaultDepth(p->display, p->screen));
X gcv.foreground = p->backColor;
X gcv.background = p->textColor;
X gc = XCreateGC(p->display, p->stippleTile, GCForeground|GCBackground, &gcv);
X image = XCreateImage(p->display, DefaultVisual(p->display, p->screen),
X 1, XYBitmap, 0, stipple_bits, stipple_width, stipple_height, 8, 0);
X XPutImage(p->display, p->stippleTile, gc, image, 0, 0, 0, 0,
X stipple_width, stipple_height);
X XFree(image);
X XFreeGC(p->display, gc);
X}
X
XgetFonts(p, prog)
Xregister struct player *p;
X char *prog;
X{
X char *font_name;
X XFontStruct *XLoadQueryFont();
X XGCValues gcv;
X
X if ((font_name = XGetDefault(p->display, prog, "font")) == NULL)
X font_name = "6x10";
X if ((p->dfont = XLoadQueryFont(p->display, font_name))
X == (XFontStruct *)NULL) {
X perror(font_name);
X return (1);
X }
X gcv.font = p->dfont->fid;
X gcv.foreground = p->textColor;
X gcv.background = p->backColor;
X p->dfgc = XCreateGC(p->display, p->w, GCForeground|GCBackground|GCFont, &gcv);
X if ((font_name = XGetDefault(p->display, PROGRAM_NAME, "boldFont")) == NULL)
X font_name = "6x10b";
X if ((p->bfont = XLoadQueryFont(p->display, font_name))
X == (XFontStruct *)NULL)
X p->bfont = p->dfont;
X gcv.font = p->bfont->fid;
X p->bfgc = XCreateGC(p->display, p->w, GCForeground|GCBackground|GCFont, &gcv);
X
X if ((font_name = XGetDefault(p->display, PROGRAM_NAME, "italicFont")) == NULL)
X font_name = "6x10i";
X if ((p->ifont = XLoadQueryFont(p->display, font_name))
X == (XFontStruct *)NULL)
X p->ifont = p->dfont;
X gcv.font = p->ifont->fid;
X p->ifgc = XCreateGC(p->display, p->w, GCForeground|GCBackground|GCFont, &gcv);
X
X if ((font_name = XGetDefault(p->display, PROGRAM_NAME, "bigFont")) == NULL)
X font_name = "-bitstream-charter-medium-r-normal-*-240-*";
X if ((p->bigFont = XLoadQueryFont(p->display, font_name))
X == (XFontStruct *)NULL)
X p->bigFont = p->dfont;
X gcv.font = p->bigFont->fid;
X p->bFgc = XCreateGC(p->display, p->w, GCForeground|GCBackground|GCFont, &gcv);
X
X if ((font_name = XGetDefault(p->display, PROGRAM_NAME, "xtrekFont")) == NULL)
X font_name = "xtrek";
X if ((p->xfont = XLoadQueryFont(p->display, font_name))
X == (XFontStruct *)NULL) {
X return (1);
X }
X gcv.font = p->xfont->fid;
X p->xfgc = XCreateGC(p->display, p->w, GCForeground|GCBackground|GCFont, &gcv);
X gcv.foreground = p->backColor;
X gcv.background = p->textColor;
X gcv.line_style = LineDoubleDash;
X gcv.dashes = 1;
X gcv.fill_style = FillStippled;
X gcv.stipple = XCreatePixmapFromBitmapData(p->display, RootWindow(p->display, p->screen), grey, grey_width, grey_height, 1, 0, 1);
X p->dimgc = XCreateGC(p->display, p->w, GCStipple|GCFillStyle|GCLineStyle|GCDashList|GCForeground|GCBackground|GCFont, &gcv);
X
X return (0);
X}
X
XredrawFed(p, fwin, flg)
Xregister struct player *p;
XWindow fwin;
X{
X register int cen;
X char buf[BUFSIZ];
X static int numfeds = -1;
X
X if (numfeds == -1 || flg || numfeds != numShips(FED)) {
X XClearWindow(p->display, fwin);
X cen = xboxsize / 2 - (XTextWidth(p->dfont, "Federation", 10) / 2);
X XDrawImageString(p->display, fwin, p->dfgc, cen, p->dfont->ascent, "Federation", 10);
X (void) sprintf(buf, "%d", numfeds = numShips(FED));
X cen = xboxsize / 2 - (XTextWidth(p->bigFont, buf, strlen(buf)) / 2);
X XDrawString(p->display, fwin, p->bFgc, cen, p->bigFont->ascent + p->dfont->ascent + 15, buf, strlen(buf));
X }
X}
X
XredrawRom(p, rwin, flg)
Xregister struct player *p;
X Window rwin;
X{
X register int cen;
X char buf[BUFSIZ];
X static int numroms = -1;
X
X if (numroms == -1 || flg || numroms != numShips(ROM)) {
X XClearWindow(p->display, rwin);
X cen = xboxsize / 2 - (XTextWidth(p->dfont, "Romulan", 7) / 2);
X XDrawImageString(p->display, rwin, p->dfgc, cen, p->dfont->ascent,
X "Romulan", 7);
X (void) sprintf(buf, "%d", numroms = numShips(ROM));
X cen = xboxsize / 2 - (XTextWidth(p->bigFont, buf, strlen(buf)) / 2);
X XDrawString(p->display, rwin, p->bFgc, cen, p->bigFont->ascent + p->dfont->ascent + 15, buf, strlen(buf));
X }
X}
X
XredrawKli(p, kwin, flg)
Xregister struct player *p;
X Window kwin;
X{
X register int cen;
X char buf[BUFSIZ];
X static int numklis = -1;
X
X if (numklis == -1 || flg || numklis != numShips(KLI)) {
X XClearWindow(p->display, kwin);
X cen = xboxsize / 2 - (XTextWidth(p->dfont, "Klingon", 7) / 2);
X XDrawImageString(p->display, kwin, p->dfgc, cen, p->dfont->ascent,
X "Klingon", 7);
X (void) sprintf(buf, "%d", numklis = numShips(KLI));
X cen = xboxsize / 2 - (XTextWidth(p->bigFont, buf, strlen(buf)) / 2);
X XDrawString(p->display, kwin, p->bFgc, cen, p->bigFont->ascent + p->dfont->ascent + 15, buf, strlen(buf));
X }
X}
X
XredrawOri(p, owin, flg)
Xregister struct player *p;
X Window owin;
X{
X register int cen;
X char buf[BUFSIZ];
X static int numoris = -1;
X
X if (numoris == -1 || flg || numoris != numShips(ORI)) {
X XClearWindow(p->display, owin);
X cen = xboxsize / 2 - (XTextWidth(p->dfont, "Orion", 5) / 2);
X XDrawImageString(p->display, owin, p->dfgc, cen, p->dfont->ascent,
X "Orion", 5);
X (void) sprintf(buf, "%d", numoris = numShips(ORI));
X cen = xboxsize / 2 - (XTextWidth(p->bigFont, buf, strlen(buf)) / 2);
X XDrawString(p->display, owin, p->bFgc, cen, p->bigFont->ascent + p->dfont->ascent + 15, buf, strlen(buf));
X }
X}
X
XredrawQuit(p, qwin)
Xregister struct player *p;
X Window qwin;
X{
X XDrawImageString(p->display, qwin, p->dfgc, p->dfont->ascent, p->dfont->ascent, "Quit xtrek", 10);
X}
X
Xchar *help_message[] = {
X "0-9 Set speed",
X "X Add 10 to next key for speed",
X "k Set course",
X "p Fire phaser",
X "t Launch torp",
X "d detonate other torps",
X "D detonate your torps",
X "+ Put up screens",
X "- Put down screens",
X "u Toggle screens",
X "b Bomb planet",
X "z Beam up armies",
X "x Beam down armies",
X "R Enter repair mode",
X "o orbit planet",
X "Q Quit",
X "? Review messages",
X "/ Stop message Review",
X "c Toggle cloak mode",
X "C Coup a planet",
X "l Lock on to player/planet",
X "@ (Dis)Allow copilots",
X "L List players",
X "P List planets",
X "S List scores",
X "s (Un)Map status window",
X "T Toggle Tractor beam",
X "U Toggle show shields",
X "M Turn on/off map window updating",
X "N Turn on/off name mode",
X "i Get info on player/planet",
X "h (Un)Map this window",
X "w (Un)Map war window",
X "* start a practice robot",
X "& send in a harder robot",
X "^ send in a very hard robot",
X 0,
X};
X
X#define MAXHELP 40
X
Xfillhelp(p)
Xregister struct player *p;
X{
X register int i = 0, row, column;
X
X for (column = 0; column < 4; column++) {
X for (row = 1; row < 9; row++) {
X if (help_message[i] == 0)
X break;
X else {
X XDrawImageString(p->display, p->helpWin, p->dfgc, fontWidth(p->dfont) * (MAXHELP * column + 1),
X fontHeight(p->dfont) * row + p->dfont->ascent,
X help_message[i], strlen(help_message[i]));
X i++;
X }
X }
X if (help_message[i] == 0)
X break;
X }
X}
X
XdrawIcon(p)
Xregister struct player *p;
X{
X if (debug)
X fprintf(stderr, "Drawing Icon Window for Player %d\n", p->p_no);
X XSetForeground(p->display, p->bmgc, p->textColor);
X XCopyPlane(p->display, p->ibm, p->iconWin, p->bmgc, 0, 0, icon_width, icon_height,
X 0, 0, 1);
X}
X
XmakeClock(p, w)
Xregister struct player *p;
X Window w;
X{
X int clky, clkx;
X
X xboxsize = p->p_xwinsize < 100 ? p->p_xwinsize : 100;
X yboxsize = p->p_ywinsize < 100 ? p->p_ywinsize : 100;
X
X clkx = (xboxsize / 2) - (clock_width / 2);
X clky = (yboxsize / 2) - (clock_height / 2);
X
X p->once = 0;
X p->oldtime = -1;
X p->clockw = XCreateWindow(p->display, w, clkx, clky,
X (unsigned) clock_width, (unsigned) (clock_height+16),
X 0, DefaultDepth(p->display, p->screen), InputOutput, (Visual *)CopyFromParent, 0L, (XSetWindowAttributes *)0);
X XSetWindowBackground(p->display, p->clockw, p->backColor);
X XSetWindowBorder(p->display, p->clockw, p->backColor);
X XMapWindow(p->display, p->clockw);
X p->tbm = XCreateBitmapFromData(p->display, p->clockw, clock_bits, clock_width, clock_height);
X
X XClearWindow(p->display, p->clockw);
X}
X
XdestroyClock(p)
Xregister struct player *p;
X{
X XFreePixmap(p->display, p->tbm);
X p->tbm = (Pixmap) NULL;
X XDestroyWindow(p->display, p->clockw);
X p->clockw = (Window) NULL;
X}
X
X#define PI 3.141592654
X
XshowTimeLeft(p, time, max, flg)
Xregister struct player *p;
X{
X char buf[BUFSIZ], *cp;
X int cx, cy, ex, ey, tx, ty;
X
X if (!p->once || flg) {
X p->once = 1;
X XClearWindow(p->display, p->clockw);
X p->oldtime = -1;
X cx = clock_width / 2; /* 45 */
X cy = ((clock_height+16) - fontHeight(p->dfont)) / 2; /* 26 */
X ex = cx - clock_width / 2; /* 21 */
X ey = cy - (clock_height+16) / 2; /* 2 */
X
X XSetForeground(p->display, p->bmgc, p->textColor);
X XCopyPlane(p->display, p->tbm, p->clockw, p->bmgc, 0, 0, clock_width, clock_height,
X ex, ey, 1);
X
X cp = "Auto Quit";
X tx = cx - (XTextWidth(p->dfont, cp, strlen(cp)) / 2);
X ty = clock_height - p->dfont->descent;
X XDrawImageString(p->display, p->clockw, p->dfgc, tx, ty, cp, strlen(cp));
X }
X
X XSetFunction(p->display, p->dfgc, GXinvert);
X if (p->oldtime != -1) {
X cx = clock_width / 2; /* 45 */
X cy = (clock_height - fontHeight(p->dfont)) / 2; /* 26 */
X ex = cx - clock_width * sin(2 * PI * p->oldtime / max) / 2;
X ey = cy - clock_height * cos(2 * PI * p->oldtime / max) / 2;
X XDrawLine(p->display, p->clockw, p->dfgc, cx, cy, ex, ey);
X }
X p->oldtime = time;
X
X cx = clock_width / 2; /* 45 */
X cy = (clock_height - fontHeight(p->dfont)) / 2; /* 26 */
X ex = cx - clock_width * sin(2 * PI * time / max) / 2;
X ey = cy - clock_height * cos(2 * PI * time / max) / 2;
X XDrawLine(p->display, p->clockw, p->dfgc, cx, cy, ex, ey);
X XSetFunction(p->display, p->dfgc, GXcopy);
X
X sprintf(buf, "%2.2d", max - time);
X tx = cx - (XTextWidth(p->dfont, buf, strlen(buf)) / 2);
X ty = cy - fontHeight(p->dfont) / 2;
X XDrawImageString(p->display, p->clockw, p->dfgc, tx, ty, buf, strlen(buf));
X}
END_OF_newwin.c
if test 37983 -ne `wc -c <newwin.c`; then
echo shar: \"newwin.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 11 \(of 11\).
cp /dev/null ark11isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 11 archives.
rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
dan
----------------------------------------------------
O'Reilly && Associates argv at sun.com / argv at ora.com
Opinions expressed reflect those of the author only.
More information about the Comp.sources.x
mailing list