home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.windows.x
- Path: sparky!uunet!snorkelwacker.mit.edu!bloom-beacon!INTERNET!dont-send-mail-to-path-lines
- From: mark@bhanu.lcs.mit.EDU (Mark Levison)
- Subject: display postscript woes
- Message-ID: <9208182014.AA03448@bhanu.andyne.on.ca>
- Sender: daemon@athena.mit.edu (Mr Background)
- Organization: The Internet
- Date: Tue, 18 Aug 1992 20:14:02 GMT
- Lines: 145
-
-
-
- I am trying to use X Display Postscript on an SGI Indigo running IRIX 4.0.1
- the X Server X11R4. My problem I can create an display postscript context
- set fonts, query string widths etc. but I cannot get my program to display
- anything on the screen (I can do normal XDraw* stuff but postscript).
- I have tried a variety of showpage and copypage commands. The program I
- will append below is a simple variation on the one found in the
- "The Display Postscript System 1.0" manual. The XDrawLine is to
- demonstrate that the graphics context and drawing are valid.
- If you would rather just send a trivial working X Display Postscript
- example and I will work from there. Please reply to me directly and I will
- summarize if there is intrest.
-
- Mark Levison
- mark@bhanu.andyne.on.ca
-
- /*---------------------------Cut Here-----------------------*/
-
- #include <X11/Intrinsic.h>
- #include <X11/Shell.h>
- #include <X11/MwmUtil.h>
-
- #include <Xm/Xm.h>
- #include <Xm/DrawingA.h>
- #include <Xm/RowColumn.h>
- #include <Xm/MainW.h>
- #include <Xm/Text.h>
-
- #include <stdlib.h>
- #include <stdio.h>
-
- #include "DPS/dpsXclient.h"
- #include "DPS/dpsops.h"
- #include "DPS/psops.h"
-
- #define DRAW_WIDTH 512
- #define DRAW_HEIGHT 100
-
- DPSContext ps_ctxt;
- DPSContext txtCtxt;
-
- Display *display;
- XtAppContext appc;
- Widget toplevel, main_window;
- Widget drawing_area;
- GC graphics;
-
- static void expose(Widget, caddr_t, caddr_t);
-
- static void
- expose(Widget parent, caddr_t client_data, caddr_t call_data)
- {
- printf("in expose callback\n");
- DPSshowpage(ps_ctxt);
- DPSsetrgbcolor(ps_ctxt, 0.5, 0.5, 0.5);
- DPSrectfill(ps_ctxt, 0.0, 0.0, 50.0, 50.0);
- DPSWaitContext(ps_ctxt);
- XDrawLine(display, XtWindow(drawing_area), graphics, 0, 0, 50, 50);
- }
-
- void main(argc,argv)
- unsigned int argc;
- char **argv;
- {
- Drawable window;
- XGCValues values;
- short ac;
- Arg al[20];
-
- /* init toolkit */
- XtToolkitInitialize();
- appc = XtCreateApplicationContext();
- display = XtOpenDisplay (
- appc, /* application context = default */
- NULL, /* use DISPLAY from environment */
- NULL, /* use last of argv[0] as name */
- NULL,
- NULL, /* no additional cmd line options*/
- 0, /* ditto */
- &argc,
- argv); /* use and delete std options */
-
- if (display == NULL) /* necessary ! */
- XtErrorMsg (
- "NErrCannotOpen", NULL, /* resource name */
- NULL, /* resource class */
- "cannot open display", /* default message */
- NULL, NULL); /* parameters */
-
- /* create application shell */
- ac = 0;
- XtSetArg(al[ac], XmNheight, 200); ac++;
- XtSetArg(al[ac], XmNwidth, 512); ac++;
- toplevel = XtAppCreateShell (
- NULL, /* use same program name */
- NULL, /* repeat class param */
- applicationShellWidgetClass,
- display,
- al, ac); /* argument list */
-
- /* create main window */
- ac = 0;
- XtSetArg(al[ac], XmNvisualPolicy, XmCONSTANT); ac++;
- XtSetArg(al[ac], XmNscrollBarDisplayPolicy, XmSTATIC); ac++;
- XtSetArg(al[ac], XmNscrollingPolicy, XmAUTOMATIC); ac++;
- main_window = XmCreateMainWindow(toplevel, "main", al, ac);
-
- ac = 0;
- XtSetArg(al[ac], XmNwidth, DRAW_WIDTH); ac++;
- XtSetArg(al[ac], XmNheight, DRAW_HEIGHT); ac++;
- drawing_area = XmCreateDrawingArea(main_window, " ", al, ac);
-
- XtAddCallback(drawing_area, XmNexposeCallback, expose, NULL);
- XmMainWindowSetAreas(main_window, NULL, NULL, NULL, NULL, drawing_area);
- /* start loop */
-
- XtManageChild(drawing_area);
- XtManageChild(main_window);
- XtRealizeWidget (toplevel);
-
- values.line_style = LineSolid;
- values.foreground = BlackPixel(XtDisplay(drawing_area), DefaultScreen(XtDisplay(drawing_area)));
- values.background = WhitePixel(XtDisplay(drawing_area), DefaultScreen(XtDisplay(drawing_area)));
- graphics = XCreateGC(XtDisplay(drawing_area),
- RootWindow(XtDisplay(drawing_area), DefaultScreen(XtDisplay(drawing_area))),
- GCLineStyle | GCForeground | GCBackground, &values);
-
- display = XtDisplay(drawing_area);
- window = XtWindow(drawing_area);
-
- if ((ps_ctxt = XDPSCreateSimpleContext(display, window, graphics, 0, 0,
- DPSDefaultTextBackstop, DPSDefaultErrorProc, NULL)) == NULL)
- {
- printf("XDPSCreateSimpleContext returned null");
- XtDestroyWidget(toplevel);
- return;
- }
-
- DPSSetContext(ps_ctxt);
- txtCtxt = DPSCreateTextContext(DPSDefaultTextBackstop, DPSDefaultErrorProc);
- DPSChainContext(ps_ctxt, txtCtxt);
-
- XtAppMainLoop (appc);
- }
-