winemenubuilder: Use CRT allocation functions.
[wine.git] / dlls / wineps.drv / psdrv.h
blob58b5062a01a9ff049851ce55bccc500fcefdcf86
1 /*
2 * PostScript driver definitions
4 * Copyright 1998 Huw D M Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __WINE_PSDRV_H
22 #define __WINE_PSDRV_H
24 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "ntgdi.h"
29 #include "winspool.h"
31 #include "unixlib.h"
33 #include "wine/list.h"
35 struct ps_bitblt_coords
37 int log_x; /* original position and size, in logical coords */
38 int log_y;
39 int log_width;
40 int log_height;
41 int x; /* mapped position and size, in device coords */
42 int y;
43 int width;
44 int height;
45 RECT visrect; /* rectangle clipped to the visible part, in device coords */
46 DWORD layout; /* DC layout */
49 struct ps_image_bits
51 void *ptr; /* pointer to the bits */
52 BOOL is_copy; /* whether this is a copy of the bits that can be modified */
53 void (*free)(struct ps_image_bits *); /* callback for freeing the bits */
56 struct ps_brush_pattern
58 BITMAPINFO *info; /* DIB info */
59 struct ps_image_bits bits; /* DIB bits */
60 UINT usage; /* color usage for DIB info */
63 typedef struct {
64 INT index;
65 LPCSTR sz;
66 } GLYPHNAME;
68 typedef struct {
69 LONG UV;
70 const GLYPHNAME *name;
71 } UNICODEGLYPH;
73 typedef struct {
74 float llx, lly, urx, ury;
75 } AFMBBOX;
77 typedef struct _tagAFMLIGS {
78 char *successor;
79 char *ligature;
80 struct _tagAFMLIGS *next;
81 } AFMLIGS;
83 typedef struct {
84 int C; /* character */
85 LONG UV;
86 float WX;
87 const GLYPHNAME *N; /* name */
88 AFMBBOX B;
89 const AFMLIGS *L; /* Ligatures */
90 } OLD_AFMMETRICS;
92 typedef struct {
93 INT C; /* AFM encoding (or -1) */
94 LONG UV; /* Unicode value */
95 FLOAT WX; /* Advance width */
96 const GLYPHNAME *N; /* Glyph name */
97 } AFMMETRICS;
99 typedef struct {
100 USHORT usUnitsPerEm; /* head:unitsPerEm */
101 SHORT sAscender; /* hhea:Ascender */
102 SHORT sDescender; /* hhea:Descender */
103 SHORT sLineGap; /* hhea:LineGap */
104 SHORT sAvgCharWidth; /* OS/2:xAvgCharWidth */
105 SHORT sTypoAscender; /* OS/2:sTypoAscender */
106 SHORT sTypoDescender; /* OS/2:sTypoDescender */
107 SHORT sTypoLineGap; /* OS/2:sTypeLineGap */
108 USHORT usWinAscent; /* OS/2:usWinAscent */
109 USHORT usWinDescent; /* OS/2:usWinDescent */
110 } WINMETRICS;
112 typedef struct _tagAFM {
113 const char *FontName;
114 const WCHAR *FullName;
115 const WCHAR *FamilyName;
116 const WCHAR *EncodingScheme;
117 LONG Weight; /* FW_NORMAL etc. */
118 float ItalicAngle;
119 BOOL IsFixedPitch;
120 float UnderlinePosition;
121 float UnderlineThickness;
122 AFMBBOX FontBBox;
123 float Ascender;
124 float Descender;
125 WINMETRICS WinMetrics;
126 int NumofMetrics;
127 const AFMMETRICS *Metrics;
128 } AFM;
130 /* Note no 'next' in AFM. Use AFMLISTENTRY as a container. This allows more than
131 one list to exist without having to reallocate the entire AFM structure. We
132 keep a global list of all afms (PSDRV_AFMFontList) plus a list of available
133 fonts for each DC (dc->physDev->Fonts) */
135 typedef struct _tagAFMLISTENTRY {
136 const AFM *afm;
137 struct _tagAFMLISTENTRY *next;
138 } AFMLISTENTRY;
140 typedef struct _tagFONTFAMILY {
141 WCHAR *FamilyName; /* family name */
142 AFMLISTENTRY *afmlist; /* list of afms for this family */
143 struct _tagFONTFAMILY *next; /* next family */
144 } FONTFAMILY;
146 extern FONTFAMILY *PSDRV_AFMFontList;
147 extern const AFM *const PSDRV_BuiltinAFMs[]; /* last element is NULL */
149 typedef struct
151 struct list entry;
152 char *Name;
153 } FONTNAME;
155 typedef struct {
156 float llx, lly, urx, ury;
157 } IMAGEABLEAREA;
159 typedef struct {
160 float x, y;
161 } PAPERDIMENSION;
163 /* Solaris kludge */
164 #undef PAGESIZE
165 typedef struct _tagPAGESIZE {
166 struct list entry;
167 char *Name;
168 WCHAR *FullName;
169 char *InvocationString;
170 IMAGEABLEAREA *ImageableArea;
171 PAPERDIMENSION *PaperDimension;
172 WORD WinPage; /*eg DMPAPER_A4. Doesn't really belong here */
173 } PAGESIZE;
175 typedef struct
177 struct list entry;
178 char *Feature1;
179 char *Value1;
180 char *Feature2;
181 char *Value2;
182 } CONSTRAINT;
184 typedef struct
186 struct list entry;
187 const char *Name;
188 const char *FullName;
189 char *InvocationString;
190 WORD WinBin; /* eg DMBIN_LOWER */
191 } INPUTSLOT;
193 typedef enum _RASTERIZEROPTION
194 {RO_None, RO_Accept68K, RO_Type42, RO_TrueImage} RASTERIZEROPTION;
196 typedef struct
198 struct list entry;
199 char *Name;
200 char *FullName;
201 char *InvocationString;
202 WORD WinDuplex; /* eg DMDUP_SIMPLEX */
203 } DUPLEX;
205 typedef struct
207 struct list entry;
208 int resx, resy;
209 char *InvocationString;
210 } RESOLUTION;
212 /* Many Mac OS X based ppd files don't include a *ColorDevice line, so
213 we use a tristate here rather than a boolean. Code that
214 cares is expected to treat these as if they were colour. */
215 typedef enum {
216 CD_NotSpecified,
217 CD_False,
218 CD_True
219 } COLORDEVICE;
221 typedef struct {
222 char *NickName;
223 int LanguageLevel;
224 COLORDEVICE ColorDevice;
225 struct list Resolutions;
226 int DefaultResolution;
227 signed int LandscapeOrientation;
228 char *JCLBegin;
229 char *JCLToPSInterpreter;
230 char *JCLEnd;
231 char *DefaultFont;
232 struct list InstalledFonts;
233 struct list PageSizes;
234 PAGESIZE *DefaultPageSize;
235 struct list Constraints;
236 struct list InputSlots;
237 RASTERIZEROPTION TTRasterizer;
238 struct list Duplexes;
239 DUPLEX *DefaultDuplex;
240 } PPD;
242 typedef struct
244 struct list entry;
245 WCHAR *friendly_name;
246 PPD *ppd;
247 PSDRV_DEVMODE *Devmode;
248 FONTFAMILY *Fonts;
249 PPRINTER_ENUM_VALUESW FontSubTable;
250 DWORD FontSubTableSize;
251 } PRINTERINFO;
253 typedef struct {
254 float r, g, b;
255 } PSRGB;
257 typedef struct {
258 float i;
259 } PSGRAY;
262 /* def's for PSCOLOR.type */
263 #define PSCOLOR_GRAY 0
264 #define PSCOLOR_RGB 1
266 typedef struct {
267 int type;
268 union {
269 PSRGB rgb;
270 PSGRAY gray;
271 } value;
272 } PSCOLOR;
274 typedef struct {
275 const AFM *afm;
276 float scale;
277 TEXTMETRICW tm;
278 } BUILTIN;
280 typedef struct tagTYPE42 TYPE42;
282 typedef struct tagTYPE1 TYPE1;
284 enum downloadtype {
285 Type1, Type42
288 typedef struct _tagDOWNLOAD {
289 enum downloadtype type;
290 union {
291 TYPE1 *Type1;
292 TYPE42 *Type42;
293 } typeinfo;
294 char *ps_name;
295 struct _tagDOWNLOAD *next;
296 } DOWNLOAD;
298 enum fontloc {
299 Builtin, Download
302 typedef struct
304 INT xx, xy, yx, yy;
305 } matrix;
307 enum fontset { UNSET = 0, HORIZONTAL_SET, VERTICAL_SET };
309 typedef struct {
310 enum fontloc fontloc;
311 union {
312 BUILTIN Builtin;
313 DOWNLOAD *Download;
314 } fontinfo;
316 matrix size;
317 PSCOLOR color;
318 enum fontset set; /* Have we done a setfont yet */
319 } PSFONT;
321 typedef struct {
322 PSCOLOR color;
323 BOOL set;
324 struct ps_brush_pattern pattern;
325 } PSBRUSH;
327 #define MAX_DASHLEN 16
329 typedef struct {
330 INT style;
331 INT width;
332 BYTE join;
333 BYTE endcap;
334 DWORD dash[MAX_DASHLEN];
335 DWORD dash_len;
336 PSCOLOR color;
337 BOOL set;
338 } PSPEN;
340 enum passthrough
342 passthrough_none,
343 passthrough_active,
344 passthrough_had_rect, /* See the comment in PSDRV_Rectangle */
347 typedef struct {
348 DWORD id; /* Job id */
349 HANDLE hprinter; /* Printer handle */
350 LPWSTR doc_name; /* Document Name */
351 BOOL OutOfPage; /* Page header not sent yet */
352 INT PageNo;
353 BOOL quiet; /* Don't actually output anything */
354 enum passthrough passthrough_state;
355 BYTE data[4096];
356 int data_cnt;
357 } JOB;
359 typedef struct
361 HDC hdc;
362 PSFONT font; /* Current PS font */
363 DOWNLOAD *downloaded_fonts;
364 PSPEN pen;
365 PSBRUSH brush;
366 PSCOLOR bkColor;
367 JOB job;
368 PSDRV_DEVMODE *Devmode;
369 PRINTERINFO *pi;
370 int pathdepth;
371 } print_ctx;
373 extern print_ctx *create_print_ctx( HDC hdc, const WCHAR *device,
374 const DEVMODEW *devmode );
377 * Every glyph name in the Adobe Glyph List and the 35 core PostScript fonts
380 extern const INT PSDRV_AGLGlyphNamesSize;
381 extern GLYPHNAME PSDRV_AGLGlyphNames[];
385 * The AGL encoding vector
388 extern const INT PSDRV_AGLbyNameSize; /* sorted by name */
389 extern const UNICODEGLYPH PSDRV_AGLbyName[]; /* duplicates omitted */
391 extern const INT PSDRV_AGLbyUVSize; /* sorted by UV */
392 extern const UNICODEGLYPH PSDRV_AGLbyUV[]; /* duplicates included */
394 extern HINSTANCE PSDRV_hInstance;
395 extern HANDLE PSDRV_Heap;
396 extern char *PSDRV_ANSIVector[256];
398 extern INPUTSLOT *find_slot( PPD *ppd, const DEVMODEW *dm );
399 extern PAGESIZE *find_pagesize( PPD *ppd, const DEVMODEW *dm );
400 extern DUPLEX *find_duplex( PPD *ppd, const DEVMODEW *dm );
402 /* GDI driver functions */
403 extern BOOL PSDRV_Arc( print_ctx *ctx, INT left, INT top, INT right, INT bottom,
404 INT xstart, INT ystart, INT xend, INT yend );
405 extern BOOL PSDRV_Chord( print_ctx *ctx, INT left, INT top, INT right, INT bottom,
406 INT xstart, INT ystart, INT xend, INT yend );
407 extern BOOL PSDRV_Ellipse( print_ctx *ctx, INT left, INT top, INT right, INT bottom);
408 extern INT PSDRV_EndPage( print_ctx *ctx );
409 extern INT PSDRV_ExtEscape( print_ctx *ctx, INT nEscape, INT cbInput, LPCVOID in_data,
410 INT cbOutput, LPVOID out_data );
411 extern BOOL PSDRV_ExtTextOut( print_ctx *ctx, INT x, INT y, UINT flags,
412 const RECT *lprect, LPCWSTR str, UINT count, const INT *lpDx );
413 extern BOOL PSDRV_FillPath( print_ctx *ctx );
414 extern BOOL PSDRV_LineTo(print_ctx *ctx, INT x, INT y);
415 extern BOOL PSDRV_PaintRgn( print_ctx *ctx, HRGN hrgn );
416 extern BOOL PSDRV_PatBlt(print_ctx *ctx, struct ps_bitblt_coords *dst, DWORD dwRop);
417 extern BOOL PSDRV_Pie( print_ctx *ctx, INT left, INT top, INT right, INT bottom,
418 INT xstart, INT ystart, INT xend, INT yend );
419 extern BOOL PSDRV_PolyBezier( print_ctx *ctx, const POINT *pts, DWORD count );
420 extern BOOL PSDRV_PolyBezierTo( print_ctx *ctx, const POINT *pts, DWORD count );
421 extern BOOL PSDRV_PolyPolygon( print_ctx *ctx, const POINT* pts, const INT* counts, UINT polygons );
422 extern BOOL PSDRV_PolyPolyline( print_ctx *ctx, const POINT* pts, const DWORD* counts, DWORD polylines );
423 extern DWORD PSDRV_PutImage( print_ctx *ctx, HRGN clip, BITMAPINFO *info,
424 const struct ps_image_bits *bits, struct ps_bitblt_coords *src,
425 struct ps_bitblt_coords *dst, DWORD rop );
426 extern BOOL PSDRV_Rectangle( print_ctx *ctx, INT left, INT top, INT right, INT bottom );
427 extern BOOL PSDRV_RoundRect( print_ctx *ctx, INT left, INT top, INT right,
428 INT bottom, INT ell_width, INT ell_height );
429 extern HBRUSH PSDRV_SelectBrush( print_ctx *ctx, HBRUSH hbrush, const struct ps_brush_pattern *pattern );
430 extern HFONT PSDRV_SelectFont( print_ctx *ctx, HFONT hfont, UINT *aa_flags );
431 extern HPEN PSDRV_SelectPen( print_ctx *ctx, HPEN hpen, const struct ps_brush_pattern *pattern );
432 extern COLORREF PSDRV_SetBkColor( print_ctx *ctx, COLORREF color );
433 extern COLORREF PSDRV_SetDCBrushColor( print_ctx *ctx, COLORREF color );
434 extern COLORREF PSDRV_SetDCPenColor( print_ctx *ctx, COLORREF color );
435 extern COLORREF PSDRV_SetPixel( print_ctx *ctx, INT x, INT y, COLORREF color );
436 extern COLORREF PSDRV_SetTextColor( print_ctx *ctx, COLORREF color );
437 extern BOOL PSDRV_StrokeAndFillPath( print_ctx *ctx );
438 extern BOOL PSDRV_StrokePath( print_ctx *ctx );
440 extern BOOL PSDRV_ResetDC( print_ctx *ctx, const DEVMODEW *lpInitData );
441 extern void PSDRV_MergeDevmodes(PSDRV_DEVMODE *dm1, const DEVMODEW *dm2,
442 PRINTERINFO *pi);
443 extern BOOL PSDRV_GetFontMetrics(void);
444 extern PPD *PSDRV_ParsePPD(const WCHAR *fname, HANDLE printer);
445 extern PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name);
446 extern const AFM *PSDRV_FindAFMinList(FONTFAMILY *head, LPCSTR name);
447 extern BOOL PSDRV_AddAFMtoList(FONTFAMILY **head, const AFM *afm,
448 BOOL *p_added);
449 extern void PSDRV_FreeAFMList( FONTFAMILY *head );
451 extern INT PSDRV_XWStoDS( print_ctx *ctx, INT width );
453 extern BOOL PSDRV_Brush(print_ctx *ctx, BOOL EO);
454 extern BOOL PSDRV_SetFont( print_ctx *ctx, BOOL vertical );
455 extern BOOL PSDRV_SetPen( print_ctx *ctx );
457 extern void PSDRV_AddClip( print_ctx *ctx, HRGN hrgn );
458 extern void PSDRV_SetClip( print_ctx *ctx );
459 extern void PSDRV_ResetClip( print_ctx *ctx );
461 extern void PSDRV_CreateColor( print_ctx *ctx, PSCOLOR *pscolor,
462 COLORREF wincolor );
463 extern PSRGB rgb_to_grayscale_scale( void );
464 extern char PSDRV_UnicodeToANSI(int u);
466 extern INT PSDRV_WriteHeader( print_ctx *ctx, LPCWSTR title );
467 extern INT PSDRV_WriteFooter( print_ctx *ctx );
468 extern INT PSDRV_WriteNewPage( print_ctx *ctx );
469 extern INT PSDRV_WriteEndPage( print_ctx *ctx );
470 extern BOOL PSDRV_WriteMoveTo(print_ctx *ctx, INT x, INT y);
471 extern BOOL PSDRV_WriteLineTo(print_ctx *ctx, INT x, INT y);
472 extern BOOL PSDRV_WriteStroke(print_ctx *ctx);
473 extern BOOL PSDRV_WriteRectangle(print_ctx *ctx, INT x, INT y, INT width, INT height);
474 extern BOOL PSDRV_WriteRRectangle(print_ctx *ctx, INT x, INT y, INT width, INT height);
475 extern BOOL PSDRV_WriteSetFont(print_ctx *ctx, const char *name, matrix size, INT escapement,
476 BOOL fake_italic);
477 extern BOOL PSDRV_WriteGlyphShow(print_ctx *ctx, LPCSTR g_name);
478 extern BOOL PSDRV_WriteSetPen(print_ctx *ctx);
479 extern BOOL PSDRV_WriteArc(print_ctx *ctx, INT x, INT y, INT w, INT h,
480 double ang1, double ang2);
481 extern BOOL PSDRV_WriteCurveTo(print_ctx *ctx, POINT pts[3]);
482 extern BOOL PSDRV_WriteSetColor(print_ctx *ctx, PSCOLOR *color);
483 extern BOOL PSDRV_WriteSetBrush(print_ctx *ctx);
484 extern BOOL PSDRV_WriteFill(print_ctx *ctx);
485 extern BOOL PSDRV_WriteEOFill(print_ctx *ctx);
486 extern BOOL PSDRV_WriteGSave(print_ctx *ctx);
487 extern BOOL PSDRV_WriteGRestore(print_ctx *ctx);
488 extern BOOL PSDRV_WriteNewPath(print_ctx *ctx);
489 extern BOOL PSDRV_WriteClosePath(print_ctx *ctx);
490 extern BOOL PSDRV_WriteClip(print_ctx *ctx);
491 extern BOOL PSDRV_WriteRectClip(print_ctx *ctx, INT x, INT y, INT w, INT h);
492 extern BOOL PSDRV_WriteRectClip2(print_ctx *ctx, CHAR *pszArrayName);
493 extern BOOL PSDRV_WriteEOClip(print_ctx *ctx);
494 extern BOOL PSDRV_WriteHatch(print_ctx *ctx);
495 extern BOOL PSDRV_WriteRotate(print_ctx *ctx, float ang);
496 extern BOOL PSDRV_WriteIndexColorSpaceBegin(print_ctx *ctx, int size);
497 extern BOOL PSDRV_WriteIndexColorSpaceEnd(print_ctx *ctx);
498 extern BOOL PSDRV_WriteRGBQUAD(print_ctx *ctx, const RGBQUAD *rgb, int number);
499 extern BOOL PSDRV_WriteImage(print_ctx *ctx, WORD depth, BOOL grayscale, INT xDst, INT yDst,
500 INT widthDst, INT heightDst, INT widthSrc,
501 INT heightSrc, BOOL mask, BOOL top_down);
502 extern BOOL PSDRV_WriteBytes(print_ctx *ctx, const BYTE *bytes, DWORD number);
503 extern BOOL PSDRV_WriteData(print_ctx *ctx, const BYTE *byte, DWORD number);
504 extern DWORD PSDRV_WriteSpool(print_ctx *ctx, LPCSTR lpData, DWORD cch);
505 extern BOOL PSDRV_WriteDIBPatternDict(print_ctx *ctx, const BITMAPINFO *bmi, BYTE *bits, UINT usage);
506 extern BOOL PSDRV_WriteArrayPut(print_ctx *ctx, CHAR *pszArrayName, INT nIndex, LONG lCoord);
507 extern BOOL PSDRV_WriteArrayDef(print_ctx *ctx, CHAR *pszArrayName, INT nSize);
509 extern INT PSDRV_StartPage( print_ctx *ctx );
511 INT PSDRV_GlyphListInit(void);
512 const GLYPHNAME *PSDRV_GlyphName(LPCSTR szName);
513 VOID PSDRV_IndexGlyphList(void);
514 BOOL PSDRV_GetType1Metrics(void);
515 SHORT PSDRV_CalcAvgCharWidth(const AFM *afm);
517 extern BOOL PSDRV_WriteSetBuiltinFont(print_ctx *ctx);
518 extern BOOL PSDRV_WriteBuiltinGlyphShow(print_ctx *ctx, LPCWSTR str, INT count);
520 extern BOOL PSDRV_WriteSetDownloadFont(print_ctx *ctx, BOOL vertical);
521 extern BOOL PSDRV_WriteDownloadGlyphShow(print_ctx *ctx, const WORD *glyphs, UINT count);
522 extern BOOL PSDRV_EmptyDownloadList(print_ctx *ctx, BOOL write_undef);
524 extern BOOL flush_spool(print_ctx *ctx);
525 extern DWORD write_spool(print_ctx *ctx, const void *data, DWORD num);
527 #define MAX_G_NAME 31 /* max length of PS glyph name */
528 extern void get_glyph_name(HDC hdc, WORD index, char *name);
530 extern TYPE1 *T1_download_header(print_ctx *ctx, char *ps_name,
531 RECT *bbox, UINT emsize);
532 extern BOOL T1_download_glyph(print_ctx *ctx, DOWNLOAD *pdl,
533 DWORD index, char *glyph_name);
534 extern void T1_free(TYPE1 *t1);
536 extern TYPE42 *T42_download_header(print_ctx *ctx, char *ps_name,
537 RECT *bbox, UINT emsize);
538 extern BOOL T42_download_glyph(print_ctx *ctx, DOWNLOAD *pdl,
539 DWORD index, char *glyph_name);
540 extern void T42_free(TYPE42 *t42);
542 extern DWORD RLE_encode(BYTE *in_buf, DWORD len, BYTE *out_buf);
543 extern DWORD ASCII85_encode(BYTE *in_buf, DWORD len, BYTE *out_buf);
545 extern void passthrough_enter(print_ctx *ctx);
546 extern void passthrough_leave(print_ctx *ctx);
548 #define push_lc_numeric(x) do { \
549 const char *tmplocale = setlocale(LC_NUMERIC,NULL); \
550 setlocale(LC_NUMERIC,x);
552 #define pop_lc_numeric() \
553 setlocale(LC_NUMERIC,tmplocale); \
554 } while (0)
556 static inline WCHAR *strdupW( const WCHAR *str )
558 int size;
559 WCHAR *ret;
561 if (!str) return NULL;
562 size = (lstrlenW( str ) + 1) * sizeof(WCHAR);
563 ret = HeapAlloc( GetProcessHeap(), 0, size );
564 if (ret) memcpy( ret, str, size );
565 return ret;
568 #endif