william@CS.UCLA.EDU (William Cheng) (08/22/90)
Submitted-by: william@CS.UCLA.EDU (William Cheng) Posting-number: Volume 8, Issue 94 Archive-name: tgif/patch4 Patch-To: Volume 7, Issue 56-76 (original: tgif-1.2) Patch-To: Volume 8, Issue 46-48 (Patch1: tgif-1.2 => tgif-1.9) Patch-To: Volume 8, Issue 58-60 (Patch2: tgif-1.9 => tgif-1.12) Patch-To: Volume 8, Issue 87-89 (Patch3: tgif-1.12 => tgif-1.13) Patch4 of tgif takes tgif-1.13 to tgif-1.14. Below is a list of added features/bug fixes, followed by the actual patch. tgif-1.13 => tgif-1.14 1) Fix Imakefile so that it works better with the X11R4 installation. This includes commenting out BINDIR, CDEBUGFLAGS, and MANPATH. Thanks to David Eckelkamp@MCC and Carl Witty@Stanford for their recommentations, and specially David Eckelkamp@MCC for his improvements. NOTE: With the current setup, those who wishes to install tgif in places outside of the X11R4 installation has to modify the Imakefile (uncomment the definition for CDEBUGFLAGS, BINDIR, MANPATH, and redefine TGIFDIR). Sorry for the inconveniences. 2) Add support for 100dpi fonts. (Actually, this was done in the previous release. I forgot to mention it.) 3) Fix a small bug in display the current font (pixmap not cleared before). 4) Use XDrawPoint() instead of XDrawLine() in drawing grid points and rotated text. Use the #ifdef construct to get around know server bugs. 5) Minor enhancement in cleaning up events in adding and deleting points. ---------------------------------> cut here <--------------------------------- *** choice.c.orig Tue Aug 21 21:32:15 1990 --- choice.c Tue Aug 21 21:32:16 1990 *************** *** 6,10 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/choice.c,v 1.6 90/08/15 16:01:40 william Exp $"; #endif --- 6,10 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/choice.c,v 1.8 90/08/21 15:55:15 william Exp $"; #endif *************** *** 104,108 **** { register int i, j; ! int x, y, pixel, w, h, saved_x, saved_y; XRectangle recs[1]; XImage * image; --- 104,108 ---- { register int i, j; ! int x, y, w, h, saved_x, saved_y; XRectangle recs[1]; XImage * image; *************** *** 173,176 **** --- 173,181 ---- else { + XSetForeground (mainDisplay, choiceGC, 0); + XFillRectangle (mainDisplay, choiceBackingPixmap, choiceGC, 0, 0, + choiceWindowW, choiceWindowH); + XSetForeground (mainDisplay, choiceGC, 1); + XDrawImageString (mainDisplay, choiceBackingPixmap, choiceGC, 0, canvasFontAsc, "W", 1); *************** *** 195,201 **** case ROTATE270: x = saved_x+j; y = saved_y-i; break; } ! /* XDrawPoint (mainDisplay, choiceWindow, defaultGC, x, y); */ ! /* Hack to run on RTs -- crash server on RTs */ XDrawLine (mainDisplay,choiceWindow,defaultGC,x,y,x,y); } --- 200,208 ---- case ROTATE270: x = saved_x+j; y = saved_y-i; break; } ! #ifdef sun ! XDrawPoint (mainDisplay, choiceWindow, defaultGC, x, y); ! #else XDrawLine (mainDisplay,choiceWindow,defaultGC,x,y,x,y); + #endif } *** edit.c.orig Tue Aug 21 21:32:37 1990 --- edit.c Tue Aug 21 21:32:38 1990 *************** *** 6,10 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/edit.c,v 1.9 90/08/16 09:35:06 william Exp $"; #endif --- 6,10 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/edit.c,v 1.13 90/08/21 16:03:43 william Exp $"; #endif *************** *** 32,35 **** --- 32,39 ---- #include "stretch.e" + #ifndef M_PI + #define M_PI 3.14159265358979323846 + #endif + #define OFFSET_X(x) (((x) - drawOrigX) >> zoomScale) #define OFFSET_Y(y) (((y) - drawOrigY) >> zoomScale) *************** *** 73,77 **** unsigned int status; Window root_win, child_win; ! XEvent input; if (!(topSel != NULL && topSel == botSel && --- 77,81 ---- unsigned int status; Window root_win, child_win; ! XEvent input, ev; if (!(topSel != NULL && topSel == botSel && *************** *** 201,204 **** --- 205,209 ---- old_x+4, old_y+defaultFontAsc, "DEL", 3); MarkRulers (old_x, old_y); + while (XCheckMaskEvent (mainDisplay, PointerMotionMask, &ev)) ; } } *************** *** 218,227 **** int n = PolyPtr->n, already_moved=FALSE, done=FALSE, before; XPoint * vs = PolyPtr->vlist, v[3]; ! int prev_x, prev_y, x, y, next_x, next_y, new_x, new_y, dx, dy; int orig_x, orig_y, grid_x, grid_y, new_mouse_x, new_mouse_y; - /* int prev_dist, next_dist, new_prev_dist, new_next_dist; */ int sel_ltx, sel_lty, sel_rbx, sel_rby, num, i; double prev_angle, next_angle, new_angle, theta_1, theta_2; ! XEvent input; MARK(OFFSET_X(vs[Index].x), OFFSET_Y(vs[Index].y)); --- 223,231 ---- int n = PolyPtr->n, already_moved=FALSE, done=FALSE, before; XPoint * vs = PolyPtr->vlist, v[3]; ! int prev_x, prev_y, x, y, next_x, next_y, new_x, new_y; int orig_x, orig_y, grid_x, grid_y, new_mouse_x, new_mouse_y; int sel_ltx, sel_lty, sel_rbx, sel_rby, num, i; double prev_angle, next_angle, new_angle, theta_1, theta_2; ! XEvent input, ev; MARK(OFFSET_X(vs[Index].x), OFFSET_Y(vs[Index].y)); *************** *** 237,241 **** next_x = vs[1].x; next_y = vs[1].y; prev_x = 2*x-next_x; prev_y = 2*y-next_y; - /* prev_dist = next_dist = (x-prev_x)*(x-prev_x) + (y-prev_y)*(y-prev_y); */ } else if (Index == n-1) --- 241,244 ---- *************** *** 243,247 **** prev_x = vs[n-2].x; prev_y = vs[n-2].y; next_x = 2*x-prev_x; next_y = 2*y-prev_y; - /* prev_dist = next_dist = (x-prev_x)*(x-prev_x) + (y-prev_y)*(y-prev_y); */ } else --- 246,249 ---- *************** *** 249,254 **** prev_x = vs[Index-1].x; prev_y = vs[Index-1].y; next_x = vs[Index+1].x; next_y = vs[Index+1].y; - /* prev_dist = (x-prev_x)*(x-prev_x) + (y-prev_y)*(y-prev_y); */ - /* next_dist = (x-next_x)*(x-next_x) + (y-next_y)*(y-next_y); */ } prev_angle = atan2 ((double)(prev_y-y), (double)(prev_x-x)); --- 251,254 ---- *************** *** 286,300 **** before = (theta_1 <= theta_2); - /* new_prev_dist = (new_x-prev_x)*(new_x-prev_x) + */ - /* (new_y-prev_y)*(new_y-prev_y); */ - /* new_next_dist = (new_x-next_x)*(new_x-next_x) + */ - /* (new_y-next_y)*(new_y-next_y); */ - - /* if ((new_prev_dist-prev_dist)*(new_next_dist-next_dist) < 0) */ - /* before = (new_prev_dist < prev_dist); */ - /* else */ - /* before = (abs (new_prev_dist-prev_dist) < */ - /* abs (new_next_dist-next_dist)); */ - if (before) { /* Add a point between the current and the previous point */ --- 286,289 ---- *************** *** 339,342 **** --- 328,332 ---- MarkRulers (grid_x, grid_y); } + while (XCheckMaskEvent (mainDisplay, PointerMotionMask, &ev)) ; } else if (input.type == ButtonRelease) *************** *** 411,420 **** int n = PolygonPtr->n, already_moved=FALSE, done=FALSE, before; XPoint * vs = PolygonPtr->vlist, v[3]; ! int prev_x, prev_y, x, y, next_x, next_y, new_x, new_y, dx, dy; int orig_x, orig_y, grid_x, grid_y, new_mouse_x, new_mouse_y; - /* int prev_dist, next_dist, new_prev_dist, new_next_dist; */ int sel_ltx, sel_lty, sel_rbx, sel_rby, i; double prev_angle, next_angle, new_angle, theta_1, theta_2; ! XEvent input; MARK(OFFSET_X(vs[Index].x), OFFSET_Y(vs[Index].y)); --- 401,409 ---- int n = PolygonPtr->n, already_moved=FALSE, done=FALSE, before; XPoint * vs = PolygonPtr->vlist, v[3]; ! int prev_x, prev_y, x, y, next_x, next_y, new_x, new_y; int orig_x, orig_y, grid_x, grid_y, new_mouse_x, new_mouse_y; int sel_ltx, sel_lty, sel_rbx, sel_rby, i; double prev_angle, next_angle, new_angle, theta_1, theta_2; ! XEvent input, ev; MARK(OFFSET_X(vs[Index].x), OFFSET_Y(vs[Index].y)); *************** *** 439,445 **** next_angle = atan2 ((double)(next_y-y), (double)(next_x-x)); - /* prev_dist = (x-prev_x)*(x-prev_x) + (y-prev_y)*(y-prev_y); */ - /* next_dist = (x-next_x)*(x-next_x) + (y-next_y)*(y-next_y); */ - GridXY (MouseX, MouseY, &orig_x, &orig_y); new_mouse_x = MouseX; new_mouse_y = MouseY; --- 428,431 ---- *************** *** 473,487 **** before = (theta_1 <= theta_2); - /* new_prev_dist = (new_x-prev_x)*(new_x-prev_x) + */ - /* (new_y-prev_y)*(new_y-prev_y); */ - /* new_next_dist = (new_x-next_x)*(new_x-next_x) + */ - /* (new_y-next_y)*(new_y-next_y); */ - - /* if ((new_prev_dist-prev_dist)*(new_next_dist-next_dist) < 0) */ - /* before = (new_prev_dist < prev_dist); */ - /* else */ - /* before = (abs (new_prev_dist-prev_dist) < */ - /* abs (new_next_dist-next_dist)); */ - if (before) { /* Add a point between the current and the previous point */ --- 459,462 ---- *************** *** 506,509 **** --- 481,485 ---- MarkRulers (grid_x, grid_y); } + while (XCheckMaskEvent (mainDisplay, PointerMotionMask, &ev)) ; } else if (input.type == ButtonRelease) *************** *** 588,600 **** void AddPoint () { - register int i; register struct ObjRec * obj_ptr; struct PolyRec * poly_ptr; struct PolygonRec * polygon_ptr; ! int index, n, point_deleted, adding = TRUE; int root_x, root_y, old_x, old_y; unsigned int status; Window root_win, child_win; ! XEvent input; if (!(topSel != NULL && topSel == botSel && --- 564,575 ---- void AddPoint () { register struct ObjRec * obj_ptr; struct PolyRec * poly_ptr; struct PolygonRec * polygon_ptr; ! int index, adding = TRUE; int root_x, root_y, old_x, old_y; unsigned int status; Window root_win, child_win; ! XEvent input, ev; if (!(topSel != NULL && topSel == botSel && *************** *** 662,665 **** --- 637,641 ---- old_x+4, old_y+defaultFontAsc, "ADD", 3); MarkRulers (old_x, old_y); + while (XCheckMaskEvent (mainDisplay, PointerMotionMask, &ev)) ; } } *** grid.c.orig Tue Aug 21 21:32:44 1990 --- grid.c Tue Aug 21 21:32:45 1990 *************** *** 6,10 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/grid.c,v 1.6 90/07/16 10:18:38 william Exp $"; #endif --- 6,10 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/grid.c,v 1.7 90/08/20 13:56:57 william Exp $"; #endif *************** *** 42,48 **** for (x = XStart; x < XEnd; x += 8) ! /* XDrawPoint (mainDisplay, Win, defaultGC, x, Y); */ ! /* Hack to run on RTs -- crash server on RTs */ XDrawLine (mainDisplay, Win, defaultGC, x, Y, x, Y); } --- 42,50 ---- for (x = XStart; x < XEnd; x += 8) ! #ifdef sun ! XDrawPoint (mainDisplay, Win, defaultGC, x, Y); ! #else XDrawLine (mainDisplay, Win, defaultGC, x, Y, x, Y); + #endif } *************** *** 54,60 **** for (y = YStart; y < YEnd; y += 8) ! /* XDrawPoint (mainDisplay, Win, defaultGC, X, y); */ ! /* Hack to run on RTs -- crash server on RTs */ XDrawLine (mainDisplay, Win, defaultGC, X, y, X, y); } --- 56,64 ---- for (y = YStart; y < YEnd; y += 8) ! #ifdef sun ! XDrawPoint (mainDisplay, Win, defaultGC, X, y); ! #else XDrawLine (mainDisplay, Win, defaultGC, X, y, X, y); + #endif } *** text.c.orig Tue Aug 21 21:33:23 1990 --- text.c Tue Aug 21 21:33:25 1990 *************** *** 6,10 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/text.c,v 1.16 90/08/16 15:44:38 william Exp $"; #endif --- 6,10 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/text.c,v 1.18 90/08/21 16:24:22 william Exp $"; #endif *************** *** 148,152 **** register int i, j; register XImage * from_image; ! int w, h, amount, left, right, len; XGCValues values; --- 148,152 ---- register int i, j; register XImage * from_image; ! int w, h, left, right, len; XGCValues values; *************** *** 290,297 **** for (j = 0; j < h; j++) if (XGetPixel (from_image, i, j) == 1) ! /* XDrawPoint (mainDisplay, Win, gc, XOff-j, YOff+i); */ ! /* Hack to run on RTs -- crash server on RTs */ XDrawLine (mainDisplay, Win, gc, XOff-j, YOff+i, XOff-j, YOff+i); break; case ROTATE180: --- 290,299 ---- for (j = 0; j < h; j++) if (XGetPixel (from_image, i, j) == 1) ! #ifdef sun ! XDrawPoint (mainDisplay, Win, gc, XOff-j, YOff+i); ! #else XDrawLine (mainDisplay, Win, gc, XOff-j, YOff+i, XOff-j, YOff+i); + #endif break; case ROTATE180: *************** *** 299,306 **** for (j = 0; j < h; j++) if (XGetPixel (from_image, i, j) == 1) ! /* XDrawPoint (mainDisplay, Win, gc, XOff-i, YOff-j); */ ! /* Hack to run on RTs -- crash server on RTs */ XDrawLine (mainDisplay, Win, gc, XOff-i, YOff-j, XOff-i, YOff-j); break; case ROTATE270: --- 301,310 ---- for (j = 0; j < h; j++) if (XGetPixel (from_image, i, j) == 1) ! #ifdef sun ! XDrawPoint (mainDisplay, Win, gc, XOff-i, YOff-j); ! #else XDrawLine (mainDisplay, Win, gc, XOff-i, YOff-j, XOff-i, YOff-j); + #endif break; case ROTATE270: *************** *** 308,315 **** for (j = 0; j < h; j++) if (XGetPixel (from_image, i, j) == 1) ! /* XDrawPoint (mainDisplay, Win, gc, XOff+j, YOff-i); */ ! /* Hack to run on RTs -- crash server on RTs */ XDrawLine (mainDisplay, Win, gc, XOff+j, YOff-i, XOff+j, YOff-i); break; } --- 312,321 ---- for (j = 0; j < h; j++) if (XGetPixel (from_image, i, j) == 1) ! #ifdef sun ! XDrawPoint (mainDisplay, Win, gc, XOff+j, YOff-i); ! #else XDrawLine (mainDisplay, Win, gc, XOff+j, YOff-i, XOff+j, YOff-i); + #endif break; } *************** *** 388,392 **** int Just, W, H, Rotate; { ! int ltx, lty, rbx, rby, mw2, pw2; switch (Just) --- 394,398 ---- int Just, W, H, Rotate; { ! register int mw2, pw2; switch (Just) *************** *** 476,480 **** register int num_lines; struct StrRec * s_ptr = ObjPtr->detail.t->first; ! int max_len = 0, len, w; SaveCurFont (); --- 482,486 ---- register int num_lines; struct StrRec * s_ptr = ObjPtr->detail.t->first; ! int max_len = 0, w; SaveCurFont (); *************** *** 510,521 **** } - static - int FindEqual (S) - register char *S; - { - while (*S != '=' && *S != '\0') S++; - return (*S == '='); - } - int CreateTextObj () /* returns TRUE if something got created */ --- 516,519 ---- *************** *** 525,530 **** struct StrRec * s_ptr; struct AttrRec * attr_ptr; ! struct ObjRec * obj_ptr; ! int max_len = 0, len, w, ltx, lty, rbx, rby; int scr_ltx, scr_lty; --- 523,527 ---- struct StrRec * s_ptr; struct AttrRec * attr_ptr; ! int max_len = 0, w, ltx, lty, rbx, rby; int scr_ltx, scr_lty; *************** *** 1314,1319 **** XEvent * input; { - int len, x, y; - Window sub_win_id; char s[80]; XKeyEvent * key_ev; --- 1311,1314 ---- *** tgif.c.orig Tue Aug 21 21:33:32 1990 --- tgif.c Tue Aug 21 21:33:33 1990 *************** *** 6,10 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/tgif.c,v 1.7 90/08/15 15:05:17 william Exp $"; #endif --- 6,10 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/tgif.c,v 1.8 90/08/21 15:52:54 william Exp $"; #endif *************** *** 54,59 **** int i; char op_name[80], file_name[80], s[80], color_name[80], val_name[80]; ! char * sp[6], * func_strp, attr_name[80], speed_name[80], type_name[80]; ! char * c_ptr, id_name[80]; file_name[0] = '\0'; --- 54,59 ---- int i; char op_name[80], file_name[80], s[80], color_name[80], val_name[80]; ! char * sp[6], * func_strp, attr_name[80], speed_name[80]; ! char id_name[80]; file_name[0] = '\0'; *** version.c.orig Tue Aug 21 21:33:36 1990 --- version.c Tue Aug 21 21:33:37 1990 *************** *** 6,11 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/version.c,v 1.16 90/08/16 09:41:02 william Exp $"; #endif ! char * version_string = "1.13"; --- 6,11 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/version.c,v 1.17 90/08/21 21:30:03 william Exp $"; #endif ! char * version_string = "1.14"; *** Makefile.noimake.orig Tue Aug 21 21:33:42 1990 --- Makefile.noimake Tue Aug 21 21:33:43 1990 *************** *** 4,8 **** # Copyright (C) 1990, William Cheng. # ! # @(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/Makefile.noimake,v 1.22 90/08/16 13:21:47 william Exp $ # --- 4,8 ---- # Copyright (C) 1990, William Cheng. # ! # @(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/Makefile.noimake,v 1.23 90/08/21 16:09:05 william Exp $ # *************** *** 13,18 **** CC = cc ! CFLAGS = -g -DTGIF_PATH=\"/u/tangram/u/william/X11/TGIF\" -DPSFILE_MOD=\"664\" \ ! -I/usr/local/include LFLAGS = -lX11 -lm --- 13,18 ---- CC = cc ! TGIFDIR = /u/tangram/lib/tgif ! CFLAGS = -g -DTGIF_PATH=\"$(TGIFDIR)\" -DPSFILE_MOD=\"664\" -I/usr/local/include LFLAGS = -lX11 -lm *************** *** 194,198 **** ld -o frontend11.o -r $(OBJ1) ! install: $(INSTALLDIR)/tgif $(INSTALLDIR)/tgif2ps @echo Making install ... --- 194,199 ---- ld -o frontend11.o -r $(OBJ1) ! install: $(INSTALLDIR)/tgif $(INSTALLDIR)/tgif2ps \ ! $(TGIFDIR)/.psmac $(TGIFDIR)/tgificon.obj @echo Making install ... *************** *** 202,205 **** --- 203,212 ---- $(INSTALLDIR)/tgif2ps: tgif2ps install -c tgif2ps $(INSTALLDIR)/tgif2ps + + $(TGIFDIR)/.psmac: .psmac + install -c .psmac $(TGIFDIR)/.psmac + + $(TGIFDIR)/tgificon.obj: tgificon.obj + install -c tgificon.obj $(TGIFDIR)/tgificon.obj OBJDEMO = an-sr-flip-flop.obj fonts.obj slide-demo.obj spice/*.obj *** Imakefile.orig Tue Aug 21 21:33:48 1990 --- Imakefile Tue Aug 21 21:33:48 1990 *************** *** 4,17 **** /**/# Copyright (C) 1990, William Cheng. /**/# ! /**/# @(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/Imakefile,v 1.23 90/08/17 09:48:59 william Exp $ /**/# ! TGIFVERSION = 1.13 PROGRAMS = tgif prtgif tgif2ps frontend11.o ! CDEBUGFLAGS = -g ! BINDIR = /u/tangram/bin ! MANPATH = /u/tangram/man ! DEFINES = -DTGIF_PATH=\"/u/tangram/u/william/X11/TGIF\" \ ! -DPSFILE_MOD=\"664\" LOCAL_LIBRARIES = $(XLIB) DEPLIBS = $(DEPXLIB) --- 4,18 ---- /**/# Copyright (C) 1990, William Cheng. /**/# ! /**/# @(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/Imakefile,v 1.25 90/08/21 21:30:40 william Exp $ /**/# ! TGIFVERSION = 1.14 PROGRAMS = tgif prtgif tgif2ps frontend11.o ! /**/#CDEBUGFLAGS= -g ! /**/#BINDIR = /u/tangram/bin ! /**/#MANPATH = /u/tangram/man ! /**/#TGIFDIR = /u/tangram/lib/tgif ! TGIFDIR = $(LIBDIR)/tgif ! DEFINES = -DTGIF_PATH=\"$(TGIFDIR)\" -DPSFILE_MOD=\"664\" LOCAL_LIBRARIES = $(XLIB) DEPLIBS = $(DEPXLIB) *************** *** 47,50 **** --- 48,55 ---- NormalRelocatableTarget(frontend11,$(OBJ1)) + + MakeDirectories(install,$(TGIFDIR)) + InstallNonExec(.psmac,$(TGIFDIR)) + InstallNonExec(tgificon.obj,$(TGIFDIR)) .SUFFIXES: .l .man ---------------------------------> cut here <--------------------------------- -- Bill Cheng // UCLA Computer Science Department // (213) 206-7135 3277 Boelter Hall // Los Angeles, California 90024 // USA william@CS.UCLA.EDU ...!{uunet|ucbvax}!cs.ucla.edu!william dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.