aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/include/DPS/dpsXpreview.h
blob: 17c050bc0f707cddaf23fffe0c8c19ca59cfed5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/*
 * dosXpreview.h
 *
 * (c) Copyright 1990-1994 Adobe Systems Incorporated.
 * All rights reserved.
 * 
 * Permission to use, copy, modify, distribute, and sublicense this software
 * and its documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notices appear in all copies and that
 * both those copyright notices and this permission notice appear in
 * supporting documentation and that the name of Adobe Systems Incorporated
 * not be used in advertising or publicity pertaining to distribution of the
 * software without specific, written prior permission.  No trademark license
 * to use the Adobe trademarks is hereby granted.  If the Adobe trademark
 * "Display PostScript"(tm) is used to describe this software, its
 * functionality or for any other purpose, such use shall be limited to a
 * statement that this software works in conjunction with the Display
 * PostScript system.  Proper trademark attribution to reflect Adobe's
 * ownership of the trademark shall be given whenever any such reference to
 * the Display PostScript system is made.
 * 
 * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
 * ANY PURPOSE.  IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
 * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NON- INFRINGEMENT OF THIRD PARTY RIGHTS.  IN NO EVENT SHALL ADOBE BE LIABLE
 * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
 * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.  ADOBE WILL NOT
 * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
 * 
 * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
 * Incorporated which may be registered in certain jurisdictions
 * 
 * Author:  Adobe Systems Incorporated
 */
/* $XFree86$ */

#ifndef DPS_X_PREVIEW_H
#define DPS_X_PREVIEW_H

#include <DPS/dpsXcommon.h>

typedef struct {
	long startPos;
	int nestingLevel;
	unsigned long binaryCount;
	Bool continuedLine;
} XDPSPosition;

#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif

/* The rewind function should set the file pointer to the beginning of an
   area of interest.
*/

typedef void (*XDPSRewindFunction)(FILE *f,
				   DPSPointer clientData);

/* The gets function should duplicate the behavior of the fgets function,
   but it may return NULL to indicate that the area of interest is over
   even if the end of file is not yet reached.
*/

typedef char *(*XDPSGetsFunction)(char *buf,
				  int n,
				  FILE *f,
				  DPSPointer clientData);

/* XDPSSetFileFunctions defines the functions XDPSCreatePixmapForEPSF and
   XDPSImageFileIntoDrawable will use to reset the file to its beginning
   and to read the next line of the file.
*/

extern int XDPSSetFileFunctions(XDPSRewindFunction rewindFunction,
				DPSPointer rewindClientData,
				XDPSGetsFunction getsFunction,
				DPSPointer getsClientData);

/* The following two functions expect NULL as client data and are appropriate
   for dealing with a separate EPSF file.  They are the default rewind and
   gets functions, and may be used to reset the functions after changing them.
*/

extern void XDPSFileRewindFunc(FILE *f,
			       DPSPointer data);

extern char *XDPSFileGetsFunc(char *buf,
			      int n,
			      FILE *f,
			      DPSPointer data);

/* The following two functions expect the address of an XDPSPosition
   structure as client data and are appropriate for dealing with an ESPF
   file embedded in another file.  The 2.0 document structuring conventions
   %%BeginDocument and %%EndDocument are used to detect the end of the
   included file and to identify any embedded files.  The startPos
   in the XDPSPosition structure should be the first character of the
   embedded file (as found by, for example, ftell).  It must *not* include
   the initial %%BeginDocument comment for this document.  The nestingLevel,
   continuedLine, and binaryCount fields are used internally by the functions
   and should not be modified.  After calling XDPSImageFileIntoDrawable,
   startPos will be modified to be the first character after the complete
   EPSF file, or -1 if the EPSF ended with end-of-file.
*/

extern void XDPSEmbeddedEPSFRewindFunc(FILE *f,
				       DPSPointer data);

extern char *XDPSEmbeddedGetsFunc(char *buf, int n, FILE *f, DPSPointer data);

extern char *XDPSEmbeddedEPSFGetsFunc(char *buf,
				      int n,
				      FILE *f,
				      DPSPointer data);

/* XDPSCreatePixmapForEPSF creates a pixmap for use on the specified screen.
   The size of the pixmap is determined by reading the %%BoundingBox comment
   in the file, scaled by the pixelsPerPoint value.  The size of the
   pixmap is returned in pixelSize (x and y will be zero) and the bounding
   box (in points) is returned in bbox.  The context parameter may be NULL,
   in which case the shared context for the display will be used.  If a real
   context is passed, it must be registered with XDPSRegisterContext.
*/

extern int XDPSCreatePixmapForEPSF(DPSContext context,
				   Screen *screen,
				   FILE *epsf,
				   int depth,
				   double pixelsPerPoint,
				   Pixmap *p,
				   XRectangle *pixelSize,
				   XRectangle *bbox);

/* XDPSPixelsPerPoint returns the number of pixels in one point on the given
   screen.  Note that if the server lies about the resolution of the screen
   (as it often does) the lie will be repeated here. */

extern double XDPSPixelsPerPoint(Screen *screen);

/* XDPSImageFileIntoDrawable images a PostScript file into a drawable.
   The imaging will be offset by the xOffset and yOffset values, these
   must be in points.  If the clear parameter is True, the area defined
   by the bbox will be cleared to white before imaging.  If createMask is
   True, the drawable must be 1 bit deep and it will end up containing a
   1 bit everywhere that the PostScript file images, if clear is also True
   any untouched bits will be 0.  If the drawable is a pixmap, the result
   is suitable for use as a mask in X drawing call.  The context parameter
   may be NULL, in which case the shared context for the display will
   be used.  If a real context is passed, it must be registered with
   XDPSRegisterContext.  

   If waitForCompletion is True, XDPSImageFileIntoDrawable
   will wait for the imaging to be finished before returning.  If
   waitForCompletion parameter is False, XDPSImageFileIntoDrawable will wait
   for a time as specified by the XDPSSetImagingTimeout before returning
   dps_status_imaging_incomplete.  The caller checks for the completion of
   the imaging by calling XDPSCheckImagingResults periodically.

   Partial imaging may be stopped by destroying the context with
   XDPSDestroySharedContext or both DPSDestroyContext and
   XDPSUnregisterContext.  Doing anything with a context between the time
   XDPSImageFileIntoDrawable returns dps_status_imaging_incomplete and the
   time XDPSCheckImagingResults returns other than
   dps_status_imaging_incomplete will yield incorrect imaging
   results and leave the context in an undefined state, don't do it.

   If the display does not support the DPS extension, the image area as
   determined by the bbox parameter will be filled with a 50% gray stipple
   pattern, or set to solid 1's if createMask is True.

   The context parameter may be NULL, in which case the shared context
   for the display will be used.  If a real context is passed, it must
   be registered with XDPSRegisterContext.
*/

extern int XDPSImageFileIntoDrawable(DPSContext context,
				     Screen *screen,
				     Drawable dest,
				     FILE *file,
				     int drawableHeight,
				     int drawableDepth,
				     XRectangle *bbox,
				     int xOffset,
				     int yOffset,
				     double pixelsPerPoint,
				     Bool clear,
				     Bool createMask,
				     Bool waitForCompletion,
				     Bool *doneFlag);

/* XDPSCheckImagingResults checks the status of the imaging on the context.
   If the imaging is not done, it returns dps_status_imaging_incomplete, if
   it is done, it returns dps_status_success or dps_status_postscript_error,
   if the context is not currently involved in imaging it returns
   dps_status_illegal_value.

   The context parameter may be NULL, in which case the shared context
   for the display will be used.  If a real context is passed, it must
   be registered with XDPSRegisterContext.
*/

extern int XDPSCheckImagingResults(DPSContext context,
				   Screen *screen);

/* XDPSSetImagingTimeout determines how long XDPSImageFileIntoDrawable will
   wait before returning after an incomplete imaging, in milliseconds.
   XDPSImageFileIntoDrawable will start by waiting the timeout and will
   repeatedly double the wait until the imaging is complete or until
   maxDoublings have occurred.  */

extern void XDPSSetImagingTimeout(int timeout,
				  int maxDoublings);

#if defined(__cplusplus) || defined(c_plusplus)
}
#endif

#endif /* DPS_X_PREVIEW_H */