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