Moved spooler configuration to HKCU\Software\Wine\Printing\Spooler.
[wine] / dlls / gdi / gdi16.c
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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.h"
29 #include "gdi_private.h"
30 #include "wine/debug.h"
31
32 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
33
34 #define HGDIOBJ_32(handle16)    ((HGDIOBJ)(ULONG_PTR)(handle16))
35 #define HGDIOBJ_16(handle32)    ((HGDIOBJ16)(ULONG_PTR)(handle32))
36
37 struct callback16_info
38 {
39     FARPROC16 proc;
40     LPARAM    param;
41 };
42
43 /* callback for LineDDA16 */
44 static void CALLBACK linedda_callback( INT x, INT y, LPARAM param )
45 {
46     const struct callback16_info *info = (struct callback16_info *)param;
47     WORD args[4];
48
49     args[3] = x;
50     args[2] = y;
51     args[1] = HIWORD(info->param);
52     args[0] = LOWORD(info->param);
53     WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, NULL );
54 }
55
56 /* callback for EnumObjects16 */
57 static INT CALLBACK enum_pens_callback( void *ptr, LPARAM param )
58 {
59     const struct callback16_info *info = (struct callback16_info *)param;
60     LOGPEN *pen = ptr;
61     LOGPEN16 pen16;
62     SEGPTR segptr;
63     DWORD ret;
64     WORD args[4];
65
66     pen16.lopnStyle   = pen->lopnStyle;
67     pen16.lopnWidth.x = pen->lopnWidth.x;
68     pen16.lopnWidth.y = pen->lopnWidth.y;
69     pen16.lopnColor   = pen->lopnColor;
70     segptr = MapLS( &pen16 );
71     args[3] = SELECTOROF(segptr);
72     args[2] = OFFSETOF(segptr);
73     args[1] = HIWORD(info->param);
74     args[0] = LOWORD(info->param);
75     WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
76     UnMapLS( segptr );
77     return LOWORD(ret);
78 }
79
80 /* callback for EnumObjects16 */
81 static INT CALLBACK enum_brushes_callback( void *ptr, LPARAM param )
82 {
83     const struct callback16_info *info = (struct callback16_info *)param;
84     LOGBRUSH *brush = ptr;
85     LOGBRUSH16 brush16;
86     SEGPTR segptr;
87     DWORD ret;
88     WORD args[4];
89
90     brush16.lbStyle = brush->lbStyle;
91     brush16.lbColor = brush->lbColor;
92     brush16.lbHatch = brush->lbHatch;
93     segptr = MapLS( &brush16 );
94     args[3] = SELECTOROF(segptr);
95     args[2] = OFFSETOF(segptr);
96     args[1] = HIWORD(info->param);
97     args[0] = LOWORD(info->param);
98     WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
99     UnMapLS( segptr );
100     return ret;
101 }
102
103 /* convert a LOGFONT16 to a LOGFONTW */
104 static void logfont_16_to_W( const LOGFONT16 *font16, LPLOGFONTW font32 )
105 {
106     font32->lfHeight = font16->lfHeight;
107     font32->lfWidth = font16->lfWidth;
108     font32->lfEscapement = font16->lfEscapement;
109     font32->lfOrientation = font16->lfOrientation;
110     font32->lfWeight = font16->lfWeight;
111     font32->lfItalic = font16->lfItalic;
112     font32->lfUnderline = font16->lfUnderline;
113     font32->lfStrikeOut = font16->lfStrikeOut;
114     font32->lfCharSet = font16->lfCharSet;
115     font32->lfOutPrecision = font16->lfOutPrecision;
116     font32->lfClipPrecision = font16->lfClipPrecision;
117     font32->lfQuality = font16->lfQuality;
118     font32->lfPitchAndFamily = font16->lfPitchAndFamily;
119     MultiByteToWideChar( CP_ACP, 0, font16->lfFaceName, -1, font32->lfFaceName, LF_FACESIZE );
120     font32->lfFaceName[LF_FACESIZE-1] = 0;
121 }
122
123
124 /***********************************************************************
125  *           SetBkColor    (GDI.1)
126  */
127 COLORREF WINAPI SetBkColor16( HDC16 hdc, COLORREF color )
128 {
129     return SetBkColor( HDC_32(hdc), color );
130 }
131
132
133 /***********************************************************************
134  *              SetBkMode (GDI.2)
135  */
136 INT16 WINAPI SetBkMode16( HDC16 hdc, INT16 mode )
137 {
138     return SetBkMode( HDC_32(hdc), mode );
139 }
140
141
142 /***********************************************************************
143  *           SetMapMode    (GDI.3)
144  */
145 INT16 WINAPI SetMapMode16( HDC16 hdc, INT16 mode )
146 {
147     return SetMapMode( HDC_32(hdc), mode );
148 }
149
150
151 /***********************************************************************
152  *              SetROP2 (GDI.4)
153  */
154 INT16 WINAPI SetROP216( HDC16 hdc, INT16 mode )
155 {
156     return SetROP2( HDC_32(hdc), mode );
157 }
158
159
160 /***********************************************************************
161  *              SetRelAbs (GDI.5)
162  */
163 INT16 WINAPI SetRelAbs16( HDC16 hdc, INT16 mode )
164 {
165     return SetRelAbs( HDC_32(hdc), mode );
166 }
167
168
169 /***********************************************************************
170  *              SetPolyFillMode (GDI.6)
171  */
172 INT16 WINAPI SetPolyFillMode16( HDC16 hdc, INT16 mode )
173 {
174     return SetPolyFillMode( HDC_32(hdc), mode );
175 }
176
177
178 /***********************************************************************
179  *              SetStretchBltMode (GDI.7)
180  */
181 INT16 WINAPI SetStretchBltMode16( HDC16 hdc, INT16 mode )
182 {
183     return SetStretchBltMode( HDC_32(hdc), mode );
184 }
185
186
187 /***********************************************************************
188  *           SetTextCharacterExtra    (GDI.8)
189  */
190 INT16 WINAPI SetTextCharacterExtra16( HDC16 hdc, INT16 extra )
191 {
192     return SetTextCharacterExtra( HDC_32(hdc), extra );
193 }
194
195
196 /***********************************************************************
197  *           SetTextColor    (GDI.9)
198  */
199 COLORREF WINAPI SetTextColor16( HDC16 hdc, COLORREF color )
200 {
201     return SetTextColor( HDC_32(hdc), color );
202 }
203
204
205 /***********************************************************************
206  *           SetTextJustification    (GDI.10)
207  */
208 INT16 WINAPI SetTextJustification16( HDC16 hdc, INT16 extra, INT16 breaks )
209 {
210     return SetTextJustification( HDC_32(hdc), extra, breaks );
211 }
212
213
214 /***********************************************************************
215  *           SetWindowOrg    (GDI.11)
216  */
217 DWORD WINAPI SetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
218 {
219     POINT pt;
220     if (!SetWindowOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
221     return MAKELONG( pt.x, pt.y );
222 }
223
224
225 /***********************************************************************
226  *           SetWindowExt    (GDI.12)
227  */
228 DWORD WINAPI SetWindowExt16( HDC16 hdc, INT16 x, INT16 y )
229 {
230     SIZE size;
231     if (!SetWindowExtEx( HDC_32(hdc), x, y, &size )) return 0;
232     return MAKELONG( size.cx, size.cy );
233 }
234
235
236 /***********************************************************************
237  *           SetViewportOrg    (GDI.13)
238  */
239 DWORD WINAPI SetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
240 {
241     POINT pt;
242     if (!SetViewportOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
243     return MAKELONG( pt.x, pt.y );
244 }
245
246
247 /***********************************************************************
248  *           SetViewportExt    (GDI.14)
249  */
250 DWORD WINAPI SetViewportExt16( HDC16 hdc, INT16 x, INT16 y )
251 {
252     SIZE size;
253     if (!SetViewportExtEx( HDC_32(hdc), x, y, &size )) return 0;
254     return MAKELONG( size.cx, size.cy );
255 }
256
257
258 /***********************************************************************
259  *           OffsetWindowOrg    (GDI.15)
260  */
261 DWORD WINAPI OffsetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
262 {
263     POINT pt;
264     if (!OffsetWindowOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
265     return MAKELONG( pt.x, pt.y );
266 }
267
268
269 /***********************************************************************
270  *           ScaleWindowExt    (GDI.16)
271  */
272 DWORD WINAPI ScaleWindowExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
273                              INT16 yNum, INT16 yDenom )
274 {
275     SIZE size;
276     if (!ScaleWindowExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom, &size ))
277         return FALSE;
278     return MAKELONG( size.cx,  size.cy );
279 }
280
281
282 /***********************************************************************
283  *           OffsetViewportOrg    (GDI.17)
284  */
285 DWORD WINAPI OffsetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
286 {
287     POINT pt;
288     if (!OffsetViewportOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
289     return MAKELONG( pt.x, pt.y );
290 }
291
292
293 /***********************************************************************
294  *           ScaleViewportExt    (GDI.18)
295  */
296 DWORD WINAPI ScaleViewportExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
297                                INT16 yNum, INT16 yDenom )
298 {
299     SIZE size;
300     if (!ScaleViewportExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom, &size ))
301         return FALSE;
302     return MAKELONG( size.cx,  size.cy );
303 }
304
305
306 /***********************************************************************
307  *           LineTo    (GDI.19)
308  */
309 BOOL16 WINAPI LineTo16( HDC16 hdc, INT16 x, INT16 y )
310 {
311     return LineTo( HDC_32(hdc), x, y );
312 }
313
314
315 /***********************************************************************
316  *           MoveTo    (GDI.20)
317  */
318 DWORD WINAPI MoveTo16( HDC16 hdc, INT16 x, INT16 y )
319 {
320     POINT pt;
321
322     if (!MoveToEx( HDC_32(hdc), x, y, &pt )) return 0;
323     return MAKELONG(pt.x,pt.y);
324 }
325
326
327 /***********************************************************************
328  *           ExcludeClipRect    (GDI.21)
329  */
330 INT16 WINAPI ExcludeClipRect16( HDC16 hdc, INT16 left, INT16 top,
331                                 INT16 right, INT16 bottom )
332 {
333     return ExcludeClipRect( HDC_32(hdc), left, top, right, bottom );
334 }
335
336
337 /***********************************************************************
338  *           IntersectClipRect    (GDI.22)
339  */
340 INT16 WINAPI IntersectClipRect16( HDC16 hdc, INT16 left, INT16 top,
341                                   INT16 right, INT16 bottom )
342 {
343     return IntersectClipRect( HDC_32(hdc), left, top, right, bottom );
344 }
345
346
347 /***********************************************************************
348  *           Arc    (GDI.23)
349  */
350 BOOL16 WINAPI Arc16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
351                      INT16 bottom, INT16 xstart, INT16 ystart,
352                      INT16 xend, INT16 yend )
353 {
354     return Arc( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
355 }
356
357
358 /***********************************************************************
359  *           Ellipse    (GDI.24)
360  */
361 BOOL16 WINAPI Ellipse16( HDC16 hdc, INT16 left, INT16 top,
362                          INT16 right, INT16 bottom )
363 {
364     return Ellipse( HDC_32(hdc), left, top, right, bottom );
365 }
366
367
368 /**********************************************************************
369  *          FloodFill   (GDI.25)
370  */
371 BOOL16 WINAPI FloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
372 {
373     return ExtFloodFill( HDC_32(hdc), x, y, color, FLOODFILLBORDER );
374 }
375
376
377 /***********************************************************************
378  *           Pie    (GDI.26)
379  */
380 BOOL16 WINAPI Pie16( HDC16 hdc, INT16 left, INT16 top,
381                      INT16 right, INT16 bottom, INT16 xstart, INT16 ystart,
382                      INT16 xend, INT16 yend )
383 {
384     return Pie( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
385 }
386
387
388 /***********************************************************************
389  *           Rectangle    (GDI.27)
390  */
391 BOOL16 WINAPI Rectangle16( HDC16 hdc, INT16 left, INT16 top,
392                            INT16 right, INT16 bottom )
393 {
394     return Rectangle( HDC_32(hdc), left, top, right, bottom );
395 }
396
397
398 /***********************************************************************
399  *           RoundRect    (GDI.28)
400  */
401 BOOL16 WINAPI RoundRect16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
402                            INT16 bottom, INT16 ell_width, INT16 ell_height )
403 {
404     return RoundRect( HDC_32(hdc), left, top, right, bottom, ell_width, ell_height );
405 }
406
407
408 /***********************************************************************
409  *           PatBlt    (GDI.29)
410  */
411 BOOL16 WINAPI PatBlt16( HDC16 hdc, INT16 left, INT16 top,
412                         INT16 width, INT16 height, DWORD rop)
413 {
414     return PatBlt( HDC_32(hdc), left, top, width, height, rop );
415 }
416
417
418 /***********************************************************************
419  *           SaveDC    (GDI.30)
420  */
421 INT16 WINAPI SaveDC16( HDC16 hdc )
422 {
423     return SaveDC( HDC_32(hdc) );
424 }
425
426
427 /***********************************************************************
428  *           SetPixel    (GDI.31)
429  */
430 COLORREF WINAPI SetPixel16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
431 {
432     return SetPixel( HDC_32(hdc), x, y, color );
433 }
434
435
436 /***********************************************************************
437  *           OffsetClipRgn    (GDI.32)
438  */
439 INT16 WINAPI OffsetClipRgn16( HDC16 hdc, INT16 x, INT16 y )
440 {
441     return OffsetClipRgn( HDC_32(hdc), x, y );
442 }
443
444
445 /***********************************************************************
446  *           TextOut    (GDI.33)
447  */
448 BOOL16 WINAPI TextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR str, INT16 count )
449 {
450     return TextOutA( HDC_32(hdc), x, y, str, count );
451 }
452
453
454 /***********************************************************************
455  *           BitBlt    (GDI.34)
456  */
457 BOOL16 WINAPI BitBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst, INT16 width,
458                         INT16 height, HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
459                         DWORD rop )
460 {
461     return BitBlt( HDC_32(hdcDst), xDst, yDst, width, height, HDC_32(hdcSrc), xSrc, ySrc, rop );
462 }
463
464
465 /***********************************************************************
466  *           StretchBlt    (GDI.35)
467  */
468 BOOL16 WINAPI StretchBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst,
469                             INT16 widthDst, INT16 heightDst,
470                             HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
471                             INT16 widthSrc, INT16 heightSrc, DWORD rop )
472 {
473     return StretchBlt( HDC_32(hdcDst), xDst, yDst, widthDst, heightDst,
474                        HDC_32(hdcSrc), xSrc, ySrc, widthSrc, heightSrc, rop );
475 }
476
477
478 /**********************************************************************
479  *          Polygon  (GDI.36)
480  */
481 BOOL16 WINAPI Polygon16( HDC16 hdc, const POINT16* pt, INT16 count )
482 {
483     register int i;
484     BOOL ret;
485     LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, count*sizeof(POINT) );
486
487     if (!pt32) return FALSE;
488     for (i=count;i--;)
489     {
490         pt32[i].x = pt[i].x;
491         pt32[i].y = pt[i].y;
492     }
493     ret = Polygon(HDC_32(hdc),pt32,count);
494     HeapFree( GetProcessHeap(), 0, pt32 );
495     return ret;
496 }
497
498
499 /**********************************************************************
500  *          Polyline  (GDI.37)
501  */
502 BOOL16 WINAPI Polyline16( HDC16 hdc, const POINT16* pt, INT16 count )
503 {
504     register int i;
505     BOOL16 ret;
506     LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, count*sizeof(POINT) );
507
508     if (!pt32) return FALSE;
509     for (i=count;i--;)
510     {
511         pt32[i].x = pt[i].x;
512         pt32[i].y = pt[i].y;
513     }
514     ret = Polyline(HDC_32(hdc),pt32,count);
515     HeapFree( GetProcessHeap(), 0, pt32 );
516     return ret;
517 }
518
519
520 /***********************************************************************
521  *            Escape   (GDI.38)
522  */
523 INT16 WINAPI Escape16( HDC16 hdc, INT16 escape, INT16 in_count, SEGPTR in_data, LPVOID out_data )
524 {
525     INT ret;
526
527     switch(escape)
528     {
529     /* Escape(hdc,CLIP_TO_PATH,LPINT16,NULL) */
530     /* Escape(hdc,DRAFTMODE,LPINT16,NULL) */
531     /* Escape(hdc,ENUMPAPERBINS,LPINT16,LPSTR); */
532     /* Escape(hdc,EPSPRINTING,LPINT16,NULL) */
533     /* Escape(hdc,EXT_DEVICE_CAPS,LPINT16,LPDWORD) */
534     /* Escape(hdc,GETCOLORTABLE,LPINT16,LPDWORD) */
535     /* Escape(hdc,MOUSETRAILS,LPINT16,NULL) */
536     /* Escape(hdc,POSTSCRIPT_IGNORE,LPINT16,NULL) */
537     /* Escape(hdc,QUERYESCSUPPORT,LPINT16,NULL) */
538     /* Escape(hdc,SET_ARC_DIRECTION,LPINT16,NULL) */
539     /* Escape(hdc,SET_POLY_MODE,LPINT16,NULL) */
540     /* Escape(hdc,SET_SCREEN_ANGLE,LPINT16,NULL) */
541     /* Escape(hdc,SET_SPREAD,LPINT16,NULL) */
542     case CLIP_TO_PATH:
543     case DRAFTMODE:
544     case ENUMPAPERBINS:
545     case EPSPRINTING:
546     case EXT_DEVICE_CAPS:
547     case GETCOLORTABLE:
548     case MOUSETRAILS:
549     case POSTSCRIPT_IGNORE:
550     case QUERYESCSUPPORT:
551     case SET_ARC_DIRECTION:
552     case SET_POLY_MODE:
553     case SET_SCREEN_ANGLE:
554     case SET_SPREAD:
555     {
556         INT16 *ptr = MapSL(in_data);
557         INT data = *ptr;
558         return Escape( HDC_32(hdc), escape, sizeof(data), (LPCSTR)&data, out_data );
559     }
560
561     /* Escape(hdc,ENABLEDUPLEX,LPUINT16,NULL) */
562     case ENABLEDUPLEX:
563     {
564         UINT16 *ptr = MapSL(in_data);
565         UINT data = *ptr;
566         return Escape( HDC_32(hdc), escape, sizeof(data), (LPCSTR)&data, NULL );
567     }
568
569     /* Escape(hdc,GETPHYSPAGESIZE,NULL,LPPOINT16) */
570     /* Escape(hdc,GETPRINTINGOFFSET,NULL,LPPOINT16) */
571     /* Escape(hdc,GETSCALINGFACTOR,NULL,LPPOINT16) */
572     case GETPHYSPAGESIZE:
573     case GETPRINTINGOFFSET:
574     case GETSCALINGFACTOR:
575     {
576         POINT16 *ptr = out_data;
577         POINT pt32;
578         ret = Escape( HDC_32(hdc), escape, 0, NULL, &pt32 );
579         ptr->x = pt32.x;
580         ptr->y = pt32.y;
581         return ret;
582     }
583
584     /* Escape(hdc,ENABLEPAIRKERNING,LPINT16,LPINT16); */
585     /* Escape(hdc,ENABLERELATIVEWIDTHS,LPINT16,LPINT16); */
586     /* Escape(hdc,SETCOPYCOUNT,LPINT16,LPINT16) */
587     /* Escape(hdc,SETKERNTRACK,LPINT16,LPINT16) */
588     /* Escape(hdc,SETLINECAP,LPINT16,LPINT16) */
589     /* Escape(hdc,SETLINEJOIN,LPINT16,LPINT16) */
590     /* Escape(hdc,SETMITERLIMIT,LPINT16,LPINT16) */
591     case ENABLEPAIRKERNING:
592     case ENABLERELATIVEWIDTHS:
593     case SETCOPYCOUNT:
594     case SETKERNTRACK:
595     case SETLINECAP:
596     case SETLINEJOIN:
597     case SETMITERLIMIT:
598     {
599         INT16 *new = MapSL(in_data);
600         INT16 *old = out_data;
601         INT out, in = *new;
602         ret = Escape( HDC_32(hdc), escape, sizeof(in), (LPCSTR)&in, &out );
603         *old = out;
604         return ret;
605     }
606
607     /* Escape(hdc,SETABORTPROC,ABORTPROC,NULL); */
608     case SETABORTPROC:
609         return SetAbortProc16( hdc, (ABORTPROC16)in_data );
610
611     /* Escape(hdc,STARTDOC,LPSTR,LPDOCINFO16);
612      * lpvOutData is actually a pointer to the DocInfo structure and used as
613      * a second input parameter */
614     case STARTDOC:
615         if (out_data)
616         {
617             ret = StartDoc16( hdc, out_data );
618             if (ret > 0) ret = StartPage( HDC_32(hdc) );
619             return ret;
620         }
621         return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), NULL );
622
623     /* Escape(hdc,SET_BOUNDS,LPRECT16,NULL); */
624     /* Escape(hdc,SET_CLIP_BOX,LPRECT16,NULL); */
625     case SET_BOUNDS:
626     case SET_CLIP_BOX:
627     {
628         RECT16 *rc16 = MapSL(in_data);
629         RECT rc;
630         rc.left   = rc16->left;
631         rc.top    = rc16->top;
632         rc.right  = rc16->right;
633         rc.bottom = rc16->bottom;
634         return Escape( HDC_32(hdc), escape, sizeof(rc), (LPCSTR)&rc, NULL );
635     }
636
637     /* Escape(hdc,NEXTBAND,NULL,LPRECT16); */
638     case NEXTBAND:
639     {
640         RECT rc;
641         RECT16 *rc16 = out_data;
642         ret = Escape( HDC_32(hdc), escape, 0, NULL, &rc );
643         rc16->left   = rc.left;
644         rc16->top    = rc.top;
645         rc16->right  = rc.right;
646         rc16->bottom = rc.bottom;
647         return ret;
648     }
649
650     /* Escape(hdc,ABORTDOC,NULL,NULL); */
651     /* Escape(hdc,BANDINFO,BANDINFOSTRUCT*,BANDINFOSTRUCT*); */
652     /* Escape(hdc,BEGIN_PATH,NULL,NULL); */
653     /* Escape(hdc,DRAWPATTERNRECT,PRECT_STRUCT*,NULL); */
654     /* Escape(hdc,ENDDOC,NULL,NULL); */
655     /* Escape(hdc,END_PATH,PATHINFO,NULL); */
656     /* Escape(hdc,EXTTEXTOUT,EXTTEXT_STRUCT*,NULL); */
657     /* Escape(hdc,FLUSHOUTPUT,NULL,NULL); */
658     /* Escape(hdc,GETFACENAME,NULL,LPSTR); */
659     /* Escape(hdc,GETPAIRKERNTABLE,NULL,KERNPAIR*); */
660     /* Escape(hdc,GETSETPAPERBINS,BinInfo*,BinInfo*); */
661     /* Escape(hdc,GETSETPRINTORIENT,ORIENT*,NULL); */
662     /* Escape(hdc,GETSETSCREENPARAMS,SCREENPARAMS*,SCREENPARAMS*); */
663     /* Escape(hdc,GETTECHNOLOGY,NULL,LPSTR); */
664     /* Escape(hdc,GETTRACKKERNTABLE,NULL,KERNTRACK*); */
665     /* Escape(hdc,MFCOMMENT,LPSTR,NULL); */
666     /* Escape(hdc,NEWFRAME,NULL,NULL); */
667     /* Escape(hdc,PASSTHROUGH,LPSTR,NULL); */
668     /* Escape(hdc,RESTORE_CTM,NULL,NULL); */
669     /* Escape(hdc,SAVE_CTM,NULL,NULL); */
670     /* Escape(hdc,SETALLJUSTVALUES,EXTTEXTDATA*,NULL); */
671     /* Escape(hdc,SETCOLORTABLE,COLORTABLE_STRUCT*,LPDWORD); */
672     /* Escape(hdc,SET_BACKGROUND_COLOR,LPDWORD,LPDWORD); */
673     /* Escape(hdc,TRANSFORM_CTM,LPSTR,NULL); */
674     case ABORTDOC:
675     case BANDINFO:
676     case BEGIN_PATH:
677     case DRAWPATTERNRECT:
678     case ENDDOC:
679     case END_PATH:
680     case EXTTEXTOUT:
681     case FLUSHOUTPUT:
682     case GETFACENAME:
683     case GETPAIRKERNTABLE:
684     case GETSETPAPERBINS:
685     case GETSETPRINTORIENT:
686     case GETSETSCREENPARAMS:
687     case GETTECHNOLOGY:
688     case GETTRACKKERNTABLE:
689     case MFCOMMENT:
690     case NEWFRAME:
691     case PASSTHROUGH:
692     case RESTORE_CTM:
693     case SAVE_CTM:
694     case SETALLJUSTVALUES:
695     case SETCOLORTABLE:
696     case SET_BACKGROUND_COLOR:
697     case TRANSFORM_CTM:
698         /* pass it unmodified to the 32-bit function */
699         return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), out_data );
700
701     /* Escape(hdc,ENUMPAPERMETRICS,LPINT16,LPRECT16); */
702     /* Escape(hdc,GETEXTENDEDTEXTMETRICS,LPUINT16,EXTTEXTMETRIC*); */
703     /* Escape(hdc,GETEXTENTTABLE,LPSTR,LPINT16); */
704     /* Escape(hdc,GETSETPAPERMETRICS,LPRECT16,LPRECT16); */
705     /* Escape(hdc,GETVECTORBRUSHSIZE,LPLOGBRUSH16,LPPOINT16); */
706     /* Escape(hdc,GETVECTORPENSIZE,LPLOGPEN16,LPPOINT16); */
707     case ENUMPAPERMETRICS:
708     case GETEXTENDEDTEXTMETRICS:
709     case GETEXTENTTABLE:
710     case GETSETPAPERMETRICS:
711     case GETVECTORBRUSHSIZE:
712     case GETVECTORPENSIZE:
713     default:
714         FIXME("unknown/unsupported 16-bit escape %x (%d,%p,%p\n",
715               escape, in_count, MapSL(in_data), out_data );
716         return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), out_data );
717     }
718 }
719
720
721 /***********************************************************************
722  *           RestoreDC    (GDI.39)
723  */
724 BOOL16 WINAPI RestoreDC16( HDC16 hdc, INT16 level )
725 {
726     return RestoreDC( HDC_32(hdc), level );
727 }
728
729
730 /***********************************************************************
731  *           FillRgn    (GDI.40)
732  */
733 BOOL16 WINAPI FillRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush )
734 {
735     return FillRgn( HDC_32(hdc), HRGN_32(hrgn), HBRUSH_32(hbrush) );
736 }
737
738
739 /***********************************************************************
740  *           FrameRgn     (GDI.41)
741  */
742 BOOL16 WINAPI FrameRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush,
743                           INT16 nWidth, INT16 nHeight )
744 {
745     return FrameRgn( HDC_32(hdc), HRGN_32(hrgn), HBRUSH_32(hbrush), nWidth, nHeight );
746 }
747
748
749 /***********************************************************************
750  *           InvertRgn    (GDI.42)
751  */
752 BOOL16 WINAPI InvertRgn16( HDC16 hdc, HRGN16 hrgn )
753 {
754     return InvertRgn( HDC_32(hdc), HRGN_32(hrgn) );
755 }
756
757
758 /***********************************************************************
759  *           PaintRgn    (GDI.43)
760  */
761 BOOL16 WINAPI PaintRgn16( HDC16 hdc, HRGN16 hrgn )
762 {
763     return PaintRgn( HDC_32(hdc), HRGN_32(hrgn) );
764 }
765
766
767 /***********************************************************************
768  *           SelectClipRgn    (GDI.44)
769  */
770 INT16 WINAPI SelectClipRgn16( HDC16 hdc, HRGN16 hrgn )
771 {
772     return SelectClipRgn( HDC_32(hdc), HRGN_32(hrgn) );
773 }
774
775
776 /***********************************************************************
777  *           SelectObject    (GDI.45)
778  */
779 HGDIOBJ16 WINAPI SelectObject16( HDC16 hdc, HGDIOBJ16 handle )
780 {
781     return HGDIOBJ_16( SelectObject( HDC_32(hdc), HGDIOBJ_32(handle) ) );
782 }
783
784
785 /***********************************************************************
786  *           CombineRgn    (GDI.47)
787  */
788 INT16 WINAPI CombineRgn16(HRGN16 hDest, HRGN16 hSrc1, HRGN16 hSrc2, INT16 mode)
789 {
790     return CombineRgn( HRGN_32(hDest), HRGN_32(hSrc1), HRGN_32(hSrc2), mode );
791 }
792
793
794 /***********************************************************************
795  *           CreateBitmap    (GDI.48)
796  */
797 HBITMAP16 WINAPI CreateBitmap16( INT16 width, INT16 height, UINT16 planes,
798                                  UINT16 bpp, LPCVOID bits )
799 {
800     return HBITMAP_16( CreateBitmap( width, height, planes & 0xff, bpp & 0xff, bits ) );
801 }
802
803
804 /***********************************************************************
805  *           CreateBitmapIndirect    (GDI.49)
806  */
807 HBITMAP16 WINAPI CreateBitmapIndirect16( const BITMAP16 * bmp )
808 {
809     return CreateBitmap16( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
810                            bmp->bmBitsPixel, MapSL( bmp->bmBits ) );
811 }
812
813
814 /***********************************************************************
815  *           CreateBrushIndirect    (GDI.50)
816  */
817 HBRUSH16 WINAPI CreateBrushIndirect16( const LOGBRUSH16 * brush )
818 {
819     LOGBRUSH brush32;
820
821     if (brush->lbStyle == BS_DIBPATTERN || brush->lbStyle == BS_DIBPATTERN8X8)
822         return CreateDIBPatternBrush16( brush->lbHatch, brush->lbColor );
823
824     brush32.lbStyle = brush->lbStyle;
825     brush32.lbColor = brush->lbColor;
826     brush32.lbHatch = brush->lbHatch;
827     return HBRUSH_16( CreateBrushIndirect(&brush32) );
828 }
829
830
831 /***********************************************************************
832  *           CreateCompatibleBitmap    (GDI.51)
833  */
834 HBITMAP16 WINAPI CreateCompatibleBitmap16( HDC16 hdc, INT16 width, INT16 height )
835 {
836     return HBITMAP_16( CreateCompatibleBitmap( HDC_32(hdc), width, height ) );
837 }
838
839
840 /***********************************************************************
841  *           CreateCompatibleDC    (GDI.52)
842  */
843 HDC16 WINAPI CreateCompatibleDC16( HDC16 hdc )
844 {
845     return HDC_16( CreateCompatibleDC( HDC_32(hdc) ) );
846 }
847
848
849 /***********************************************************************
850  *           CreateDC    (GDI.53)
851  */
852 HDC16 WINAPI CreateDC16( LPCSTR driver, LPCSTR device, LPCSTR output,
853                          const DEVMODEA *initData )
854 {
855     return HDC_16( CreateDCA( driver, device, output, initData ) );
856 }
857
858
859 /***********************************************************************
860  *           CreateEllipticRgn    (GDI.54)
861  */
862 HRGN16 WINAPI CreateEllipticRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom )
863 {
864     return HRGN_16( CreateEllipticRgn( left, top, right, bottom ) );
865 }
866
867
868 /***********************************************************************
869  *           CreateEllipticRgnIndirect    (GDI.55)
870  */
871 HRGN16 WINAPI CreateEllipticRgnIndirect16( const RECT16 *rect )
872 {
873     return HRGN_16( CreateEllipticRgn( rect->left, rect->top, rect->right, rect->bottom ) );
874 }
875
876
877 /***********************************************************************
878  *           CreateFont    (GDI.56)
879  */
880 HFONT16 WINAPI CreateFont16(INT16 height, INT16 width, INT16 esc, INT16 orient,
881                             INT16 weight, BYTE italic, BYTE underline,
882                             BYTE strikeout, BYTE charset, BYTE outpres,
883                             BYTE clippres, BYTE quality, BYTE pitch,
884                             LPCSTR name )
885 {
886     return HFONT_16( CreateFontA( height, width, esc, orient, weight, italic, underline,
887                                   strikeout, charset, outpres, clippres, quality, pitch, name ));
888 }
889
890 /***********************************************************************
891  *           CreateFontIndirect   (GDI.57)
892  */
893 HFONT16 WINAPI CreateFontIndirect16( const LOGFONT16 *plf16 )
894 {
895     HFONT ret;
896
897     if (plf16)
898     {
899         LOGFONTW lfW;
900         logfont_16_to_W( plf16, &lfW );
901         ret = CreateFontIndirectW( &lfW );
902     }
903     else ret = CreateFontIndirectW( NULL );
904     return HFONT_16(ret);
905 }
906
907
908 /***********************************************************************
909  *           CreateHatchBrush    (GDI.58)
910  */
911 HBRUSH16 WINAPI CreateHatchBrush16( INT16 style, COLORREF color )
912 {
913     return HBRUSH_16( CreateHatchBrush( style, color ) );
914 }
915
916
917 /***********************************************************************
918  *           CreatePatternBrush    (GDI.60)
919  */
920 HBRUSH16 WINAPI CreatePatternBrush16( HBITMAP16 hbitmap )
921 {
922     return HBRUSH_16( CreatePatternBrush( HBITMAP_32(hbitmap) ));
923 }
924
925
926 /***********************************************************************
927  *           CreatePen    (GDI.61)
928  */
929 HPEN16 WINAPI CreatePen16( INT16 style, INT16 width, COLORREF color )
930 {
931     LOGPEN logpen;
932
933     logpen.lopnStyle = style;
934     logpen.lopnWidth.x = width;
935     logpen.lopnWidth.y = 0;
936     logpen.lopnColor = color;
937     return HPEN_16( CreatePenIndirect( &logpen ) );
938 }
939
940
941 /***********************************************************************
942  *           CreatePenIndirect    (GDI.62)
943  */
944 HPEN16 WINAPI CreatePenIndirect16( const LOGPEN16 * pen )
945 {
946     LOGPEN logpen;
947
948     if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
949     logpen.lopnStyle   = pen->lopnStyle;
950     logpen.lopnWidth.x = pen->lopnWidth.x;
951     logpen.lopnWidth.y = pen->lopnWidth.y;
952     logpen.lopnColor   = pen->lopnColor;
953     return HPEN_16( CreatePenIndirect( &logpen ) );
954 }
955
956
957 /***********************************************************************
958  *           CreatePolygonRgn    (GDI.63)
959  */
960 HRGN16 WINAPI CreatePolygonRgn16( const POINT16 * points, INT16 count, INT16 mode )
961 {
962     return CreatePolyPolygonRgn16( points, &count, 1, mode );
963 }
964
965
966 /***********************************************************************
967  *           CreateRectRgn    (GDI.64)
968  *
969  * NOTE: cf. SetRectRgn16
970  */
971 HRGN16 WINAPI CreateRectRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom )
972 {
973     HRGN hrgn;
974
975     if (left < right) hrgn = CreateRectRgn( left, top, right, bottom );
976     else hrgn = CreateRectRgn( 0, 0, 0, 0 );
977     return HRGN_16(hrgn);
978 }
979
980
981 /***********************************************************************
982  *           CreateRectRgnIndirect    (GDI.65)
983  */
984 HRGN16 WINAPI CreateRectRgnIndirect16( const RECT16* rect )
985 {
986     return CreateRectRgn16( rect->left, rect->top, rect->right, rect->bottom );
987 }
988
989
990 /***********************************************************************
991  *           CreateSolidBrush    (GDI.66)
992  */
993 HBRUSH16 WINAPI CreateSolidBrush16( COLORREF color )
994 {
995     return HBRUSH_16( CreateSolidBrush( color ) );
996 }
997
998
999 /***********************************************************************
1000  *           DeleteDC    (GDI.68)
1001  */
1002 BOOL16 WINAPI DeleteDC16( HDC16 hdc )
1003 {
1004     return DeleteDC( HDC_32(hdc) );
1005 }
1006
1007
1008 /***********************************************************************
1009  *           DeleteObject    (GDI.69)
1010  *           SysDeleteObject (GDI.605)
1011  */
1012 BOOL16 WINAPI DeleteObject16( HGDIOBJ16 obj )
1013 {
1014     return DeleteObject( HGDIOBJ_32(obj) );
1015 }
1016
1017
1018 /***********************************************************************
1019  *           EnumObjects    (GDI.71)
1020  */
1021 INT16 WINAPI EnumObjects16( HDC16 hdc, INT16 obj, GOBJENUMPROC16 proc, LPARAM lParam )
1022 {
1023     struct callback16_info info;
1024
1025     info.proc  = (FARPROC16)proc;
1026     info.param = lParam;
1027     switch(obj)
1028     {
1029     case OBJ_PEN:
1030         return EnumObjects( HDC_32(hdc), OBJ_PEN, enum_pens_callback, (LPARAM)&info );
1031     case OBJ_BRUSH:
1032         return EnumObjects( HDC_32(hdc), OBJ_BRUSH, enum_brushes_callback, (LPARAM)&info );
1033     }
1034     return 0;
1035 }
1036
1037
1038 /***********************************************************************
1039  *           EqualRgn    (GDI.72)
1040  */
1041 BOOL16 WINAPI EqualRgn16( HRGN16 rgn1, HRGN16 rgn2 )
1042 {
1043     return EqualRgn( HRGN_32(rgn1), HRGN_32(rgn2) );
1044 }
1045
1046
1047 /***********************************************************************
1048  *           GetBitmapBits    (GDI.74)
1049  */
1050 LONG WINAPI GetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPVOID buffer )
1051 {
1052     return GetBitmapBits( HBITMAP_32(hbitmap), count, buffer );
1053 }
1054
1055
1056 /***********************************************************************
1057  *              GetBkColor (GDI.75)
1058  */
1059 COLORREF WINAPI GetBkColor16( HDC16 hdc )
1060 {
1061     return GetBkColor( HDC_32(hdc) );
1062 }
1063
1064
1065 /***********************************************************************
1066  *              GetBkMode (GDI.76)
1067  */
1068 INT16 WINAPI GetBkMode16( HDC16 hdc )
1069 {
1070     return GetBkMode( HDC_32(hdc) );
1071 }
1072
1073
1074 /***********************************************************************
1075  *           GetClipBox    (GDI.77)
1076  */
1077 INT16 WINAPI GetClipBox16( HDC16 hdc, LPRECT16 rect )
1078 {
1079     RECT rect32;
1080     INT ret = GetClipBox( HDC_32(hdc), &rect32 );
1081
1082     if (ret != ERROR)
1083     {
1084         rect->left   = rect32.left;
1085         rect->top    = rect32.top;
1086         rect->right  = rect32.right;
1087         rect->bottom = rect32.bottom;
1088     }
1089     return ret;
1090 }
1091
1092
1093 /***********************************************************************
1094  *              GetCurrentPosition (GDI.78)
1095  */
1096 DWORD WINAPI GetCurrentPosition16( HDC16 hdc )
1097 {
1098     POINT pt32;
1099     if (!GetCurrentPositionEx( HDC_32(hdc), &pt32 )) return 0;
1100     return MAKELONG( pt32.x, pt32.y );
1101 }
1102
1103
1104 /***********************************************************************
1105  *           GetDCOrg    (GDI.79)
1106  */
1107 DWORD WINAPI GetDCOrg16( HDC16 hdc )
1108 {
1109     POINT pt;
1110     if (GetDCOrgEx( HDC_32(hdc), &pt )) return MAKELONG( pt.x, pt.y );
1111     return 0;
1112 }
1113
1114
1115 /***********************************************************************
1116  *           GetDeviceCaps    (GDI.80)
1117  */
1118 INT16 WINAPI GetDeviceCaps16( HDC16 hdc, INT16 cap )
1119 {
1120     INT16 ret = GetDeviceCaps( HDC_32(hdc), cap );
1121     /* some apps don't expect -1 and think it's a B&W screen */
1122     if ((cap == NUMCOLORS) && (ret == -1)) ret = 2048;
1123     return ret;
1124 }
1125
1126
1127 /***********************************************************************
1128  *              GetMapMode (GDI.81)
1129  */
1130 INT16 WINAPI GetMapMode16( HDC16 hdc )
1131 {
1132     return GetMapMode( HDC_32(hdc) );
1133 }
1134
1135
1136 /***********************************************************************
1137  *           GetPixel    (GDI.83)
1138  */
1139 COLORREF WINAPI GetPixel16( HDC16 hdc, INT16 x, INT16 y )
1140 {
1141     return GetPixel( HDC_32(hdc), x, y );
1142 }
1143
1144
1145 /***********************************************************************
1146  *              GetPolyFillMode (GDI.84)
1147  */
1148 INT16 WINAPI GetPolyFillMode16( HDC16 hdc )
1149 {
1150     return GetPolyFillMode( HDC_32(hdc) );
1151 }
1152
1153
1154 /***********************************************************************
1155  *              GetROP2 (GDI.85)
1156  */
1157 INT16 WINAPI GetROP216( HDC16 hdc )
1158 {
1159     return GetROP2( HDC_32(hdc) );
1160 }
1161
1162
1163 /***********************************************************************
1164  *              GetRelAbs (GDI.86)
1165  */
1166 INT16 WINAPI GetRelAbs16( HDC16 hdc )
1167 {
1168     return GetRelAbs( HDC_32(hdc), 0 );
1169 }
1170
1171
1172 /***********************************************************************
1173  *           GetStockObject    (GDI.87)
1174  */
1175 HGDIOBJ16 WINAPI GetStockObject16( INT16 obj )
1176 {
1177     return HGDIOBJ_16( GetStockObject( obj ) );
1178 }
1179
1180
1181 /***********************************************************************
1182  *              GetStretchBltMode (GDI.88)
1183  */
1184 INT16 WINAPI GetStretchBltMode16( HDC16 hdc )
1185 {
1186     return GetStretchBltMode( HDC_32(hdc) );
1187 }
1188
1189
1190 /***********************************************************************
1191  *           GetTextCharacterExtra    (GDI.89)
1192  */
1193 INT16 WINAPI GetTextCharacterExtra16( HDC16 hdc )
1194 {
1195     return GetTextCharacterExtra( HDC_32(hdc) );
1196 }
1197
1198
1199 /***********************************************************************
1200  *              GetTextColor (GDI.90)
1201  */
1202 COLORREF WINAPI GetTextColor16( HDC16 hdc )
1203 {
1204     return GetTextColor( HDC_32(hdc) );
1205 }
1206
1207
1208 /***********************************************************************
1209  *           GetTextExtent    (GDI.91)
1210  */
1211 DWORD WINAPI GetTextExtent16( HDC16 hdc, LPCSTR str, INT16 count )
1212 {
1213     SIZE size;
1214     if (!GetTextExtentPoint32A( HDC_32(hdc), str, count, &size )) return 0;
1215     return MAKELONG( size.cx, size.cy );
1216 }
1217
1218
1219 /***********************************************************************
1220  *           GetTextFace    (GDI.92)
1221  */
1222 INT16 WINAPI GetTextFace16( HDC16 hdc, INT16 count, LPSTR name )
1223 {
1224     return GetTextFaceA( HDC_32(hdc), count, name );
1225 }
1226
1227
1228 /***********************************************************************
1229  *           GetTextMetrics    (GDI.93)
1230  */
1231 BOOL16 WINAPI GetTextMetrics16( HDC16 hdc, TEXTMETRIC16 *tm )
1232 {
1233     TEXTMETRICW tm32;
1234
1235     if (!GetTextMetricsW( HDC_32(hdc), &tm32 )) return FALSE;
1236
1237     tm->tmHeight           = tm32.tmHeight;
1238     tm->tmAscent           = tm32.tmAscent;
1239     tm->tmDescent          = tm32.tmDescent;
1240     tm->tmInternalLeading  = tm32.tmInternalLeading;
1241     tm->tmExternalLeading  = tm32.tmExternalLeading;
1242     tm->tmAveCharWidth     = tm32.tmAveCharWidth;
1243     tm->tmMaxCharWidth     = tm32.tmMaxCharWidth;
1244     tm->tmWeight           = tm32.tmWeight;
1245     tm->tmOverhang         = tm32.tmOverhang;
1246     tm->tmDigitizedAspectX = tm32.tmDigitizedAspectX;
1247     tm->tmDigitizedAspectY = tm32.tmDigitizedAspectY;
1248     tm->tmFirstChar        = tm32.tmFirstChar;
1249     tm->tmLastChar         = tm32.tmLastChar;
1250     tm->tmDefaultChar      = tm32.tmDefaultChar;
1251     tm->tmBreakChar        = tm32.tmBreakChar;
1252     tm->tmItalic           = tm32.tmItalic;
1253     tm->tmUnderlined       = tm32.tmUnderlined;
1254     tm->tmStruckOut        = tm32.tmStruckOut;
1255     tm->tmPitchAndFamily   = tm32.tmPitchAndFamily;
1256     tm->tmCharSet          = tm32.tmCharSet;
1257     return TRUE;
1258 }
1259
1260
1261 /***********************************************************************
1262  *              GetViewportExt (GDI.94)
1263  */
1264 DWORD WINAPI GetViewportExt16( HDC16 hdc )
1265 {
1266     SIZE size;
1267     if (!GetViewportExtEx( HDC_32(hdc), &size )) return 0;
1268     return MAKELONG( size.cx, size.cy );
1269 }
1270
1271
1272 /***********************************************************************
1273  *              GetViewportOrg (GDI.95)
1274  */
1275 DWORD WINAPI GetViewportOrg16( HDC16 hdc )
1276 {
1277     POINT pt;
1278     if (!GetViewportOrgEx( HDC_32(hdc), &pt )) return 0;
1279     return MAKELONG( pt.x, pt.y );
1280 }
1281
1282
1283 /***********************************************************************
1284  *              GetWindowExt (GDI.96)
1285  */
1286 DWORD WINAPI GetWindowExt16( HDC16 hdc )
1287 {
1288     SIZE size;
1289     if (!GetWindowExtEx( HDC_32(hdc), &size )) return 0;
1290     return MAKELONG( size.cx, size.cy );
1291 }
1292
1293
1294 /***********************************************************************
1295  *              GetWindowOrg (GDI.97)
1296  */
1297 DWORD WINAPI GetWindowOrg16( HDC16 hdc )
1298 {
1299     POINT pt;
1300     if (!GetWindowOrgEx( HDC_32(hdc), &pt )) return 0;
1301     return MAKELONG( pt.x, pt.y );
1302 }
1303
1304
1305
1306
1307 /**********************************************************************
1308  *           LineDDA   (GDI.100)
1309  */
1310 void WINAPI LineDDA16( INT16 nXStart, INT16 nYStart, INT16 nXEnd,
1311                        INT16 nYEnd, LINEDDAPROC16 proc, LPARAM lParam )
1312 {
1313     struct callback16_info info;
1314     info.proc  = (FARPROC16)proc;
1315     info.param = lParam;
1316     LineDDA( nXStart, nYStart, nXEnd, nYEnd, linedda_callback, (LPARAM)&info );
1317 }
1318
1319
1320 /***********************************************************************
1321  *           OffsetRgn    (GDI.101)
1322  */
1323 INT16 WINAPI OffsetRgn16( HRGN16 hrgn, INT16 x, INT16 y )
1324 {
1325     return OffsetRgn( HRGN_32(hrgn), x, y );
1326 }
1327
1328
1329 /***********************************************************************
1330  *           PtVisible    (GDI.103)
1331  */
1332 BOOL16 WINAPI PtVisible16( HDC16 hdc, INT16 x, INT16 y )
1333 {
1334     return PtVisible( HDC_32(hdc), x, y );
1335 }
1336
1337
1338 /***********************************************************************
1339  *           SetBitmapBits    (GDI.106)
1340  */
1341 LONG WINAPI SetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPCVOID buffer )
1342 {
1343     return SetBitmapBits( HBITMAP_32(hbitmap), count, buffer );
1344 }
1345
1346
1347 /***********************************************************************
1348  *           AddFontResource    (GDI.119)
1349  */
1350 INT16 WINAPI AddFontResource16( LPCSTR filename )
1351 {
1352     return AddFontResourceA( filename );
1353 }
1354
1355
1356 /***********************************************************************
1357  *           Death    (GDI.121)
1358  *
1359  * Disables GDI, switches back to text mode.
1360  * We don't have to do anything here,
1361  * just let console support handle everything
1362  */
1363 void WINAPI Death16(HDC16 hdc)
1364 {
1365     MESSAGE("Death(%04x) called. Application enters text mode...\n", hdc);
1366 }
1367
1368
1369 /***********************************************************************
1370  *           Resurrection    (GDI.122)
1371  *
1372  * Restores GDI functionality
1373  */
1374 void WINAPI Resurrection16(HDC16 hdc,
1375                            WORD w1, WORD w2, WORD w3, WORD w4, WORD w5, WORD w6)
1376 {
1377     MESSAGE("Resurrection(%04x, %04x, %04x, %04x, %04x, %04x, %04x) called. Application left text mode.\n",
1378             hdc, w1, w2, w3, w4, w5, w6);
1379 }
1380
1381
1382 /**********************************************************************
1383  *           CreateMetaFile     (GDI.125)
1384  */
1385 HDC16 WINAPI CreateMetaFile16( LPCSTR filename )
1386 {
1387     return HDC_16( CreateMetaFileA( filename ) );
1388 }
1389
1390
1391 /***********************************************************************
1392  *           MulDiv   (GDI.128)
1393  */
1394 INT16 WINAPI MulDiv16( INT16 nMultiplicand, INT16 nMultiplier, INT16 nDivisor)
1395 {
1396     INT ret;
1397     if (!nDivisor) return -32768;
1398     /* We want to deal with a positive divisor to simplify the logic. */
1399     if (nDivisor < 0)
1400     {
1401       nMultiplicand = - nMultiplicand;
1402       nDivisor = -nDivisor;
1403     }
1404     /* If the result is positive, we "add" to round. else,
1405      * we subtract to round. */
1406     if ( ( (nMultiplicand <  0) && (nMultiplier <  0) ) ||
1407          ( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
1408         ret = (((int)nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
1409     else
1410         ret = (((int)nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
1411     if ((ret > 32767) || (ret < -32767)) return -32768;
1412     return (INT16) ret;
1413 }
1414
1415
1416 /***********************************************************************
1417  *           GetRgnBox    (GDI.134)
1418  */
1419 INT16 WINAPI GetRgnBox16( HRGN16 hrgn, LPRECT16 rect )
1420 {
1421     RECT r;
1422     INT16 ret = GetRgnBox( HRGN_32(hrgn), &r );
1423     rect->left   = r.left;
1424     rect->top    = r.top;
1425     rect->right  = r.right;
1426     rect->bottom = r.bottom;
1427     return ret;
1428 }
1429
1430
1431 /***********************************************************************
1432  *           RemoveFontResource    (GDI.136)
1433  */
1434 BOOL16 WINAPI RemoveFontResource16( LPCSTR str )
1435 {
1436     return RemoveFontResourceA(str);
1437 }
1438
1439
1440 /***********************************************************************
1441  *           SetBrushOrg    (GDI.148)
1442  */
1443 DWORD WINAPI SetBrushOrg16( HDC16 hdc, INT16 x, INT16 y )
1444 {
1445     POINT pt;
1446
1447     if (!SetBrushOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
1448     return MAKELONG( pt.x, pt.y );
1449 }
1450
1451
1452 /***********************************************************************
1453  *              GetBrushOrg (GDI.149)
1454  */
1455 DWORD WINAPI GetBrushOrg16( HDC16 hdc )
1456 {
1457     POINT pt;
1458     if (!GetBrushOrgEx( HDC_32(hdc), &pt )) return 0;
1459     return MAKELONG( pt.x, pt.y );
1460 }
1461
1462
1463 /***********************************************************************
1464  *           UnrealizeObject    (GDI.150)
1465  */
1466 BOOL16 WINAPI UnrealizeObject16( HGDIOBJ16 obj )
1467 {
1468     return UnrealizeObject( HGDIOBJ_32(obj) );
1469 }
1470
1471
1472 /***********************************************************************
1473  *           CreateIC    (GDI.153)
1474  */
1475 HDC16 WINAPI CreateIC16( LPCSTR driver, LPCSTR device, LPCSTR output,
1476                          const DEVMODEA* initData )
1477 {
1478     return HDC_16( CreateICA( driver, device, output, initData ) );
1479 }
1480
1481
1482 /***********************************************************************
1483  *           GetNearestColor   (GDI.154)
1484  */
1485 COLORREF WINAPI GetNearestColor16( HDC16 hdc, COLORREF color )
1486 {
1487     return GetNearestColor( HDC_32(hdc), color );
1488 }
1489
1490
1491 /***********************************************************************
1492  *           CreateDiscardableBitmap    (GDI.156)
1493  */
1494 HBITMAP16 WINAPI CreateDiscardableBitmap16( HDC16 hdc, INT16 width, INT16 height )
1495 {
1496     return HBITMAP_16( CreateDiscardableBitmap( HDC_32(hdc), width, height ) );
1497 }
1498
1499
1500 /***********************************************************************
1501  *           PtInRegion    (GDI.161)
1502  */
1503 BOOL16 WINAPI PtInRegion16( HRGN16 hrgn, INT16 x, INT16 y )
1504 {
1505     return PtInRegion( HRGN_32(hrgn), x, y );
1506 }
1507
1508
1509 /***********************************************************************
1510  *           GetBitmapDimension    (GDI.162)
1511  */
1512 DWORD WINAPI GetBitmapDimension16( HBITMAP16 hbitmap )
1513 {
1514     SIZE16 size;
1515     if (!GetBitmapDimensionEx16( hbitmap, &size )) return 0;
1516     return MAKELONG( size.cx, size.cy );
1517 }
1518
1519
1520 /***********************************************************************
1521  *           SetBitmapDimension    (GDI.163)
1522  */
1523 DWORD WINAPI SetBitmapDimension16( HBITMAP16 hbitmap, INT16 x, INT16 y )
1524 {
1525     SIZE16 size;
1526     if (!SetBitmapDimensionEx16( hbitmap, x, y, &size )) return 0;
1527     return MAKELONG( size.cx, size.cy );
1528 }
1529
1530
1531 /***********************************************************************
1532  *           SetRectRgn    (GDI.172)
1533  *
1534  * NOTE: Win 3.1 sets region to empty if left > right
1535  */
1536 void WINAPI SetRectRgn16( HRGN16 hrgn, INT16 left, INT16 top, INT16 right, INT16 bottom )
1537 {
1538     if (left < right) SetRectRgn( HRGN_32(hrgn), left, top, right, bottom );
1539     else SetRectRgn( HRGN_32(hrgn), 0, 0, 0, 0 );
1540 }
1541
1542
1543 /******************************************************************
1544  *             PlayMetaFileRecord   (GDI.176)
1545  */
1546 void WINAPI PlayMetaFileRecord16( HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr, UINT16 handles )
1547 {
1548     HANDLETABLE *ht32 = HeapAlloc( GetProcessHeap(), 0, handles * sizeof(*ht32) );
1549     unsigned int i;
1550
1551     for (i = 0; i < handles; i++) ht32->objectHandle[i] = (HGDIOBJ)(ULONG_PTR)ht->objectHandle[i];
1552     PlayMetaFileRecord( HDC_32(hdc), ht32, mr, handles );
1553     for (i = 0; i < handles; i++) ht->objectHandle[i] = LOWORD(ht32->objectHandle[i]);
1554     HeapFree( GetProcessHeap(), 0, ht32 );
1555 }
1556
1557
1558 /***********************************************************************
1559  *           SetBoundsRect    (GDI.193)
1560  */
1561 UINT16 WINAPI SetBoundsRect16( HDC16 hdc, const RECT16* rect, UINT16 flags )
1562 {
1563     if (rect)
1564     {
1565         RECT rect32;
1566         rect32.left   = rect->left;
1567         rect32.top    = rect->top;
1568         rect32.right  = rect->right;
1569         rect32.bottom = rect->bottom;
1570         return SetBoundsRect( HDC_32( hdc ), &rect32, flags );
1571     }
1572     else return SetBoundsRect( HDC_32( hdc ), NULL, flags );
1573 }
1574
1575
1576 /***********************************************************************
1577  *           GetBoundsRect    (GDI.194)
1578  */
1579 UINT16 WINAPI GetBoundsRect16( HDC16 hdc, LPRECT16 rect, UINT16 flags)
1580 {
1581     RECT rect32;
1582     UINT ret = GetBoundsRect( HDC_32( hdc ), &rect32, flags );
1583     if (rect)
1584     {
1585         rect->left   = rect32.left;
1586         rect->top    = rect32.top;
1587         rect->right  = rect32.right;
1588         rect->bottom = rect32.bottom;
1589     }
1590     return ret;
1591 }
1592
1593
1594 /***********************************************************************
1595  *              EngineEnumerateFont (GDI.300)
1596  */
1597 WORD WINAPI EngineEnumerateFont16(LPSTR fontname, FARPROC16 proc, DWORD data )
1598 {
1599     FIXME("(%s,%p,%lx),stub\n",fontname,proc,data);
1600     return 0;
1601 }
1602
1603
1604 /***********************************************************************
1605  *              EngineDeleteFont (GDI.301)
1606  */
1607 WORD WINAPI EngineDeleteFont16(LPFONTINFO16 lpFontInfo)
1608 {
1609     WORD handle;
1610
1611     /*  untested, don't know if it works.
1612         We seem to access some structure that is located after the
1613         FONTINFO. The FONTINFO documentation says that there may
1614         follow some char-width table or font bitmap or vector info.
1615         I think it is some kind of font bitmap that begins at offset 0x52,
1616         as FONTINFO goes up to 0x51.
1617         If this is correct, everything should be implemented correctly.
1618     */
1619     if ( ((lpFontInfo->dfType & (RASTER_FONTTYPE|DEVICE_FONTTYPE)) == (RASTER_FONTTYPE|DEVICE_FONTTYPE))
1620          && (LOWORD(lpFontInfo->dfFace) == LOWORD(lpFontInfo)+0x6e)
1621          && (handle = *(WORD *)(lpFontInfo+0x54)) )
1622     {
1623         *(WORD *)(lpFontInfo+0x54) = 0;
1624         GlobalFree16(handle);
1625     }
1626     return 1;
1627 }
1628
1629
1630 /***********************************************************************
1631  *              EngineRealizeFont (GDI.302)
1632  */
1633 WORD WINAPI EngineRealizeFont16(LPLOGFONT16 lplogFont, LPTEXTXFORM16 lptextxform, LPFONTINFO16 lpfontInfo)
1634 {
1635     FIXME("(%p,%p,%p),stub\n",lplogFont,lptextxform,lpfontInfo);
1636
1637     return 0;
1638 }
1639
1640
1641 /***********************************************************************
1642  *              EngineRealizeFontExt (GDI.315)
1643  */
1644 WORD WINAPI EngineRealizeFontExt16(LONG l1, LONG l2, LONG l3, LONG l4)
1645 {
1646     FIXME("(%08lx,%08lx,%08lx,%08lx),stub\n",l1,l2,l3,l4);
1647
1648     return 0;
1649 }
1650
1651
1652 /***********************************************************************
1653  *              EngineGetCharWidth (GDI.303)
1654  */
1655 WORD WINAPI EngineGetCharWidth16(LPFONTINFO16 lpFontInfo, BYTE firstChar, BYTE lastChar, LPINT16 buffer)
1656 {
1657     int i;
1658
1659     for (i = firstChar; i <= lastChar; i++)
1660        FIXME(" returns font's average width for range %d to %d\n", firstChar, lastChar);
1661     *buffer++ = lpFontInfo->dfAvgWidth; /* insert some charwidth functionality here; use average width for now */
1662     return 1;
1663 }
1664
1665
1666 /***********************************************************************
1667  *              EngineSetFontContext (GDI.304)
1668  */
1669 WORD WINAPI EngineSetFontContext(LPFONTINFO16 lpFontInfo, WORD data)
1670 {
1671    FIXME("stub?\n");
1672    return 0;
1673 }
1674
1675 /***********************************************************************
1676  *              EngineGetGlyphBMP (GDI.305)
1677  */
1678 WORD WINAPI EngineGetGlyphBMP(WORD word, LPFONTINFO16 lpFontInfo, WORD w1, WORD w2,
1679                               LPSTR string, DWORD dword, /*LPBITMAPMETRICS16*/ LPVOID metrics)
1680 {
1681     FIXME("stub?\n");
1682     return 0;
1683 }
1684
1685
1686 /***********************************************************************
1687  *              EngineMakeFontDir (GDI.306)
1688  */
1689 DWORD WINAPI EngineMakeFontDir(HDC16 hdc, LPFONTDIR16 fontdir, LPCSTR string)
1690 {
1691     FIXME(" stub! (always fails)\n");
1692     return ~0UL; /* error */
1693 }
1694
1695
1696 /***********************************************************************
1697  *           GetCharABCWidths   (GDI.307)
1698  */
1699 BOOL16 WINAPI GetCharABCWidths16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar, LPABC16 abc )
1700 {
1701     BOOL ret;
1702     UINT i;
1703     LPABC abc32 = HeapAlloc( GetProcessHeap(), 0, sizeof(ABC) * (lastChar - firstChar + 1) );
1704
1705     if ((ret = GetCharABCWidthsA( HDC_32(hdc), firstChar, lastChar, abc32 )))
1706     {
1707         for (i = firstChar; i <= lastChar; i++)
1708         {
1709             abc[i-firstChar].abcA = abc32[i-firstChar].abcA;
1710             abc[i-firstChar].abcB = abc32[i-firstChar].abcB;
1711             abc[i-firstChar].abcC = abc32[i-firstChar].abcC;
1712         }
1713     }
1714     HeapFree( GetProcessHeap(), 0, abc32 );
1715     return ret;
1716 }
1717
1718
1719 /***********************************************************************
1720  *           GetGlyphOutline    (GDI.309)
1721  */
1722 DWORD WINAPI GetGlyphOutline16( HDC16 hdc, UINT16 uChar, UINT16 fuFormat,
1723                                 LPGLYPHMETRICS16 lpgm, DWORD cbBuffer,
1724                                 LPVOID lpBuffer, const MAT2 *lpmat2 )
1725 {
1726     DWORD ret;
1727     GLYPHMETRICS gm32;
1728
1729     ret = GetGlyphOutlineA( HDC_32(hdc), uChar, fuFormat, &gm32, cbBuffer, lpBuffer, lpmat2);
1730     lpgm->gmBlackBoxX = gm32.gmBlackBoxX;
1731     lpgm->gmBlackBoxY = gm32.gmBlackBoxY;
1732     lpgm->gmptGlyphOrigin.x = gm32.gmptGlyphOrigin.x;
1733     lpgm->gmptGlyphOrigin.y = gm32.gmptGlyphOrigin.y;
1734     lpgm->gmCellIncX = gm32.gmCellIncX;
1735     lpgm->gmCellIncY = gm32.gmCellIncY;
1736     return ret;
1737 }
1738
1739
1740 /***********************************************************************
1741  *           CreateScalableFontResource   (GDI.310)
1742  */
1743 BOOL16 WINAPI CreateScalableFontResource16( UINT16 fHidden, LPCSTR lpszResourceFile,
1744                                             LPCSTR fontFile, LPCSTR path )
1745 {
1746     return CreateScalableFontResourceA( fHidden, lpszResourceFile, fontFile, path );
1747 }
1748
1749
1750 /*************************************************************************
1751  *             GetFontData    (GDI.311)
1752  *
1753  */
1754 DWORD WINAPI GetFontData16( HDC16 hdc, DWORD table, DWORD offset, LPVOID buffer, DWORD count )
1755 {
1756     return GetFontData( HDC_32(hdc), table, offset, buffer, count );
1757 }
1758
1759
1760 /*************************************************************************
1761  *             GetRasterizerCaps   (GDI.313)
1762  */
1763 BOOL16 WINAPI GetRasterizerCaps16( LPRASTERIZER_STATUS lprs, UINT16 cbNumBytes )
1764 {
1765     return GetRasterizerCaps( lprs, cbNumBytes );
1766 }
1767
1768
1769 /*************************************************************************
1770  *             GetKerningPairs   (GDI.332)
1771  *
1772  */
1773 INT16 WINAPI GetKerningPairs16( HDC16 hdc, INT16 count, LPKERNINGPAIR16 pairs )
1774 {
1775     KERNINGPAIR *pairs32;
1776     INT i, ret;
1777
1778     if (!count) return 0;
1779
1780     if (!(pairs32 = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*pairs32) ))) return 0;
1781     if ((ret = GetKerningPairsA( HDC_32(hdc), count, pairs32 )))
1782     {
1783         for (i = 0; i < ret; i++)
1784         {
1785             pairs->wFirst      = pairs32->wFirst;
1786             pairs->wSecond     = pairs32->wSecond;
1787             pairs->iKernAmount = pairs32->iKernAmount;
1788         }
1789     }
1790     HeapFree( GetProcessHeap(), 0, pairs32 );
1791     return ret;
1792 }
1793
1794
1795
1796 /***********************************************************************
1797  *              GetTextAlign (GDI.345)
1798  */
1799 UINT16 WINAPI GetTextAlign16( HDC16 hdc )
1800 {
1801     return GetTextAlign( HDC_32(hdc) );
1802 }
1803
1804
1805 /***********************************************************************
1806  *           SetTextAlign    (GDI.346)
1807  */
1808 UINT16 WINAPI SetTextAlign16( HDC16 hdc, UINT16 align )
1809 {
1810     return SetTextAlign( HDC_32(hdc), align );
1811 }
1812
1813
1814 /***********************************************************************
1815  *           Chord    (GDI.348)
1816  */
1817 BOOL16 WINAPI Chord16( HDC16 hdc, INT16 left, INT16 top,
1818                        INT16 right, INT16 bottom, INT16 xstart, INT16 ystart,
1819                        INT16 xend, INT16 yend )
1820 {
1821     return Chord( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
1822 }
1823
1824
1825 /***********************************************************************
1826  *           SetMapperFlags    (GDI.349)
1827  */
1828 DWORD WINAPI SetMapperFlags16( HDC16 hdc, DWORD flags )
1829 {
1830     return SetMapperFlags( HDC_32(hdc), flags );
1831 }
1832
1833
1834 /***********************************************************************
1835  *           GetCharWidth    (GDI.350)
1836  */
1837 BOOL16 WINAPI GetCharWidth16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar, LPINT16 buffer )
1838 {
1839     BOOL retVal = FALSE;
1840
1841     if( firstChar != lastChar )
1842     {
1843         LPINT buf32 = HeapAlloc(GetProcessHeap(), 0, sizeof(INT)*(1 + (lastChar - firstChar)));
1844         if( buf32 )
1845         {
1846             LPINT obuf32 = buf32;
1847             int i;
1848
1849             retVal = GetCharWidth32A( HDC_32(hdc), firstChar, lastChar, buf32);
1850             if (retVal)
1851             {
1852                 for (i = firstChar; i <= lastChar; i++) *buffer++ = *buf32++;
1853             }
1854             HeapFree(GetProcessHeap(), 0, obuf32);
1855         }
1856     }
1857     else /* happens quite often to warrant a special treatment */
1858     {
1859         INT chWidth;
1860         retVal = GetCharWidth32A( HDC_32(hdc), firstChar, lastChar, &chWidth );
1861         *buffer = chWidth;
1862     }
1863     return retVal;
1864 }
1865
1866
1867 /***********************************************************************
1868  *           ExtTextOut   (GDI.351)
1869  */
1870 BOOL16 WINAPI ExtTextOut16( HDC16 hdc, INT16 x, INT16 y, UINT16 flags,
1871                             const RECT16 *lprect, LPCSTR str, UINT16 count,
1872                             const INT16 *lpDx )
1873 {
1874     BOOL        ret;
1875     int         i;
1876     RECT        rect32;
1877     LPINT       lpdx32 = NULL;
1878
1879     if (lpDx) {
1880         lpdx32 = HeapAlloc( GetProcessHeap(),0, sizeof(INT)*count );
1881         if(lpdx32 == NULL) return FALSE;
1882         for (i=count;i--;) lpdx32[i]=lpDx[i];
1883     }
1884     if (lprect)
1885     {
1886         rect32.left   = lprect->left;
1887         rect32.top    = lprect->top;
1888         rect32.right  = lprect->right;
1889         rect32.bottom = lprect->bottom;
1890     }
1891     ret = ExtTextOutA(HDC_32(hdc),x,y,flags,lprect?&rect32:NULL,str,count,lpdx32);
1892     HeapFree( GetProcessHeap(), 0, lpdx32 );
1893     return ret;
1894 }
1895
1896
1897 /***********************************************************************
1898  *           CreatePalette    (GDI.360)
1899  */
1900 HPALETTE16 WINAPI CreatePalette16( const LOGPALETTE* palette )
1901 {
1902     return HPALETTE_16( CreatePalette( palette ) );
1903 }
1904
1905
1906 /***********************************************************************
1907  *           GDISelectPalette   (GDI.361)
1908  */
1909 HPALETTE16 WINAPI GDISelectPalette16( HDC16 hdc, HPALETTE16 hpalette, WORD wBkg )
1910 {
1911     return HPALETTE_16( GDISelectPalette( HDC_32(hdc), HPALETTE_32(hpalette), wBkg ));
1912 }
1913
1914
1915 /***********************************************************************
1916  *           GDIRealizePalette   (GDI.362)
1917  */
1918 UINT16 WINAPI GDIRealizePalette16( HDC16 hdc )
1919 {
1920     return GDIRealizePalette( HDC_32(hdc) );
1921 }
1922
1923
1924 /***********************************************************************
1925  *           GetPaletteEntries    (GDI.363)
1926  */
1927 UINT16 WINAPI GetPaletteEntries16( HPALETTE16 hpalette, UINT16 start,
1928                                    UINT16 count, LPPALETTEENTRY entries )
1929 {
1930     return GetPaletteEntries( HPALETTE_32(hpalette), start, count, entries );
1931 }
1932
1933
1934 /***********************************************************************
1935  *           SetPaletteEntries    (GDI.364)
1936  */
1937 UINT16 WINAPI SetPaletteEntries16( HPALETTE16 hpalette, UINT16 start,
1938                                    UINT16 count, const PALETTEENTRY *entries )
1939 {
1940     return SetPaletteEntries( HPALETTE_32(hpalette), start, count, entries );
1941 }
1942
1943
1944 /**********************************************************************
1945  *            UpdateColors   (GDI.366)
1946  */
1947 INT16 WINAPI UpdateColors16( HDC16 hdc )
1948 {
1949     UpdateColors( HDC_32(hdc) );
1950     return TRUE;
1951 }
1952
1953
1954 /***********************************************************************
1955  *           AnimatePalette   (GDI.367)
1956  */
1957 void WINAPI AnimatePalette16( HPALETTE16 hpalette, UINT16 StartIndex,
1958                               UINT16 NumEntries, const PALETTEENTRY* PaletteColors)
1959 {
1960     AnimatePalette( HPALETTE_32(hpalette), StartIndex, NumEntries, PaletteColors );
1961 }
1962
1963
1964 /***********************************************************************
1965  *           ResizePalette   (GDI.368)
1966  */
1967 BOOL16 WINAPI ResizePalette16( HPALETTE16 hpalette, UINT16 cEntries )
1968 {
1969     return ResizePalette( HPALETTE_32(hpalette), cEntries );
1970 }
1971
1972
1973 /***********************************************************************
1974  *           GetNearestPaletteIndex   (GDI.370)
1975  */
1976 UINT16 WINAPI GetNearestPaletteIndex16( HPALETTE16 hpalette, COLORREF color )
1977 {
1978     return GetNearestPaletteIndex( HPALETTE_32(hpalette), color );
1979 }
1980
1981
1982 /**********************************************************************
1983  *          ExtFloodFill   (GDI.372)
1984  */
1985 BOOL16 WINAPI ExtFloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color,
1986                               UINT16 fillType )
1987 {
1988     return ExtFloodFill( HDC_32(hdc), x, y, color, fillType );
1989 }
1990
1991
1992 /***********************************************************************
1993  *           SetSystemPaletteUse   (GDI.373)
1994  */
1995 UINT16 WINAPI SetSystemPaletteUse16( HDC16 hdc, UINT16 use )
1996 {
1997     return SetSystemPaletteUse( HDC_32(hdc), use );
1998 }
1999
2000
2001 /***********************************************************************
2002  *           GetSystemPaletteUse   (GDI.374)
2003  */
2004 UINT16 WINAPI GetSystemPaletteUse16( HDC16 hdc )
2005 {
2006     return GetSystemPaletteUse( HDC_32(hdc) );
2007 }
2008
2009
2010 /***********************************************************************
2011  *           GetSystemPaletteEntries   (GDI.375)
2012  */
2013 UINT16 WINAPI GetSystemPaletteEntries16( HDC16 hdc, UINT16 start, UINT16 count,
2014                                          LPPALETTEENTRY entries )
2015 {
2016     return GetSystemPaletteEntries( HDC_32(hdc), start, count, entries );
2017 }
2018
2019
2020 /***********************************************************************
2021  *           ResetDC    (GDI.376)
2022  */
2023 HDC16 WINAPI ResetDC16( HDC16 hdc, const DEVMODEA *devmode )
2024 {
2025     return HDC_16( ResetDCA(HDC_32(hdc), devmode) );
2026 }
2027
2028
2029 /******************************************************************
2030  *           StartDoc   (GDI.377)
2031  */
2032 INT16 WINAPI StartDoc16( HDC16 hdc, const DOCINFO16 *lpdoc )
2033 {
2034     DOCINFOA docA;
2035
2036     docA.cbSize = lpdoc->cbSize;
2037     docA.lpszDocName = MapSL(lpdoc->lpszDocName);
2038     docA.lpszOutput = MapSL(lpdoc->lpszOutput);
2039     if(lpdoc->cbSize > offsetof(DOCINFO16,lpszDatatype))
2040         docA.lpszDatatype = MapSL(lpdoc->lpszDatatype);
2041     else
2042         docA.lpszDatatype = NULL;
2043     if(lpdoc->cbSize > offsetof(DOCINFO16,fwType))
2044         docA.fwType = lpdoc->fwType;
2045     else
2046         docA.fwType = 0;
2047     return StartDocA( HDC_32(hdc), &docA );
2048 }
2049
2050
2051 /******************************************************************
2052  *           EndDoc   (GDI.378)
2053  */
2054 INT16 WINAPI EndDoc16( HDC16 hdc )
2055 {
2056     return EndDoc( HDC_32(hdc) );
2057 }
2058
2059
2060 /******************************************************************
2061  *           StartPage   (GDI.379)
2062  */
2063 INT16 WINAPI StartPage16( HDC16 hdc )
2064 {
2065     return StartPage( HDC_32(hdc) );
2066 }
2067
2068
2069 /******************************************************************
2070  *           EndPage   (GDI.380)
2071  */
2072 INT16 WINAPI EndPage16( HDC16 hdc )
2073 {
2074     return EndPage( HDC_32(hdc) );
2075 }
2076
2077
2078 /******************************************************************************
2079  *           AbortDoc   (GDI.382)
2080  */
2081 INT16 WINAPI AbortDoc16( HDC16 hdc )
2082 {
2083     return AbortDoc( HDC_32(hdc) );
2084 }
2085
2086
2087 /***********************************************************************
2088  *           FastWindowFrame    (GDI.400)
2089  */
2090 BOOL16 WINAPI FastWindowFrame16( HDC16 hdc, const RECT16 *rect,
2091                                INT16 width, INT16 height, DWORD rop )
2092 {
2093     HDC hdc32 = HDC_32(hdc);
2094     HBRUSH hbrush = SelectObject( hdc32, GetStockObject( GRAY_BRUSH ) );
2095     PatBlt( hdc32, rect->left, rect->top,
2096             rect->right - rect->left - width, height, rop );
2097     PatBlt( hdc32, rect->left, rect->top + height, width,
2098             rect->bottom - rect->top - height, rop );
2099     PatBlt( hdc32, rect->left + width, rect->bottom - 1,
2100             rect->right - rect->left - width, -height, rop );
2101     PatBlt( hdc32, rect->right - 1, rect->top, -width,
2102             rect->bottom - rect->top - height, rop );
2103     SelectObject( hdc32, hbrush );
2104     return TRUE;
2105 }
2106
2107
2108 /***********************************************************************
2109  *           CreateUserBitmap    (GDI.407)
2110  */
2111 HBITMAP16 WINAPI CreateUserBitmap16( INT16 width, INT16 height, UINT16 planes,
2112                                      UINT16 bpp, LPCVOID bits )
2113 {
2114     return CreateBitmap16( width, height, planes, bpp, bits );
2115 }
2116
2117
2118 /***********************************************************************
2119  *           CreateUserDiscardableBitmap    (GDI.409)
2120  */
2121 HBITMAP16 WINAPI CreateUserDiscardableBitmap16( WORD dummy, INT16 width, INT16 height )
2122 {
2123     HDC hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
2124     HBITMAP ret = CreateCompatibleBitmap( hdc, width, height );
2125     DeleteDC( hdc );
2126     return HBITMAP_16(ret);
2127 }
2128
2129
2130 /***********************************************************************
2131  *              GetCurLogFont (GDI.411)
2132  */
2133 HFONT16 WINAPI GetCurLogFont16( HDC16 hdc )
2134 {
2135     return HFONT_16( GetCurrentObject( HDC_32(hdc), OBJ_FONT ) );
2136 }
2137
2138
2139 /***********************************************************************
2140  *           StretchDIBits   (GDI.439)
2141  */
2142 INT16 WINAPI StretchDIBits16( HDC16 hdc, INT16 xDst, INT16 yDst, INT16 widthDst,
2143                               INT16 heightDst, INT16 xSrc, INT16 ySrc, INT16 widthSrc,
2144                               INT16 heightSrc, const VOID *bits,
2145                               const BITMAPINFO *info, UINT16 wUsage, DWORD dwRop )
2146 {
2147     return StretchDIBits( HDC_32(hdc), xDst, yDst, widthDst, heightDst,
2148                           xSrc, ySrc, widthSrc, heightSrc, bits,
2149                           info, wUsage, dwRop );
2150 }
2151
2152
2153 /***********************************************************************
2154  *           SetDIBits    (GDI.440)
2155  */
2156 INT16 WINAPI SetDIBits16( HDC16 hdc, HBITMAP16 hbitmap, UINT16 startscan,
2157                           UINT16 lines, LPCVOID bits, const BITMAPINFO *info,
2158                           UINT16 coloruse )
2159 {
2160     return SetDIBits( HDC_32(hdc), HBITMAP_32(hbitmap), startscan, lines, bits, info, coloruse );
2161 }
2162
2163
2164 /***********************************************************************
2165  *           GetDIBits    (GDI.441)
2166  */
2167 INT16 WINAPI GetDIBits16( HDC16 hdc, HBITMAP16 hbitmap, UINT16 startscan,
2168                           UINT16 lines, LPVOID bits, BITMAPINFO * info,
2169                           UINT16 coloruse )
2170 {
2171     return GetDIBits( HDC_32(hdc), HBITMAP_32(hbitmap), startscan, lines, bits, info, coloruse );
2172 }
2173
2174
2175 /***********************************************************************
2176  *           CreateDIBitmap    (GDI.442)
2177  */
2178 HBITMAP16 WINAPI CreateDIBitmap16( HDC16 hdc, const BITMAPINFOHEADER * header,
2179                                    DWORD init, LPCVOID bits, const BITMAPINFO * data,
2180                                    UINT16 coloruse )
2181 {
2182     return HBITMAP_16( CreateDIBitmap( HDC_32(hdc), header, init, bits, data, coloruse ) );
2183 }
2184
2185
2186 /***********************************************************************
2187  *           SetDIBitsToDevice    (GDI.443)
2188  */
2189 INT16 WINAPI SetDIBitsToDevice16( HDC16 hdc, INT16 xDest, INT16 yDest, INT16 cx,
2190                                   INT16 cy, INT16 xSrc, INT16 ySrc, UINT16 startscan,
2191                                   UINT16 lines, LPCVOID bits, const BITMAPINFO *info,
2192                                   UINT16 coloruse )
2193 {
2194     return SetDIBitsToDevice( HDC_32(hdc), xDest, yDest, cx, cy, xSrc, ySrc,
2195                               startscan, lines, bits, info, coloruse );
2196 }
2197
2198
2199 /***********************************************************************
2200  *           CreateRoundRectRgn    (GDI.444)
2201  *
2202  * If either ellipse dimension is zero we call CreateRectRgn16 for its
2203  * `special' behaviour. -ve ellipse dimensions can result in GPFs under win3.1
2204  * we just let CreateRoundRectRgn convert them to +ve values.
2205  */
2206
2207 HRGN16 WINAPI CreateRoundRectRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom,
2208                                     INT16 ellipse_width, INT16 ellipse_height )
2209 {
2210     if( ellipse_width == 0 || ellipse_height == 0 )
2211         return CreateRectRgn16( left, top, right, bottom );
2212     else
2213         return HRGN_16( CreateRoundRectRgn( left, top, right, bottom,
2214                                             ellipse_width, ellipse_height ));
2215 }
2216
2217
2218 /***********************************************************************
2219  *           CreateDIBPatternBrush    (GDI.445)
2220  */
2221 HBRUSH16 WINAPI CreateDIBPatternBrush16( HGLOBAL16 hbitmap, UINT16 coloruse )
2222 {
2223     BITMAPINFO *bmi;
2224     HBRUSH16 ret;
2225
2226     if (!(bmi = GlobalLock16( hbitmap ))) return 0;
2227     ret = HBRUSH_16( CreateDIBPatternBrushPt( bmi, coloruse ));
2228     GlobalUnlock16( hbitmap );
2229     return ret;
2230 }
2231
2232
2233 /**********************************************************************
2234  *          PolyPolygon (GDI.450)
2235  */
2236 BOOL16 WINAPI PolyPolygon16( HDC16 hdc, const POINT16* pt, const INT16* counts,
2237                              UINT16 polygons )
2238 {
2239     int         i,nrpts;
2240     LPPOINT     pt32;
2241     LPINT       counts32;
2242     BOOL16      ret;
2243
2244     nrpts=0;
2245     for (i=polygons;i--;)
2246         nrpts+=counts[i];
2247     pt32 = HeapAlloc( GetProcessHeap(), 0, sizeof(POINT)*nrpts);
2248     if(pt32 == NULL) return FALSE;
2249     for (i=nrpts;i--;)
2250     {
2251         pt32[i].x = pt[i].x;
2252         pt32[i].y = pt[i].y;
2253     }
2254     counts32 = HeapAlloc( GetProcessHeap(), 0, polygons*sizeof(INT) );
2255     if(counts32 == NULL) {
2256         HeapFree( GetProcessHeap(), 0, pt32 );
2257         return FALSE;
2258     }
2259     for (i=polygons;i--;) counts32[i]=counts[i];
2260
2261     ret = PolyPolygon(HDC_32(hdc),pt32,counts32,polygons);
2262     HeapFree( GetProcessHeap(), 0, counts32 );
2263     HeapFree( GetProcessHeap(), 0, pt32 );
2264     return ret;
2265 }
2266
2267
2268 /***********************************************************************
2269  *           CreatePolyPolygonRgn    (GDI.451)
2270  */
2271 HRGN16 WINAPI CreatePolyPolygonRgn16( const POINT16 *points,
2272                                       const INT16 *count, INT16 nbpolygons, INT16 mode )
2273 {
2274     HRGN hrgn;
2275     int i, npts = 0;
2276     INT *count32;
2277     POINT *points32;
2278
2279     for (i = 0; i < nbpolygons; i++) npts += count[i];
2280     points32 = HeapAlloc( GetProcessHeap(), 0, npts * sizeof(POINT) );
2281     for (i = 0; i < npts; i++)
2282     {
2283         points32[i].x = points[i].x;
2284         points32[i].y = points[i].y;
2285     }
2286
2287     count32 = HeapAlloc( GetProcessHeap(), 0, nbpolygons * sizeof(INT) );
2288     for (i = 0; i < nbpolygons; i++) count32[i] = count[i];
2289     hrgn = CreatePolyPolygonRgn( points32, count32, nbpolygons, mode );
2290     HeapFree( GetProcessHeap(), 0, count32 );
2291     HeapFree( GetProcessHeap(), 0, points32 );
2292     return HRGN_16(hrgn);
2293 }
2294
2295
2296 /***********************************************************************
2297  *           SetObjectOwner    (GDI.461)
2298  */
2299 void WINAPI SetObjectOwner16( HGDIOBJ16 handle, HANDLE16 owner )
2300 {
2301     /* Nothing to do */
2302 }
2303
2304
2305 /***********************************************************************
2306  *           RectVisible    (GDI.465)
2307  *           RectVisibleOld (GDI.104)
2308  */
2309 BOOL16 WINAPI RectVisible16( HDC16 hdc, const RECT16* rect16 )
2310 {
2311     RECT rect;
2312
2313     rect.left   = rect16->left;
2314     rect.top    = rect16->top;
2315     rect.right  = rect16->right;
2316     rect.bottom = rect16->bottom;
2317     return RectVisible( HDC_32(hdc), &rect );
2318 }
2319
2320
2321 /***********************************************************************
2322  *           RectInRegion    (GDI.466)
2323  *           RectInRegionOld (GDI.181)
2324  */
2325 BOOL16 WINAPI RectInRegion16( HRGN16 hrgn, const RECT16 *rect )
2326 {
2327     RECT r32;
2328
2329     r32.left   = rect->left;
2330     r32.top    = rect->top;
2331     r32.right  = rect->right;
2332     r32.bottom = rect->bottom;
2333     return RectInRegion( HRGN_32(hrgn), &r32 );
2334 }
2335
2336
2337 /***********************************************************************
2338  *           GetBitmapDimensionEx    (GDI.468)
2339  */
2340 BOOL16 WINAPI GetBitmapDimensionEx16( HBITMAP16 hbitmap, LPSIZE16 size )
2341 {
2342     SIZE size32;
2343     BOOL ret = GetBitmapDimensionEx( HBITMAP_32(hbitmap), &size32 );
2344
2345     if (ret)
2346     {
2347         size->cx = size32.cx;
2348         size->cy = size32.cy;
2349     }
2350     return ret;
2351 }
2352
2353
2354 /***********************************************************************
2355  *              GetBrushOrgEx (GDI.469)
2356  */
2357 BOOL16 WINAPI GetBrushOrgEx16( HDC16 hdc, LPPOINT16 pt )
2358 {
2359     POINT pt32;
2360     if (!GetBrushOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
2361     pt->x = pt32.x;
2362     pt->y = pt32.y;
2363     return TRUE;
2364 }
2365
2366
2367 /***********************************************************************
2368  *              GetCurrentPositionEx (GDI.470)
2369  */
2370 BOOL16 WINAPI GetCurrentPositionEx16( HDC16 hdc, LPPOINT16 pt )
2371 {
2372     POINT pt32;
2373     if (!GetCurrentPositionEx( HDC_32(hdc), &pt32 )) return FALSE;
2374     pt->x = pt32.x;
2375     pt->y = pt32.y;
2376     return TRUE;
2377 }
2378
2379
2380 /***********************************************************************
2381  *           GetTextExtentPoint    (GDI.471)
2382  *
2383  * FIXME: Should this have a bug for compatibility?
2384  * Original Windows versions of GetTextExtentPoint{A,W} have documented
2385  * bugs (-> MSDN KB q147647.txt).
2386  */
2387 BOOL16 WINAPI GetTextExtentPoint16( HDC16 hdc, LPCSTR str, INT16 count, LPSIZE16 size )
2388 {
2389     SIZE size32;
2390     BOOL ret = GetTextExtentPoint32A( HDC_32(hdc), str, count, &size32 );
2391
2392     if (ret)
2393     {
2394         size->cx = size32.cx;
2395         size->cy = size32.cy;
2396     }
2397     return ret;
2398 }
2399
2400
2401 /***********************************************************************
2402  *              GetViewportExtEx (GDI.472)
2403  */
2404 BOOL16 WINAPI GetViewportExtEx16( HDC16 hdc, LPSIZE16 size )
2405 {
2406     SIZE size32;
2407     if (!GetViewportExtEx( HDC_32(hdc), &size32 )) return FALSE;
2408     size->cx = size32.cx;
2409     size->cy = size32.cy;
2410     return TRUE;
2411 }
2412
2413
2414 /***********************************************************************
2415  *              GetViewportOrgEx (GDI.473)
2416  */
2417 BOOL16 WINAPI GetViewportOrgEx16( HDC16 hdc, LPPOINT16 pt )
2418 {
2419     POINT pt32;
2420     if (!GetViewportOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
2421     pt->x = pt32.x;
2422     pt->y = pt32.y;
2423     return TRUE;
2424 }
2425
2426
2427 /***********************************************************************
2428  *              GetWindowExtEx (GDI.474)
2429  */
2430 BOOL16 WINAPI GetWindowExtEx16( HDC16 hdc, LPSIZE16 size )
2431 {
2432     SIZE size32;
2433     if (!GetWindowExtEx( HDC_32(hdc), &size32 )) return FALSE;
2434     size->cx = size32.cx;
2435     size->cy = size32.cy;
2436     return TRUE;
2437 }
2438
2439
2440 /***********************************************************************
2441  *              GetWindowOrgEx (GDI.475)
2442  */
2443 BOOL16 WINAPI GetWindowOrgEx16( HDC16 hdc, LPPOINT16 pt )
2444 {
2445     POINT pt32;
2446     if (!GetWindowOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
2447     pt->x = pt32.x;
2448     pt->y = pt32.y;
2449     return TRUE;
2450 }
2451
2452
2453 /***********************************************************************
2454  *           OffsetViewportOrgEx    (GDI.476)
2455  */
2456 BOOL16 WINAPI OffsetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt)
2457 {
2458     POINT pt32;
2459     BOOL16 ret = OffsetViewportOrgEx( HDC_32(hdc), x, y, &pt32 );
2460     if (pt)
2461     {
2462         pt->x = pt32.x;
2463         pt->y = pt32.y;
2464     }
2465     return ret;
2466 }
2467
2468
2469 /***********************************************************************
2470  *           OffsetWindowOrgEx    (GDI.477)
2471  */
2472 BOOL16 WINAPI OffsetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
2473 {
2474     POINT pt32;
2475     BOOL16 ret = OffsetWindowOrgEx( HDC_32(hdc), x, y, &pt32 );
2476     if (pt)
2477     {
2478         pt->x = pt32.x;
2479         pt->y = pt32.y;
2480     }
2481     return ret;
2482 }
2483
2484
2485 /***********************************************************************
2486  *           SetBitmapDimensionEx    (GDI.478)
2487  */
2488 BOOL16 WINAPI SetBitmapDimensionEx16( HBITMAP16 hbitmap, INT16 x, INT16 y, LPSIZE16 prevSize )
2489 {
2490     SIZE size32;
2491     BOOL ret = SetBitmapDimensionEx( HBITMAP_32(hbitmap), x, y, &size32 );
2492
2493     if (ret && prevSize)
2494     {
2495         prevSize->cx = size32.cx;
2496         prevSize->cy = size32.cy;
2497     }
2498     return ret;
2499 }
2500
2501
2502 /***********************************************************************
2503  *           SetViewportExtEx    (GDI.479)
2504  */
2505 BOOL16 WINAPI SetViewportExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
2506 {
2507     SIZE size32;
2508     BOOL16 ret = SetViewportExtEx( HDC_32(hdc), x, y, &size32 );
2509     if (size) { size->cx = size32.cx; size->cy = size32.cy; }
2510     return ret;
2511 }
2512
2513
2514 /***********************************************************************
2515  *           SetViewportOrgEx    (GDI.480)
2516  */
2517 BOOL16 WINAPI SetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
2518 {
2519     POINT pt32;
2520     BOOL16 ret = SetViewportOrgEx( HDC_32(hdc), x, y, &pt32 );
2521     if (pt)
2522     {
2523         pt->x = pt32.x;
2524         pt->y = pt32.y;
2525     }
2526     return ret;
2527 }
2528
2529
2530 /***********************************************************************
2531  *           SetWindowExtEx    (GDI.481)
2532  */
2533 BOOL16 WINAPI SetWindowExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
2534 {
2535     SIZE size32;
2536     BOOL16 ret = SetWindowExtEx( HDC_32(hdc), x, y, &size32 );
2537     if (size) { size->cx = size32.cx; size->cy = size32.cy; }
2538     return ret;
2539 }
2540
2541
2542 /***********************************************************************
2543  *           SetWindowOrgEx    (GDI.482)
2544  */
2545 BOOL16 WINAPI SetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
2546 {
2547     POINT pt32;
2548     BOOL16 ret = SetWindowOrgEx( HDC_32(hdc), x, y, &pt32 );
2549     if (pt)
2550     {
2551         pt->x = pt32.x;
2552         pt->y = pt32.y;
2553     }
2554     return ret;
2555 }
2556
2557
2558 /***********************************************************************
2559  *           MoveToEx    (GDI.483)
2560  */
2561 BOOL16 WINAPI MoveToEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
2562 {
2563     POINT pt32;
2564
2565     if (!MoveToEx( HDC_32(hdc), x, y, &pt32 )) return FALSE;
2566     if (pt)
2567     {
2568         pt->x = pt32.x;
2569         pt->y = pt32.y;
2570     }
2571     return TRUE;
2572 }
2573
2574
2575 /***********************************************************************
2576  *           ScaleViewportExtEx    (GDI.484)
2577  */
2578 BOOL16 WINAPI ScaleViewportExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
2579                                     INT16 yNum, INT16 yDenom, LPSIZE16 size )
2580 {
2581     SIZE size32;
2582     BOOL16 ret = ScaleViewportExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom,
2583                                        &size32 );
2584     if (size) { size->cx = size32.cx; size->cy = size32.cy; }
2585     return ret;
2586 }
2587
2588
2589 /***********************************************************************
2590  *           ScaleWindowExtEx    (GDI.485)
2591  */
2592 BOOL16 WINAPI ScaleWindowExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
2593                                   INT16 yNum, INT16 yDenom, LPSIZE16 size )
2594 {
2595     SIZE size32;
2596     BOOL16 ret = ScaleWindowExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom,
2597                                      &size32 );
2598     if (size) { size->cx = size32.cx; size->cy = size32.cy; }
2599     return ret;
2600 }
2601
2602
2603 /******************************************************************************
2604  *           PolyBezier  (GDI.502)
2605  */
2606 BOOL16 WINAPI PolyBezier16( HDC16 hdc, const POINT16* lppt, INT16 cPoints )
2607 {
2608     int i;
2609     BOOL16 ret;
2610     LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, cPoints*sizeof(POINT) );
2611     if(!pt32) return FALSE;
2612     for (i=cPoints;i--;)
2613     {
2614         pt32[i].x = lppt[i].x;
2615         pt32[i].y = lppt[i].y;
2616     }
2617     ret= PolyBezier(HDC_32(hdc), pt32, cPoints);
2618     HeapFree( GetProcessHeap(), 0, pt32 );
2619     return ret;
2620 }
2621
2622
2623 /******************************************************************************
2624  *           PolyBezierTo  (GDI.503)
2625  */
2626 BOOL16 WINAPI PolyBezierTo16( HDC16 hdc, const POINT16* lppt, INT16 cPoints )
2627 {
2628     int i;
2629     BOOL16 ret;
2630     LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0,
2631                                            cPoints*sizeof(POINT) );
2632     if(!pt32) return FALSE;
2633     for (i=cPoints;i--;)
2634     {
2635         pt32[i].x = lppt[i].x;
2636         pt32[i].y = lppt[i].y;
2637     }
2638     ret= PolyBezierTo(HDC_32(hdc), pt32, cPoints);
2639     HeapFree( GetProcessHeap(), 0, pt32 );
2640     return ret;
2641 }
2642
2643
2644 /******************************************************************************
2645  *           ExtSelectClipRgn   (GDI.508)
2646  */
2647 INT16 WINAPI ExtSelectClipRgn16( HDC16 hdc, HRGN16 hrgn, INT16 fnMode )
2648 {
2649   return ExtSelectClipRgn( HDC_32(hdc), HRGN_32(hrgn), fnMode);
2650 }
2651
2652
2653 /***********************************************************************
2654  *           AbortPath    (GDI.511)
2655  */
2656 BOOL16 WINAPI AbortPath16(HDC16 hdc)
2657 {
2658     return AbortPath( HDC_32(hdc) );
2659 }
2660
2661
2662 /***********************************************************************
2663  *           BeginPath    (GDI.512)
2664  */
2665 BOOL16 WINAPI BeginPath16(HDC16 hdc)
2666 {
2667     return BeginPath( HDC_32(hdc) );
2668 }
2669
2670
2671 /***********************************************************************
2672  *           CloseFigure    (GDI.513)
2673  */
2674 BOOL16 WINAPI CloseFigure16(HDC16 hdc)
2675 {
2676     return CloseFigure( HDC_32(hdc) );
2677 }
2678
2679
2680 /***********************************************************************
2681  *           EndPath    (GDI.514)
2682  */
2683 BOOL16 WINAPI EndPath16(HDC16 hdc)
2684 {
2685     return EndPath( HDC_32(hdc) );
2686 }
2687
2688
2689 /***********************************************************************
2690  *           FillPath    (GDI.515)
2691  */
2692 BOOL16 WINAPI FillPath16(HDC16 hdc)
2693 {
2694     return FillPath( HDC_32(hdc) );
2695 }
2696
2697
2698 /*******************************************************************
2699  *           FlattenPath    (GDI.516)
2700  */
2701 BOOL16 WINAPI FlattenPath16(HDC16 hdc)
2702 {
2703     return FlattenPath( HDC_32(hdc) );
2704 }
2705
2706
2707 /***********************************************************************
2708  *           GetPath    (GDI.517)
2709  */
2710 INT16 WINAPI GetPath16(HDC16 hdc, LPPOINT16 pPoints, LPBYTE pTypes, INT16 nSize)
2711 {
2712     FIXME("(%d,%p,%p): stub\n",hdc,pPoints,pTypes);
2713     return 0;
2714 }
2715
2716
2717 /***********************************************************************
2718  *           PathToRegion    (GDI.518)
2719  */
2720 HRGN16 WINAPI PathToRegion16(HDC16 hdc)
2721 {
2722     return HRGN_16( PathToRegion( HDC_32(hdc) ));
2723 }
2724
2725
2726 /***********************************************************************
2727  *           SelectClipPath    (GDI.519)
2728  */
2729 BOOL16 WINAPI SelectClipPath16(HDC16 hdc, INT16 iMode)
2730 {
2731     return SelectClipPath( HDC_32(hdc), iMode );
2732 }
2733
2734
2735 /*******************************************************************
2736  *           StrokeAndFillPath    (GDI.520)
2737  */
2738 BOOL16 WINAPI StrokeAndFillPath16(HDC16 hdc)
2739 {
2740     return StrokeAndFillPath( HDC_32(hdc) );
2741 }
2742
2743
2744 /*******************************************************************
2745  *           StrokePath    (GDI.521)
2746  */
2747 BOOL16 WINAPI StrokePath16(HDC16 hdc)
2748 {
2749     return StrokePath( HDC_32(hdc) );
2750 }
2751
2752
2753 /*******************************************************************
2754  *           WidenPath    (GDI.522)
2755  */
2756 BOOL16 WINAPI WidenPath16(HDC16 hdc)
2757 {
2758     return WidenPath( HDC_32(hdc) );
2759 }
2760
2761
2762 /***********************************************************************
2763  *              GetArcDirection (GDI.524)
2764  */
2765 INT16 WINAPI GetArcDirection16( HDC16 hdc )
2766 {
2767     return GetArcDirection( HDC_32(hdc) );
2768 }
2769
2770
2771 /***********************************************************************
2772  *           SetArcDirection    (GDI.525)
2773  */
2774 INT16 WINAPI SetArcDirection16( HDC16 hdc, INT16 nDirection )
2775 {
2776     return SetArcDirection( HDC_32(hdc), (INT)nDirection );
2777 }
2778
2779
2780 /***********************************************************************
2781  *           CreateHalftonePalette (GDI.529)
2782  */
2783 HPALETTE16 WINAPI CreateHalftonePalette16( HDC16 hdc )
2784 {
2785     return HPALETTE_16( CreateHalftonePalette( HDC_32(hdc) ));
2786 }
2787
2788
2789 /***********************************************************************
2790  *           SetDIBColorTable    (GDI.602)
2791  */
2792 UINT16 WINAPI SetDIBColorTable16( HDC16 hdc, UINT16 startpos, UINT16 entries, RGBQUAD *colors )
2793 {
2794     return SetDIBColorTable( HDC_32(hdc), startpos, entries, colors );
2795 }
2796
2797
2798 /***********************************************************************
2799  *           GetDIBColorTable    (GDI.603)
2800  */
2801 UINT16 WINAPI GetDIBColorTable16( HDC16 hdc, UINT16 startpos, UINT16 entries, RGBQUAD *colors )
2802 {
2803     return GetDIBColorTable( HDC_32(hdc), startpos, entries, colors );
2804 }
2805
2806
2807 /***********************************************************************
2808  *           GetRegionData   (GDI.607)
2809  *
2810  * FIXME: is LPRGNDATA the same in Win16 and Win32 ?
2811  */
2812 DWORD WINAPI GetRegionData16( HRGN16 hrgn, DWORD count, LPRGNDATA rgndata )
2813 {
2814     return GetRegionData( HRGN_32(hrgn), count, rgndata );
2815 }
2816
2817
2818 /***********************************************************************
2819  *           GetTextCharset   (GDI.612)
2820  */
2821 UINT16 WINAPI GetTextCharset16( HDC16 hdc )
2822 {
2823     return GetTextCharset( HDC_32(hdc) );
2824 }
2825
2826
2827 /*************************************************************************
2828  *             GetFontLanguageInfo   (GDI.616)
2829  */
2830 DWORD WINAPI GetFontLanguageInfo16( HDC16 hdc )
2831 {
2832     return GetFontLanguageInfo( HDC_32(hdc) );
2833 }
2834
2835
2836 /***********************************************************************
2837  *           SetLayout   (GDI.1000)
2838  *
2839  * Sets left->right or right->left text layout flags of a dc.
2840  */
2841 BOOL16 WINAPI SetLayout16( HDC16 hdc, DWORD layout )
2842 {
2843     return SetLayout( HDC_32(hdc), layout );
2844 }