# use AROS_LIB/INCLUDES
[AROS-Contrib.git] / arospdf / xpdf / Annot.h
blob2f1fae30c60ebff24fea0adaa53383363b033a31
1 //========================================================================
2 //
3 // Annot.h
4 //
5 // Copyright 2000-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
9 #ifndef ANNOT_H
10 #define ANNOT_H
12 #include <aconf.h>
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
18 class XRef;
19 class Catalog;
20 class Gfx;
21 class GfxFontDict;
23 //------------------------------------------------------------------------
24 // AnnotBorderStyle
25 //------------------------------------------------------------------------
27 enum AnnotBorderType {
28 annotBorderSolid,
29 annotBorderDashed,
30 annotBorderBeveled,
31 annotBorderInset,
32 annotBorderUnderlined
35 class AnnotBorderStyle {
36 public:
38 AnnotBorderStyle(AnnotBorderType typeA, double widthA,
39 double *dashA, int dashLengthA,
40 double rA, double gA, double bA);
41 ~AnnotBorderStyle();
43 AnnotBorderType getType() { return type; }
44 double getWidth() { return width; }
45 void getDash(double **dashA, int *dashLengthA)
46 { *dashA = dash; *dashLengthA = dashLength; }
47 void getColor(double *rA, double *gA, double *bA)
48 { *rA = r; *gA = g; *bA = b; }
50 private:
52 AnnotBorderType type;
53 double width;
54 double *dash;
55 int dashLength;
56 double r, g, b;
59 //------------------------------------------------------------------------
60 // Annot
61 //------------------------------------------------------------------------
63 class Annot {
64 public:
66 Annot(XRef *xrefA, Dict *acroForm, Dict *dict, Ref *refA);
67 ~Annot();
68 GBool isOk() { return ok; }
70 void draw(Gfx *gfx, GBool printing);
72 // Get appearance xObject.
73 xObject *getAppearance(xObject *obj) { return appearance.fetch(xref, obj); }
75 AnnotBorderStyle *getBorderStyle() { return borderStyle; }
77 GBool match(Ref *refA)
78 { return ref.num == refA->num && ref.gen == refA->gen; }
80 void generateFieldAppearance(Dict *field, Dict *annot, Dict *acroForm);
82 private:
84 void setColor(Array *a, GBool fill, int adjust);
85 void drawText(GString *text, GString *da, GfxFontDict *fontDict,
86 GBool multiline, int comb, int quadding,
87 GBool txField, GBool forceZapfDingbats);
88 void drawListBox(GString **text, GBool *selection,
89 int nOptions, int topIdx,
90 GString *da, GfxFontDict *fontDict, GBool quadding);
91 void getNextLine(GString *text, int start,
92 GfxFont *font, double fontSize, double wMax,
93 int *end, double *width, int *next);
94 void drawCircle(double cx, double cy, double r, GBool fill);
95 void drawCircleTopLeft(double cx, double cy, double r);
96 void drawCircleBottomRight(double cx, double cy, double r);
97 xObject *fieldLookup(Dict *field, char *key, xObject *obj);
99 XRef *xref; // the xref table for this PDF file
100 Ref ref; // xObject ref identifying this annotation
101 GString *type; // annotation type
102 xObject appearance; // a reference to the Form XObject stream
103 // for the normal appearance
104 GString *appearBuf;
105 double xMin, yMin, // annotation rectangle
106 xMax, yMax;
107 Guint flags;
108 AnnotBorderStyle *borderStyle;
109 GBool ok;
112 //------------------------------------------------------------------------
113 // Annots
114 //------------------------------------------------------------------------
116 class Annots {
117 public:
119 // Build a list of Annot xObjects.
120 Annots(XRef *xref, Catalog *catalog, xObject *annotsObj);
122 ~Annots();
124 // Iterate through list of annotations.
125 int getNumAnnots() { return nAnnots; }
126 Annot *getAnnot(int i) { return annots[i]; }
128 // (Re)generate the appearance streams for all annotations belonging
129 // to a form field.
130 void generateAppearances(Dict *acroForm);
132 private:
134 void scanFieldAppearances(Dict *node, Ref *ref, Dict *parent,
135 Dict *acroForm);
136 Annot *findAnnot(Ref *ref);
138 Annot **annots;
139 int nAnnots;
142 #endif