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