1 /*
2 * GDI 16-bit functions
3 *
4 * Copyright 2002 Alexandre Julliard
5 *
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.
10 *
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.
15 *
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
19 */
20
21 #include <stdarg.h>
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "wingdi.h"
26 #include "wownt32.h"
27 #include "wine/wingdi16.h"
28 #include "gdi_private.h"
29 #include "wine/debug.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
32
33 #define HGDIOBJ_32(handle16) ((HGDIOBJ)(ULONG_PTR)(handle16))
34 #define HGDIOBJ_16(handle32) ((HGDIOBJ16)(ULONG_PTR)(handle32))
35
36 struct callback16_info
37 {
38 FARPROC16 proc;
39 LPARAM param;
40 };
41
42 /* callback for LineDDA16 */
43 static void CALLBACK linedda_callback( INT x, INT y, LPARAM param )
44 {
45 const struct callback16_info *info = (struct callback16_info *)param;
46 WORD args[4];
47
48 args[3] = x;
49 args[2] = y;
50 args[1] = HIWORD(info->param);
51 args[0] = LOWORD(info->param);
52 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, NULL );
53 }
54
55 /* callback for EnumObjects16 */
56 static INT CALLBACK enum_pens_callback( void *ptr, LPARAM param )
57 {
58 const struct callback16_info *info = (struct callback16_info *)param;
59 LOGPEN *pen = ptr;
60 LOGPEN16 pen16;
61 SEGPTR segptr;
62 DWORD ret;
63 WORD args[4];
64
65 pen16.lopnStyle = pen->lopnStyle;
66 pen16.lopnWidth.x = pen->lopnWidth.x;
67 pen16.lopnWidth.y = pen->lopnWidth.y;
68 pen16.lopnColor = pen->lopnColor;
69 segptr = MapLS( &pen16 );
70 args[3] = SELECTOROF(segptr);
71 args[2] = OFFSETOF(segptr);
72 args[1] = HIWORD(info->param);
73 args[0] = LOWORD(info->param);
74 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
75 UnMapLS( segptr );
76 return LOWORD(ret);
77 }
78
79 /* callback for EnumObjects16 */
80 static INT CALLBACK enum_brushes_callback( void *ptr, LPARAM param )
81 {
82 const struct callback16_info *info = (struct callback16_info *)param;
83 LOGBRUSH *brush = ptr;
84 LOGBRUSH16 brush16;
85 SEGPTR segptr;
86 DWORD ret;
87 WORD args[4];
88
89 brush16.lbStyle = brush->lbStyle;
90 brush16.lbColor = brush->lbColor;
91 brush16.lbHatch = brush->lbHatch;
92 segptr = MapLS( &brush16 );
93 args[3] = SELECTOROF(segptr);
94 args[2] = OFFSETOF(segptr);
95 args[1] = HIWORD(info->param);
96 args[0] = LOWORD(info->param);
97 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
98 UnMapLS( segptr );
99 return ret;
100 }
101
102 /* convert a LOGFONT16 to a LOGFONTW */
103 static void logfont_16_to_W( const LOGFONT16 *font16, LPLOGFONTW font32 )
104 {
105 font32->lfHeight = font16->lfHeight;
106 font32->lfWidth = font16->lfWidth;
107 font32->lfEscapement = font16->lfEscapement;
108 font32->lfOrientation = font16->lfOrientation;
109 font32->lfWeight = font16->lfWeight;
110 font32->lfItalic = font16->lfItalic;
111 font32->lfUnderline = font16->lfUnderline;
112 font32->lfStrikeOut = font16->lfStrikeOut;
113 font32->lfCharSet = font16->lfCharSet;
114 font32->lfOutPrecision = font16->lfOutPrecision;
115 font32->lfClipPrecision = font16->lfClipPrecision;
116 font32->lfQuality = font16->lfQuality;
117 font32->lfPitchAndFamily = font16->lfPitchAndFamily;
118 MultiByteToWideChar( CP_ACP, 0, font16->lfFaceName, -1, font32->lfFaceName, LF_FACESIZE );
119 font32->lfFaceName[LF_FACESIZE-1] = 0;
120 }
121
122 /* convert a LOGFONTW to a LOGFONT16 */
123 static void logfont_W_to_16( const LOGFONTW* font32, LPLOGFONT16 font16 )
124 {
125 font16->lfHeight = font32->lfHeight;
126 font16->lfWidth = font32->lfWidth;
127 font16->lfEscapement = font32->lfEscapement;
128 font16->lfOrientation = font32->lfOrientation;
129 font16->lfWeight = font32->lfWeight;
130 font16->lfItalic = font32->lfItalic;
131 font16->lfUnderline = font32->lfUnderline;
132 font16->lfStrikeOut = font32->lfStrikeOut;
133 font16->lfCharSet = font32->lfCharSet;
134 font16->lfOutPrecision = font32->lfOutPrecision;
135 font16->lfClipPrecision = font32->lfClipPrecision;
136 font16->lfQuality = font32->lfQuality;
137 font16->lfPitchAndFamily = font32->lfPitchAndFamily;
138 WideCharToMultiByte( CP_ACP, 0, font32->lfFaceName, -1, font16->lfFaceName, LF_FACESIZE, NULL, NULL );
139 font16->lfFaceName[LF_FACESIZE-1] = 0;
140 }
141
142 /* convert a ENUMLOGFONTEXW to a ENUMLOGFONTEX16 */
143 static void enumlogfontex_W_to_16( const ENUMLOGFONTEXW *fontW,
144 LPENUMLOGFONTEX16 font16 )
145 {
146 logfont_W_to_16( (const LOGFONTW *)fontW, (LPLOGFONT16)font16);
147
148 WideCharToMultiByte( CP_ACP, 0, fontW->elfFullName, -1,
149 (LPSTR) font16->elfFullName, LF_FULLFACESIZE, NULL, NULL );
150 font16->elfFullName[LF_FULLFACESIZE-1] = '\0';
151 WideCharToMultiByte( CP_ACP, 0, fontW->elfStyle, -1,
152 (LPSTR) font16->elfStyle, LF_FACESIZE, NULL, NULL );
153 font16->elfStyle[LF_FACESIZE-1] = '\0';
154 WideCharToMultiByte( CP_ACP, 0, fontW->elfScript, -1,
155 (LPSTR) font16->elfScript, LF_FACESIZE, NULL, NULL );
156 font16->elfScript[LF_FACESIZE-1] = '\0';
157 }
158
159 /* convert a NEWTEXTMETRICEXW to a NEWTEXTMETRICEX16 */
160 static void newtextmetricex_W_to_16( const NEWTEXTMETRICEXW *ptmW,
161 LPNEWTEXTMETRICEX16 ptm16 )
162 {
163 ptm16->ntmTm.tmHeight = ptmW->ntmTm.tmHeight;
164 ptm16->ntmTm.tmAscent = ptmW->ntmTm.tmAscent;
165 ptm16->ntmTm.tmDescent = ptmW->ntmTm.tmDescent;
166 ptm16->ntmTm.tmInternalLeading = ptmW->ntmTm.tmInternalLeading;
167 ptm16->ntmTm.tmExternalLeading = ptmW->ntmTm.tmExternalLeading;
168 ptm16->ntmTm.tmAveCharWidth = ptmW->ntmTm.tmAveCharWidth;
169 ptm16->ntmTm.tmMaxCharWidth = ptmW->ntmTm.tmMaxCharWidth;
170 ptm16->ntmTm.tmWeight = ptmW->ntmTm.tmWeight;
171 ptm16->ntmTm.tmOverhang = ptmW->ntmTm.tmOverhang;
172 ptm16->ntmTm.tmDigitizedAspectX = ptmW->ntmTm.tmDigitizedAspectX;
173 ptm16->ntmTm.tmDigitizedAspectY = ptmW->ntmTm.tmDigitizedAspectY;
174 ptm16->ntmTm.tmFirstChar = ptmW->ntmTm.tmFirstChar > 255 ? 255 : ptmW->ntmTm.tmFirstChar;
175 ptm16->ntmTm.tmLastChar = ptmW->ntmTm.tmLastChar > 255 ? 255 : ptmW->ntmTm.tmLastChar;
176 ptm16->ntmTm.tmDefaultChar = ptmW->ntmTm.tmDefaultChar > 255 ? 255 : ptmW->ntmTm.tmDefaultChar;
177 ptm16->ntmTm.tmBreakChar = ptmW->ntmTm.tmBreakChar > 255 ? 255 : ptmW->ntmTm.tmBreakChar;
178 ptm16->ntmTm.tmItalic = ptmW->ntmTm.tmItalic;
179 ptm16->ntmTm.tmUnderlined = ptmW->ntmTm.tmUnderlined;
180 ptm16->ntmTm.tmStruckOut = ptmW->ntmTm.tmStruckOut;
181 ptm16->ntmTm.tmPitchAndFamily = ptmW->ntmTm.tmPitchAndFamily;
182 ptm16->ntmTm.tmCharSet = ptmW->ntmTm.tmCharSet;
183 ptm16->ntmTm.ntmFlags = ptmW->ntmTm.ntmFlags;
184 ptm16->ntmTm.ntmSizeEM = ptmW->ntmTm.ntmSizeEM;
185 ptm16->ntmTm.ntmCellHeight = ptmW->ntmTm.ntmCellHeight;
186 ptm16->ntmTm.ntmAvgWidth = ptmW->ntmTm.ntmAvgWidth;
187 ptm16->ntmFontSig = ptmW->ntmFontSig;
188 }
189
190 /*
191 * callback for EnumFontFamiliesEx16
192 * Note: plf is really an ENUMLOGFONTEXW, and ptm is a NEWTEXTMETRICEXW.
193 * We have to use other types because of the FONTENUMPROCW definition.
194 */
195 static INT CALLBACK enum_font_callback( const LOGFONTW *plf,
196 const TEXTMETRICW *ptm, DWORD fType,
197 LPARAM param )
198 {
199 const struct callback16_info *info = (struct callback16_info *)param;
200 ENUMLOGFONTEX16 elfe16;
201 NEWTEXTMETRICEX16 ntm16;
202 SEGPTR segelfe16;
203 SEGPTR segntm16;
204 WORD args[7];
205 DWORD ret;
206
207 enumlogfontex_W_to_16((const ENUMLOGFONTEXW *)plf, &elfe16);
208 newtextmetricex_W_to_16((const NEWTEXTMETRICEXW *)ptm, &ntm16);
209 segelfe16 = MapLS( &elfe16 );
210 segntm16 = MapLS( &ntm16 );
211 args[6] = SELECTOROF(segelfe16);
212 args[5] = OFFSETOF(segelfe16);
213 args[4] = SELECTOROF(segntm16);
214 args[3] = OFFSETOF(segntm16);
215 args[2] = fType;
216 args[1] = HIWORD(info->param);
217 args[0] = LOWORD(info->param);
218
219 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
220 UnMapLS( segelfe16 );
221 UnMapLS( segntm16 );
222 return LOWORD(ret);
223 }
224
225
226 /***********************************************************************
227 * SetBkColor (GDI.1)
228 */
229 COLORREF WINAPI SetBkColor16( HDC16 hdc, COLORREF color )
230 {
231 return SetBkColor( HDC_32(hdc), color );
232 }
233
234
235 /***********************************************************************
236 * SetBkMode (GDI.2)
237 */
238 INT16 WINAPI SetBkMode16( HDC16 hdc, INT16 mode )
239 {
240 return SetBkMode( HDC_32(hdc), mode );
241 }
242
243
244 /***********************************************************************
245 * SetMapMode (GDI.3)
246 */
247 INT16 WINAPI SetMapMode16( HDC16 hdc, INT16 mode )
248 {
249 return SetMapMode( HDC_32(hdc), mode );
250 }
251
252
253 /***********************************************************************
254 * SetROP2 (GDI.4)
255 */
256 INT16 WINAPI SetROP216( HDC16 hdc, INT16 mode )
257 {
258 return SetROP2( HDC_32(hdc), mode );
259 }
260
261
262 /***********************************************************************
263 * SetRelAbs (GDI.5)
264 */
265 INT16 WINAPI SetRelAbs16( HDC16 hdc, INT16 mode )
266 {
267 return SetRelAbs( HDC_32(hdc), mode );
268 }
269
270
271 /***********************************************************************
272 * SetPolyFillMode (GDI.6)
273 */
274 INT16 WINAPI SetPolyFillMode16( HDC16 hdc, INT16 mode )
275 {
276 return SetPolyFillMode( HDC_32(hdc), mode );
277 }
278
279
280 /***********************************************************************
281 * SetStretchBltMode (GDI.7)
282 */
283 INT16 WINAPI SetStretchBltMode16( HDC16 hdc, INT16 mode )
284 {
285 return SetStretchBltMode( HDC_32(hdc), mode );
286 }
287
288
289 /***********************************************************************
290 * SetTextCharacterExtra (GDI.8)
291 */
292 INT16 WINAPI SetTextCharacterExtra16( HDC16 hdc, INT16 extra )
293 {
294 return SetTextCharacterExtra( HDC_32(hdc), extra );
295 }
296
297
298 /***********************************************************************
299 * SetTextColor (GDI.9)
300 */
301 COLORREF WINAPI SetTextColor16( HDC16 hdc, COLORREF color )
302 {
303 return SetTextColor( HDC_32(hdc), color );
304 }
305
306
307 /***********************************************************************
308 * SetTextJustification (GDI.10)
309 */
310 INT16 WINAPI SetTextJustification16( HDC16 hdc, INT16 extra, INT16 breaks )
311 {
312 return SetTextJustification( HDC_32(hdc), extra, breaks );
313 }
314
315
316 /***********************************************************************
317 * SetWindowOrg (GDI.11)
318 */
319 DWORD WINAPI SetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
320 {
321 POINT pt;
322 if (!SetWindowOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
323 return MAKELONG( pt.x, pt.y );
324 }
325
326
327 /***********************************************************************
328 * SetWindowExt (GDI.12)
329 */
330 DWORD WINAPI SetWindowExt16( HDC16 hdc, INT16 x, INT16 y )
331 {
332 SIZE size;
333 if (!SetWindowExtEx( HDC_32(hdc), x, y, &size )) return 0;
334 return MAKELONG( size.cx, size.cy );
335 }
336
337
338 /***********************************************************************
339 * SetViewportOrg (GDI.13)
340 */
341 DWORD WINAPI SetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
342 {
343 POINT pt;
344 if (!SetViewportOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
345 return MAKELONG( pt.x, pt.y );
346 }
347
348
349 /***********************************************************************
350 * SetViewportExt (GDI.14)
351 */
352 DWORD WINAPI SetViewportExt16( HDC16 hdc, INT16 x, INT16 y )
353 {
354 SIZE size;
355 if (!SetViewportExtEx( HDC_32(hdc), x, y, &size )) return 0;
356 return MAKELONG( size.cx, size.cy );
357 }
358
359
360 /***********************************************************************
361 * OffsetWindowOrg (GDI.15)
362 */
363 DWORD WINAPI OffsetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
364 {
365 POINT pt;
366 if (!OffsetWindowOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
367 return MAKELONG( pt.x, pt.y );
368 }
369
370
371 /***********************************************************************
372 * ScaleWindowExt (GDI.16)
373 */
374 DWORD WINAPI ScaleWindowExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
375 INT16 yNum, INT16 yDenom )
376 {
377 SIZE size;
378 if (!ScaleWindowExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom, &size ))
379 return FALSE;
380 return MAKELONG( size.cx, size.cy );
381 }
382
383
384 /***********************************************************************
385 * OffsetViewportOrg (GDI.17)
386 */
387 DWORD WINAPI OffsetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
388 {
389 POINT pt;
390 if (!OffsetViewportOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
391 return MAKELONG( pt.x, pt.y );
392 }
393
394
395 /***********************************************************************
396 * ScaleViewportExt (GDI.18)
397 */
398 DWORD WINAPI ScaleViewportExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
399 INT16 yNum, INT16 yDenom )
400 {
401 SIZE size;
402 if (!ScaleViewportExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom, &size ))
403 return FALSE;
404 return MAKELONG( size.cx, size.cy );
405 }
406
407
408 /***********************************************************************
409 * LineTo (GDI.19)
410 */
411 BOOL16 WINAPI LineTo16( HDC16 hdc, INT16 x, INT16 y )
412 {
413 return LineTo( HDC_32(hdc), x, y );
414 }
415
416
417 /***********************************************************************
418 * MoveTo (GDI.20)
419 */
420 DWORD WINAPI MoveTo16( HDC16 hdc, INT16 x, INT16 y )
421 {
422 POINT pt;
423
424 if (!MoveToEx( HDC_32(hdc), x, y, &pt )) return 0;
425 return MAKELONG(pt.x,pt.y);
426 }
427
428
429 /***********************************************************************
430 * ExcludeClipRect (GDI.21)
431 */
432 INT16 WINAPI ExcludeClipRect16( HDC16 hdc, INT16 left, INT16 top,
433 INT16 right, INT16 bottom )
434 {
435 return ExcludeClipRect( HDC_32(hdc), left, top, right, bottom );
436 }
437
438
439 /***********************************************************************
440 * IntersectClipRect (GDI.22)
441 */
442 INT16 WINAPI IntersectClipRect16( HDC16 hdc, INT16 left, INT16 top,
443 INT16 right, INT16 bottom )
444 {
445 return IntersectClipRect( HDC_32(hdc), left, top, right, bottom );
446 }
447
448
449 /***********************************************************************
450 * Arc (GDI.23)
451 */
452 BOOL16 WINAPI Arc16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
453 INT16 bottom, INT16 xstart, INT16 ystart,
454 INT16 xend, INT16 yend )
455 {
456 return Arc( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
457 }
458
459
460 /***********************************************************************
461 * Ellipse (GDI.24)
462 */
463 BOOL16 WINAPI Ellipse16( HDC16 hdc, INT16 left, INT16 top,
464 INT16 right, INT16 bottom )
465 {
466 return Ellipse( HDC_32(hdc), left, top, right, bottom );
467 }
468
469
470 /**********************************************************************
471 * FloodFill (GDI.25)
472 */
473 BOOL16 WINAPI FloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
474 {
475 return ExtFloodFill( HDC_32(hdc), x, y, color, FLOODFILLBORDER );
476 }
477
478
479 /***********************************************************************
480 * Pie (GDI.26)
481 */
482 BOOL16 WINAPI Pie16( HDC16 hdc, INT16 left, INT16 top,
483 INT16 right, INT16 bottom, INT16 xstart, INT16 ystart,
484 INT16 xend, INT16 yend )
485 {
486 return Pie( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
487 }
488
489
490 /***********************************************************************
491 * Rectangle (GDI.27)
492 */
493 BOOL16 WINAPI Rectangle16( HDC16 hdc, INT16 left, INT16 top,
494 INT16 right, INT16 bottom )
495 {
496 return Rectangle( HDC_32(hdc), left, top, right, bottom );
497 }
498
499
500 /***********************************************************************
501 * RoundRect (GDI.28)
502 */
503 BOOL16 WINAPI RoundRect16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
504 INT16 bottom, INT16 ell_width, INT16 ell_height )
505 {
506 return RoundRect( HDC_32(hdc), left, top, right, bottom, ell_width, ell_height );
507 }
508
509
510 /***********************************************************************
511 * PatBlt (GDI.29)
512 */
513 BOOL16 WINAPI PatBlt16( HDC16 hdc, INT16 left, INT16 top,
514 INT16 width, INT16 height, DWORD rop)
515 {
516 return PatBlt( HDC_32(hdc), left, top, width, height, rop );
517 }
518
519
520 /***********************************************************************
521 * SaveDC (GDI.30)
522 */
523 INT16 WINAPI SaveDC16( HDC16 hdc )
524 {
525 return SaveDC( HDC_32(hdc) );
526 }
527
528
529 /***********************************************************************
530 * SetPixel (GDI.31)
531 */
532 COLORREF WINAPI SetPixel16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
533 {
534 return SetPixel( HDC_32(hdc), x, y, color );
535 }
536
537
538 /***********************************************************************
539 * OffsetClipRgn (GDI.32)
540 */
541 INT16 WINAPI OffsetClipRgn16( HDC16 hdc, INT16 x, INT16 y )
542 {
543 return OffsetClipRgn( HDC_32(hdc), x, y );
544 }
545
546
547 /***********************************************************************
548 * TextOut (GDI.33)
549 */
550 BOOL16 WINAPI TextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR str, INT16 count )
551 {
552 return TextOutA( HDC_32(hdc), x, y, str, count );
553 }
554
555
556 /***********************************************************************
557 * BitBlt (GDI.34)
558 */
559 BOOL16 WINAPI BitBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst, INT16 width,
560 INT16 height, HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
561 DWORD rop )
562 {
563 return BitBlt( HDC_32(hdcDst), xDst, yDst, width, height, HDC_32(hdcSrc), xSrc, ySrc, rop );
564 }
565
566
567 /***********************************************************************
568 * StretchBlt (GDI.35)
569 */
570 BOOL16 WINAPI StretchBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst,
571 INT16 widthDst, INT16 heightDst,
572 HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
573 INT16 widthSrc, INT16 heightSrc, DWORD rop )
574 {
575 return StretchBlt( HDC_32(hdcDst), xDst, yDst, widthDst, heightDst,
576 HDC_32(hdcSrc), xSrc, ySrc, widthSrc, heightSrc, rop );
577 }
578
579
580 /**********************************************************************
581 * Polygon (GDI.36)
582 */
583 BOOL16 WINAPI Polygon16( HDC16 hdc, const POINT16* pt, INT16 count )
584 {
585 register int i;
586 BOOL ret;
587 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, count*sizeof(POINT) );
588
589 if (!pt32) return FALSE;
590 for (i=count;i--;)
591 {
592 pt32[i].x = pt[i].x;
593 pt32[i].y = pt[i].y;
594 }
595 ret = Polygon(HDC_32(hdc),pt32,count);
596 HeapFree( GetProcessHeap(), 0, pt32 );
597 return ret;
598 }
599
600
601 /**********************************************************************
602 * Polyline (GDI.37)
603 */
604 BOOL16 WINAPI Polyline16( HDC16 hdc, const POINT16* pt, INT16 count )
605 {
606 register int i;
607 BOOL16 ret;
608 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, count*sizeof(POINT) );
609
610 if (!pt32) return FALSE;
611 for (i=count;i--;)
612 {
613 pt32[i].x = pt[i].x;
614 pt32[i].y = pt[i].y;
615 }
616 ret = Polyline(HDC_32(hdc),pt32,count);
617 HeapFree( GetProcessHeap(), 0, pt32 );
618 return ret;
619 }
620
621
622 /***********************************************************************
623 * Escape (GDI.38)
624 */
625 INT16 WINAPI Escape16( HDC16 hdc, INT16 escape, INT16 in_count, SEGPTR in_data, LPVOID out_data )
626 {
627 INT ret;
628
629 switch(escape)
630 {
631 /* Escape(hdc,CLIP_TO_PATH,LPINT16,NULL) */
632 /* Escape(hdc,DRAFTMODE,LPINT16,NULL) */
633 /* Escape(hdc,ENUMPAPERBINS,LPINT16,LPSTR); */
634 /* Escape(hdc,EPSPRINTING,LPINT16,NULL) */
635 /* Escape(hdc,EXT_DEVICE_CAPS,LPINT16,LPDWORD) */
636 /* Escape(hdc,GETCOLORTABLE,LPINT16,LPDWORD) */
637 /* Escape(hdc,MOUSETRAILS,LPINT16,NULL) */
638 /* Escape(hdc,POSTSCRIPT_IGNORE,LPINT16,NULL) */
639 /* Escape(hdc,QUERYESCSUPPORT,LPINT16,NULL) */
640 /* Escape(hdc,SET_ARC_DIRECTION,LPINT16,NULL) */
641 /* Escape(hdc,SET_POLY_MODE,LPINT16,NULL) */
642 /* Escape(hdc,SET_SCREEN_ANGLE,LPINT16,NULL) */
643 /* Escape(hdc,SET_SPREAD,LPINT16,NULL) */
644 case CLIP_TO_PATH:
645 case DRAFTMODE:
646 case ENUMPAPERBINS:
647 case EPSPRINTING:
648 case EXT_DEVICE_CAPS:
649 case GETCOLORTABLE:
650 case MOUSETRAILS:
651 case POSTSCRIPT_IGNORE:
652 case QUERYESCSUPPORT:
653 case SET_ARC_DIRECTION:
654 case SET_POLY_MODE:
655 case SET_SCREEN_ANGLE:
656 case SET_SPREAD:
657 {
658 INT16 *ptr = MapSL(in_data);
659 INT data = *ptr;
660 return Escape( HDC_32(hdc), escape, sizeof(data), (LPCSTR)&data, out_data );
661 }
662
663 /* Escape(hdc,ENABLEDUPLEX,LPUINT16,NULL) */
664 case ENABLEDUPLEX:
665 {
666 UINT16 *ptr = MapSL(in_data);
667 UINT data = *ptr;
668 return Escape( HDC_32(hdc), escape, sizeof(data), (LPCSTR)&data, NULL );
669 }
670
671 /* Escape(hdc,GETPHYSPAGESIZE,NULL,LPPOINT16) */
672 /* Escape(hdc,GETPRINTINGOFFSET,NULL,LPPOINT16) */
673 /* Escape(hdc,GETSCALINGFACTOR,NULL,LPPOINT16) */
674 case GETPHYSPAGESIZE:
675 case GETPRINTINGOFFSET:
676 case GETSCALINGFACTOR:
677 {
678 POINT16 *ptr = out_data;
679 POINT pt32;
680 ret = Escape( HDC_32(hdc), escape, 0, NULL, &pt32 );
681 ptr->x = pt32.x;
682 ptr->y = pt32.y;
683 return ret;
684 }
685
686 /* Escape(hdc,ENABLEPAIRKERNING,LPINT16,LPINT16); */
687 /* Escape(hdc,ENABLERELATIVEWIDTHS,LPINT16,LPINT16); */
688 /* Escape(hdc,SETCOPYCOUNT,LPINT16,LPINT16) */
689 /* Escape(hdc,SETKERNTRACK,LPINT16,LPINT16) */
690 /* Escape(hdc,SETLINECAP,LPINT16,LPINT16) */
691 /* Escape(hdc,SETLINEJOIN,LPINT16,LPINT16) */
692 /* Escape(hdc,SETMITERLIMIT,LPINT16,LPINT16) */
693 case ENABLEPAIRKERNING:
694 case ENABLERELATIVEWIDTHS:
695 case SETCOPYCOUNT:
696 case SETKERNTRACK:
697 case SETLINECAP:
698 case SETLINEJOIN:
699 case SETMITERLIMIT:
700 {
701 INT16 *new = MapSL(in_data);
702 INT16 *old = out_data;
703 INT out, in = *new;
704 ret = Escape( HDC_32(hdc), escape, sizeof(in), (LPCSTR)&in, &out );
705 *old = out;
706 return ret;
707 }
708
709 /* Escape(hdc,SETABORTPROC,ABORTPROC,NULL); */
710 case SETABORTPROC:
711 return SetAbortProc16( hdc, (ABORTPROC16)in_data );
712
713 /* Escape(hdc,STARTDOC,LPSTR,LPDOCINFO16);
714 * lpvOutData is actually a pointer to the DocInfo structure and used as
715 * a second input parameter */
716 case STARTDOC:
717 if (out_data)
718 {
719 ret = StartDoc16( hdc, out_data );
720 if (ret > 0) ret = StartPage( HDC_32(hdc) );
721 return ret;
722 }
723 return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), NULL );
724
725 /* Escape(hdc,SET_BOUNDS,LPRECT16,NULL); */
726 /* Escape(hdc,SET_CLIP_BOX,LPRECT16,NULL); */
727 case SET_BOUNDS:
728 case SET_CLIP_BOX:
729 {
730 RECT16 *rc16 = MapSL(in_data);
731 RECT rc;
732 rc.left = rc16->left;
733 rc.top = rc16->top;
734 rc.right = rc16->right;
735 rc.bottom = rc16->bottom;
736 return Escape( HDC_32(hdc), escape, sizeof(rc), (LPCSTR)&rc, NULL );
737 }
738
739 /* Escape(hdc,NEXTBAND,NULL,LPRECT16); */
740 case NEXTBAND:
741 {
742 RECT rc;
743 RECT16 *rc16 = out_data;
744 ret = Escape( HDC_32(hdc), escape, 0, NULL, &rc );
745 rc16->left = rc.left;
746 rc16->top = rc.top;
747 rc16->right = rc.right;
748 rc16->bottom = rc.bottom;
749 return ret;
750 }
751 /* Escape(hdc,DRAWPATTERNRECT,PRECT_STRUCT*,NULL); */
752 case DRAWPATTERNRECT:
753 {
754 DRAWPATRECT pr;
755 DRAWPATRECT16 *pr16 = (DRAWPATRECT16*)MapSL(in_data);
756
757 pr.ptPosition.x = pr16->ptPosition.x;
758 pr.ptPosition.y = pr16->ptPosition.y;
759 pr.ptSize.x = pr16->ptSize.x;
760 pr.ptSize.y = pr16->ptSize.y;
761 pr.wStyle = pr16->wStyle;
762 pr.wPattern = pr16->wPattern;
763 return Escape( HDC_32(hdc), escape, sizeof(pr), (LPCSTR)&pr, NULL );
764 }
765
766 /* Escape(hdc,ABORTDOC,NULL,NULL); */
767 /* Escape(hdc,BANDINFO,BANDINFOSTRUCT*,BANDINFOSTRUCT*); */
768 /* Escape(hdc,BEGIN_PATH,NULL,NULL); */
769 /* Escape(hdc,ENDDOC,NULL,NULL); */
770 /* Escape(hdc,END_PATH,PATHINFO,NULL); */
771 /* Escape(hdc,EXTTEXTOUT,EXTTEXT_STRUCT*,NULL); */
772 /* Escape(hdc,FLUSHOUTPUT,NULL,NULL); */
773 /* Escape(hdc,GETFACENAME,NULL,LPSTR); */
774 /* Escape(hdc,GETPAIRKERNTABLE,NULL,KERNPAIR*); */
775 /* Escape(hdc,GETSETPAPERBINS,BinInfo*,BinInfo*); */
776 /* Escape(hdc,GETSETPRINTORIENT,ORIENT*,NULL); */
777 /* Escape(hdc,GETSETSCREENPARAMS,SCREENPARAMS*,SCREENPARAMS*); */
778 /* Escape(hdc,GETTECHNOLOGY,NULL,LPSTR); */
779 /* Escape(hdc,GETTRACKKERNTABLE,NULL,KERNTRACK*); */
780 /* Escape(hdc,MFCOMMENT,LPSTR,NULL); */
781 /* Escape(hdc,NEWFRAME,NULL,NULL); */
782 /* Escape(hdc,PASSTHROUGH,LPSTR,NULL); */
783 /* Escape(hdc,RESTORE_CTM,NULL,NULL); */
784 /* Escape(hdc,SAVE_CTM,NULL,NULL); */
785 /* Escape(hdc,SETALLJUSTVALUES,EXTTEXTDATA*,NULL); */
786 /* Escape(hdc,SETCOLORTABLE,COLORTABLE_STRUCT*,LPDWORD); */
787 /* Escape(hdc,SET_BACKGROUND_COLOR,LPDWORD,LPDWORD); */
788 /* Escape(hdc,TRANSFORM_CTM,LPSTR,NULL); */
789 case ABORTDOC:
790 case BANDINFO:
791 case BEGIN_PATH:
792 case ENDDOC:
793 case END_PATH:
794 case EXTTEXTOUT:
795 case FLUSHOUTPUT:
796 case GETFACENAME:
797 case GETPAIRKERNTABLE:
798 case GETSETPAPERBINS:
799 case GETSETPRINTORIENT:
800 case GETSETSCREENPARAMS:
801 case GETTECHNOLOGY:
802 case GETTRACKKERNTABLE:
803 case MFCOMMENT:
804 case NEWFRAME:
805 case PASSTHROUGH:
806 case RESTORE_CTM:
807 case SAVE_CTM:
808 case SETALLJUSTVALUES:
809 case SETCOLORTABLE:
810 case SET_BACKGROUND_COLOR:
811 case TRANSFORM_CTM:
812 /* pass it unmodified to the 32-bit function */
813 return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), out_data );
814
815 /* Escape(hdc,ENUMPAPERMETRICS,LPINT16,LPRECT16); */
816 /* Escape(hdc,GETEXTENDEDTEXTMETRICS,LPUINT16,EXTTEXTMETRIC*); */
817 /* Escape(hdc,GETEXTENTTABLE,LPSTR,LPINT16); */
818 /* Escape(hdc,GETSETPAPERMETRICS,LPRECT16,LPRECT16); */
819 /* Escape(hdc,GETVECTORBRUSHSIZE,LPLOGBRUSH16,LPPOINT16); */
820 /* Escape(hdc,GETVECTORPENSIZE,LPLOGPEN16,LPPOINT16); */
821 case ENUMPAPERMETRICS:
822 case GETEXTENDEDTEXTMETRICS:
823 case GETEXTENTTABLE:
824 case GETSETPAPERMETRICS:
825 case GETVECTORBRUSHSIZE:
826 case GETVECTORPENSIZE:
827 default:
828 FIXME("unknown/unsupported 16-bit escape %x (%d,%p,%p\n",
829 escape, in_count, MapSL(in_data), out_data );
830 return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), out_data );
831 }
832 }
833
834
835 /***********************************************************************
836 * RestoreDC (GDI.39)
837 */
838 BOOL16 WINAPI RestoreDC16( HDC16 hdc, INT16 level )
839 {
840 return RestoreDC( HDC_32(hdc), level );
841 }
842
843
844 /***********************************************************************
845 * FillRgn (GDI.40)
846 */
847 BOOL16 WINAPI FillRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush )
848 {
849 return FillRgn( HDC_32(hdc), HRGN_32(hrgn), HBRUSH_32(hbrush) );
850 }
851
852
853 /***********************************************************************
854 * FrameRgn (GDI.41)
855 */
856 BOOL16 WINAPI FrameRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush,
857 INT16 nWidth, INT16 nHeight )
858 {
859 return FrameRgn( HDC_32(hdc), HRGN_32(hrgn), HBRUSH_32(hbrush), nWidth, nHeight );
860 }
861
862
863 /***********************************************************************
864 * InvertRgn (GDI.42)
865 */
866 BOOL16 WINAPI InvertRgn16( HDC16 hdc, HRGN16 hrgn )
867 {
868 return InvertRgn( HDC_32(hdc), HRGN_32(hrgn) );
869 }
870
871
872 /***********************************************************************
873 * PaintRgn (GDI.43)
874 */
875 BOOL16 WINAPI PaintRgn16( HDC16 hdc, HRGN16 hrgn )
876 {
877 return PaintRgn( HDC_32(hdc), HRGN_32(hrgn) );
878 }
879
880
881 /***********************************************************************
882 * SelectClipRgn (GDI.44)
883 */
884 INT16 WINAPI SelectClipRgn16( HDC16 hdc, HRGN16 hrgn )
885 {
886 return SelectClipRgn( HDC_32(hdc), HRGN_32(hrgn) );
887 }
888
889
890 /***********************************************************************
891 * SelectObject (GDI.45)
892 */
893 HGDIOBJ16 WINAPI SelectObject16( HDC16 hdc, HGDIOBJ16 handle )
894 {
895 return HGDIOBJ_16( SelectObject( HDC_32(hdc), HGDIOBJ_32(handle) ) );
896 }
897
898
899 /***********************************************************************
900 * CombineRgn (GDI.47)
901 */
902 INT16 WINAPI CombineRgn16(HRGN16 hDest, HRGN16 hSrc1, HRGN16 hSrc2, INT16 mode)
903 {
904 return CombineRgn( HRGN_32(hDest), HRGN_32(hSrc1), HRGN_32(hSrc2), mode );
905 }
906
907
908 /***********************************************************************
909 * CreateBitmap (GDI.48)
910 */
911 HBITMAP16 WINAPI CreateBitmap16( INT16 width, INT16 height, UINT16 planes,
912 UINT16 bpp, LPCVOID bits )
913 {
914 return HBITMAP_16( CreateBitmap( width, height, planes & 0xff, bpp & 0xff, bits ) );
915 }
916
917
918 /***********************************************************************
919 * CreateBitmapIndirect (GDI.49)
920 */
921 HBITMAP16 WINAPI CreateBitmapIndirect16( const BITMAP16 * bmp )
922 {
923 return CreateBitmap16( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
924 bmp->bmBitsPixel, MapSL( bmp->bmBits ) );
925 }
926
927
928 /***********************************************************************
929 * CreateBrushIndirect (GDI.50)