First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xprint / pcl / Pcl.h
blob217e304386d48cfd75ddd404711ca2218ea8156e
1 /*******************************************************************
2 **
3 ** *********************************************************
4 ** *
5 ** * File: Pcl.h
6 ** *
7 ** * Contents: defines and includes for the Pcl driver
8 ** * for a printing X server.
9 ** *
10 ** * Created: 1/30/95
11 ** *
12 ** *********************************************************
14 ********************************************************************/
16 (c) Copyright 1996 Hewlett-Packard Company
17 (c) Copyright 1996 International Business Machines Corp.
18 (c) Copyright 1996 Sun Microsystems, Inc.
19 (c) Copyright 1996 Novell, Inc.
20 (c) Copyright 1996 Digital Equipment Corp.
21 (c) Copyright 1996 Fujitsu Limited
22 (c) Copyright 1996 Hitachi, Ltd.
24 Permission is hereby granted, free of charge, to any person obtaining a copy
25 of this software and associated documentation files (the "Software"), to deal
26 in the Software without restriction, including without limitation the rights
27 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28 copies of the Software, and to permit persons to whom the Software is
29 furnished to do so, subject to the following conditions:
31 The above copyright notice and this permission notice shall be included in
32 all copies or substantial portions of the Software.
34 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 Except as contained in this notice, the names of the copyright holders shall
42 not be used in advertising or otherwise to promote the sale, use or other
43 dealings in this Software without prior written authorization from said
44 copyright holders.
47 #ifdef HAVE_DIX_CONFIG_H
48 #include <dix-config.h>
49 #endif
51 #ifndef _PCL_H_
52 #define _PCL_H_
54 #include <stdio.h>
55 #include "scrnintstr.h"
57 #include "PclDef.h"
58 #include "Pclmap.h"
59 #include "PclSFonts.h"
61 #include <X11/extensions/Print.h>
62 #include <X11/extensions/Printstr.h>
64 #include "regionstr.h"
65 #include <X11/fonts/fontstruct.h>
66 #include "dixfontstr.h"
67 #include "gcstruct.h"
70 * Some sleazes to force the XrmDB stuff into the server
72 #ifndef HAVE_XPointer
73 typedef char *XPointer;
74 #endif
75 #define Status int
76 #define True 1
77 #define False 0
78 #include "misc.h"
79 #include <X11/Xfuncproto.h>
80 #include <X11/Xresource.h>
81 #include "attributes.h"
83 /******
84 * externally visible variables from PclInit.c
85 ******/
86 extern int PclScreenPrivateIndex, PclWindowPrivateIndex;
87 extern int PclContextPrivateIndex;
88 extern int PclPixmapPrivateIndex;
89 extern int PclGCPrivateIndex;
91 /******
92 * externally visible variables from PclAttVal.c
93 ******/
94 extern XpValidatePoolsRec PclValidatePoolsRec;
97 * This structure defines a mapping from an X colormap ID to a list of
98 * print contexts which use the colormap.
100 typedef struct _pclcontextlist {
101 XpContextPtr context;
102 struct _pclcontextlist *next;
103 } PclContextList, *PclContextListPtr;
105 typedef struct _pclcmaptocontexts {
106 long colormapId;
107 PclContextListPtr contexts;
108 struct _pclcmaptocontexts *next;
109 } PclCmapToContexts;
111 typedef struct {
112 PclCmapToContexts *colormaps;
113 CloseScreenProcPtr CloseScreen;
114 } PclScreenPrivRec, *PclScreenPrivPtr;
117 * This structure defines a mapping from an X colormap ID to a PCL
118 * palette ID.
120 typedef struct _palettemap {
121 long colormapId;
122 int paletteId;
123 int downloaded;
124 struct _palettemap *next;
125 } PclPaletteMap, *PclPaletteMapPtr;
127 typedef struct {
128 char *jobFileName;
129 FILE *pJobFile;
130 char *pageFileName;
131 FILE *pPageFile;
132 GC lastGC;
133 unsigned char *dash;
134 int validGC;
135 ClientPtr getDocClient;
136 int getDocBufSize;
137 PclSoftFontInfoPtr pSoftFontInfo;
138 PclPaletteMapPtr palettes;
139 int currentPalette;
140 int nextPaletteId;
141 PclPaletteMap staticGrayPalette;
142 PclPaletteMap trueColorPalette;
143 PclPaletteMap specialTrueColorPalette;
144 unsigned char *ctbl;
145 int ctbldim;
146 int isRaw;
147 #ifdef XP_PCL_LJ3
148 unsigned int fcount;
149 unsigned int fcount_max;
150 char *figures;
151 #endif /* XP_PCL_LJ3 */
152 } PclContextPrivRec, *PclContextPrivPtr;
154 typedef struct {
155 int validContext;
156 XpContextPtr context;
157 } PclWindowPrivRec, *PclWindowPrivPtr;
159 typedef struct {
160 unsigned long stippleFg, stippleBg;
161 } PclGCPrivRec, *PclGCPrivPtr;
163 typedef struct {
164 XpContextPtr context;
165 char *tempFileName;
166 FILE *tempFile;
167 GC lastGC;
168 int validGC;
169 } PclPixmapPrivRec, *PclPixmapPrivPtr;
171 /******
172 * Defined functions
173 ******/
174 #define SEND_PCL(f,c) fwrite( c, sizeof( char ), strlen( c ), f )
175 #define SEND_PCL_COUNT(f,c,n) fwrite( c, sizeof( char ), n, f )
177 #ifndef XP_PCL_LJ3
178 #define SAVE_PCL(f,p,c) SEND_PCL(f,c)
179 #define SAVE_PCL_COUNT(f,p,c,n) SEND_PCL_COUNT(f,c,n)
180 #define MACRO_START(f,p) SEND_PCL(f, "\033&f1Y\033&f0X")
181 #define MACRO_END(f) SEND_PCL(f, "\033&f1X")
182 #else
183 #define SAVE_PCL(f,p,c) PclSpoolFigs(p, c, strlen(c))
184 #define SAVE_PCL_COUNT(f,p,c,n) PclSpoolFigs(p, c, n)
185 #define MACRO_START(f,p) p->fcount = 0
186 #define MACRO_END(f) /* do nothing */
187 #endif /* XP_PCL_LJ3 */
189 #define MIN(a,b) (((a)<(b))?(a):(b))
190 #ifndef MAX
191 #define MAX(a,b) (((a)>(b))?(a):(b))
192 #endif
194 /******
195 * Functions in PclArc.c
196 ******/
197 extern void PclPolyArc(
198 DrawablePtr pDrawable,
199 GCPtr pGC,
200 int nArcs,
201 xArc *pArcs);
202 extern void PclPolyFillArc(
203 DrawablePtr pDrawable,
204 GCPtr pGC,
205 int nArcs,
206 xArc *pArcs);
208 /******
209 * Functions in PclArea.c
210 ******/
211 extern void PclPutImage(
212 DrawablePtr pDrawable,
213 GCPtr pGC,
214 int depth,
215 int x,
216 int y,
217 int w,
218 int h,
219 int leftPad,
220 int format,
221 char *pImage);
222 extern RegionPtr PclCopyArea(
223 DrawablePtr pSrc,
224 DrawablePtr pDst,
225 GCPtr pGC,
226 int srcx,
227 int srcy,
228 int width,
229 int height,
230 int dstx,
231 int dsty);
232 RegionPtr PclCopyPlane(
233 DrawablePtr pSrc,
234 DrawablePtr pDst,
235 GCPtr pGC,
236 int srcx,
237 int srcy,
238 int width,
239 int height,
240 int dstx,
241 int dsty,
242 unsigned long plane);
245 /******
246 * Functions in PclAttr.c
247 ******/
248 extern char *PclGetAttributes(
249 XpContextPtr pCon,
250 XPAttributes pool );
251 extern char *PclGetOneAttribute(
252 XpContextPtr pCon,
253 XPAttributes pool,
254 char *attr );
255 extern int PclAugmentAttributes(
256 XpContextPtr pCon,
257 XPAttributes pool,
258 char *attrs );
259 extern int PclSetAttributes(
260 XpContextPtr pCon,
261 XPAttributes pool,
262 char *attrs );
264 /******
265 * Functions in PclColor.c
266 ******/
267 extern Bool PclCreateDefColormap(ScreenPtr pScreen);
268 extern Bool PclCreateColormap(ColormapPtr pColor);
269 extern void PclDestroyColormap(ColormapPtr pColor);
270 extern void PclInstallColormap(ColormapPtr pColor);
271 extern void PclUninstallColormap(ColormapPtr pColor);
272 extern int PclListInstalledColormaps(ScreenPtr pScreen,
273 XID *pCmapList);
274 extern void PclStoreColors(ColormapPtr pColor,
275 int ndef,
276 xColorItem *pdefs);
277 extern void PclResolveColor(unsigned short *pRed,
278 unsigned short *pGreen,
279 unsigned short *pBlue,
280 VisualPtr pVisual);
281 extern int PclUpdateColormap(DrawablePtr pDrawable,
282 XpContextPtr pCon,
283 GCPtr gc,
284 FILE *outFile);
285 extern void PclLookUp(ColormapPtr cmap,
286 PclContextPrivPtr cPriv,
287 unsigned short *r,
288 unsigned short *g,
289 unsigned short *b);
290 extern PclPaletteMapPtr PclFindPaletteMap(PclContextPrivPtr cPriv,
291 ColormapPtr cmap,
292 GCPtr gc);
293 extern unsigned char *PclReadMap(char *, int *);
296 /******
297 * Functions in PclCursor.c
298 ******/
299 extern void PclConstrainCursor(
300 ScreenPtr pScreen,
301 BoxPtr pBox);
302 extern void PclCursorLimits(
303 ScreenPtr pScreen,
304 CursorPtr pCursor,
305 BoxPtr pHotBox,
306 BoxPtr pTopLeftbox);
307 extern Bool PclDisplayCursor(
308 ScreenPtr pScreen,
309 CursorPtr pCursor);
310 extern Bool PclRealizeCursor(
311 ScreenPtr pScreen,
312 CursorPtr pCursor);
313 extern Bool PclUnrealizeCursor(
314 ScreenPtr pScreen,
315 CursorPtr pCursor);
316 extern void PclRecolorCursor(
317 ScreenPtr pScreen,
318 CursorPtr pCursor,
319 Bool displayed);
320 extern Bool PclSetCursorPosition(
321 ScreenPtr pScreen,
322 int x,
323 int y,
324 Bool generateEvent);
326 /******
327 * Functions in PclSFonts.c
328 ******/
329 extern void
330 PclDownloadSoftFont8(
331 FILE *fp,
332 PclSoftFontInfoPtr pSoftFontInfo,
333 PclFontHead8Ptr pfh,
334 PclCharDataPtr pcd,
335 unsigned char *code);
336 extern void PclDownloadSoftFont16(
337 FILE *fp,
338 PclSoftFontInfoPtr pSoftFontInfo,
339 PclFontHead16Ptr pfh,
340 PclCharDataPtr pcd,
341 unsigned char row,
342 unsigned char col);
343 extern PclSoftFontInfoPtr PclCreateSoftFontInfo(void);
344 extern void PclDestroySoftFontInfo(
345 PclSoftFontInfoPtr pSoftFontInfo );
347 /******
348 * Functions in PclGC.c
349 ******/
350 extern Bool PclCreateGC(GCPtr pGC);
351 extern void PclDestroyGC(GCPtr pGC);
352 extern int PclUpdateDrawableGC(
353 GCPtr pGC,
354 DrawablePtr pDrawable,
355 FILE **outFile);
356 extern void PclValidateGC(
357 GCPtr pGC,
358 unsigned long changes,
359 DrawablePtr pDrawable);
360 extern void PclSetDrawablePrivateStuff(
361 DrawablePtr pDrawable,
362 GC gc );
363 extern int PclGetDrawablePrivateStuff(
364 DrawablePtr pDrawable,
365 GC *gc,
366 unsigned long *valid,
367 FILE **file );
368 extern void PclSetDrawablePrivateGC(
369 DrawablePtr pDrawable,
370 GC gc);
371 extern void PclComputeCompositeClip(
372 GCPtr pGC,
373 DrawablePtr pDrawable);
375 /******
376 * Functions in PclInit.c
377 ******/
378 extern Bool PclCloseScreen(
379 int index,
380 ScreenPtr pScreen);
381 extern Bool InitializeColorPclDriver(
382 int ndx,
383 ScreenPtr pScreen,
384 int argc,
385 char **argv);
386 extern Bool InitializeMonoPclDriver(
387 int ndx,
388 ScreenPtr pScreen,
389 int argc,
390 char **argv);
391 extern Bool InitializeLj3PclDriver(
392 int ndx,
393 ScreenPtr pScreen,
394 int argc,
395 char **argv);
396 extern XpContextPtr PclGetContextFromWindow( WindowPtr win );
398 /******
399 * Functions in PclLine.c
400 ******/
401 extern void PclPolyLine(
402 DrawablePtr pDrawable,
403 GCPtr pGC,
404 int mode,
405 int nPoints,
406 xPoint *pPoints);
407 extern void PclPolySegment(
408 DrawablePtr pDrawable,
409 GCPtr pGC,
410 int nSegments,
411 xSegment *pSegments);
413 /******
414 * Functions in PclMisc.c
415 ******/
416 extern void PclQueryBestSize(
417 int class,
418 short *pwidth,
419 short *pheight,
420 ScreenPtr pScreen);
421 extern char *GetPropString(WindowPtr pWin, char *propName);
422 extern int SystemCmd(char *cmdStr);
423 extern int PclGetMediumDimensions(
424 XpContextPtr pCon,
425 CARD16 *pWidth,
426 CARD16 *pHeight);
427 extern int PclGetReproducibleArea(
428 XpContextPtr pCon,
429 xRectangle *pRect);
430 extern void PclSendData(
431 FILE *outFile,
432 PclContextPrivPtr pConPriv,
433 BoxPtr pbox,
434 int nbox,
435 double ratio);
437 /******
438 * Functions in PclPixel.c
439 ******/
440 extern void PclPolyPoint(
441 DrawablePtr pDrawable,
442 GCPtr pGC,
443 int mode,
444 int nPoints,
445 xPoint *pPoints);
446 extern void PclPushPixels(
447 GCPtr pGC,
448 PixmapPtr pBitmap,
449 DrawablePtr pDrawable,
450 int width,
451 int height,
452 int x,
453 int y);
455 /******
456 * Functions in PclPixmap.c
457 ******/
458 extern PixmapPtr PclCreatePixmap(
459 ScreenPtr pScreen,
460 int width,
461 int height,
462 int depth);
463 extern Bool PclDestroyPixmap(PixmapPtr pPixmap);
465 /******
466 * Functions in PclPolygon.c
467 ******/
468 extern void PclPolyRectangle(
469 DrawablePtr pDrawable,
470 GCPtr pGC,
471 int nRects,
472 xRectangle *pRects);
473 extern void PclFillPolygon(
474 DrawablePtr pDrawable,
475 GCPtr pGC,
476 int shape,
477 int mode,
478 int nPoints,
479 DDXPointPtr pPoints);
480 extern void PclPolyFillRect(
481 DrawablePtr pDrawable,
482 GCPtr pGC,
483 int nRects,
484 xRectangle *pRects);
486 /******
487 * Functions in PclSpans.c
488 ******/
489 extern void PclFillSpans(
490 DrawablePtr pDrawable,
491 GCPtr pGC,
492 int nSpans,
493 DDXPointPtr pPoints,
494 int *pWidths,
495 int fSorted);
496 extern void PclSetSpans(
497 DrawablePtr pDrawable,
498 GCPtr pGC,
499 char *pSrc,
500 DDXPointPtr pPoints,
501 int *pWidths,
502 int nSpans,
503 int fSorted);
505 /******
506 * Functions in PclText.c
507 ******/
508 extern int PclPolyText8(
509 DrawablePtr pDrawable,
510 GCPtr pGC,
511 int x,
512 int y,
513 int count,
514 char *string);
515 extern int PclPolyText16(
516 DrawablePtr pDrawable,
517 GCPtr pGC,
518 int x,
519 int y,
520 int count,
521 unsigned short *string);
522 extern void PclImageText8(
523 DrawablePtr pDrawable,
524 GCPtr pGC,
525 int x,
526 int y,
527 int count,
528 char *string);
529 extern void PclImageText16(
530 DrawablePtr pDrawable,
531 GCPtr pGC,
532 int x,
533 int y,
534 int count,
535 unsigned short *string);
536 extern void PclImageGlyphBlt(
537 DrawablePtr pDrawable,
538 GCPtr pGC,
539 int x,
540 int y,
541 unsigned int nGlyphs,
542 CharInfoPtr *pCharInfo,
543 pointer pGlyphBase);
544 extern void PclPolyGlyphBlt(
545 DrawablePtr pDrawable,
546 GCPtr pGC,
547 int x,
548 int y,
549 unsigned int nGlyphs,
550 CharInfoPtr *pCharInfo,
551 pointer pGlyphBase);
553 /******
554 * Functions in PclWindow.c
555 ******/
556 extern Bool PclCreateWindow(register WindowPtr pWin);
557 extern Bool PclDestroyWindow(WindowPtr pWin);
558 extern Bool PclMapWindow(WindowPtr pWindow);
559 extern Bool PclPositionWindow(
560 register WindowPtr pWin,
561 int x,
562 int y);
563 extern Bool PclUnmapWindow(WindowPtr pWindow);
564 extern void PclCopyWindow(
565 WindowPtr pWin,
566 DDXPointRec ptOldOrg,
567 RegionPtr prgnSrc);
568 extern Bool PclChangeWindowAttributes(
569 register WindowPtr pWin,
570 register unsigned long mask);
571 extern void PclPaintWindow(
572 WindowPtr pWin,
573 RegionPtr pRegion,
574 int what);
576 /******
577 * Functions in PclFonts.c
578 ******/
579 extern Bool PclRealizeFont(
580 ScreenPtr pscr,
581 FontPtr pFont);
582 extern Bool PclUnrealizeFont(
583 ScreenPtr pscr,
584 FontPtr pFont);
586 /******
587 * Functions in PclPrint.c
588 ******/
589 extern int PclStartJob(
590 XpContextPtr pCon,
591 Bool sendClientData,
592 ClientPtr client);
593 extern int PclEndJob(
594 XpContextPtr pCon,
595 Bool cancel);
596 extern int PclStartPage(
597 XpContextPtr pCon,
598 WindowPtr pWin);
599 extern int PclEndPage(
600 XpContextPtr pCon,
601 WindowPtr pWin);
602 extern int PclStartDoc(XpContextPtr pCon,
603 XPDocumentType type);
604 extern int PclEndDoc(
605 XpContextPtr pCon,
606 Bool cancel);
607 extern int PclDocumentData(
608 XpContextPtr pCon,
609 DrawablePtr pDraw,
610 char *pData,
611 int len_data,
612 char *pFmt,
613 int len_fmt,
614 char *pOpt,
615 int len_opt,
616 ClientPtr client);
617 extern int PclGetDocumentData(
618 XpContextPtr pCon,
619 ClientPtr client,
620 int maxBufferSize);
623 #endif /* _PCL_H_ */