2 * Windows Device Context initialisation functions
4 * Copyright 1996 John Harvey
21 #define SUPPORT_REALIZED_FONTS 1
30 } EXTTEXTDATA
, *LPEXTTEXTDATA
;
33 SEGPTR win16drv_SegPtr_TextXForm
;
34 LPTEXTXFORM16 win16drv_TextXFormP
;
35 SEGPTR win16drv_SegPtr_DrawMode
;
36 LPDRAWMODE win16drv_DrawModeP
;
39 static BOOL32
WIN16DRV_CreateDC( DC
*dc
, LPCSTR driver
, LPCSTR device
,
40 LPCSTR output
, const DEVMODE16
* initData
);
41 static INT32
WIN16DRV_Escape( DC
*dc
, INT32 nEscape
, INT32 cbInput
,
42 SEGPTR lpInData
, SEGPTR lpOutData
);
44 static const DC_FUNCTIONS WIN16DRV_Funcs
=
48 NULL
, /* pBitmapBits */
50 NULL
, /* pCreateBitmap */
51 WIN16DRV_CreateDC
, /* pCreateDC */
53 NULL
, /* pDeleteObject */
54 WIN16DRV_Ellipse
, /* pEllipse */
55 WIN16DRV_EnumDeviceFonts
, /* pEnumDeviceFonts */
56 WIN16DRV_Escape
, /* pEscape */
57 NULL
, /* pExcludeClipRect */
58 NULL
, /* pExcludeVisRect */
59 NULL
, /* pExtFloodFill */
60 WIN16DRV_ExtTextOut
, /* pExtTextOut */
61 WIN16DRV_GetCharWidth
, /* pGetCharWidth */
63 WIN16DRV_GetTextExtentPoint
, /* pGetTextExtentPoint */
64 WIN16DRV_GetTextMetrics
, /* pGetTextMetrics */
65 NULL
, /* pIntersectClipRect */
66 NULL
, /* pIntersectVisRect */
67 WIN16DRV_LineTo
, /* pLineTo */
68 NULL
, /* pLoadOEMResource */
69 WIN16DRV_MoveToEx
, /* pMoveToEx */
70 NULL
, /* pOffsetClipRgn */
71 NULL
, /* pOffsetViewportOrgEx */
72 NULL
, /* pOffsetWindowOrgEx */
74 WIN16DRV_PatBlt
, /* pPatBlt */
76 NULL
, /* pPolyPolygon */
77 NULL
, /* pPolyPolyline */
78 WIN16DRV_Polygon
, /* pPolygon */
79 WIN16DRV_Polyline
, /* pPolyline */
80 NULL
, /* pPolyBezier */
81 NULL
, /* pRealizePalette */
82 WIN16DRV_Rectangle
, /* pRectangle */
83 NULL
, /* pRestoreDC */
84 NULL
, /* pRoundRect */
86 NULL
, /* pScaleViewportExtEx */
87 NULL
, /* pScaleWindowExtEx */
88 NULL
, /* pSelectClipRgn */
89 WIN16DRV_SelectObject
, /* pSelectObject */
90 NULL
, /* pSelectPalette */
91 NULL
, /* pSetBkColor */
92 NULL
, /* pSetBkMode */
93 NULL
, /* pSetDeviceClipping */
94 NULL
, /* pSetDIBitsToDevice */
95 NULL
, /* pSetMapMode */
96 NULL
, /* pSetMapperFlags */
98 NULL
, /* pSetPolyFillMode */
100 NULL
, /* pSetRelAbs */
101 NULL
, /* pSetStretchBltMode */
102 NULL
, /* pSetTextAlign */
103 NULL
, /* pSetTextCharacterExtra */
104 NULL
, /* pSetTextColor */
105 NULL
, /* pSetTextJustification */
106 NULL
, /* pSetViewportExtEx */
107 NULL
, /* pSetViewportOrgEx */
108 NULL
, /* pSetWindowExtEx */
109 NULL
, /* pSetWindowOrgEx */
110 NULL
, /* pStretchBlt */
111 NULL
/* pStretchDIBits */
118 /**********************************************************************
121 BOOL32
WIN16DRV_Init(void)
123 return DRIVER_RegisterDriver( NULL
/* generic driver */, &WIN16DRV_Funcs
);
127 /* Tempory functions, for initialising structures */
128 /* These values should be calculated, not hardcoded */
129 void InitTextXForm(LPTEXTXFORM16 lpTextXForm
)
131 lpTextXForm
->txfHeight
= 0x0001;
132 lpTextXForm
->txfWidth
= 0x000c;
133 lpTextXForm
->txfEscapement
= 0x0000;
134 lpTextXForm
->txfOrientation
= 0x0000;
135 lpTextXForm
->txfWeight
= 0x0190;
136 lpTextXForm
->txfItalic
= 0x00;
137 lpTextXForm
->txfUnderline
= 0x00;
138 lpTextXForm
->txfStrikeOut
= 0x00;
139 lpTextXForm
->txfOutPrecision
= 0x02;
140 lpTextXForm
->txfClipPrecision
= 0x01;
141 lpTextXForm
->txfAccelerator
= 0x0001;
142 lpTextXForm
->txfOverhang
= 0x0000;
146 void InitDrawMode(LPDRAWMODE lpDrawMode
)
148 lpDrawMode
->Rop2
= 0x000d;
149 lpDrawMode
->bkMode
= 0x0001;
150 lpDrawMode
->bkColor
= 0x3fffffff;
151 lpDrawMode
->TextColor
= 0x20000000;
152 lpDrawMode
->TBreakExtra
= 0x0000;
153 lpDrawMode
->BreakExtra
= 0x0000;
154 lpDrawMode
->BreakErr
= 0x0000;
155 lpDrawMode
->BreakRem
= 0x0000;
156 lpDrawMode
->BreakCount
= 0x0000;
157 lpDrawMode
->CharExtra
= 0x0000;
158 lpDrawMode
->LbkColor
= 0x00ffffff;
159 lpDrawMode
->LTextColor
= 0x00000000;
162 BOOL32
WIN16DRV_CreateDC( DC
*dc
, LPCSTR driver
, LPCSTR device
, LPCSTR output
,
163 const DEVMODE16
* initData
)
165 LOADED_PRINTER_DRIVER
*pLPD
;
167 DeviceCaps
*printerDevCaps
;
169 PDEVICE_HEADER
*pPDH
;
170 WIN16DRV_PDEVICE
*physDev
;
171 char printerEnabled
[20];
172 PROFILE_GetWineIniString( "wine", "printer", "off",
173 printerEnabled
, sizeof(printerEnabled
) );
174 if (lstrcmpi32A(printerEnabled
,"on"))
176 MSG("Printing disabled in wine.conf or .winerc file\n");
177 MSG("Use \"printer=on\" in the \"[wine]\" section to enable it.\n");
181 TRACE(win16drv
, "In creatdc for (%s,%s,%s) initData 0x%p\n",
182 driver
, device
, output
, initData
);
184 physDev
= (WIN16DRV_PDEVICE
*)HeapAlloc( SystemHeap
, 0, sizeof(*physDev
) );
185 if (!physDev
) return FALSE
;
186 dc
->physDev
= physDev
;
188 pLPD
= LoadPrinterDriver(driver
);
191 WARN(win16drv
, "Failed to find printer driver\n");
192 HeapFree( SystemHeap
, 0, physDev
);
195 TRACE(win16drv
, "windevCreateDC pLPD 0x%p\n", pLPD
);
197 /* Now Get the device capabilities from the printer driver */
199 printerDevCaps
= (DeviceCaps
*) xmalloc(sizeof(DeviceCaps
));
200 memset(printerDevCaps
, 0, sizeof(DeviceCaps
));
202 /* Get GDIINFO which is the same as a DeviceCaps structure */
203 wRet
= PRTDRV_Enable(printerDevCaps
, GETGDIINFO
, device
, driver
, output
,NULL
);
205 /* Add this to the DC */
206 dc
->w
.devCaps
= printerDevCaps
;
207 dc
->w
.hVisRgn
= CreateRectRgn32(0, 0, dc
->w
.devCaps
->horzRes
, dc
->w
.devCaps
->vertRes
);
208 dc
->w
.bitsPerPixel
= dc
->w
.devCaps
->bitsPixel
;
210 TRACE(win16drv
, "Got devcaps width %d height %d bits %d planes %d\n",
211 dc
->w
.devCaps
->horzRes
, dc
->w
.devCaps
->vertRes
,
212 dc
->w
.devCaps
->bitsPixel
, dc
->w
.devCaps
->planes
);
214 /* Now we allocate enough memory for the PDEVICE structure */
215 /* The size of this varies between printer drivers */
216 /* This PDEVICE is used by the printer DRIVER not by the GDI so must */
217 /* be accessable from 16 bit code */
218 nPDEVICEsize
= dc
->w
.devCaps
->pdeviceSize
+ sizeof(PDEVICE_HEADER
);
220 /* TTD Shouldn't really do pointer arithmetic on segment points */
221 physDev
->segptrPDEVICE
= WIN16_GlobalLock16(GlobalAlloc16(GHND
, nPDEVICEsize
))+sizeof(PDEVICE_HEADER
);
222 *((BYTE
*)PTR_SEG_TO_LIN(physDev
->segptrPDEVICE
)+0) = 'N';
223 *((BYTE
*)PTR_SEG_TO_LIN(physDev
->segptrPDEVICE
)+1) = 'B';
225 /* Set up the header */
226 pPDH
= (PDEVICE_HEADER
*)((BYTE
*)PTR_SEG_TO_LIN(physDev
->segptrPDEVICE
) - sizeof(PDEVICE_HEADER
));
229 TRACE(win16drv
, "PDEVICE allocated %08lx\n",(DWORD
)(physDev
->segptrPDEVICE
));
231 /* Now get the printer driver to initialise this data */
232 wRet
= PRTDRV_Enable((LPVOID
)physDev
->segptrPDEVICE
, INITPDEVICE
, device
, driver
, output
, NULL
);
234 physDev
->FontInfo
= NULL
;
235 physDev
->BrushInfo
= NULL
;
236 physDev
->PenInfo
= NULL
;
237 win16drv_SegPtr_TextXForm
= WIN16_GlobalLock16(GlobalAlloc16(GHND
, sizeof(TEXTXFORM16
)));
238 win16drv_TextXFormP
= PTR_SEG_TO_LIN(win16drv_SegPtr_TextXForm
);
240 InitTextXForm(win16drv_TextXFormP
);
242 /* TTD Lots more to do here */
243 win16drv_SegPtr_DrawMode
= WIN16_GlobalLock16(GlobalAlloc16(GHND
, sizeof(DRAWMODE
)));
244 win16drv_DrawModeP
= PTR_SEG_TO_LIN(win16drv_SegPtr_DrawMode
);
246 InitDrawMode(win16drv_DrawModeP
);
251 BOOL32
WIN16DRV_PatBlt( struct tagDC
*dc
, INT32 left
, INT32 top
,
252 INT32 width
, INT32 height
, DWORD rop
)
255 WIN16DRV_PDEVICE
*physDev
= (WIN16DRV_PDEVICE
*)dc
->physDev
;
258 bRet
= PRTDRV_StretchBlt( physDev
->segptrPDEVICE
, left
, top
, width
, height
, (SEGPTR
)NULL
, 0, 0, width
, height
,
259 PATCOPY
, physDev
->BrushInfo
, win16drv_SegPtr_DrawMode
, NULL
);
266 static INT32
WIN16DRV_Escape( DC
*dc
, INT32 nEscape
, INT32 cbInput
,
267 SEGPTR lpInData
, SEGPTR lpOutData
)
269 WIN16DRV_PDEVICE
*physDev
= (WIN16DRV_PDEVICE
*)dc
->physDev
;
272 /* We should really process the nEscape parameter, but for now just
273 pass it all to the driver */
274 if (dc
!= NULL
&& physDev
->segptrPDEVICE
!= 0)
278 case ENABLEPAIRKERNING
:
279 FIXME(win16drv
,"Escape: ENABLEPAIRKERNING ignored.\n");
282 case GETPAIRKERNTABLE
:
283 FIXME(win16drv
,"Escape: GETPAIRKERNTABLE ignored.\n");
287 /* FIXME: The AbortProc should be called:
288 - After every write to printer port or spool file
289 - Several times when no more disk space
290 - Before every metafile record when GDI does banding
293 /* save the callback address and call Control with hdc as lpInData */
294 HDC16
*seghdc
= SEGPTR_NEW(HDC16
);
296 dc
->w
.lpfnPrint
= (FARPROC16
)lpInData
;
297 nRet
= PRTDRV_Control(physDev
->segptrPDEVICE
, nEscape
,
298 SEGPTR_GET(seghdc
), lpOutData
);
305 LPPOINT16 newInData
= SEGPTR_NEW(POINT16
);
307 nRet
= PRTDRV_Control(physDev
->segptrPDEVICE
, nEscape
,
308 SEGPTR_GET(newInData
), lpOutData
);
309 SEGPTR_FREE(newInData
);
313 case GETEXTENDEDTEXTMETRICS
:
315 EXTTEXTDATA
*textData
= SEGPTR_NEW(EXTTEXTDATA
);
317 textData
->nSize
= cbInput
;
318 textData
->lpindata
= lpInData
;
319 textData
->lpFont
= SEGPTR_GET( physDev
->FontInfo
);
320 textData
->lpXForm
= win16drv_SegPtr_TextXForm
;
321 textData
->lpDrawMode
= win16drv_SegPtr_DrawMode
;
322 nRet
= PRTDRV_Control(physDev
->segptrPDEVICE
, nEscape
,
323 SEGPTR_GET(textData
), lpOutData
);
324 SEGPTR_FREE(textData
);
328 nRet
= PRTDRV_Control(physDev
->segptrPDEVICE
, nEscape
,
329 lpInData
, lpOutData
);
332 HDC32
*tmpHdc
= SEGPTR_NEW(HDC32
);
334 #define SETPRINTERDC SETABORTPROC
337 PRTDRV_Control(physDev
->segptrPDEVICE
, SETPRINTERDC
,
338 SEGPTR_GET(tmpHdc
), (SEGPTR
)NULL
);
343 nRet
= PRTDRV_Control(physDev
->segptrPDEVICE
, nEscape
,
344 lpInData
, lpOutData
);
349 WARN(win16drv
, "Escape(nEscape = %04x) - ???\n", nEscape
);