[comp.sources.x] v11i063: tgif, Patch6, Part01/06

william@CS.UCLA.EDU (William Cheng) (02/13/91)

Submitted-by: william@CS.UCLA.EDU (William Cheng)
Posting-number: Volume 11, Issue 63
Archive-name: tgif/patch6.01
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)
Patch-To: Volume 8, Issue 94 (Patch4: tgif-1.13 => tgif-1.14)
Patch-To: Volume 8, Issue 95 (Patch5: tgif-1.14 => tgif-1.15)

Patch6 of tgif takes tgif-1.15 to tgif-1.19.  Below is a list of
added features/bug fixes, followed by the actual patch.

tgif-1.15 => tgif-1.16

1) Fix bugs related makeing a grouped object iconic.  Used to have the
   wrong file name.
2) Remove the restriction of just being able to edit files under the
   current directory.
3) New implementation of domains.  Now a domain specifies a search path
   for the .sym files.

tgif-1.16 => tgif-1.17

1) Fix bugs to use getwd() to get current working directory.  Thanks to
   Peter Mutsaers (muts@fysaj.fys.ruu.nl) for pointing it out.
2) Add color attributes in color PostScript files.  (Default for
   printing is still non-color.  Type ^#K to switch to color
   PostScript output.)
3) Add dash patterns and change tgif file version to 9.
4) Add 4 more buttons in the panel (choice window).  Now all secondary
   pop-up menus can be poped-up from the panel (except for the edit menu).
5) Add the ``UpdateSymbols()'' feature.  Selected icons can be
   ``brought up-to-date'' with the current representations found
   in the symbol path.  Each new icon is placed so that it is lined
   up at the upper-left corner with the old icon.  This feature is
   accessible by typing ^#U.
6) If one of the font can not be found, a font with a different
   dots-per-inch is automatically chosen.  If both can not be found,
   tgif exits.  (Apparently some machines only support 100dpi fonts
   by default.)

tgif-1.17 => tgif-1.18

1) Fix rotated text.  On some servers it doesn't work.  (Should use
   ZPixmap instead of XYPixmap when calling XGetImage ().)
2) There was this problem that after a new symbol file is saved and
   one tries to save it again (with ^s), tgif thinks the file name
   is /symbolfilename.  This bug is fixed.
3) If fonts of certain dots-per-inch can not be found and an
   alternative fonts with different dots-per-inch can be found,
   the file status should be set to 'MODIFIED'.
4) If the symbol path contains a ".", then whenever a directory is
   changed, the symbol name cache should be updated.

Due to the SMALL size of this patch, the patch file is posted in this
newsgroup.

tgif-1.18 => tgif-1.19

1) Fix a bug in names.c which cause segmentation faults on some machines.
2) If certain color can not be found, skip it, don't leave it blank.
3) Add explanations in tgif.man about how the alignments work.

The following is the patch to take tgif from version 1.15 to 1.19.
---------------------------------> cut here <---------------------------------
*** box.c.orig	Wed Dec 12 14:32:37 1990
--- box.c	Wed Dec 12 14:32:39 1990
***************
*** 6,10 ****
  #ifndef lint
  static char RCSid[] =
!       "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/box.c,v 1.7 90/08/13 09:23:32 william Exp $";
  #endif
  
--- 6,10 ----
  #ifndef lint
  static char RCSid[] =
!       "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/box.c,v 1.11 90/11/10 13:50:41 william Exp $";
  #endif
  
***************
*** 70,75 ****
     struct ObjRec	* ObjPtr;
  {
!    register int	ltx, lty, rbx, rby;
!    int		fill, width, pen;
  
     ltx = ObjPtr->obbox.ltx;
--- 70,75 ----
     struct ObjRec	* ObjPtr;
  {
!    register int	ltx, lty, rbx, rby, i;
!    int		fill, width, pen, dash, color_index;
  
     ltx = ObjPtr->obbox.ltx;
***************
*** 81,87 ****
--- 81,97 ----
     pen = ObjPtr->detail.b->pen;
     width = ObjPtr->detail.b->width;
+    dash = ObjPtr->detail.b->dash;
  
     if (fill == NONEPAT && pen == NONEPAT) return;
  
+    if (colorDump)
+    {
+       color_index = ObjPtr->color;
+       fprintf (FP, "%.3f %.3f %.3f setrgbcolor\n",
+             ((float)tgifColors[color_index].red/maxRGB),
+             ((float)tgifColors[color_index].green/maxRGB),
+             ((float)tgifColors[color_index].blue/maxRGB));
+    }
+ 
     switch (fill)
     {
***************
*** 117,120 ****
--- 127,138 ----
  
     fprintf (FP, "%1d setlinewidth\n", widthOfLine[width]);
+    if (dash != 0)
+    {
+       fprintf (FP, "[");
+       for (i = 0; i < dashListLength[dash]-1; i++)
+          fprintf (FP, "%1d ", (int)(dashList[dash][i]));
+       fprintf (FP, "%1d] 0 setdash\n",
+             (int)(dashList[dash][dashListLength[dash]-1]));
+    }
  
     switch (pen)
***************
*** 149,152 ****
--- 167,171 ----
           break;
     }
+    if (dash != 0) fprintf (FP, "[] 0 setdash\n");
     fprintf (FP, "1 setlinewidth\n\n");
  }
***************
*** 157,161 ****
  {
     struct BoxRec	* box_ptr = ObjPtr->detail.b;
!    int			fill, pen, pixel, func, ltx, lty, rbx, rby, width;
     int			real_x_off, real_y_off;
     char			s[80];
--- 176,180 ----
  {
     struct BoxRec	* box_ptr = ObjPtr->detail.b;
!    int			fill, pen, pixel, func, ltx, lty, rbx, rby, width, dash;
     int			real_x_off, real_y_off;
     char			s[80];
***************
*** 165,168 ****
--- 184,188 ----
     fill = ObjPtr->detail.b->fill;
     width = ObjPtr->detail.b->width;
+    dash = ObjPtr->detail.b->dash;
     pixel = colorPixels[ObjPtr->color];
  
***************
*** 193,199 ****
        values.stipple = patPixmap[pen];
        values.line_width = widthOfLine[width] >> zoomScale;
        XChangeGC (mainDisplay, drawGC,
!             GCForeground | GCFunction | GCFillStyle | GCStipple | GCLineWidth,
!             &values);
        XDrawRectangle (mainDisplay, win, drawGC, ltx, lty, rbx-ltx, rby-lty);
     }
--- 213,227 ----
        values.stipple = patPixmap[pen];
        values.line_width = widthOfLine[width] >> zoomScale;
+       if (dash != 0)
+       {
+          XSetDashes (mainDisplay, drawGC, 0, dashList[dash],
+                dashListLength[dash]);
+          values.line_style = LineOnOffDash;
+       }
+       else
+          values.line_style = LineSolid;
        XChangeGC (mainDisplay, drawGC,
!             GCForeground | GCFunction | GCFillStyle | GCStipple | GCLineWidth |
!             GCLineStyle, &values);
        XDrawRectangle (mainDisplay, win, drawGC, ltx, lty, rbx-ltx, rby-lty);
     }
***************
*** 212,215 ****
--- 240,244 ----
     box_ptr->width = lineWidth;
     box_ptr->pen = penPat;
+    box_ptr->dash = curDash;
  
     obj_ptr = (struct ObjRec *) calloc (1, sizeof(struct ObjRec));
***************
*** 273,279 ****
     values.fill_style = FillSolid;
     values.line_width = 0;
  
     XChangeGC (mainDisplay, drawGC,
!          GCForeground | GCFunction | GCFillStyle | GCLineWidth, &values);
  
     saved_x = grid_x = OrigX;
--- 302,310 ----
     values.fill_style = FillSolid;
     values.line_width = 0;
+    values.line_style = LineSolid;
  
     XChangeGC (mainDisplay, drawGC,
!          GCForeground | GCFunction | GCFillStyle | GCLineWidth | GCLineStyle,
!          &values);
  
     saved_x = grid_x = OrigX;
***************
*** 341,349 ****
     struct ObjRec	* ObjPtr;
  {
!    fprintf (FP, "box(%s,", colorMenuItems[ObjPtr->color]);
!    fprintf (FP, "%1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d,", ObjPtr->obbox.ltx,
           ObjPtr->obbox.lty, ObjPtr->obbox.rbx, ObjPtr->obbox.rby,
           ObjPtr->detail.b->fill, ObjPtr->detail.b->width,
!          ObjPtr->detail.b->pen, ObjPtr->id);
     SaveAttrs (FP, ObjPtr->lattr);
     fprintf (FP, ")");
--- 372,380 ----
     struct ObjRec	* ObjPtr;
  {
!    fprintf (FP, "box('%s',", colorMenuItems[ObjPtr->color]);
!    fprintf (FP, "%1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d,%1d,", ObjPtr->obbox.ltx,
           ObjPtr->obbox.lty, ObjPtr->obbox.rbx, ObjPtr->obbox.rby,
           ObjPtr->detail.b->fill, ObjPtr->detail.b->width,
!          ObjPtr->detail.b->pen, ObjPtr->id, ObjPtr->detail.b->dash);
     SaveAttrs (FP, ObjPtr->lattr);
     fprintf (FP, ")");
***************
*** 356,360 ****
     struct BoxRec	* box_ptr;
     char			color_str[20], * s;
!    int			ltx, lty, rbx, rby, fill, width, pen, w;
  
     *ObjPtr = (struct ObjRec *) calloc (1, sizeof(struct ObjRec));
--- 387,391 ----
     struct BoxRec	* box_ptr;
     char			color_str[20], * s;
!    int			ltx, lty, rbx, rby, fill, width, pen, dash, w;
  
     *ObjPtr = (struct ObjRec *) calloc (1, sizeof(struct ObjRec));
***************
*** 373,376 ****
--- 404,408 ----
        }
        (*ObjPtr)->id = objId++;
+       dash = 0;
     }
     else if (fileVersion <= 7)
***************
*** 379,384 ****
              &ltx, &lty, &rbx, &rby, &fill, &width, &pen);
        (*ObjPtr)->id = objId++;
     }
!    else
     {
        sscanf (s, "%d , %d , %d , %d , %d , %d , %d , %d",
--- 411,417 ----
              &ltx, &lty, &rbx, &rby, &fill, &width, &pen);
        (*ObjPtr)->id = objId++;
+       dash = 0;
     }
!    else if (fileVersion <= 8)
     {
        sscanf (s, "%d , %d , %d , %d , %d , %d , %d , %d",
***************
*** 385,389 ****
--- 418,430 ----
              &ltx, &lty, &rbx, &rby, &fill, &width, &pen, &((*ObjPtr)->id));
        if ((*ObjPtr)->id >= objId) objId = (*ObjPtr)->id + 1;
+       dash = 0;
     }
+    else
+    {
+       sscanf (s, "%d , %d , %d , %d , %d , %d , %d , %d , %d",
+             &ltx, &lty, &rbx, &rby, &fill, &width, &pen, &((*ObjPtr)->id),
+             &dash);
+       if ((*ObjPtr)->id >= objId) objId = (*ObjPtr)->id + 1;
+    }
  
     box_ptr->fill = fill;
***************
*** 390,393 ****
--- 431,435 ----
     box_ptr->width = width;
     box_ptr->pen = pen;
+    box_ptr->dash = dash;
     (*ObjPtr)->x = ltx;
     (*ObjPtr)->y = lty;
*** choice.c.orig	Wed Dec 12 14:32:48 1990
--- choice.c	Wed Dec 12 14:32:51 1990
***************
*** 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
  
--- 6,10 ----
  #ifndef lint
  static char RCSid[] =
!       "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/choice.c,v 1.10 90/11/01 08:41:44 william Exp $";
  #endif
  
***************
*** 62,67 ****
  }
  
! void ShowColor ()
  {
     XGCValues	values;
  
--- 62,79 ----
  }
  
! void ShowWhereToPrint ()
  {
+    if (colorDump)
+       XSetForeground (mainDisplay, rasterGC, colorPixels[colorIndex]);
+    XSetStipple (mainDisplay, rasterGC, whereToPrintPixmap[whereToPrint]);
+    XFillRectangle (mainDisplay, choiceWindow, rasterGC, 6*choiceImageW, 0,
+          choiceImageW, choiceImageH);
+    if (colorDump)
+       XSetForeground (mainDisplay, rasterGC, myFgPixel);
+ }
+ 
+ void ShowColor (PropagateWhereToPrint)
+    int	PropagateWhereToPrint;
+ {
     XGCValues	values;
  
***************
*** 78,81 ****
--- 90,94 ----
              0, choiceImageH, choiceImageW, choiceImageH);
     }
+    if (PropagateWhereToPrint) ShowWhereToPrint ();
  }
  
***************
*** 117,155 ****
     h = canvasFontHeight;
  
!    switch (curRotate)
!    {
!       case ROTATE0:
!          x = (w > choiceImageW) ?
!                2*choiceImageW - (w-choiceImageW)/2 :
!                2*choiceImageW + (choiceImageW-w)/2;
!          y = (h > choiceImageH) ?
!                choiceImageH + (canvasFontAsc-(h-choiceImageH)/2) :
!                choiceImageH + (canvasFontAsc+(choiceImageH-h)/2);
!          break;
!       case ROTATE90:
!          x = (h > choiceImageW) ?
!                2*choiceImageW + h - (h-choiceImageW)/2 :
!                2*choiceImageW + h + (choiceImageW-h)/2;
!          y = (w > choiceImageH) ?
!                choiceImageH - (w-choiceImageH)/2 :
!                choiceImageH + (choiceImageH-w)/2;
!          break;
!       case ROTATE180:
!          x = (w > choiceImageW) ?
!                2*choiceImageW + w - (w-choiceImageW)/2 :
!                2*choiceImageW + w + (choiceImageW-w)/2;
!          y = (h > choiceImageH) ?
!                2*choiceImageH + (h-choiceImageH)/2 :
!                2*choiceImageH - (choiceImageH-h)/2;
!          break;
!       case ROTATE270:
!          x = (h > choiceImageW) ?
!                2*choiceImageW - (h-choiceImageW)/2 :
!                2*choiceImageW + (choiceImageW-h)/2;
!          y = (w > choiceImageH) ?
!                2*choiceImageH + (w-choiceImageH)/2 :
!                2*choiceImageH - (choiceImageH-w)/2;
!          break;
!    }
  
     XClearArea (mainDisplay, choiceWindow, 2*choiceImageW, choiceImageH,
--- 130,139 ----
     h = canvasFontHeight;
  
!    x = (w > choiceImageW) ?
!          2*choiceImageW - (w-choiceImageW)/2 :
!          2*choiceImageW + (choiceImageW-w)/2;
!    y = (h > choiceImageH) ?
!          choiceImageH + (canvasFontAsc-(h-choiceImageH)/2) :
!          choiceImageH + (canvasFontAsc+(choiceImageH-h)/2);
  
     XClearArea (mainDisplay, choiceWindow, 2*choiceImageW, choiceImageH,
***************
*** 157,215 ****
  
     XSetFont (mainDisplay, choiceGC, canvasFontPtr->fid);
!    if (curRotate == 0)
!    {
!       XSetClipRectangles (mainDisplay, choiceGC, 0, 0, recs, 1, YXBanded);
  
!       values.foreground = myFgPixel;
!       values.background = myBgPixel;
!       XChangeGC (mainDisplay, choiceGC, GCForeground | GCBackground, &values);
  
!       XDrawString (mainDisplay, choiceWindow, choiceGC, x, y, "W", 1);
  
!       values.foreground = 1;
!       values.background = 0;
!       XChangeGC (mainDisplay, choiceGC, GCForeground | GCBackground, &values);
!    }
!    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);
-       image = XGetImage (mainDisplay, choiceBackingPixmap, 0, 0, w, h, 1,
-             XYPixmap);
-       XSetClipRectangles (mainDisplay, choiceGC, 0, 0, recs, 1, YXBanded);
- 
-       values.foreground = myFgPixel;
-       values.background = myBgPixel;
-       XChangeGC (mainDisplay, choiceGC, GCForeground | GCBackground, &values);
- 
-       saved_x = x;
-       saved_y = y;
-       for (i = 0; i < w; i++)
-          for (j = 0; j < h; j++)
-             if (XGetPixel (image, i, j) == 1)
-             {
-                switch (curRotate)
-                {
-                   case ROTATE90: x = saved_x-j; y = saved_y+i; break;
-                   case ROTATE180: x = saved_x-i; y = saved_y-j; break;
-                   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
-             }
- 
-       values.foreground = 1;
-       values.background = 0;
-       XChangeGC (mainDisplay, choiceGC, GCForeground | GCBackground, &values);
-    }
- 
     recs[0].x = 0;
     recs[0].y = 0;
--- 141,156 ----
  
     XSetFont (mainDisplay, choiceGC, canvasFontPtr->fid);
!    XSetClipRectangles (mainDisplay, choiceGC, 0, 0, recs, 1, YXBanded);
  
!    values.foreground = myFgPixel;
!    values.background = myBgPixel;
!    XChangeGC (mainDisplay, choiceGC, GCForeground | GCBackground, &values);
  
!    XDrawString (mainDisplay, choiceWindow, choiceGC, x, y, "W", 1);
  
!    values.foreground = 1;
!    values.background = 0;
!    XChangeGC (mainDisplay, choiceGC, GCForeground | GCBackground, &values);
  
     recs[0].x = 0;
     recs[0].y = 0;
***************
*** 219,225 ****
  }
  
! void ShowLineWidth ()
  {
!    XSetStipple (mainDisplay, rasterGC, shortLineWidthPixmap[lineWidth]);
     XFillRectangle (mainDisplay, choiceWindow, rasterGC, 3*choiceImageW, 0,
           choiceImageW, choiceImageH);
--- 160,166 ----
  }
  
! void ShowRotate ()
  {
!    XSetStipple (mainDisplay, rasterGC, rotatePixmap[curRotate]);
     XFillRectangle (mainDisplay, choiceWindow, rasterGC, 3*choiceImageW, 0,
           choiceImageW, choiceImageH);
***************
*** 226,232 ****
  }
  
! void ShowLineStyle ()
  {
!    XSetStipple (mainDisplay, rasterGC, shortLineStylePixmap[lineStyle]);
     XFillRectangle (mainDisplay, choiceWindow, rasterGC, 3*choiceImageW,
           choiceImageH, choiceImageW, choiceImageH);
--- 167,173 ----
  }
  
! void ShowSpecial ()
  {
!    XSetStipple (mainDisplay, rasterGC, specialPixmap);
     XFillRectangle (mainDisplay, choiceWindow, rasterGC, 3*choiceImageW,
           choiceImageH, choiceImageW, choiceImageH);
***************
*** 233,239 ****
  }
  
! void ShowWhereToPrint ()
  {
!    XSetStipple (mainDisplay, rasterGC, whereToPrintPixmap[whereToPrint]);
     XFillRectangle (mainDisplay, choiceWindow, rasterGC, 4*choiceImageW, 0,
           choiceImageW, choiceImageH);
--- 174,180 ----
  }
  
! void ShowLineWidth ()
  {
!    XSetStipple (mainDisplay, rasterGC, shortLineWidthPixmap[lineWidth]);
     XFillRectangle (mainDisplay, choiceWindow, rasterGC, 4*choiceImageW, 0,
           choiceImageW, choiceImageH);
***************
*** 240,250 ****
  }
  
  void ShowLineType ()
  {
     XSetStipple (mainDisplay, rasterGC, shortLineTypePixmap[curSpline]);
!    XFillRectangle (mainDisplay, choiceWindow, rasterGC, 4*choiceImageW,
           choiceImageH, choiceImageW, choiceImageH);
  }
  
  void ShowFill ()
  {
--- 181,212 ----
  }
  
+ void ShowLineStyle ()
+ {
+    XSetStipple (mainDisplay, rasterGC, shortLineStylePixmap[lineStyle]);
+    XFillRectangle (mainDisplay, choiceWindow, rasterGC, 4*choiceImageW,
+          choiceImageH, choiceImageW, choiceImageH);
+ }
+ 
  void ShowLineType ()
  {
     XSetStipple (mainDisplay, rasterGC, shortLineTypePixmap[curSpline]);
!    XFillRectangle (mainDisplay, choiceWindow, rasterGC, 5*choiceImageW, 0,
!          choiceImageW, choiceImageH);
! }
! 
! void ShowDash ()
! {
!    XSetStipple (mainDisplay, rasterGC, shortDashPixmap[curDash]);
!    XFillRectangle (mainDisplay, choiceWindow, rasterGC, 5*choiceImageW,
           choiceImageH, choiceImageW, choiceImageH);
  }
  
+ void ShowFile ()
+ {
+    XSetStipple (mainDisplay, rasterGC, filePixmap);
+    XFillRectangle (mainDisplay, choiceWindow, rasterGC, 6*choiceImageW,
+          choiceImageH, choiceImageW, choiceImageH);
+ }
+ 
  void ShowFill ()
  {
***************
*** 261,265 ****
  
     XFillRectangle (mainDisplay, choiceWindow, patGC,
!          5*choiceImageW, 0, choiceImageW, choiceImageH);
  }
  
--- 223,227 ----
  
     XFillRectangle (mainDisplay, choiceWindow, patGC,
!          7*choiceImageW, 0, choiceImageW, choiceImageH);
  }
  
***************
*** 278,282 ****
  
     XFillRectangle (mainDisplay, choiceWindow, patGC,
!          5*choiceImageW, choiceImageH, choiceImageW, choiceImageH);
  }
  
--- 240,244 ----
  
     XFillRectangle (mainDisplay, choiceWindow, patGC,
!          7*choiceImageW, choiceImageH, choiceImageW, choiceImageH);
  }
  
***************
*** 385,389 ****
                    if (curChoice != NOTHING) SetCurChoice (NOTHING);
                    colorIndex = (colorIndex+maxColors+delta) % maxColors;
!                   ShowColor ();
                    if (topSel != NULL) ChangeAllSelColor (colorIndex);
                 }
--- 347,351 ----
                    if (curChoice != NOTHING) SetCurChoice (NOTHING);
                    colorIndex = (colorIndex+maxColors+delta) % maxColors;
!                   ShowColor (TRUE);
                    if (topSel != NULL) ChangeAllSelColor (colorIndex);
                 }
***************
*** 393,397 ****
              if (yindex == 0)
              {
!                if (delta != 0)
                 {
                    horiAlign = (horiAlign+MAXALIGNS+delta) % MAXALIGNS;
--- 355,361 ----
              if (yindex == 0)
              {
!                if (delta == 0)
!                   SizeMenu (x, y);
!                else
                 {
                    horiAlign = (horiAlign+MAXALIGNS+delta) % MAXALIGNS;
***************
*** 401,405 ****
              else
              {
!                if (delta != 0)
                 {
                    vertAlign = (vertAlign+MAXALIGNS+delta) % MAXALIGNS;
--- 365,371 ----
              else
              {
!                if (delta == 0)
!                   FontDPIMenu (x, y);
!                else
                 {
                    vertAlign = (vertAlign+MAXALIGNS+delta) % MAXALIGNS;
***************
*** 428,433 ****
                 {
                    if (curChoice != NOTHING) SetCurChoice (NOTHING);
!                   curRotate = (curRotate+4+delta) % 4;
                    ShowCurFont ();
                    if (topSel != NULL)
                    {
--- 394,414 ----
                 {
                    if (curChoice != NOTHING) SetCurChoice (NOTHING);
!                   curFont = (curFont+MAXFONTS+delta) % MAXFONTS;
!                   SetCanvasFont ();
                    ShowCurFont ();
+                   if (topSel != NULL) ChangeFont (curFont);
+                }
+             }
+             break;
+          case 3:
+             if (yindex == 0)
+             {
+                if (delta == 0)
+                   ArrangeMenu (x, y);
+                else
+                {
+                   if (curChoice != NOTHING) SetCurChoice (NOTHING);
+                   curRotate = (curRotate+4+delta) % 4;
+                   ShowRotate ();
                    if (topSel != NULL)
                    {
***************
*** 439,444 ****
                 }
              }
              break;
!          case 3:
              if (yindex == 0)
              {
--- 420,430 ----
                 }
              }
+             else
+             {
+                if (delta == 0)
+                   SpecialMenu (x, y);
+             }
              break;
!          case 4:
              if (yindex == 0)
              {
***************
*** 466,482 ****
              }
              break;
!          case 4:
              if (yindex == 0)
              {
                 if (delta == 0)
!                   LayoutMenu (x, y);
                 else
                 {
!                   whereToPrint = !whereToPrint;
!                   ShowWhereToPrint ();
!                   if (whereToPrint == PRINTER)
!                      Msg ("Print device set to printer.");
!                   else
!                      Msg ("Print device set to LaTeX-Figure file.");
                 }
              }
--- 452,466 ----
              }
              break;
!          case 5:
              if (yindex == 0)
              {
                 if (delta == 0)
!                   LineStyleMenu (x, y);
                 else
                 {
!                   if (curChoice != NOTHING) SetCurChoice (NOTHING);
!                   curSpline = (curSpline+MAXLINETYPES+delta) % MAXLINETYPES;
!                   ShowLineType ();
!                   if (topSel != NULL) ChangeAllSelLineType (curSpline);
                 }
              }
***************
*** 488,498 ****
                 {
                    if (curChoice != NOTHING) SetCurChoice (NOTHING);
!                   curSpline = (curSpline+MAXLINETYPES+delta) % MAXLINETYPES;
!                   ShowLineType ();
!                   if (topSel != NULL) ChangeAllSelLineType (curSpline);
                 }
              }
              break;
!          case 5:
              if (yindex == 0)
              {
--- 472,496 ----
                 {
                    if (curChoice != NOTHING) SetCurChoice (NOTHING);
!                   curDash = (curDash+MAXDASHES+delta) % MAXDASHES;
!                   ShowDash ();
!                   if (topSel != NULL) ChangeAllSelDashes (curDash);
                 }
              }
              break;
!          case 6:
!             if (yindex == 0)
!             {
!                if (delta == 0)
!                   LayoutMenu (x, y);
!                else
!                   ToggleWhereToPrint ();
!             }
!             else
!             {
!                if (delta == 0)
!                   FileMenu (x, y);
!             }
!             break;
!          case 7:
              if (yindex == 0)
              {
*** color.c.orig	Wed Dec 12 14:32:58 1990
--- color.c	Wed Dec 12 14:33:00 1990
***************
*** 6,10 ****
  #ifndef lint
  static char RCSid[] =
!       "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/color.c,v 1.11 90/07/31 15:11:08 william Exp $";
  #endif
  
--- 6,10 ----
  #ifndef lint
  static char RCSid[] =
!       "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/color.c,v 1.16 90/11/10 13:47:29 william Exp $";
  #endif
  
***************
*** 22,25 ****
--- 22,27 ----
  #include "text.e"
  
+ #define COLORSTRLEN 80
+ 
  int	maxColors = MAXCOLORS;
  int	defaultColorIndex = 4;
***************
*** 28,32 ****
--- 30,39 ----
  int	* xorColorPixels = NULL;
  char	* * colorMenuItems = NULL;
+ XColor	* tgifColors;
+ int	maxRGB = 0;
+ int	colorDump = FALSE;
  
+ static int	allocatedMaxColors = MAXCOLORS;
+ 
  static char	* defaultColorMenuItems[MAXCOLORS] =
  {
***************
*** 63,67 ****
     if (i == maxColors)
     {
!       printf ("Can not find color `%s', use `%s' instead.\n", s,
              colorMenuItems[defaultColorIndex]);
        return (defaultColorIndex);
--- 70,74 ----
     if (i == maxColors)
     {
!       printf ("Can not find color '%s', use '%s' instead.\n", s,
              colorMenuItems[defaultColorIndex]);
        return (defaultColorIndex);
***************
*** 72,76 ****
  void InitColor ()
  {
!    register int	i;
     XColor	color, exact_def;
     char		buf[80], * c_ptr, fg_color[80], bg_color[80], brdr_color[80];
--- 79,83 ----
  void InitColor ()
  {
!    register int	i, index;
     XColor	color, exact_def;
     char		buf[80], * c_ptr, fg_color[80], bg_color[80], brdr_color[80];
***************
*** 77,80 ****
--- 84,88 ----
     int		num, color_in_x_default = FALSE;
     int		bg_allocated=FALSE, fg_allocated=FALSE, brdr_allocated=FALSE;
+    int		tmp_max, white_allocated=FALSE, black_allocated=TRUE;
  
     if ((c_ptr = XGetDefault (mainDisplay, TOOL_NAME, "ReverseVideo")) != NULL)
***************
*** 148,151 ****
--- 156,165 ----
     colorMenuItems = (char * *) calloc (maxColors, sizeof (char *));
  
+    tgifColors = (XColor *) calloc (maxColors, sizeof (XColor));
+ 
+    allocatedMaxColors = maxColors;
+    for (i = 0; i < allocatedMaxColors; i++)
+       colorMenuItems[i] = (char *) calloc (COLORSTRLEN, sizeof(char));
+ 
     if (color_in_x_default)
     {
***************
*** 154,161 ****
           sprintf (buf, "Color%1d", i);
           if ((c_ptr = XGetDefault (mainDisplay, TOOL_NAME, buf)) != NULL)
-          {
-             colorMenuItems[i] = (char *) calloc (strlen(c_ptr),sizeof(char));
              strcpy (colorMenuItems[i], c_ptr);
-          }
           else
           {
--- 168,172 ----
***************
*** 171,179 ****
     if (colorDisplay)
     {
        for (i = 0; i < maxColors; i++)
        {
!          XAllocNamedColor(mainDisplay, mainColormap, colorMenuItems[i], &color,
!                &exact_def);
!          colorPixels[i] = color.pixel;
     
           if (strcmp (colorMenuItems[i], fg_color) == 0)
--- 182,199 ----
     if (colorDisplay)
     {
+       index = 0;
        for (i = 0; i < maxColors; i++)
        {
!          if (!XAllocNamedColor(mainDisplay, mainColormap, colorMenuItems[i],
!                &color, &exact_def))
!             continue;
! 
!          if (i != index) strcpy (colorMenuItems[index], colorMenuItems[i]);
! 
!          colorPixels[index] = color.pixel;
! 
!          tgifColors[index].red = color.red;
!          tgifColors[index].green = color.green;
!          tgifColors[index].blue = color.blue;
     
           if (strcmp (colorMenuItems[i], fg_color) == 0)
***************
*** 200,205 ****
--- 220,228 ----
              brdr_allocated = TRUE;
           }
+          index++;
        }
  
+       maxColors = index;
+ 
        if (!fg_allocated)
        {
***************
*** 248,251 ****
--- 271,282 ----
        colorIndex = 0;
     }
+    XAllocNamedColor(mainDisplay, mainColormap, "black", &color, &exact_def);
+    tmp_max = max(color.red,max(color.green,color.blue));
+    if (tmp_max > maxRGB) maxRGB = tmp_max;
+    XAllocNamedColor(mainDisplay, mainColormap, "white", &color, &exact_def);
+    tmp_max = max(color.red,max(color.green,color.blue));
+    if (tmp_max > maxRGB) maxRGB = tmp_max;
+    if (tmp_max == 0)
+       printf ("Warning:  Unexpected maximum RGB intensity 0.");
  }
  
***************
*** 296,300 ****
        text_obj_created = TieLooseEnds ();
        colorIndex = ColorIndex;
!       ShowColor ();
        if (!text_obj_created && curChoice == DRAWTEXT && text_cursor_shown)
        {
--- 327,331 ----
        text_obj_created = TieLooseEnds ();
        colorIndex = ColorIndex;
!       ShowColor (TRUE);
        if (!text_obj_created && curChoice == DRAWTEXT && text_cursor_shown)
        {
***************
*** 363,368 ****
     else
        w = (int)(maxColors / 10) + 1;
!    index = PxMpMenuLoop (X, Y, choiceImageW, choiceImageH, 10, w,
!          maxColors, fore_colors, pixmap, MULTICOLOR);
  
     if (index != INVALID) ChangeAllSelColor (index);
--- 394,403 ----
     else
        w = (int)(maxColors / 10) + 1;
!    if (maxColors <= 10)
!       index = PxMpMenuLoop (X, Y, choiceImageW, choiceImageH, maxColors, w,
!             maxColors, fore_colors, pixmap, MULTICOLOR);
!    else
!       index = PxMpMenuLoop (X, Y, choiceImageW, choiceImageH, 10, w,
!             maxColors, fore_colors, pixmap, MULTICOLOR);
  
     if (index != INVALID) ChangeAllSelColor (index);
***************
*** 376,380 ****
     cfree (colorPixels);
     cfree (xorColorPixels);
!    if (colorDisplay) for (i = 0; i < maxColors; i++) cfree (colorMenuItems[i]);
     cfree (colorMenuItems);
  
--- 411,415 ----
     cfree (colorPixels);
     cfree (xorColorPixels);
!    for (i = 0; i < allocatedMaxColors; i++) cfree (colorMenuItems[i]);
     cfree (colorMenuItems);
  
*** copypaste.c.orig	Wed Dec 12 14:33:06 1990
--- copypaste.c	Wed Dec 12 14:33:07 1990
***************
*** 7,11 ****
  #ifndef lint
  static char RCSid[] =
!       "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/copypaste.c,v 1.8 90/08/25 17:26:51 william Exp $";
  #endif
  
--- 7,11 ----
  #ifndef lint
  static char RCSid[] =
!       "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/copypaste.c,v 1.10 90/09/04 07:26:02 william Exp $";
  #endif
  
***************
*** 219,225 ****
        return;
     }
- #ifdef KANJI
-       myPasteKanji (cut_buffer, len);
- #endif
     cut_buffer++;
     len--;
--- 219,222 ----
*** cursor.c.orig	Wed Dec 12 14:33:12 1990
--- cursor.c	Wed Dec 12 14:33:13 1990
***************
*** 6,10 ****
  #ifndef lint
  static char RCSid[] =
!       "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/cursor.c,v 1.5 90/07/16 10:31:01 william Exp $";
  #endif
  
--- 6,10 ----
  #ifndef lint
  static char RCSid[] =
!       "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/cursor.c,v 1.6 90/09/04 17:59:03 william Exp $";
  #endif
  
***************
*** 17,20 ****
--- 17,21 ----
  #include "setup.e"
  
+ #include "bitmaps/null.bm"
  #include "bitmaps/nullmask.bm"
  #include "bitmaps/text_cur_image.bm"
***************
*** 29,32 ****
--- 30,34 ----
  static Pixmap	textPixmap;
  static Pixmap	nullPixmap;
+ static Pixmap	nullMaskPixmap;
  
  static XImage	* textCursorImage;
***************
*** 85,91 ****
     handCursor = XCreateFontCursor (mainDisplay, XC_hand2);
  
!    nullPixmap = XCreatePixmap (mainDisplay, mainWindow, nullmask_width,
           nullmask_height, 1);
!    nullCursor = XCreatePixmapCursor (mainDisplay, nullPixmap, nullPixmap,
           &color, &color, 0, 0);
  }
--- 87,95 ----
     handCursor = XCreateFontCursor (mainDisplay, XC_hand2);
  
!    nullPixmap = XCreatePixmap (mainDisplay, mainWindow, null_width,
!          null_height, 1);
!    nullMaskPixmap = XCreatePixmap (mainDisplay, mainWindow, nullmask_width,
           nullmask_height, 1);
!    nullCursor = XCreatePixmapCursor (mainDisplay, nullPixmap, nullMaskPixmap,
           &color, &color, 0, 0);
  }
***************
*** 112,115 ****
--- 116,120 ----
  
     XFreePixmap (mainDisplay, nullPixmap);
+    XFreePixmap (mainDisplay, nullMaskPixmap);
     XFreeCursor (mainDisplay, nullCursor);
  }
*** drawing.c.orig	Wed Dec 12 14:33:23 1990
--- drawing.c	Wed Dec 12 14:33:25 1990
***************
*** 6,10 ****
  #ifndef lint
  static char RCSid[] =
!       "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/drawing.c,v 1.11 90/08/16 09:34:54 william Exp $";
  #endif
  
--- 6,10 ----
  #ifndef lint
  static char RCSid[] =
!       "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/drawing.c,v 1.13 90/11/01 18:06:41 william Exp $";
  #endif
  
***************
*** 549,553 ****
              case '\011': /*^#I*/ MakeIconic (); break;
              case '\012': /*^#J*/ UnMakeIconic (); break;
!             case '\013': /*^#K*/ break;
              case '\014': /*^#L*/ ChangeFontJust (JUST_L); break;
              case '\015': /*^#M*/ MakeSymbolic (); break;
--- 549,553 ----
              case '\011': /*^#I*/ MakeIconic (); break;
              case '\012': /*^#J*/ UnMakeIconic (); break;
!             case '\013': /*^#K*/ ToggleColorPostScript (); break;
              case '\014': /*^#L*/ ChangeFontJust (JUST_L); break;
              case '\015': /*^#M*/ MakeSymbolic (); break;
***************
*** 559,566 ****
              case '\023': /*^#S*/ SaveNewFile (); break;
              case '\024': /*^#T*/ ChangeFontStyle (STYLE_NI); break;
!             case '\025': /*^#U*/ break;
              case '\026': /*^#V*/ SetCurChoice (DRAWCIRCLE); break;
              case '\027': /*^#W*/ ToggleAllSelLineType (); break;
!             case '\030': /*^#X*/ break;
              case '\031': /*^#Y*/ PasteFromCutBuffer (); break;
              case '\032': /*^#Z*/ break;
--- 559,566 ----
              case '\023': /*^#S*/ SaveNewFile (); break;
              case '\024': /*^#T*/ ChangeFontStyle (STYLE_NI); break;
!             case '\025': /*^#U*/ UpdateSymbols (); break;
              case '\026': /*^#V*/ SetCurChoice (DRAWCIRCLE); break;
              case '\027': /*^#W*/ ToggleAllSelLineType (); break;
!             case '\030': /*^#X*/ ToggleWhereToPrint (); break;
              case '\031': /*^#Y*/ PasteFromCutBuffer (); break;
              case '\032': /*^#Z*/ break;
*** dup.c.orig	Wed Dec 12 14:33:31 1990
--- dup.c	Wed Dec 12 14:33:33 1990
***************
*** 6,10 ****
  #ifndef lint
  static char RCSid[] =
!       "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/dup.c,v 1.6 90/08/16 09:35:11 william Exp $";
  #endif
  
--- 6,10 ----
  #ifndef lint
  static char RCSid[] =
!       "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/dup.c,v 1.7 90/10/30 16:57:29 william Exp $";
  #endif
  
***************
*** 77,80 ****
--- 77,81 ----
        poly_ptr->svlist = v;
     }
+    poly_ptr->dash = PolyPtr->dash;
  
     ObjPtr->detail.p = poly_ptr;
***************
*** 113,116 ****
--- 114,118 ----
        polygon_ptr->svlist = v;
     }
+    polygon_ptr->dash = PolygonPtr->dash;
  
     ObjPtr->detail.g = polygon_ptr;
***************
*** 128,131 ****
--- 130,134 ----
     oval_ptr->width = OvalPtr->width;
     oval_ptr->pen = OvalPtr->pen;
+    oval_ptr->dash = OvalPtr->dash;
  
     ObjPtr->detail.o = oval_ptr;
***************
*** 143,146 ****
--- 146,150 ----
     box_ptr->width = BoxPtr->width;
     box_ptr->pen = BoxPtr->pen;
+    box_ptr->dash = BoxPtr->dash;
  
     ObjPtr->detail.b = box_ptr;
*** edit.c.orig	Wed Dec 12 14:33:52 1990
--- edit.c	Wed Dec 12 14:33:53 1990
***************
*** 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
  
--- 6,10 ----
  #ifndef lint
  static char RCSid[] =
!       "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/edit.c,v 1.14 90/11/01 18:21:29 william Exp $";
  #endif
  
***************
*** 29,32 ****
--- 29,33 ----
  #include "select.e"
  #include "setup.e"
+ #include "special.e"
  #include "spline.e"
  #include "stretch.e"
***************
*** 739,741 ****
--- 740,837 ----
        case ROTATE_COUNTER: RotateCounter (); break;
     }
+ }
+ 
+ static struct ObjRec	* tmpTopObj, * tmpBotObj;
+ static struct SelRec	* tmpTopSel, * tmpBotSel;
+ 
+ static
+ void PushTmpSel (ObjPtr)
+    struct ObjRec	* ObjPtr;
+ {
+    struct SelRec	* sel_ptr;
+ 
+    ObjPtr->next = tmpTopObj;
+    ObjPtr->prev = NULL;
+ 
+    sel_ptr = (struct SelRec *) calloc (1, sizeof (struct SelRec));
+    sel_ptr->next = tmpTopSel;
+    sel_ptr->prev = NULL;
+    sel_ptr->obj = ObjPtr;
+ 
+    if (tmpTopObj == NULL)
+    {
+       tmpBotObj = ObjPtr;
+       tmpBotSel = sel_ptr;
+    }
+    else
+    {
+       tmpTopObj->prev = ObjPtr;
+       tmpTopSel->prev = sel_ptr;
+    }
+    tmpTopObj = ObjPtr;
+    tmpTopSel = sel_ptr;
+ }
+ 
+ void UpdateSymbols ()
+ {
+    int			dx, dy, changed = FALSE;
+    char			path_name[MAXPATHLENGTH], sym_name[MAXPATHLENGTH];
+    struct ObjRec	* obj_ptr, * new_obj_ptr;
+    struct SelRec	* sel_ptr;
+ 
+    if (topSel == NULL) return;
+ 
+    tmpTopObj = tmpBotObj = NULL;
+    tmpTopSel = tmpBotSel = NULL;
+ 
+    for (sel_ptr = botSel; sel_ptr != NULL; sel_ptr = sel_ptr->prev)
+    {
+       obj_ptr = sel_ptr->obj;
+       if (obj_ptr->type != OBJ_ICON) continue;
+ 
+       strcpy (sym_name, obj_ptr->detail.r->s);
+       if (GetSymbolPath (obj_ptr->detail.r->s, path_name))
+       {
+          if ((new_obj_ptr = GetObjRepresentation (path_name, sym_name)) != NULL)
+          {
+             dx = obj_ptr->obbox.ltx - new_obj_ptr->obbox.ltx;
+             dy = obj_ptr->obbox.lty - new_obj_ptr->obbox.lty;
+             MoveObj (new_obj_ptr, dx, dy);
+ 
+             if (new_obj_ptr->bbox.ltx < selLtX) selLtX = new_obj_ptr->bbox.ltx;
+             if (new_obj_ptr->bbox.lty < selLtY) selLtY = new_obj_ptr->bbox.lty;
+             if (new_obj_ptr->bbox.rbx < selRbX) selRbX = new_obj_ptr->bbox.rbx;
+             if (new_obj_ptr->bbox.rby < selRbY) selRbY = new_obj_ptr->bbox.rby;
+             if (new_obj_ptr->obbox.ltx < selObjLtX)
+                   selObjLtX = new_obj_ptr->obbox.ltx;
+             if (new_obj_ptr->obbox.lty < selObjLtY)
+                   selObjLtY = new_obj_ptr->obbox.lty;
+             if (new_obj_ptr->obbox.rbx < selObjRbX)
+                   selObjRbX = new_obj_ptr->obbox.rbx;
+             if (new_obj_ptr->obbox.rby < selObjRbY)
+                   selObjRbY = new_obj_ptr->obbox.rby;
+ 
+             changed = TRUE;
+ 
+             UnlinkObj (obj_ptr);
+             PushTmpSel (obj_ptr);
+ 
+             sel_ptr->obj = new_obj_ptr;
+             AddObj (NULL, topObj, new_obj_ptr);
+          }
+       }
+    }
+ 
+    PushToCutBuffer (tmpTopSel, tmpBotSel);
+ 
+    if (changed)
+    {
+       HighLightReverse ();
+       RedrawAnArea (botObj, selLtX-(1<<zoomScale), selLtY-(1<<zoomScale),
+             selRbX+(1<<zoomScale), selRbY+(1<<zoomScale));
+       UpdSelBBox ();
+       HighLightForward ();
+       SetFileModified (TRUE);
+    }
+    justDupped = FALSE;
  }
-- 
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 Heller
------------------------------------------------
O'Reilly && Associates 		      Zyrcom Inc
Senior Writer			       President
argv@ora.com			argv@zipcode.com