# Correct the needed linklibs in curl-config also.
[AROS-Contrib.git] / arospdf / xpdf / Gfx.h
blob614c454f7a8282dd075c000ff7e44c786551e973
1 //========================================================================
2 //
3 // Gfx.h
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
9 #ifndef GFX_H
10 #define GFX_H
12 #include <aconf.h>
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
18 #include "gtypes.h"
20 class GString;
21 class XRef;
22 class Array;
23 class Stream;
24 class Parser;
25 class Dict;
26 class Function;
27 class OutputDev;
28 class GfxFontDict;
29 class GfxFont;
30 class GfxPattern;
31 class GfxTilingPattern;
32 class GfxShadingPattern;
33 class GfxShading;
34 class GfxFunctionShading;
35 class GfxAxialShading;
36 class GfxRadialShading;
37 class GfxGouraudTriangleShading;
38 class GfxPatchMeshShading;
39 struct GfxPatch;
40 class GfxState;
41 struct GfxColor;
42 class GfxColorSpace;
43 class Gfx;
44 class PDFRectangle;
45 class AnnotBorderStyle;
47 //------------------------------------------------------------------------
49 enum GfxClipType {
50 clipNone,
51 clipNormal,
52 clipEO
55 enum TchkType {
56 tchkBool, // boolean
57 tchkInt, // integer
58 tchkNum, // number (integer or real)
59 tchkString, // string
60 tchkName, // name
61 tchkArray, // array
62 tchkProps, // properties (dictionary or name)
63 tchkSCN, // scn/SCN args (number of name)
64 tchkNone // used to avoid empty initializer lists
67 #define maxArgs 33
69 struct Operator {
70 char name[4];
71 int numArgs;
72 TchkType tchk[maxArgs];
73 void (Gfx::*func)(xObject args[], int numArgs);
76 //------------------------------------------------------------------------
78 class GfxResources {
79 public:
81 GfxResources(XRef *xref, Dict *resDict, GfxResources *nextA);
82 ~GfxResources();
84 GfxFont *lookupFont(char *name);
85 GBool lookupXObject(char *name, xObject *obj);
86 GBool lookupXObjectNF(char *name, xObject *obj);
87 void lookupColorSpace(char *name, xObject *obj);
88 GfxPattern *lookupPattern(char *name);
89 GfxShading *lookupShading(char *name);
90 GBool lookupGState(char *name, xObject *obj);
92 GfxResources *getNext() { return next; }
94 private:
96 GfxFontDict *fonts;
97 xObject xObjDict;
98 xObject colorSpaceDict;
99 xObject patternDict;
100 xObject shadingDict;
101 xObject gStateDict;
102 GfxResources *next;
105 //------------------------------------------------------------------------
106 // Gfx
107 //------------------------------------------------------------------------
109 class Gfx {
110 public:
112 // Constructor for regular output.
113 Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict,
114 double hDPI, double vDPI, PDFRectangle *box,
115 PDFRectangle *cropBox, int rotate,
116 GBool (*abortCheckCbkA)(void *data) = NULL,
117 void *abortCheckCbkDataA = NULL);
119 // Constructor for a sub-page xObject.
120 Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
121 PDFRectangle *box, PDFRectangle *cropBox,
122 GBool (*abortCheckCbkA)(void *data) = NULL,
123 void *abortCheckCbkDataA = NULL);
125 ~Gfx();
127 // Interpret a stream or array of streams.
128 void display(xObject *obj, GBool topLevel = gTrue);
130 // Display an annotation, given its appearance (a Form XObject),
131 // border style, and bounding box (in default user space).
132 void drawAnnot(xObject *str, AnnotBorderStyle *borderStyle,
133 double xMin, double yMin, double xMax, double yMax);
135 // Save graphics state.
136 void saveState();
138 // Restore graphics state.
139 void restoreState();
141 // Get the current graphics state xObject.
142 GfxState *getState() { return state; }
144 private:
146 XRef *xref; // the xref table for this PDF file
147 OutputDev *out; // output device
148 GBool subPage; // is this a sub-page xObject?
149 GBool printCommands; // print the drawing commands (for debugging)
150 GfxResources *res; // resource stack
151 int updateLevel;
153 GfxState *state; // current graphics state
154 GBool fontChanged; // set if font or text matrix has changed
155 GfxClipType clip; // do a clip?
156 int ignoreUndef; // current BX/EX nesting level
157 double baseMatrix[6]; // default matrix for most recent
158 // page/form/pattern
159 int formDepth;
161 Parser *parser; // parser for page content stream(s)
163 GBool // callback to check for an abort
164 (*abortCheckCbk)(void *data);
165 void *abortCheckCbkData;
167 static Operator opTab[]; // table of operators
169 void go(GBool topLevel);
170 void execOp(xObject *cmd, xObject args[], int numArgs);
171 Operator *findOp(char *name);
172 GBool checkArg(xObject *arg, TchkType type);
173 int getPos();
175 // graphics state operators
176 void opSave(xObject args[], int numArgs);
177 void opRestore(xObject args[], int numArgs);
178 void opConcat(xObject args[], int numArgs);
179 void opSetDash(xObject args[], int numArgs);
180 void opSetFlat(xObject args[], int numArgs);
181 void opSetLineJoin(xObject args[], int numArgs);
182 void opSetLineCap(xObject args[], int numArgs);
183 void opSetMiterLimit(xObject args[], int numArgs);
184 void opSetLineWidth(xObject args[], int numArgs);
185 void opSetExtGState(xObject args[], int numArgs);
186 void doSoftMask(xObject *str, GBool alpha,
187 GfxColorSpace *blendingColorSpace,
188 GBool isolated, GBool knockout,
189 Function *transferFunc, GfxColor *backdropColor);
190 void opSetRenderingIntent(xObject args[], int numArgs);
192 // color operators
193 void opSetFillGray(xObject args[], int numArgs);
194 void opSetStrokeGray(xObject args[], int numArgs);
195 void opSetFillCMYKColor(xObject args[], int numArgs);
196 void opSetStrokeCMYKColor(xObject args[], int numArgs);
197 void opSetFillRGBColor(xObject args[], int numArgs);
198 void opSetStrokeRGBColor(xObject args[], int numArgs);
199 void opSetFillColorSpace(xObject args[], int numArgs);
200 void opSetStrokeColorSpace(xObject args[], int numArgs);
201 void opSetFillColor(xObject args[], int numArgs);
202 void opSetStrokeColor(xObject args[], int numArgs);
203 void opSetFillColorN(xObject args[], int numArgs);
204 void opSetStrokeColorN(xObject args[], int numArgs);
206 // path segment operators
207 void opMoveTo(xObject args[], int numArgs);
208 void opLineTo(xObject args[], int numArgs);
209 void opCurveTo(xObject args[], int numArgs);
210 void opCurveTo1(xObject args[], int numArgs);
211 void opCurveTo2(xObject args[], int numArgs);
212 void opRectangle(xObject args[], int numArgs);
213 void opClosePath(xObject args[], int numArgs);
215 // path painting operators
216 void opEndPath(xObject args[], int numArgs);
217 void opStroke(xObject args[], int numArgs);
218 void opCloseStroke(xObject args[], int numArgs);
219 void opFill(xObject args[], int numArgs);
220 void opEOFill(xObject args[], int numArgs);
221 void opFillStroke(xObject args[], int numArgs);
222 void opCloseFillStroke(xObject args[], int numArgs);
223 void opEOFillStroke(xObject args[], int numArgs);
224 void opCloseEOFillStroke(xObject args[], int numArgs);
225 void doPatternFill(GBool eoFill);
226 void doPatternStroke();
227 void doTilingPatternFill(GfxTilingPattern *tPat,
228 GBool stroke, GBool eoFill);
229 void doShadingPatternFill(GfxShadingPattern *sPat,
230 GBool stroke, GBool eoFill);
231 void opShFill(xObject args[], int numArgs);
232 void doFunctionShFill(GfxFunctionShading *shading);
233 void doFunctionShFill1(GfxFunctionShading *shading,
234 double x0, double y0,
235 double x1, double y1,
236 GfxColor *colors, int depth);
237 void doAxialShFill(GfxAxialShading *shading);
238 void doRadialShFill(GfxRadialShading *shading);
239 void doGouraudTriangleShFill(GfxGouraudTriangleShading *shading);
240 void gouraudFillTriangle(double x0, double y0, GfxColor *color0,
241 double x1, double y1, GfxColor *color1,
242 double x2, double y2, GfxColor *color2,
243 int nComps, int depth);
244 void doPatchMeshShFill(GfxPatchMeshShading *shading);
245 void fillPatch(GfxPatch *patch, int nComps, int depth);
246 void doEndPath();
248 // path clipping operators
249 void opClip(xObject args[], int numArgs);
250 void opEOClip(xObject args[], int numArgs);
252 // text xObject operators
253 void opBeginText(xObject args[], int numArgs);
254 void opEndText(xObject args[], int numArgs);
256 // text state operators
257 void opSetCharSpacing(xObject args[], int numArgs);
258 void opSetFont(xObject args[], int numArgs);
259 void opSetTextLeading(xObject args[], int numArgs);
260 void opSetTextRender(xObject args[], int numArgs);
261 void opSetTextRise(xObject args[], int numArgs);
262 void opSetWordSpacing(xObject args[], int numArgs);
263 void opSetHorizScaling(xObject args[], int numArgs);
265 // text positioning operators
266 void opTextMove(xObject args[], int numArgs);
267 void opTextMoveSet(xObject args[], int numArgs);
268 void opSetTextMatrix(xObject args[], int numArgs);
269 void opTextNextLine(xObject args[], int numArgs);
271 // text string operators
272 void opShowText(xObject args[], int numArgs);
273 void opMoveShowText(xObject args[], int numArgs);
274 void opMoveSetShowText(xObject args[], int numArgs);
275 void opShowSpaceText(xObject args[], int numArgs);
276 void doShowText(GString *s);
278 // XObject operators
279 void opXObject(xObject args[], int numArgs);
280 void doImage(xObject *ref, Stream *str, GBool inlineImg);
281 void doForm(xObject *str);
282 void doForm1(xObject *str, Dict *resDict, double *matrix, double *bbox,
283 GBool transpGroup = gFalse, GBool softMask = gFalse,
284 GfxColorSpace *blendingColorSpace = NULL,
285 GBool isolated = gFalse, GBool knockout = gFalse,
286 GBool alpha = gFalse, Function *transferFunc = NULL,
287 GfxColor *backdropColor = NULL);
289 // in-line image operators
290 void opBeginImage(xObject args[], int numArgs);
291 Stream *buildImageStream();
292 void opImageData(xObject args[], int numArgs);
293 void opEndImage(xObject args[], int numArgs);
295 // type 3 font operators
296 void opSetCharWidth(xObject args[], int numArgs);
297 void opSetCacheDevice(xObject args[], int numArgs);
299 // compatibility operators
300 void opBeginIgnoreUndef(xObject args[], int numArgs);
301 void opEndIgnoreUndef(xObject args[], int numArgs);
303 // marked content operators
304 void opBeginMarkedContent(xObject args[], int numArgs);
305 void opEndMarkedContent(xObject args[], int numArgs);
306 void opMarkPoint(xObject args[], int numArgs);
308 void pushResources(Dict *resDict);
309 void popResources();
312 #endif