home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / windows / x / 15399 < prev    next >
Encoding:
Text File  |  1992-08-18  |  5.2 KB  |  156 lines

  1. Newsgroups: comp.windows.x
  2. Path: sparky!uunet!snorkelwacker.mit.edu!bloom-beacon!INTERNET!dont-send-mail-to-path-lines
  3. From: mark@bhanu.lcs.mit.EDU (Mark Levison)
  4. Subject: display postscript woes
  5. Message-ID: <9208182014.AA03448@bhanu.andyne.on.ca>
  6. Sender: daemon@athena.mit.edu (Mr Background)
  7. Organization: The Internet
  8. Date: Tue, 18 Aug 1992 20:14:02 GMT
  9. Lines: 145
  10.  
  11.  
  12.  
  13.     I am trying to use X Display Postscript on an SGI Indigo running IRIX 4.0.1
  14. the X Server X11R4.  My problem I can create an display postscript context
  15. set fonts, query string widths etc. but I cannot get my program to display
  16. anything on the screen (I can do normal XDraw* stuff but postscript).
  17. I have tried a variety of showpage and copypage commands. The program I
  18. will append below is a simple variation on the one found in the
  19. "The Display Postscript System 1.0" manual.  The XDrawLine is to
  20. demonstrate that the graphics context and drawing are valid.
  21. If you would rather just send a trivial working X Display Postscript
  22. example and I will work from there.  Please reply to me directly and I will
  23. summarize if there is intrest.
  24.  
  25. Mark Levison
  26. mark@bhanu.andyne.on.ca
  27.  
  28. /*---------------------------Cut Here-----------------------*/
  29.  
  30. #include <X11/Intrinsic.h>
  31. #include <X11/Shell.h>
  32. #include <X11/MwmUtil.h>
  33.  
  34. #include <Xm/Xm.h>
  35. #include <Xm/DrawingA.h>
  36. #include <Xm/RowColumn.h>
  37. #include <Xm/MainW.h>
  38. #include <Xm/Text.h>
  39.  
  40. #include <stdlib.h>
  41. #include <stdio.h>
  42.  
  43. #include "DPS/dpsXclient.h"
  44. #include "DPS/dpsops.h"
  45. #include "DPS/psops.h"
  46.  
  47. #define DRAW_WIDTH  512
  48. #define DRAW_HEIGHT 100
  49.  
  50. DPSContext      ps_ctxt;
  51. DPSContext      txtCtxt;
  52.  
  53. Display        *display;
  54. XtAppContext    appc;
  55. Widget          toplevel, main_window;
  56. Widget          drawing_area;
  57. GC              graphics;
  58.  
  59. static void expose(Widget, caddr_t, caddr_t);
  60.  
  61. static void
  62. expose(Widget parent, caddr_t client_data, caddr_t call_data)
  63. {
  64.     printf("in expose callback\n");
  65.     DPSshowpage(ps_ctxt);
  66.     DPSsetrgbcolor(ps_ctxt, 0.5, 0.5, 0.5);
  67.     DPSrectfill(ps_ctxt, 0.0, 0.0, 50.0, 50.0);
  68.     DPSWaitContext(ps_ctxt);
  69.     XDrawLine(display, XtWindow(drawing_area), graphics, 0, 0, 50, 50);
  70. }
  71.  
  72. void main(argc,argv)
  73. unsigned int    argc;
  74. char        **argv;
  75. {
  76.     Drawable    window;
  77.     XGCValues   values;
  78.     short   ac;
  79.     Arg     al[20];
  80.  
  81.     /* init toolkit */
  82.     XtToolkitInitialize();
  83.     appc = XtCreateApplicationContext();
  84.     display = XtOpenDisplay (
  85.                   appc,          /* application context = default */
  86.                   NULL,        /* use DISPLAY from environment  */
  87.                   NULL,        /* use last of argv[0] as name   */
  88.                   NULL,
  89.                   NULL,        /* no additional cmd line options*/
  90.                   0,           /* ditto                         */
  91.                   &argc,
  92.                   argv);       /* use and delete std options    */
  93.  
  94.     if (display == NULL)       /* necessary !                   */
  95.         XtErrorMsg (
  96.             "NErrCannotOpen", NULL,    /* resource name         */
  97.             NULL,                      /* resource class        */
  98.             "cannot open display",     /* default message       */
  99.             NULL, NULL);               /* parameters            */
  100.  
  101.     /* create application shell */
  102.     ac = 0;
  103.     XtSetArg(al[ac], XmNheight, 200); ac++;
  104.     XtSetArg(al[ac], XmNwidth, 512); ac++;
  105.     toplevel = XtAppCreateShell (
  106.                    NULL,               /* use same program name */
  107.                    NULL,               /* repeat class param    */
  108.                    applicationShellWidgetClass,
  109.                    display,
  110.                    al, ac);           /* argument list         */
  111.  
  112.     /* create main window */
  113.     ac = 0;
  114.     XtSetArg(al[ac], XmNvisualPolicy, XmCONSTANT); ac++;
  115.     XtSetArg(al[ac], XmNscrollBarDisplayPolicy, XmSTATIC); ac++;
  116.     XtSetArg(al[ac], XmNscrollingPolicy, XmAUTOMATIC); ac++;
  117.     main_window = XmCreateMainWindow(toplevel, "main", al, ac);
  118.  
  119.     ac = 0;
  120.     XtSetArg(al[ac], XmNwidth, DRAW_WIDTH); ac++;
  121.     XtSetArg(al[ac], XmNheight, DRAW_HEIGHT); ac++;
  122.     drawing_area = XmCreateDrawingArea(main_window, " ", al, ac);
  123.  
  124.     XtAddCallback(drawing_area, XmNexposeCallback, expose, NULL);
  125.     XmMainWindowSetAreas(main_window, NULL, NULL, NULL, NULL, drawing_area);
  126.     /* start loop */
  127.  
  128.     XtManageChild(drawing_area);
  129.     XtManageChild(main_window);
  130.     XtRealizeWidget (toplevel);
  131.  
  132.     values.line_style = LineSolid;
  133.     values.foreground = BlackPixel(XtDisplay(drawing_area), DefaultScreen(XtDisplay(drawing_area)));
  134.     values.background = WhitePixel(XtDisplay(drawing_area), DefaultScreen(XtDisplay(drawing_area)));
  135.     graphics = XCreateGC(XtDisplay(drawing_area),
  136.         RootWindow(XtDisplay(drawing_area), DefaultScreen(XtDisplay(drawing_area))),
  137.         GCLineStyle | GCForeground | GCBackground, &values);
  138.  
  139.     display = XtDisplay(drawing_area);
  140.     window = XtWindow(drawing_area);
  141.  
  142.     if ((ps_ctxt = XDPSCreateSimpleContext(display, window, graphics, 0, 0,
  143.         DPSDefaultTextBackstop, DPSDefaultErrorProc, NULL)) == NULL)
  144.     {
  145.       printf("XDPSCreateSimpleContext returned null");
  146.       XtDestroyWidget(toplevel);
  147.       return;
  148.     }
  149.  
  150.     DPSSetContext(ps_ctxt);
  151.     txtCtxt = DPSCreateTextContext(DPSDefaultTextBackstop, DPSDefaultErrorProc);
  152.     DPSChainContext(ps_ctxt, txtCtxt);
  153.  
  154.     XtAppMainLoop (appc);
  155. }
  156.