Tk
view release on metacpan or search on metacpan
pTk/mTk/generic/tkCanvPs.c view on Meta::CPAN
}
if ((mode & TCL_WRITABLE) == 0) {
Tcl_AppendResult(interp, "channel \"",
psInfo.channelName, "\" wasn't opened for writing",
(char *) NULL);
result = TCL_ERROR;
goto cleanup;
}
}
/*
*--------------------------------------------------------
* Make a pre-pass over all of the items, generating Postscript
* and then throwing it away. The purpose of this pass is just
* to collect information about all the fonts in use, so that
* we can output font information in the proper form required
* by the Document Structuring Conventions.
*--------------------------------------------------------
*/
psInfo.prepass = 1;
for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL;
itemPtr = itemPtr->nextPtr) {
if ((itemPtr->x1 >= psInfo.x2) || (itemPtr->x2 < psInfo.x)
|| (itemPtr->y1 >= psInfo.y2) || (itemPtr->y2 < psInfo.y)) {
continue;
}
if (itemPtr->group != canvasPtr->activeGroup) {
continue;
}
if (itemPtr->typePtr->postscriptProc == NULL) {
continue;
}
result = (*itemPtr->typePtr->postscriptProc)(interp,
(Tk_Canvas) canvasPtr, itemPtr, 1);
Tcl_ResetResult(interp);
if (result != TCL_OK) {
/*
* An error just occurred. Just skip out of this loop.
* There's no need to report the error now; it can be
* reported later (errors can happen later that don't
* happen now, so we still have to check for errors later
* anyway).
*/
break;
}
}
psInfo.prepass = 0;
/*
*--------------------------------------------------------
* Generate the header and prolog for the Postscript.
*--------------------------------------------------------
*/
if (psInfo.prolog) {
Tcl_AppendResult(interp, "%!PS-Adobe-3.0 EPSF-3.0\n",
"%%Creator: Tk Canvas Widget\n", (char *) NULL);
#ifdef HAVE_PW_GECOS
if (!Tcl_IsSafe(interp)) {
struct passwd *pwPtr = getpwuid(getuid()); /* INTL: Native. */
Tcl_AppendResult(interp, "%%For: ",
(pwPtr != NULL) ? pwPtr->pw_gecos : "Unknown", "\n",
(char *) NULL);
endpwent();
}
#endif /* HAVE_PW_GECOS */
Tcl_AppendResult(interp, "%%Title: Window ",
Tk_PathName(tkwin), "\n", (char *) NULL);
time(&now);
Tcl_AppendResult(interp, "%%CreationDate: ",
ctime(&now), (char *) NULL); /* INTL: Native. */
if (!psInfo.rotate) {
sprintf(string, "%d %d %d %d",
(int) (psInfo.pageX + psInfo.scale*deltaX),
(int) (psInfo.pageY + psInfo.scale*deltaY),
(int) (psInfo.pageX + psInfo.scale*(deltaX + psInfo.width)
+ 1.0),
(int) (psInfo.pageY + psInfo.scale*(deltaY + psInfo.height)
+ 1.0));
} else {
sprintf(string, "%d %d %d %d",
(int) (psInfo.pageX - psInfo.scale*(deltaY + psInfo.height)),
(int) (psInfo.pageY + psInfo.scale*deltaX),
(int) (psInfo.pageX - psInfo.scale*deltaY + 1.0),
(int) (psInfo.pageY + psInfo.scale*(deltaX + psInfo.width)
+ 1.0));
}
Tcl_AppendResult(interp, "%%BoundingBox: ", string,
"\n", (char *) NULL);
Tcl_AppendResult(interp, "%%Pages: 1\n",
"%%DocumentData: Clean7Bit\n", (char *) NULL);
Tcl_AppendResult(interp, "%%Orientation: ",
psInfo.rotate ? "Landscape\n" : "Portrait\n", (char *) NULL);
p = "%%DocumentNeededResources: font ";
for (hPtr = Tcl_FirstHashEntry(&psInfo.fontTable, &search);
hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
Tcl_AppendResult(interp, p,
Tcl_GetHashKey(&psInfo.fontTable, hPtr),
"\n", (char *) NULL);
p = "%%+ font ";
}
Tcl_AppendResult(interp, "%%EndComments\n\n", (char *) NULL);
/*
* Insert the prolog
*/
Tcl_AppendResult(interp, Tcl_GetVar(interp,"::tk::ps_preamable",
TCL_GLOBAL_ONLY), (char *) NULL);
if (psInfo.chan != NULL) {
Tcl_Write(psInfo.chan, Tcl_GetStringResult(interp), -1);
Tcl_ResetResult(canvasPtr->interp);
}
/*
*-----------------------------------------------------------
* Document setup: set the color level and include fonts.
*-----------------------------------------------------------
*/
( run in 1.206 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )