2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: cgm.h /main/6 1996/07/18 16:36:10 drk $ */
24 /* This is the module containing common definitions for all modules of */
25 /* the CGM Pixmap generator */
26 #include <stdio.h> /* standard I/O package */
28 #include <X11/Xlib.h> /* XLib stuff */
29 #include <X11/Intrinsic.h> /* Xt toolkit */
30 #include "GraphicsP.h"
32 extern int open_cgm_file(_DtGrStream *stream); /* in cgmio.c */
33 extern int open_cgm_buffer(_DtGrStream *stream); /* in cgmio.c */
35 extern int xl_setup(Screen*, Display*, Window, int, Colormap, Visual*, GC,
36 Dimension*, Dimension*, Pixel**, int*, Pixmap*, unsigned short);
37 /* the external entry point */
39 /* define the standard CGM elements and classes in terms of their CGM */
40 /* binary representations */
41 /* how many classes ? */
43 /* the Delimiter elements (Class 0) */
44 #define B_DELIMCLASS 0 /* Class Number */
45 #define B_DELIMSIZE 6 /* Class Size */
46 /* now the elements */
47 #define B_NOOP 0 /* No-op */
48 #define B_BMF 1 /* Begin Metafile */
49 #define B_EMF 2 /* End Metafile */
50 #define B_BPIC 3 /* Begin Picture */
51 #define B_BPICBODY 4 /* Begin Picture Body */
52 #define B_EPIC 5 /* End Picture */
54 /* the Metafile descriptor elements (Class 1) */
55 #define B_MDESCLASS 1 /* Class Number */
56 #define B_MDESSIZE 16 /* Class Size */
57 /* now the elements */
58 #define B_MFVERSION 1 /* Metafile version */
59 #define B_MFDESCRIP 2 /* Metafile descriptor */
60 #define B_VDCTYPE 3 /* VDC type */
61 #define B_INTPREC 4 /* Integer Precision */
62 #define B_REALPREC 5 /* Real precision */
63 #define B_INDEXPREC 6 /* Index precision */
64 #define B_COLPREC 7 /* Colour precision */
65 #define B_CINDPREC 8 /* Colour index precision */
66 #define B_MAXCIND 9 /* Maximum colour index */
67 #define B_CVEXTENT 10 /* Colour value extent */
68 #define B_MFELLIST 11 /* Metafile element list */
69 #define B_MFDEFREP 12 /* Metafile defaults replacement */
70 #define B_FONTLIST 13 /* Font list */
71 #define B_CHARLIST 14 /* Character set list */
72 #define B_CHARANNOUNCE 15 /* Character coding announcer */
74 /* the Picture descriptor elements (Class 2) */
75 #define B_PDESCLASS 2 /* Class Number */
76 #define B_PDESSIZE 8 /* Class Size */
77 /* now the elements */
78 #define B_SCALMODE 1 /* Scaling Mode */
79 #define B_COLSELMODE 2 /* Colour Selection Mode */
80 #define B_LWIDSPECMODE 3 /* Line Width Specification Mode */
81 #define B_MARKSIZSPECMODE 4 /* Marker Size Specification Mode */
82 #define B_EDWIDSPECMODE 5 /* Edge Width Specification Mode */
83 #define B_VDCEXTENT 6 /* VDC Extent */
84 #define B_BACKCOLR 7 /* Background Colour */
86 /* the Control elements (Class 3) */
87 #define B_CTRLCLASS 3 /* Class Number */
88 #define B_CTRLSIZE 7 /* Class Size */
89 /* now the elements */
90 #define B_VDCINTPREC 1 /* VDC Integer Precision */
91 #define B_VDCRPREC 2 /* VDC Real Precision */
92 #define B_AUXCOLR 3 /* Auxiliary Colour */
93 #define B_TRANSP 4 /* Transparency */
94 #define B_CLIPRECT 5 /* Clip Rectangle */
95 #define B_CLIPINDIC 6 /* Clip Indicator */
97 /* the Graphical Primitives (Class 4) */
98 #define B_GPRIMCLASS 4 /* Class Number */
99 #define B_GPRIMSIZE 20 /* Class Size */
100 /* now the elements */
101 #define B_POLYLINE 1 /* Polyline */
102 #define B_DISPOLY 2 /* Disjoint Polyline */
103 #define B_POLYMARKER 3 /* Polymarker */
104 #define B_TEXT 4 /* regular text */
105 #define B_RESTEXT 5 /* Restricted Text */
106 #define B_APPTEXT 6 /* Appended Text */
107 #define B_POLYGON 7 /* Polygon */
108 #define B_POLYSET 8 /* Polygon Set */
109 #define B_CELLARRAY 9 /* Cell Array */
110 #define B_GENDPRIM 10 /* Generalised Drawing Primitive */
111 #define B_RECTANGLE 11 /* Rectangle */
112 #define B_CIRCLE 12 /* Circle */
113 #define B_CIRC3 13 /* 3 pt circular arc */
114 #define B_CIRC3CLOSE 14 /* 3 pt circular arc, closed */
115 #define B_CIRCCENTRE 15 /* Circular arc specified by centre */
116 #define B_CIRCCCLOSE 16 /* Circular arc, centre, closed */
117 #define B_ELLIPSE 17 /* Ellipse */
118 #define B_ELARC 18 /* Elliptical arc */
119 #define B_ELARCCLOSE 19 /* Elliptical arc, closed */
121 /* the Attribute elements (Class 5) */
122 #define B_ATTRCLASS 5 /* Class Number */
123 #define B_ATTRSIZE 36 /* Class Size */
124 /* now the elements */
125 #define B_LBINDEX 1 /* Line Bundle index */
126 #define B_LTYPE 2 /* Line Type */
127 #define B_LWIDTH 3 /* Line Width */
128 #define B_LCOLR 4 /* Line Colour */
129 #define B_MBINDEX 5 /* Marker Bundle Index */
130 #define B_MTYPE 6 /* Marker Type */
131 #define B_MSIZE 7 /* Marker Size */
132 #define B_MCOLR 8 /* Marker Colour */
133 #define B_TBINDEX 9 /* Text Bundle Index */
134 #define B_TFINDEX 10 /* Text Font Index */
135 #define B_TPREC 11 /* Text Precision */
136 #define B_CEXPFAC 12 /* Character Expansion Factor */
137 #define B_CSPACE 13 /* Character Spacing */
138 #define B_TCOLR 14 /* Text Colour */
139 #define B_CHEIGHT 15 /* Character Height */
140 #define B_CORIENT 16 /* Character Orientation */
141 #define B_TPATH 17 /* Text Path */
142 #define B_TALIGN 18 /* Text Alignment */
143 #define B_CSETINDEX 19 /* Character Set Index */
144 #define B_ALTCSETINDEX 20 /* Alternate Character Set Index */
145 #define B_FILLBINDEX 21 /* Fill Bundle Index */
146 #define B_INTSTYLE 22 /* Interior Style */
147 #define B_FILLCOLR 23 /* Fill Colour */
148 #define B_HATCHINDEX 24 /* Hatch Index */
149 #define B_PATINDEX 25 /* Patern Index */
150 #define B_EDBINDEX 26 /* Edge Bundle Index */
151 #define B_ETYPE 27 /* Edge Type */
152 #define B_EWIDTH 28 /* Edge Width */
153 #define B_ECOLR 29 /* Edge Colour */
154 #define B_EVIS 30 /* Edge Visibility */
155 #define B_FILLREF 31 /* Fill Reference Point */
156 #define B_PATTAB 32 /* Pattern Table */
157 #define B_PATSIZE 33 /* Pattern Size */
158 #define B_COLTAB 34 /* Colour Table */
159 #define B_ASPSFLAGS 35 /* Aspect Source Flags */
161 /* the Escape element (Class 6) */
162 #define B_ESCCLASS 6 /* Class Number */
163 #define B_ESCSIZE 2 /* Class Size */
164 /* now the elements */
165 #define B_ESCAPE 1 /* Escape Flag */
167 /* the External elements (Class 7) */
168 #define B_EXTCLASS 7 /* Class Number */
169 #define B_EXTSIZE 3 /* Class Size */
170 /* now the elements */
171 #define B_MESSAGE 1 /* Message data */
172 #define B_APDATA 2 /* application data */
174 /* macro for error messages */
175 #define burp (void) fprintf
177 /* now the structure that maintains the state of the CGM file */
178 /* first some required typedefs and macros */
179 #define MAX_FONTS 10 /* maximum no. of fonts */
180 #define VDC_INT 0 /* integer vdc type */
181 #define VDC_REAL 1 /* real VDC type */
182 #define ABSTRACT_S 0 /* abstract scaling */
183 #define METRIC_S 1 /* metric scaling */
184 #define I_C_M 0 /* indexed colour mode */
185 #define D_C_M 1 /* direct colour mode */
186 #define ABSOLUTE 0 /* absolute mode */
187 #define SCALED 1 /* scaled mode */
188 #define OFF 0 /* boolean */
189 #define ON 1 /* boolean */
190 #define STRING_P 0 /* string precision */
191 #define CHARACTER_P 1 /* character precision */
192 #define STROKE_P 2 /* stroke precision */
193 #define RIGHT_P 0 /* right path */
194 #define LEFT_P 1 /* left path */
195 #define UP_P 2 /* up path */
196 #define DOWN_P 3 /* down path */
197 #define NORMAL_H 0 /* normal horizontal alignment */
198 #define LEFT_H 1 /* left horizontal alignment */
199 #define CENTRE_H 2 /* centre horizontal alignment */
200 #define RIGHT_H 3 /* right horizontal alignment */
201 #define CONT_H 4 /* continuous horizontal alignment */
202 #define NORMAL_V 0 /* normal vertical alignment */
203 #define TOP_V 1 /* top vertical alignment */
204 #define CAP_V 2 /* cap vertical alignment */
205 #define HALF_V 3 /* half vertical alignment */
206 #define BASE_V 4 /* base vertical alignment */
207 #define BOTTOM_V 5 /* bottom vertical alignment */
208 #define CONT_V 6 /* continuous vertical alignment */
216 #define HOR_H 1 /* horizontal hatch */
217 #define VER_H 2 /* vertical hatch */
218 #define POS_H 3 /* positive slope hatch */
219 #define NEG_H 4 /* negative slope hatch */
220 #define VH_H 5 /* vertical and horizontal hatch */
221 #define LR_H 5 /* left and right horizontal hatch */
222 #define SOLID_L 1 /* solid line */
223 #define DASH_L 2 /* dashed line */
224 #define DOT_L 3 /* dotted line */
225 #define DASH_D_L 4 /* dash-dot line */
226 #define DASH_D_D_L 5 /* dash-dot-dot line */
227 #define NO_ASPSF 18 /* no of aspect source flags */
228 #define F_INDIV 0 /* individual flag */
229 #define F_BUNDLED 1 /* bundled flag */
230 /* now the individual aspect source flags */
231 #define F_LTYPE 0 /* Line Type */
232 #define F_LWIDTH 1 /* Line Width */
233 #define F_LCOLR 2 /* Line Colour */
234 #define F_MTYPE 3 /* Marker Type */
235 #define F_MSIZE 4 /* Marker Size */
236 #define F_MCOLR 5 /* Marker Colour */
237 #define F_TFINDEX 6 /* Text Font Index */
238 #define F_TPREC 7 /* Text Precision */
239 #define F_CEXPFAC 8 /* Character Expansion Factor */
240 #define F_CSPACE 9 /* Character Spacing */
241 #define F_TCOLR 10 /* Text Colour */
242 #define F_INTSTYLE 11 /* Interior Style */
243 #define F_FILLCOLR 12 /* Fill Colour */
244 #define F_HATCHINDEX 13 /* Hatch Index */
245 #define F_PATINDEX 14 /* Patern Index */
246 #define F_ETYPE 15 /* Edge Type */
247 #define F_EWIDTH 16 /* Edge Width */
248 #define F_ECOLR 17 /* Edge Colour */
250 /* the real precision type */
251 typedef struct rp_struct {int fixed; int exp; int fract;} rp_type;
252 /* type for values that can be real or integer */
253 typedef struct ri_struct {float r; int i;} ri_type;
254 /* type for values that can be real, integer, or scaled */
255 typedef struct ris_struct {float r; int i; float s;} ris_type;
256 /* the pattern table type */
257 typedef struct pat_struct {
258 int index; /* pattern table index */
259 int nx; /* x dimension */
260 int ny; /* y dimension */
261 int l_c_p; /* local colour precision */
262 int *array; /* colour array */
263 struct pat_struct *next; /* pointer to next one */
267 typedef struct cgm_state_struct {
268 /* Metafile descriptors */
269 int mfversion; /* version number */
270 char *mfdescrip; /* metafile descriptor */
271 int vdctype; /* vdc type */
272 int intprec; /* integer precision */
273 rp_type realprec; /* real precision */
274 int indexprec; /* index precision */
275 int colprec; /* colour precision */
276 int cindprec; /* colour index prec. */
277 int maxcind; /* max. colour index */
278 int cvextent[6]; /* colour value extent */
279 int mfellist_s; /* mf element list size */
280 int *mfellist; /* mf element list */
281 char *fontlist[MAX_FONTS]; /* font list */
282 int charlist_s; /* character set size */
283 int chartype[MAX_FONTS]; /* character set type */
284 char *charlist[MAX_FONTS]; /* character set list */
285 int charannounce; /* character announcer */
286 /* picture descriptors */
287 int scalmode; /* scaling mode */
288 float scalmode_f; /* metric scaling factor*/
289 int colselmode; /* colour selection mode*/
290 int lwidspecmode; /* line width spec mode */
291 int marksizspecmode; /* marker size spec mode*/
292 int edwidspecmode; /* edge width spec mode */
293 ri_type vdcextent[4]; /* vdc extent */
294 int backcolr[3]; /* background colour */
295 /* control elements */
296 int vdcintprec; /* vdc integer precision*/
297 rp_type vdcrprec; /* vdc real precision */
298 int auxcolr[4]; /* auxiliary colour */
299 int transp; /* transparency */
300 ri_type cliprect[4]; /* clipping rectangle */
301 int clipindic; /* clipping indicator */
302 /* attribute elements */
303 int lbindex; /* line bundle index */
304 int ltype; /* line type */
305 ris_type lwidth; /* line width */
306 int lcolr[4]; /* line colour */
307 int mbindex; /* marker bundle index */
308 int mtype; /* marker type */
309 ris_type msize; /* marker size */
310 int mcolr[4]; /* marker colour */
311 int tbindex; /* text bundle index */
312 int tfindex; /* text font index */
313 int tprec; /* text precision */
314 float cexpfac; /* character exp factor */
315 float cspace; /* character space */
316 int tcolr[4]; /* text colour */
317 Pixel tPixel; /* text colour */
318 ri_type cheight; /* character height */
319 ri_type corient[4]; /* character orientation*/
320 int tpath; /* text path */
321 ri_type talign[2]; /* text alignment */
322 int csetindex; /* character set index */
323 int altcsetindex; /* alt. char set index */
324 int fillbindex; /* fill bundle index */
325 int intstyle; /* interior style */
326 int fillcolr[4]; /* fill colour */
327 int hatchindex; /* hatch index */
328 int patindex; /* pattern index */
329 int edbindex; /* edge bundle index */
330 int etype; /* edge type */
331 ris_type ewidth; /* edge width */
332 int ecolr[4]; /* edge colour */
333 int evis; /* edge visibility */
334 ri_type fillref[2]; /* fill reference point */
335 pat_type *pattab; /* pattern table */
336 ri_type patsize[4]; /* pattern size */
337 int *coltab; /* colour table */
338 int aspsflags[NO_ASPSF]; /* aspect source flags */
341 #define CGM_WARN 2 /* warning code */
342 /* structure to keep info on the command being processed */
344 int Class; /* command Class */
345 int element; /* command element number */
346 int no; /* its command position in file */
347 int sub_no; /* its subcommand position in file */
348 int byte_no; /* its byte position in file */
349 int p_len; /* its parameter length */
352 /* now put in the strings we will use for diagnostics and listings */
353 /* use B_ATTRSIZE since it is the largest Class (of 8) */
354 static char *cgm_name[8][B_ATTRSIZE] = {
355 { /* Delimiters first */
360 "Begin Picture Body",
365 /* Metafile Descriptors */
368 "Metafile Description",
374 "Colour Index Precision",
375 "Maximum Colour Index",
376 "Colour Value Extent",
377 "Metafile Element List",
378 "Metafile Defaults Replacement",
380 "Character Set List",
381 "Character Coding Announcer"
384 { /* Picture Descriptors */
387 "Colour Selection Mode",
388 "Line Width Specification Mode",
389 "Marker Size Specification Mode",
390 "Edge Width Specification Mode",
395 { /* Control Elements */
397 "VDC Integer Precision",
398 "VDC Real Precision",
405 { /* Graphical Primitives */
416 "Generalised Drawing Primitive",
419 "Circular Arc 3 Point",
421 "Circular Arc Centre",
422 "Circular Arc Centre Close",
425 "Elliptical Arc Close",
428 { /* Attribute Elements */
434 "Marker Bundle Index",
441 "Character Expansion Factor",
445 "Character Orientation",
448 "Character Set Index",
449 "Alternate Character Set Index",
460 "Fill Reference Point",
464 "Aspect Source Flags"
467 { /* Escape Element */
472 { /* External Element */
480 extern unsigned char *get_b_cmd(struct cmd_info_s*,
481 _DtGrStream *stream); /* in cgmio.c */
482 extern int do_b_cmd(struct cmd_info_s*, unsigned char*,cgm_s_type*);
484 extern int cgm_defs(cgm_s_type*); /* in cgmcommon.c */
485 extern int cgm_assign(cgm_s_type*, cgm_s_type*); /* in cgmcommon.c */
486 /* structure for the description of partial text pieces */
487 struct partialTextStruct {
493 struct partialTextStruct *next;
495 typedef struct partialTextStruct partialText;