| 12 |
|
|
| 13 |
|
#include "plot.h" |
| 14 |
|
|
| 15 |
+ |
#include "string.h" |
| 16 |
+ |
|
| 17 |
|
#undef TRUE |
| 18 |
|
|
| 19 |
|
#undef FALSE |
| 20 |
|
|
| 21 |
|
#include <X11/Xlib.h> |
| 22 |
|
|
| 23 |
+ |
extern void replay(int xmin, int ymin, int xmax, int ymax); |
| 24 |
|
|
| 25 |
|
#define BORWIDTH 5 |
| 26 |
|
|
| 27 |
|
#define BlackPix BlackPixel(dpy,0 ) |
| 28 |
|
#define WhitePix WhitePixel(dpy,0 ) |
| 29 |
|
|
| 30 |
< |
#define mapx(x) CONV(x,dxsize) |
| 31 |
< |
#define mapy(y) CONV((XYSIZE-1)-(y),dysize) |
| 30 |
> |
#define mapx(x) CONV(x,dxsiz) |
| 31 |
> |
#define mapy(y) CONV((XYSIZE-1)-(y),dysiz) |
| 32 |
|
|
| 33 |
|
#define MAXVERT 128 |
| 34 |
|
|
| 82 |
|
int curlinetype; /* current line style */ |
| 83 |
|
XGCValues gcval; |
| 84 |
|
int pixel[4]; |
| 85 |
< |
int dxsize, dysize; /* window size */ |
| 85 |
> |
int dxsiz, dysiz; /* window size */ |
| 86 |
|
int debug = False; /* use XSynchronize if true */ |
| 87 |
|
|
| 88 |
|
static void |
| 89 |
|
adjustsize() |
| 90 |
|
{ |
| 91 |
< |
if (dxsize > dysize) |
| 92 |
< |
dxsize = dysize; |
| 91 |
> |
if (dxsiz > dysiz) |
| 92 |
> |
dxsiz = dysiz; |
| 93 |
|
else |
| 94 |
< |
dysize = dxsize; |
| 94 |
> |
dysiz = dxsiz; |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
|
| 114 |
|
if (debug) |
| 115 |
|
(void) XSynchronize(dpy, True); |
| 116 |
|
|
| 117 |
< |
dxsize = DisplayWidth(dpy,0) - 2*BORWIDTH-4; |
| 118 |
< |
dysize = DisplayHeight(dpy,0) - 2*BORWIDTH-100; |
| 117 |
> |
dxsiz = DisplayWidth(dpy,0) - 2*BORWIDTH-4; |
| 118 |
> |
dysiz = DisplayHeight(dpy,0) - 2*BORWIDTH-100; |
| 119 |
|
adjustsize(); |
| 120 |
|
|
| 121 |
< |
sprintf(defgeom, "=%dx%d+2+25", dxsize, dysize); |
| 121 |
> |
sprintf(defgeom, "=%dx%d+2+25", dxsiz, dysiz); |
| 122 |
|
/* XUseGeometry(dpy,0,geom,defgeom,BORWIDTH,100,100,100,100, |
| 123 |
< |
&xoff,&yoff,&dxsize,&dysize); */ |
| 123 |
> |
&xoff,&yoff,&dxsiz,&dysiz); */ |
| 124 |
|
gc = DefaultGC(dpy,0); /* get default gc */ |
| 125 |
|
cmap = DefaultColormap(dpy,0); /* and colormap */ |
| 126 |
|
|
| 127 |
< |
wind = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,dxsize,dysize, |
| 127 |
> |
wind = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,dxsiz,dysiz, |
| 128 |
|
BORWIDTH,BlackPix,WhitePix); |
| 129 |
|
if (wind == 0) |
| 130 |
|
error(SYSTEM, "can't create window"); |
| 163 |
|
if (evnt.type == ConfigureNotify) /* wait for first ConfigureNotify */ |
| 164 |
|
break; |
| 165 |
|
} |
| 166 |
< |
dxsize = evnt.xconfigure.width; |
| 167 |
< |
dysize = evnt.xconfigure.height; |
| 166 |
> |
dxsiz = evnt.xconfigure.width; |
| 167 |
> |
dysiz = evnt.xconfigure.height; |
| 168 |
|
adjustsize(); |
| 169 |
|
while (1) |
| 170 |
|
{ |
| 187 |
|
XNextEvent(dpy, &evnt); |
| 188 |
|
switch (evnt.type) { |
| 189 |
|
case ConfigureNotify: |
| 190 |
< |
dxsize = evnt.xconfigure.width; |
| 191 |
< |
dysize = evnt.xconfigure.height; |
| 190 |
> |
dxsiz = evnt.xconfigure.width; |
| 191 |
> |
dysiz = evnt.xconfigure.height; |
| 192 |
|
adjustsize(); |
| 193 |
|
break; |
| 194 |
|
case Expose: |
| 195 |
< |
replay((int)((long)XYSIZE*evnt.xexpose.x/dxsize), |
| 196 |
< |
(int)((long)XYSIZE*(dysize-evnt.xexpose.y-evnt.xexpose.height)/dysize), |
| 197 |
< |
(int)((long)XYSIZE*(evnt.xexpose.x+evnt.xexpose.width)/dxsize), |
| 198 |
< |
(int)((long)XYSIZE*(dysize-evnt.xexpose.y)/dysize)); |
| 195 |
> |
replay((int)((long)XYSIZE*evnt.xexpose.x/dxsiz), |
| 196 |
> |
(int)((long)XYSIZE*(dysiz-evnt.xexpose.y-evnt.xexpose.height)/dysiz), |
| 197 |
> |
(int)((long)XYSIZE*(evnt.xexpose.x+evnt.xexpose.width)/dxsiz), |
| 198 |
> |
(int)((long)XYSIZE*(dysiz-evnt.xexpose.y)/dysiz)); |
| 199 |
|
break; |
| 200 |
|
case ButtonPress: |
| 201 |
|
quit = True; |
| 263 |
|
col = p->arg0 & 03; /* color */ |
| 264 |
|
|
| 265 |
|
ps = WIDTH((p->arg0 >> 2) & 03); |
| 266 |
< |
pw = CONV((ps)/2, dxsize); |
| 266 |
> |
pw = CONV((ps)/2, dxsiz); |
| 267 |
|
|
| 268 |
|
x1 = mapx(p->xy[XMN]); |
| 269 |
|
x2 = mapx(p->xy[XMX]); |