File: appWinMeta.h

package info (click to toggle)
ted 2.11-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 11,064 kB
  • ctags: 13,935
  • sloc: ansic: 120,446; makefile: 7,469; sh: 253
file content (548 lines) | stat: -rw-r--r-- 15,246 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
/************************************************************************/
/*									*/
/*  Windows Meta File specific definitions.				*/
/*									*/
/************************************************************************/

#   include	<appGuiBase.h>

#   include	<bitmap.h>
#   include	<docFont.h>
#   include	<utilPostscriptFace.h>
#   include	<appDraw.h>
#   include	<appImage.h>
#   include	<sioGeneral.h>

#   define	WINMETA_Arc			0x0817
#   define	WINMETA_Chord			0x0830
#   define	WINMETA_Ellipse			0x0418
#   define	WINMETA_ExcludeClipRect		0x0415
#   define	WINMETA_FloodFill		0x0419
#   define	WINMETA_IntersectClipRect	0x0416
#   define	WINMETA_LineTo			0x0213
#   define	WINMETA_MoveTo			0x0214
#   define	WINMETA_OffsetClipRgn		0x0220
#   define	WINMETA_OffsetViewportOrg	0x0211
#   define	WINMETA_OffsetWindowOrg		0x020f
#   define	WINMETA_PatBlt			0x061d
#   define	WINMETA_Pie			0x081a
#   define	WINMETA_RealizePalette		0x0035
#   define	WINMETA_Rectangle		0x041b
#   define	WINMETA_ResizePalette		0x0319
#   define	WINMETA_RestoreDC		0x0127
#   define	WINMETA_RoundRect		0x061c
#   define	WINMETA_SaveDC			0x001e
#   define	WINMETA_ScaleViewportExt	0x0412
#   define	WINMETA_ScaleWindowExt		0x0400
#   define	WINMETA_SetBkColor		0x0201
#   define	WINMETA_SetBkMode		0x0102
#   define	WINMETA_SetMapMode		0x0103
#   define	WINMETA_SetMapperFlags		0x0231
#   define	WINMETA_SetPixel		0x041f
#   define	WINMETA_SetPolyFillMode		0x0106
#   define	WINMETA_SetROP2			0x0104
#   define	WINMETA_SetStretchBltMode	0x0107
#   define	WINMETA_SetTextAlign		0x012e
#   define	WINMETA_SetTextCharExtra	0x0108
#   define	WINMETA_SetTextColor		0x0209
#   define	WINMETA_SetTextJustification	0x020a
#   define	WINMETA_SetViewportExt		0x020e
#   define	WINMETA_SetViewportOrg		0x020d
#   define	WINMETA_SetWindowExt		0x020c
#   define	WINMETA_SetWindowOrg		0x020b

#   define	WINMETA_AnimatePalette		0x0436
#   define	WINMETA_BitBlt_2		0x0922
#   define	WINMETA_BitBlt			0x0940
#   define	WINMETA_CreateBrushIndirect	0x02fc
#   define	WINMETA_CreateFontIndirect	0x02fb
#   define	WINMETA_CreatePalette		0x00f7
#   define	WINMETA_CreatePatternBrush_2	0x01f9
#   define	WINMETA_CreatePatternBrush	0x0142
#   define	WINMETA_CreatePenIndirect	0x02fa
#   define	WINMETA_CreateRegion		0x06ff
#   define	WINMETA_DeleteObject		0x01f0
#   define	WINMETA_Escape			0x0626
#   define	WINMETA_ExtTextOut		0x0a32
#   define	WINMETA_Polygon			0x0324
#   define	WINMETA_PolyPolygon		0x0538
#   define	WINMETA_PolyLine		0x0325
#   define	WINMETA_SelectClipRgn		0x012c
#   define	WINMETA_SelectObject		0x012d
#   define	WINMETA_SelectPalette		0x0234
#   define	WINMETA_SetDIBitsToDevice	0x0d33
#   define	WINMETA_SetPaletteEntries	0x0037
#   define	WINMETA_StretchBlt_2		0x0b23
#   define	WINMETA_StretchBlt		0x0b41
#   define	WINMETA_StretchDIBits		0x0f43
#   define	WINMETA_TextOut			0x0521

/************************************************************************/
/*									*/
/*  1)  Various MapModes: Refer to petzold for an explanation.		*/
/*  2)  StrechBlt() modes.						*/
/*  3)  Font family styles.						*/
/*  4)  Polygon Fill Modes.						*/
/*									*/
/************************************************************************/

/*  1  */
#   define	MM_TEXT				1
#   define	MM_LOMETRIC			2
#   define	MM_HIMETRIC			3
#   define	MM_LOENGLISH			4
#   define	MM_HIENGLISH			5
#   define	MM_TWIPS			6
#   define	MM_ISOTROPIC			7
#   define	MM_ANISOTROPIC			8

/*  2  */
#   define	STRETCH_BLT_BLACKONWHITE	1
#   define	STRETCH_BLT_WHITEONBLACK	2
#   define	STRETCH_BLT_COLORONCOLOR	3

/*  3  */
#   define	FF_DONTCARE			0x00
#   define	FF_ROMAN			0x10
#   define	FF_SWISS			0x20
#   define	FF_MODERN			0x30
#   define	FF_SCRIPT			0x40
#   define	FF_DECORATIVE			0x50

/*  4  */
#   define	ALTERNATE			1
#   define	WINDING				2

/************************************************************************/
/*									*/
/*  Implementation of a metafile 'Object'				*/
/*									*/
/************************************************************************/

#   define TA_NOUPDATECP			0x0000
#   define TA_UPDATECP				0x0001
#   define TA_LEFT				0x0000
#   define TA_RIGHT				0x0002
#   define TA_CENTER				0x0006
#   define TA_TOP				0x0000
#   define TA_BOTTOM				0x0008
#   define TA_BASELINE				0x0018

#   define	BKMODE_OPAQUE		0
#   define	BKMODE_TRANSPARENT	1

typedef struct LogicalBrush
    {
    int			lbStyle;
#			define		BS_SOLID	0
#			define		BS_NULL		1
#			define		BS_HOLLOW	BS_NULL
#			define		BS_HATCHED	2
#			define		BS_PATTERN	3
#			define		BS_INDEXED	4
#			define		BS_DIBPATTERN	5
    RGB8Color		lbColor;
    int			lbHatch;
#			define HS_HORIZONTAL       0
#			define HS_VERTICAL         1
#			define HS_FDIAGONAL        2
#			define HS_BDIAGONAL        3
#			define HS_CROSS            4
#			define HS_DIAGCROSS        5

    APP_BITMAP_IMAGE	lbTilePixmap;
    } LogicalBrush;

typedef struct PatternBrush
    {
    int			pbType;		/*  == 5	*/
    int			pbUsage;	/*  == 0	*/
    AppBitmapImage	pbAbi;
    APP_BITMAP_IMAGE	pbTilePixmap;
    } PatternBrush;

typedef struct LogicalPen
    {
    int		lpStyle;
#		define		PS_SOLID	0
#		define		PS_DASH		1
#		define		PS_DOT		2
#		define		PS_DASHDOT	3
#		define		PS_DASHDOTDOT	4
#		define		PS_NULL		5
#		define		PS_INSIDEFRAME	6
    int		lpWidth;
    RGB8Color	lpColor;
    } LogicalPen;

typedef struct LogicalFont
    {
    int			lfHeight;
    int			lfWidth;
    int			lfEscapement;
    int			lfOrientation;
    int			lfWeight;
    unsigned char	lfItalic;
    unsigned char	lfUnderline;
    unsigned char	lfStrikeOut;
    unsigned char	lfCharSet;
    unsigned char	lfOutPrecision;
    unsigned char	lfClipPrecision;
    unsigned char	lfQuality;
    unsigned char	lfPitchAndFamily;
    char		lfFaceName[32];

    /************************************/
    /*  Implementation			*/
    /************************************/
    TextAttribute	lfTextAttribute;
    int			lfPrivateFont;
    } LogicalFont;

typedef struct LogicalPalette
    {
    int		lpVersion;
    int		lpColorCount;
    } LogicalPalette;

typedef union MetafileSpecific
    {
    LogicalBrush	mfsLogicalBrush;
    LogicalPen		mfsLogicalPen;
    LogicalFont		mfsLogicalFont;
    PatternBrush	mfsPatternBrush;
    } MetafileSpecific;

typedef struct MetaFileObject
    {
    int			mfoType;
    MetafileSpecific	mfoSpecific;
    } MetaFileObject;

#   define	MFtypeFREE		0
#   define	MFtypeBRUSH		1
#   define	MFtypePEN		2
#   define	MFtypeFONT		3
#   define	MFtypePALETTE		4
#   define	MFtypePATTERNBRUSH	5

#   define	mfoLogicalBrush		mfoSpecific.mfsLogicalBrush
#   define	mfoLogicalPen		mfoSpecific.mfsLogicalPen
#   define	mfoLogicalFont		mfoSpecific.mfsLogicalFont
#   define	mfoPatternBrush		mfoSpecific.mfsPatternBrush

/************************************************************************/
/*									*/
/*  Refer to Petzold, Charles: "Programming Windows 95", Microsoft	*/
/*  Press, Redmond, WA, 1996 pp138..					*/
/*									*/
/*  Terminology is extremely confusing: The window is the system of	*/
/*  'logical' user coordinates. The viewport is the sytem of 'hard'	*/
/*  device coordinates. Viewport=Device coordinates usually are in	*/
/*  pixels.								*/
/*									*/
/************************************************************************/

typedef struct DeviceCoordinateTransform
    {
    int					dct_xWinOrg;
    int					dct_yWinOrg;
    int					dct_xWinExt;
    int					dct_yWinExt;

    int					dct_xViewOrg;
    int					dct_yViewOrg;
    int					dct_xViewExt;
    int					dct_yViewExt;

    struct DeviceCoordinateTransform *	dctPushed;
    } DeviceCoordinateTransform;

# define DC_xWinOrg(dc)		((dc)->dcTransform.dct_xWinOrg)
# define DC_yWinOrg(dc)		((dc)->dcTransform.dct_yWinOrg)
# define DC_xWinExt(dc)		((dc)->dcTransform.dct_xWinExt)
# define DC_yWinExt(dc)		((dc)->dcTransform.dct_yWinExt)

# define DC_xViewOrg(dc)	((dc)->dcTransform.dct_xViewOrg)
# define DC_yViewOrg(dc)	((dc)->dcTransform.dct_yViewOrg)
# define DC_xViewExt(dc)	((dc)->dcTransform.dct_xViewExt)
# define DC_yViewExt(dc)	((dc)->dcTransform.dct_yViewExt)

# define DC_xViewport(x,dc) ( ( ( x-DC_xWinOrg(dc) )* DC_xViewExt(dc) ) / \
					    DC_xWinExt(dc)+ DC_xViewOrg(dc) )
# define DC_yViewport(y,dc) ( ( ( y-DC_yWinOrg(dc) )* DC_yViewExt(dc) ) / \
					    DC_yWinExt(dc)+ DC_yViewOrg(dc) )

# define DC_wViewport(w,dc) ( ( (w)* DC_xViewExt(dc) ) / DC_xWinExt(dc) )
# define DC_hViewport(h,dc) ( ( (h)* DC_yViewExt(dc) ) / DC_yWinExt(dc) )

typedef struct DeviceContext
    {
    int				dcMapMode;
    int				dcDrawBorders;
    int				dcFillInsides;
    int				dcROP2;

    int				dcClipX0;
    int				dcClipY0;
    int				dcClipX1;
    int				dcClipY1;

    int				dcFillHatched;
    int				dcFillPattern;

    DocumentFontList		x_dcFontList;
    AppDrawingData		dcDrawingData;

    LogicalPen			dcPen;
    LogicalBrush		dcBrush;
    LogicalFont			dcFont;

    RGB8Color			dcBkColor;
    RGB8Color			dcTextColor;
    int				dcBkMode;

    int				dcRedSet;
    int				dcGreenSet;
    int				dcBlueSet;
    TextAttribute		dcTextAttributeSet;
    LogicalPen			dcPenSet;

    int				dcExtraTextSpacing;
    int				dcJustificationAmount;
    int				dcJustificationSpaces;
    int				dcTextAlignment;
    long			dcStretchBltMode;

    int				dcX;
    int				dcY;

    unsigned char *		dcString;

    DeviceCoordinateTransform	dcTransform;
    int				dcTwipsWide;
    int				dcTwipsHigh;

    MetaFileObject *		dcObjects;
    int				dcObjectCount;

    APP_POINT *			dcPoints;

    AfmFontInfo *		dcAfi;
    int				dcFontEncoding;
    } DeviceContext;

# define DCX_xViewport(x,dcx)	(DC_xViewport(x,&(dcx->dcxDeviceContext)))
# define DCX_yViewport(y,dcx)	(DC_yViewport(y,&(dcx->dcxDeviceContext)))
# define DCX_wViewport(w,dcx)	(DC_wViewport(w,&(dcx->dcxDeviceContext)))
# define DCX_hViewport(h,dcx)	(DC_hViewport(h,&(dcx->dcxDeviceContext)))

typedef struct DeviceContextX11
    {
    DeviceContext	dcxDeviceContext;

    int			dcxPixelsWide;
    int			dcxPixelsHigh;

    APP_COLOR_RGB	dcxPenColor;
    APP_COLOR_RGB	dcxBrushColor;

    APP_COLOR_RGB	dcxBkColor;
    APP_COLOR_RGB	dcxTextColor;
    int			dcxFillTiled;
    int			dcxFillHatched;

    AppPhysicalFont *	dcxPhysicalFont;
    } DeviceContextX11;

/************************************************************************/
/*									*/
/*  Routine declarations.						*/
/*									*/
/************************************************************************/

extern int appMetaPlayWmfX11(	SimpleInputStream *	sis,
				void **			pPrivate,
				AppColors *		ac,
				AppDrawingData *	add,
				APP_WINDOW		pixmap,
				int			mapMode,
				int			xWinExt,
				int			yWinExt,
				int			pixelsWide,
				int			pixelsHigh,
				int			twipsWide,
				int			twipsHigh );

extern int appMetaPlayEmfX11(	SimpleInputStream *	sis,
				void **			pPrivate,
				AppColors *		ac,
				AppDrawingData *	add,
				APP_WINDOW		pixmap,
				int			mapMode,
				int			xExt,
				int			yExt,
				int			pixelsWide,
				int			pixelsHigh,
				int			twipsWide,
				int			twipsHigh );

extern int appMetaSaveBitmapMetafile(	const BitmapDescription *	bd,
					const unsigned char *		buffer,
					SimpleOutputStream *		sos );

extern int appMetaPlayFilePs(	FILE *				f,
				SimpleInputStream *		sis,
				const char *			afmDirectory,
				int				mapMode,
				int				xWinExt,
				int				yWinExt,
				int				twipsWide,
				int				twipsHigh );

extern void appMetaCleanDeviceContext(	DeviceContext *		dc );

extern int appMetaInitDeviceContext(	DeviceContext *		dc,
					int			objectCount,
					int			mapMode,
					int			xWinExt,
					int			yWinExt,
					int			xViewExt,
					int			yViewExt,
					int			twipsWide,
					int			twipsHigh );

extern void appMetaCleanObject( MetaFileObject *	mfo );

extern int appMeta_ExtTextOut(		SimpleInputStream *	sis,
					int			recordSize,
					int *			pX0,
					int *			pY0,
					int *			pCount,
					int *			pStyle,
					int *			pX1,
					int *			pY1,
					int *			pH1,
					int *			pW1,
					DeviceContext *		dc );

extern int appMeta_TextOut(	SimpleInputStream *	sis,
				int			recordSize,
				int *			pX0,
				int *			pY0,
				int *			pCount,
				DeviceContext *		dc );

extern int appMeta_GetCounts(	SimpleInputStream *	sis,
				int			recordSize,
				int *			pCount,
				int **			pCounts,
				DeviceContext *		dc );

extern int appMetaCreateBrushIndirect(	DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaCreatePenIndirect(	DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaCreateFontIndirect(	DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaCreatePatternBrush(	DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaCreatePalette(	DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaGetColor(		SimpleInputStream *	sis,
					RGB8Color *		rgb8 );

extern int appMetaListFontsPs(	PostScriptFaceList *	psfl,
				SimpleInputStream *	sis,
				const char *		afmDirectory,
				const char *		prefix,
				int			mapMode,
				int			xExt,
				int			yExt,
				int			twipsWide,
				int			twipsHigh );

extern int appMetaBitmapImage(		AppBitmapImage **	pAbi,
					SimpleInputStream *	sis,
					int			expectBytes );

extern int appMetaSetTextAlign(		DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaDefineProcsetPs(	FILE *		f );

extern int appMetaPlayWmfImg(	BitmapDescription *	pBd,
				unsigned char **	pBuffer,
				SimpleInputStream *	sis );

extern int appMetaSetMapMode(		DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaOffsetWindowOrg(	DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaSetWindowOrg(		DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaSetWindowExt(		DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaSetViewportOrg(	DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaSetViewportExt(	DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaScaleViewportExt(	DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaScaleWindowExt(	DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaSaveDC(		DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaRestoreDC(		DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaOffsetClipRgn(	DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaExcludeClipRect(	DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaIntersectClipRect(	DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaSetBkColor(		DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );

extern int appMetaSetTextColor(		DeviceContext *		dc,
					int			recordSize,
					SimpleInputStream *	sis );