home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / stex2-18.zip / SeeTeX / Xtex / DviPageGS-1.c < prev    next >
C/C++ Source or Header  |  1992-05-05  |  4KB  |  146 lines

  1. /*
  2.  * Copyright 1989 Dirk Grunwald
  3.  * 
  4.  * Permission to use, copy, modify, distribute, and sell this software
  5.  * and its documentation for any purpose is hereby granted without fee,
  6.  * provided that the above copyright notice appear in all copies and that
  7.  * both that copyright notice and this permission notice appear in
  8.  * supporting documentation, and that the name of Dirk Grunwald or M.I.T.
  9.  * not be used in advertising or publicity pertaining to distribution of
  10.  * the software without specific, written prior permission.  Dirk
  11.  * Grunwald and M.I.T. makes no representations about the suitability of
  12.  * this software for any purpose.  It is provided "as is" without express
  13.  * or implied warranty.
  14.  * 
  15.  * DIRK GRUNWALD AND M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  16.  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17.  * FITNESS, IN NO EVENT SHALL M.I.T.  BE LIABLE FOR ANY SPECIAL, INDIRECT
  18.  * OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
  19.  * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  20.  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  21.  * OR PERFORMANCE OF THIS SOFTWARE.
  22.  * 
  23.  * Author:
  24.  *     Dr. Dirk Grunwald
  25.  *     Dept. of Computer Science
  26.  *     Campus Box 430
  27.  *     Univ. of Colorado, Boulder
  28.  *     Boulder, CO 80309
  29.  * 
  30.  *     grunwald@colorado.edu
  31.  *     
  32.  */ 
  33.  
  34. #include <stdio.h>
  35. #include <sys/time.h>
  36. #include <X11/IntrinsicP.h>
  37. #include <X11/StringDefs.h>
  38. #include <X11/Xatom.h>
  39. #include <stdio.h>
  40. #include <assert.h>
  41. #include <varargs.h>
  42. #include <math.h>
  43. #include <ctype.h>
  44.  
  45. #include "xtex.h"
  46. #include "dvi-simple.h"
  47. #include "DviPageP.h"
  48. #include "page.h"
  49.  
  50. #include "DviPageGS-1.h"
  51.  
  52. #ifdef __STDC__
  53. static void callbackGhostOutput (Widget, XtPointer, XtPointer);
  54. #else
  55. static void callbackGhostOutput ();
  56. #endif
  57.  
  58. /*
  59.  *
  60.  * Routines for (re-)setting interface fields on various events.
  61.  *
  62.  */
  63.  
  64. /*
  65.  * Initialize interface fields to indicate no interpreter.
  66.  */
  67. void
  68. gsintInitialize (w)
  69. DviPageWidget w;
  70.     {
  71.     w->dviPage.ghostPID = -1;
  72.     w->dviPage.ghostMsgWin = None;
  73.     w->dviPage.ghostInputId = w->dviPage.ghostOutputId =
  74.         w->dviPage.ghostErrorId = None;
  75.     w->dviPage.ghostInputFD = w->dviPage.ghostOutputFD =
  76.         w->dviPage.ghostErrorFD = -1;
  77.     w->dviPage.ghostPixmap = None;
  78.     w->dviPage.ghostPixWidth = w->dviPage.ghostPixHeight = 
  79.         w->dviPage.ghostPixDepth = 0;
  80.     }
  81.  
  82. /*
  83.  * Install callback and event handlers.
  84.  */
  85. void
  86. gsintRealize (w)
  87. DviPageWidget w;
  88.     {
  89.     XtAddCallback ((Widget) w, XtNghostOutput, callbackGhostOutput, 
  90.         (XtPointer) 0);
  91.     gsintResize (w);
  92.     }
  93.  
  94. void
  95. gsintResize (w)
  96. DviPageWidget w;
  97.     {
  98.     /* Allocate pixmap for gs */
  99.     if (w->dviPage.ghostPixmap != None)
  100.         XFreePixmap (XtDisplay (w), w->dviPage.ghostPixmap);
  101.     
  102.     w->dviPage.ghostPixmap = XCreatePixmap (XtDisplay (w), XtWindow (w),
  103.         w->dviPage.pixelsWide, w->dviPage.pixelsHigh, w->dviPage.ghostPixDepth);
  104.     
  105.     if (w->dviPage.ghostPixmap == None)
  106.         DialogMessage ("Couldn't get pixmap; won't run interpreter.\n", False);
  107.     else
  108.         {
  109.         w->dviPage.ghostPixWidth = w->dviPage.pixelsWide;
  110.         w->dviPage.ghostPixHeight = w->dviPage.pixelsHigh;
  111.         }
  112.     
  113.     if (w->dviPage.ghostPID != -1)
  114.         StopInterpreter (w);
  115.     }
  116.  
  117. /*
  118.  * Destroy interface fields.
  119.  */
  120. void
  121. gsintDestroy (w)
  122. DviPageWidget w;
  123.     {
  124.     if (w->dviPage.ghostPID >= 0)
  125.         StopInterpreter (w);
  126.  
  127.     /* Delete all the callback lists */
  128.     XtRemoveAllCallbacks ((Widget) w, XtNghostOutput);
  129.  
  130.     /* Just to be safe */
  131.     gsintInitialize (w);
  132.     }
  133.  
  134. /*
  135.  *
  136.  * Callback and event handlers.
  137.  *
  138.  */
  139. static void
  140. callbackGhostOutput (gw, client_data, call_data)
  141. Widget gw;
  142. XtPointer client_data, call_data;
  143.     {
  144.     DialogMessage ((char *) call_data, False);
  145.     }    
  146.