home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / tcl / 2318 < prev    next >
Encoding:
Text File  |  1993-01-07  |  11.0 KB  |  342 lines

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!timbuk.cray.com!hemlock.cray.com!hrp
  3. From: hrp@cray.com (Hal Peterson)
  4. Subject: graph-1.0 under tk3.0
  5. Message-ID: <HRP.93Jan7162919@pecan03.cray.com>
  6. Lines: 331
  7. Nntp-Posting-Host: pecan03
  8. Organization: Cray Research, Inc.
  9. Date: 7 Jan 93 16:29:16 CST
  10.  
  11. Here are some patches to get graph-1.0 (Hypertext, x-y plots, and bar
  12. charts) to run under tk3.0.  Beware, though, this is a fifteen-minute
  13. hack and some of it looks mighty fishy.  Can somebody suggest a better
  14. way to handle the deletion of the window following the
  15. Tk_EventuallyFree?
  16.  
  17.                         Hal
  18.  
  19. -----------------------------------------------------------------
  20. *** 1.1    1993/01/06 23:02:54
  21. --- graph.c    1993/01/07 00:33:22
  22. ***************
  23. *** 672,678 ****
  24.   static void DestroyGraph _ANSI_ARGS_((ClientData clientData));
  25.   static int GraphWidgetCmd _ANSI_ARGS_((ClientData clientData,
  26.                      Tcl_Interp * interp, int argc, char **argv));
  27. - extern void TkBindError _ANSI_ARGS_((Tcl_Interp * interp));
  28.   
  29.   extern char *sys_errlist[];
  30.   
  31. --- 672,677 ----
  32. ***************
  33. *** 2441,2451 ****
  34.           EventuallyRedraw(graphPtr);
  35.       break;
  36.       case DestroyNotify:
  37. -     Tcl_DeleteCommand(graphPtr->interp, Tk_PathName(graphPtr->tkwin));
  38. -     graphPtr->tkwin = NULL;
  39.       if (graphPtr->flags & REDRAW_PENDING)
  40.           Tk_CancelIdleCall(DisplayGraph, (ClientData) graphPtr);
  41.       Tk_EventuallyFree((ClientData) graphPtr, DestroyGraph);
  42.       break;
  43.       case ConfigureNotify:
  44.       graphPtr->flags |= LAYOUT_NEEDED;
  45. --- 2440,2450 ----
  46.           EventuallyRedraw(graphPtr);
  47.       break;
  48.       case DestroyNotify:
  49.       if (graphPtr->flags & REDRAW_PENDING)
  50.           Tk_CancelIdleCall(DisplayGraph, (ClientData) graphPtr);
  51.       Tk_EventuallyFree((ClientData) graphPtr, DestroyGraph);
  52. +     Tcl_DeleteCommand(graphPtr->interp, Tk_PathName(graphPtr->tkwin));
  53. +     graphPtr->tkwin = NULL;
  54.       break;
  55.       case ConfigureNotify:
  56.       graphPtr->flags |= LAYOUT_NEEDED;
  57. ***************
  58. *** 2533,2545 ****
  59.       if (linePtr->name != NULL)
  60.       ckfree(linePtr->name);
  61.       if (linePtr->stipple != None)
  62. !     Tk_FreeBitmap(linePtr->stipple);
  63.       if (linePtr->fgColor != NULL)
  64.       Tk_FreeColor((XColor *) linePtr->fgColor);
  65.       if (linePtr->bgColor != NULL)
  66.       Tk_FreeColor((XColor *) linePtr->bgColor);
  67.       if (linePtr->gc != None)
  68. !     Tk_FreeGC(linePtr->gc);
  69.       if (linePtr->x.valueArr != NULL)
  70.       ckfree((char *)linePtr->x.valueArr);
  71.       if (linePtr->y.valueArr != NULL)
  72. --- 2532,2544 ----
  73.       if (linePtr->name != NULL)
  74.       ckfree(linePtr->name);
  75.       if (linePtr->stipple != None)
  76. !     Tk_FreeBitmap(Tk_Display(linePtr->parent->tkwin), linePtr->stipple);
  77.       if (linePtr->fgColor != NULL)
  78.       Tk_FreeColor((XColor *) linePtr->fgColor);
  79.       if (linePtr->bgColor != NULL)
  80.       Tk_FreeColor((XColor *) linePtr->bgColor);
  81.       if (linePtr->gc != None)
  82. !     Tk_FreeGC(Tk_Display(linePtr->parent->tkwin), linePtr->gc);
  83.       if (linePtr->x.valueArr != NULL)
  84.       ckfree((char *)linePtr->x.valueArr);
  85.       if (linePtr->y.valueArr != NULL)
  86. ***************
  87. *** 2615,2621 ****
  88.       }
  89.       newGC = Tk_GetGC(tkwin, valueMask, &gcValues);
  90.       if (linePtr->gc != None)
  91. !     Tk_FreeGC(linePtr->gc);
  92.       linePtr->gc = newGC;
  93.       return TCL_OK;
  94.   }
  95. --- 2614,2620 ----
  96.       }
  97.       newGC = Tk_GetGC(tkwin, valueMask, &gcValues);
  98.       if (linePtr->gc != None)
  99. !     Tk_FreeGC(Tk_Display(tkwin), linePtr->gc);
  100.       linePtr->gc = newGC;
  101.       return TCL_OK;
  102.   }
  103. ***************
  104. *** 2778,2784 ****
  105.       valueMask = (GCForeground | GCBackground | GCFont);
  106.       newGC = Tk_GetGC(graphPtr->tkwin, valueMask, &gcValues);
  107.       if (tagPtr->gc != None)
  108. !     Tk_FreeGC(tagPtr->gc);
  109.       tagPtr->gc = newGC;
  110.       return TCL_OK;
  111.   }
  112. --- 2777,2783 ----
  113.       valueMask = (GCForeground | GCBackground | GCFont);
  114.       newGC = Tk_GetGC(graphPtr->tkwin, valueMask, &gcValues);
  115.       if (tagPtr->gc != None)
  116. !     Tk_FreeGC(Tk_Display(graphPtr->tkwin), tagPtr->gc);
  117.       tagPtr->gc = newGC;
  118.       return TCL_OK;
  119.   }
  120. ***************
  121. *** 3317,3323 ****
  122.           if (tagPtr->bitmap != None) {
  123.           int w, h;
  124.   
  125. !         Tk_SizeOfBitmap(tagPtr->bitmap, &w, &h);
  126.           DrawRotatedBitmap(graphPtr, tagPtr->bitmap, tagPtr->gc, w, h,
  127.                     GX(graphPtr, x), GY(graphPtr, y),
  128.                     tagPtr->rotation, tagPtr->anchor);
  129. --- 3316,3323 ----
  130.           if (tagPtr->bitmap != None) {
  131.           int w, h;
  132.   
  133. !         Tk_SizeOfBitmap(Tk_Display(graphPtr->tkwin), tagPtr->bitmap,
  134. !                 &w, &h);
  135.           DrawRotatedBitmap(graphPtr, tagPtr->bitmap, tagPtr->gc, w, h,
  136.                     GX(graphPtr, x), GY(graphPtr, y),
  137.                     tagPtr->rotation, tagPtr->anchor);
  138. ***************
  139. *** 5260,5266 ****
  140.       if (graphPtr->geometry)  /* Geometry */
  141.       free(graphPtr->geometry);
  142.       if (graphPtr->gc != None)/* Graphics context of graph */
  143. !     Tk_FreeGC(graphPtr->gc);
  144.       if (graphPtr->title)     /* Graph title */
  145.       free(graphPtr->title);
  146.       if (graphPtr->fontPtr)   /* Normal font */
  147. --- 5260,5266 ----
  148.       if (graphPtr->geometry)  /* Geometry */
  149.       free(graphPtr->geometry);
  150.       if (graphPtr->gc != None)/* Graphics context of graph */
  151. !     Tk_FreeGC(Tk_Display(graphPtr->tkwin), graphPtr->gc);
  152.       if (graphPtr->title)     /* Graph title */
  153.       free(graphPtr->title);
  154.       if (graphPtr->fontPtr)   /* Normal font */
  155. ***************
  156. *** 5270,5280 ****
  157.       if (graphPtr->numberFg)  /* Axis/number color */
  158.       Tk_FreeColor(graphPtr->numberFg);
  159.       if (graphPtr->numberGC != None)    /* Graphics context of axis */
  160. !     Tk_FreeGC(graphPtr->numberGC);
  161.       if (graphPtr->fgColor)   /* Foreground color */
  162.       Tk_FreeColor(graphPtr->fgColor);
  163.       if (graphPtr->cursor != None)    /* cursor */
  164. !     Tk_FreeCursor(graphPtr->cursor);
  165.       if (graphPtr->X.label)   /* X axis label */
  166.       ckfree(graphPtr->X.label);
  167.       if (graphPtr->Y.label)   /* Y axis label */
  168. --- 5270,5280 ----
  169.       if (graphPtr->numberFg)  /* Axis/number color */
  170.       Tk_FreeColor(graphPtr->numberFg);
  171.       if (graphPtr->numberGC != None)    /* Graphics context of axis */
  172. !     Tk_FreeGC(Tk_Display(graphPtr->tkwin), graphPtr->numberGC);
  173.       if (graphPtr->fgColor)   /* Foreground color */
  174.       Tk_FreeColor(graphPtr->fgColor);
  175.       if (graphPtr->cursor != None)    /* cursor */
  176. !     Tk_FreeCursor(Tk_Display(graphPtr->tkwin), graphPtr->cursor);
  177.       if (graphPtr->X.label)   /* X axis label */
  178.       ckfree(graphPtr->X.label);
  179.       if (graphPtr->Y.label)   /* Y axis label */
  180. ***************
  181. *** 5357,5363 ****
  182.       valueMask = (GCForeground | GCBackground | GCFont | GCLineWidth);
  183.       newGC = Tk_GetGC(graphPtr->tkwin, valueMask, &gcValues);
  184.       if (graphPtr->gc != None)
  185. !     Tk_FreeGC(graphPtr->gc);
  186.       graphPtr->gc = newGC;
  187.   
  188.       /* Create axis GC */
  189. --- 5357,5363 ----
  190.       valueMask = (GCForeground | GCBackground | GCFont | GCLineWidth);
  191.       newGC = Tk_GetGC(graphPtr->tkwin, valueMask, &gcValues);
  192.       if (graphPtr->gc != None)
  193. !     Tk_FreeGC(Tk_Display(graphPtr->tkwin), graphPtr->gc);
  194.       graphPtr->gc = newGC;
  195.   
  196.       /* Create axis GC */
  197. ***************
  198. *** 5365,5371 ****
  199.       gcValues.foreground = graphPtr->numberFg->pixel;
  200.       newGC = Tk_GetGC(graphPtr->tkwin, valueMask, &gcValues);
  201.       if (graphPtr->numberGC != None)
  202. !     Tk_FreeGC(graphPtr->numberGC);
  203.       graphPtr->numberGC = newGC;
  204.   
  205.       return TCL_OK;
  206. --- 5365,5371 ----
  207.       gcValues.foreground = graphPtr->numberFg->pixel;
  208.       newGC = Tk_GetGC(graphPtr->tkwin, valueMask, &gcValues);
  209.       if (graphPtr->numberGC != None)
  210. !     Tk_FreeGC(Tk_Display(graphPtr->tkwin), graphPtr->numberGC);
  211.       graphPtr->numberGC = newGC;
  212.   
  213.       return TCL_OK;
  214. ***************
  215. *** 5706,5712 ****
  216.       break;
  217.       }
  218.       if (result != TCL_OK) {
  219. !         TkBindError(graphPtr->interp);
  220.       return;
  221.       }
  222.       if (graphPtr->doubleBuffered) {
  223. --- 5706,5712 ----
  224.       break;
  225.       }
  226.       if (result != TCL_OK) {
  227. !         Tk_BackgroundError(graphPtr->interp);
  228.       return;
  229.       }
  230.       if (graphPtr->doubleBuffered) {
  231. *** 1.1    1993/01/06 23:02:54
  232. --- htext2.c    1993/01/07 00:36:37
  233. ***************
  234. *** 410,416 ****
  235.   extern int TkMeasureChars _ANSI_ARGS_ ((XFontStruct * fontStructPtr,
  236.           char *source, int maxChars, int startX, int maxX, int flags,
  237.                       int *nextXPtr));
  238. - extern void TkBindError _ANSI_ARGS_ ((Tcl_Interp * interp));
  239.   
  240.   /* end of Forward Declarations */
  241.   
  242. --- 410,415 ----
  243. ***************
  244. *** 874,880 ****
  245.   
  246.       /* Free allocated memory for the following: */
  247.       if (textPtr->gc != None) /* Graphics context */
  248. !     Tk_FreeGC (textPtr->gc);
  249.       if (textPtr->border)     /* 3D Border */
  250.       Tk_Free3DBorder (textPtr->border);
  251.       if (textPtr->normalFg)   /* Foreground color */
  252. --- 873,879 ----
  253.   
  254.       /* Free allocated memory for the following: */
  255.       if (textPtr->gc != None) /* Graphics context */
  256. !     Tk_FreeGC (Tk_Display(textPtr->tkwin), textPtr->gc);
  257.       if (textPtr->border)     /* 3D Border */
  258.       Tk_Free3DBorder (textPtr->border);
  259.       if (textPtr->normalFg)   /* Foreground color */
  260. ***************
  261. *** 892,898 ****
  262.       if (textPtr->text != NULL)    /* Text string */
  263.       ckfree (textPtr->text);
  264.       if (textPtr->cursor != None)    /* Cursor */
  265. !     Tk_FreeCursor (textPtr->cursor);
  266.       FreeLines (textPtr);
  267.       ckfree ((char *)textPtr);/* */
  268.   }
  269. --- 891,897 ----
  270.       if (textPtr->text != NULL)    /* Text string */
  271.       ckfree (textPtr->text);
  272.       if (textPtr->cursor != None)    /* Cursor */
  273. !     Tk_FreeCursor (Tk_Display(textPtr->tkwin), textPtr->cursor);
  274.       FreeLines (textPtr);
  275.       ckfree ((char *)textPtr);/* */
  276.   }
  277. ***************
  278. *** 955,961 ****
  279.       valueMask = GCForeground | GCFont;
  280.       newGC = Tk_GetGC (tkwin, valueMask, &gcValues);
  281.       if (textPtr->gc != None)
  282. !     Tk_FreeGC (textPtr->gc);
  283.       textPtr->gc = newGC;
  284.   
  285.       /* Kill the -file option, if the -text option exists */
  286. --- 954,960 ----
  287.       valueMask = GCForeground | GCFont;
  288.       newGC = Tk_GetGC (tkwin, valueMask, &gcValues);
  289.       if (textPtr->gc != None)
  290. !     Tk_FreeGC (Tk_Display(textPtr->tkwin), textPtr->gc);
  291.       textPtr->gc = newGC;
  292.   
  293.       /* Kill the -file option, if the -text option exists */
  294. ***************
  295. *** 1032,1042 ****
  296.       break;
  297.   
  298.       case DestroyNotify:
  299. -     Tcl_DeleteCommand (textPtr->interp, Tk_PathName (textPtr->tkwin));
  300. -     textPtr->tkwin = NULL;
  301.       if (textPtr->flags & REDRAW_PENDING)
  302.           Tk_CancelIdleCall (DisplayText, (ClientData) textPtr);
  303.       Tk_EventuallyFree ((ClientData) textPtr, DestroyText);
  304.       break;
  305.   
  306.       }
  307. --- 1031,1041 ----
  308.       break;
  309.   
  310.       case DestroyNotify:
  311.       if (textPtr->flags & REDRAW_PENDING)
  312.           Tk_CancelIdleCall (DisplayText, (ClientData) textPtr);
  313.       Tk_EventuallyFree ((ClientData) textPtr, DestroyText);
  314. +     Tcl_DeleteCommand (textPtr->interp, Tk_PathName (textPtr->tkwin));
  315. +     textPtr->tkwin = NULL;
  316.       break;
  317.   
  318.       }
  319. ***************
  320. *** 2170,2176 ****
  321.       sprintf (cmdbuf, "%s %d %d %d %d", command, totalUnits, windowUnits,
  322.            firstUnit, lastUnit);
  323.       if (Tcl_Eval (interp, cmdbuf, 0, NULL) != TCL_OK) {
  324. !     TkBindError (interp);
  325.       }
  326.   }
  327.   
  328. --- 2169,2175 ----
  329.       sprintf (cmdbuf, "%s %d %d %d %d", command, totalUnits, windowUnits,
  330.            firstUnit, lastUnit);
  331.       if (Tcl_Eval (interp, cmdbuf, 0, NULL) != TCL_OK) {
  332. !     Tk_BackgroundError (interp);
  333.       }
  334.   }
  335.   
  336. --
  337. Hal Peterson                Internet:  hrp@cray.com
  338. Cray Research, Inc.            Telephone:  +1 612 683 5440
  339.  
  340.     The working class and the employing class have nothing in common.
  341.                         - The IWW Preamble
  342.