static void Kill(Engine *engine) { PSEngine *psEngine= (PSEngine *)engine; long fonts= psEngine->fonts; int i, xll, yll, xur, yur; int bad= 0; if (psEngine->e.marked) bad= EndPage(psEngine); if (psEngine->file) { if (!bad) bad= PutLine(psEngine); if (!bad) bad= Append(psEngine, "%%Trailer"); if (!bad) bad= PutLine(psEngine); sprintf(line, "%%%%Pages: %d", psEngine->currentPage-1); if (!bad) bad= Append(psEngine, line); if (!bad) bad= PutLine(psEngine); xll= psEngine->docBB.xll; xur= psEngine->docBB.xur; if (xll < xur) { yll= psEngine->docBB.yll; yur= psEngine->docBB.yur; } else { xll= yll= 0; xur= 612; yur= 792; } sprintf(line, "%%%%BoundingBox: %d %d %d %d", xll, yll, xur, yur); if (!bad) bad= Append(psEngine, line); if (!bad) bad= PutLine(psEngine); strcpy(line, "%%DocumentFonts: "); for (i=0 ; i<N_PSFONTS ; i++) { if ((1<<i) & fonts) { strcat(line, psFontNames[i]); if (!bad) bad= Append(psEngine, line); if (!bad) bad= PutLine(psEngine); strcpy(line, "%%+ "); } } if (psEngine->file!=pf_stdout) p_fclose(psEngine->file); } GpDelEngine(engine); }
Engine * GpBXEngine(char *name, int landscape, int dpi, char *displayName) { p_scr *s = g_connect(displayName); int topWidth = DefaultTopWidth(dpi); int topHeight = DefaultTopHeight(dpi); GpTransform toPixels; int x, y, width, height, hints; XEngine *xeng; if (!s) return 0; SetXTransform(&toPixels, landscape, dpi); width = (int)toPixels.window.xmax; height = (int)toPixels.window.ymin; x = (width-topWidth)/2; if (landscape) y = (height-topHeight)/2; else y = (width-topHeight)/2; if (y<0) y = 0; if (x<0) x = 0; xeng = GxEngine(s, name, &toPixels, -x,-y,0,0, sizeof(XEngine)); xeng->wtop = topWidth; xeng->htop = topHeight; /* possibly want optional P_RGBMODEL as well */ hints = (gist_private_map?P_PRIVMAP:0) | (gist_input_hint?0:P_NOKEY) | (gist_rgb_hint?P_RGBMODEL:0); xeng->win = xeng->w = gx_parent? p_subwindow(s, topWidth, topHeight, gx_parent, gx_xloc, gx_yloc, P_BG, hints, xeng) : p_window(s, topWidth, topHeight, name, P_BG, hints, xeng); gx_parent = 0; if (!xeng->win) { GpDelEngine(&xeng->e); return 0; } return &xeng->e; }
static void ShutDown(XEngine *xeng) { p_scr *s = xeng->s; p_win *w = xeng->w; p_win *win = xeng->win; if ((Engine *)xeng == gxCurrentEngine) gxCurrentEngine = NULL; xeng->mapped= 0; /* turn off all event callbacks (probably unnecessary) */ xeng->e.on = 0; /* destroy any hlevel references without further ado */ if (HLevelHook) HLevelHook((Engine *)xeng); xeng->w = xeng->win = 0; xeng->s = 0; /* note that p_destroy and GpDelEngine call on_destroy in Windows */ if (w && w!=win) p_destroy(w); GpDelEngine(&xeng->e); if (s) { if (!p_wincount(s)) g_pending_task = g_do_disconnect; } }
static void ShutDown(XEngine *xeng) { p_scr *s = xeng->s; p_win *w = xeng->w; p_win *win = xeng->win; xeng->mapped= 0; /* destroy any hlevel references without further ado */ if (HLevelHook) HLevelHook((Engine *)xeng); xeng->w = xeng->win = 0; xeng->s = 0; if (w && w!=win) p_destroy(w); GpDelEngine(&xeng->e); if (s) { Engine *eng; XEngine *xe2; for (eng=GpNextEngine(0) ; eng ; eng=GpNextEngine(eng)) { xe2 = GisXEngine(eng); if (xe2 && xe2->s==s) break; } if (!eng) { int i; if (g_pending_task == g_do_disconnect) { for (i=0 ; i<=G_N_PENDING ; i++) if (g_pending_scr[i] == s) break; if (i >= G_N_PENDING) { for (i=0 ; i<=G_N_PENDING ; i++) if (!g_pending_scr[i]) break; if (i < G_N_PENDING) g_pending_scr[i] = s; } } else { g_pending_scr[0] = s; for (i=1 ; i<=G_N_PENDING ; i++) g_pending_scr[i] = 0; g_pending_task = g_do_disconnect; } } } }