push b00f9bcd3487b4cb0fef1c9e26a0e57bdeabe83d
[wine/hacks.git] / dlls / gdi32 / gdi16.c
blob643f682c46799442d06a04277066e440a97ae209
1 /*
2 * GDI 16-bit functions
4 * Copyright 2002 Alexandre Julliard
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.
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.
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
21 #include <stdarg.h>
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"
31 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
33 #define HGDIOBJ_32(handle16) ((HGDIOBJ)(ULONG_PTR)(handle16))
34 #define HGDIOBJ_16(handle32) ((HGDIOBJ16)(ULONG_PTR)(handle32))
36 struct callback16_info
38 FARPROC16 proc;
39 LPARAM param;
42 /* callback for LineDDA16 */
43 static void CALLBACK linedda_callback( INT x, INT y, LPARAM param )
45 const struct callback16_info *info = (struct callback16_info *)param;
46 WORD args[4];
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 );
55 /* callback for EnumObjects16 */
56 static INT CALLBACK enum_pens_callback( void *ptr, LPARAM param )
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];
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);
79 /* callback for EnumObjects16 */
80 static INT CALLBACK enum_brushes_callback( void *ptr, LPARAM param )
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];
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;
102 /* convert a LOGFONT16 to a LOGFONTW */
103 static void logfont_16_to_W( const LOGFONT16 *font16, LPLOGFONTW font32 )
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;
122 /* convert a LOGFONTW to a LOGFONT16 */
123 static void logfont_W_to_16( const LOGFONTW* font32, LPLOGFONT16 font16 )
125 font16->lfHeight = font32->lfHeight;
126 font16->lfWidth = font32->lfWidth;
127 font16->lfEscapement = font32->lfEscapement;
128 font16->lfOrientation = font32->lfOrientation;
129 font16->lfWeight = font32->lfWeight;
130 font16->lfItalic = font32->lfItalic;
131 font16->lfUnderline = font32->lfUnderline;
132 font16->lfStrikeOut = font32->lfStrikeOut;
133 font16->lfCharSet = font32->lfCharSet;
134 font16->lfOutPrecision = font32->lfOutPrecision;
135 font16->lfClipPrecision = font32->lfClipPrecision;
136 font16->lfQuality = font32->lfQuality;
137 font16->lfPitchAndFamily = font32->lfPitchAndFamily;
138 WideCharToMultiByte( CP_ACP, 0, font32->lfFaceName, -1, font16->lfFaceName, LF_FACESIZE, NULL, NULL );
139 font16->lfFaceName[LF_FACESIZE-1] = 0;
142 /* convert a ENUMLOGFONTEXW to a ENUMLOGFONTEX16 */
143 static void enumlogfontex_W_to_16( const ENUMLOGFONTEXW *fontW,
144 LPENUMLOGFONTEX16 font16 )
146 logfont_W_to_16( (const LOGFONTW *)fontW, (LPLOGFONT16)font16);
148 WideCharToMultiByte( CP_ACP, 0, fontW->elfFullName, -1,
149 (LPSTR) font16->elfFullName, LF_FULLFACESIZE, NULL, NULL );
150 font16->elfFullName[LF_FULLFACESIZE-1] = '\0';
151 WideCharToMultiByte( CP_ACP, 0, fontW->elfStyle, -1,
152 (LPSTR) font16->elfStyle, LF_FACESIZE, NULL, NULL );
153 font16->elfStyle[LF_FACESIZE-1] = '\0';
154 WideCharToMultiByte( CP_ACP, 0, fontW->elfScript, -1,
155 (LPSTR) font16->elfScript, LF_FACESIZE, NULL, NULL );
156 font16->elfScript[LF_FACESIZE-1] = '\0';
159 /* convert a NEWTEXTMETRICEXW to a NEWTEXTMETRICEX16 */
160 static void newtextmetricex_W_to_16( const NEWTEXTMETRICEXW *ptmW,
161 LPNEWTEXTMETRICEX16 ptm16 )
163 ptm16->ntmTm.tmHeight = ptmW->ntmTm.tmHeight;
164 ptm16->ntmTm.tmAscent = ptmW->ntmTm.tmAscent;
165 ptm16->ntmTm.tmDescent = ptmW->ntmTm.tmDescent;
166 ptm16->ntmTm.tmInternalLeading = ptmW->ntmTm.tmInternalLeading;
167 ptm16->ntmTm.tmExternalLeading = ptmW->ntmTm.tmExternalLeading;
168 ptm16->ntmTm.tmAveCharWidth = ptmW->ntmTm.tmAveCharWidth;
169 ptm16->ntmTm.tmMaxCharWidth = ptmW->ntmTm.tmMaxCharWidth;
170 ptm16->ntmTm.tmWeight = ptmW->ntmTm.tmWeight;
171 ptm16->ntmTm.tmOverhang = ptmW->ntmTm.tmOverhang;
172 ptm16->ntmTm.tmDigitizedAspectX = ptmW->ntmTm.tmDigitizedAspectX;
173 ptm16->ntmTm.tmDigitizedAspectY = ptmW->ntmTm.tmDigitizedAspectY;
174 ptm16->ntmTm.tmFirstChar = ptmW->ntmTm.tmFirstChar > 255 ? 255 : ptmW->ntmTm.tmFirstChar;
175 ptm16->ntmTm.tmLastChar = ptmW->ntmTm.tmLastChar > 255 ? 255 : ptmW->ntmTm.tmLastChar;
176 ptm16->ntmTm.tmDefaultChar = ptmW->ntmTm.tmDefaultChar > 255 ? 255 : ptmW->ntmTm.tmDefaultChar;
177 ptm16->ntmTm.tmBreakChar = ptmW->ntmTm.tmBreakChar > 255 ? 255 : ptmW->ntmTm.tmBreakChar;
178 ptm16->ntmTm.tmItalic = ptmW->ntmTm.tmItalic;
179 ptm16->ntmTm.tmUnderlined = ptmW->ntmTm.tmUnderlined;
180 ptm16->ntmTm.tmStruckOut = ptmW->ntmTm.tmStruckOut;
181 ptm16->ntmTm.tmPitchAndFamily = ptmW->ntmTm.tmPitchAndFamily;
182 ptm16->ntmTm.tmCharSet = ptmW->ntmTm.tmCharSet;
183 ptm16->ntmTm.ntmFlags = ptmW->ntmTm.ntmFlags;
184 ptm16->ntmTm.ntmSizeEM = ptmW->ntmTm.ntmSizeEM;
185 ptm16->ntmTm.ntmCellHeight = ptmW->ntmTm.ntmCellHeight;
186 ptm16->ntmTm.ntmAvgWidth = ptmW->ntmTm.ntmAvgWidth;
187 ptm16->ntmFontSig = ptmW->ntmFontSig;
191 * callback for EnumFontFamiliesEx16
192 * Note: plf is really an ENUMLOGFONTEXW, and ptm is a NEWTEXTMETRICEXW.
193 * We have to use other types because of the FONTENUMPROCW definition.
195 static INT CALLBACK enum_font_callback( const LOGFONTW *plf,
196 const TEXTMETRICW *ptm, DWORD fType,
197 LPARAM param )
199 const struct callback16_info *info = (struct callback16_info *)param;
200 ENUMLOGFONTEX16 elfe16;
201 NEWTEXTMETRICEX16 ntm16;
202 SEGPTR segelfe16;
203 SEGPTR segntm16;
204 WORD args[7];
205 DWORD ret;
207 enumlogfontex_W_to_16((const ENUMLOGFONTEXW *)plf, &elfe16);
208 newtextmetricex_W_to_16((const NEWTEXTMETRICEXW *)ptm, &ntm16);
209 segelfe16 = MapLS( &elfe16 );
210 segntm16 = MapLS( &ntm16 );
211 args[6] = SELECTOROF(segelfe16);
212 args[5] = OFFSETOF(segelfe16);
213 args[4] = SELECTOROF(segntm16);
214 args[3] = OFFSETOF(segntm16);
215 args[2] = fType;
216 args[1] = HIWORD(info->param);
217 args[0] = LOWORD(info->param);
219 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
220 UnMapLS( segelfe16 );
221 UnMapLS( segntm16 );
222 return LOWORD(ret);
226 /***********************************************************************
227 * SetBkColor (GDI.1)
229 COLORREF WINAPI SetBkColor16( HDC16 hdc, COLORREF color )
231 return SetBkColor( HDC_32(hdc), color );
235 /***********************************************************************
236 * SetBkMode (GDI.2)
238 INT16 WINAPI SetBkMode16( HDC16 hdc, INT16 mode )
240 return SetBkMode( HDC_32(hdc), mode );
244 /***********************************************************************
245 * SetMapMode (GDI.3)
247 INT16 WINAPI SetMapMode16( HDC16 hdc, INT16 mode )
249 return SetMapMode( HDC_32(hdc), mode );
253 /***********************************************************************
254 * SetROP2 (GDI.4)
256 INT16 WINAPI SetROP216( HDC16 hdc, INT16 mode )
258 return SetROP2( HDC_32(hdc), mode );
262 /***********************************************************************
263 * SetRelAbs (GDI.5)
265 INT16 WINAPI SetRelAbs16( HDC16 hdc, INT16 mode )
267 return SetRelAbs( HDC_32(hdc), mode );
271 /***********************************************************************
272 * SetPolyFillMode (GDI.6)
274 INT16 WINAPI SetPolyFillMode16( HDC16 hdc, INT16 mode )
276 return SetPolyFillMode( HDC_32(hdc), mode );
280 /***********************************************************************
281 * SetStretchBltMode (GDI.7)
283 INT16 WINAPI SetStretchBltMode16( HDC16 hdc, INT16 mode )
285 return SetStretchBltMode( HDC_32(hdc), mode );
289 /***********************************************************************
290 * SetTextCharacterExtra (GDI.8)
292 INT16 WINAPI SetTextCharacterExtra16( HDC16 hdc, INT16 extra )
294 return SetTextCharacterExtra( HDC_32(hdc), extra );
298 /***********************************************************************
299 * SetTextColor (GDI.9)
301 COLORREF WINAPI SetTextColor16( HDC16 hdc, COLORREF color )
303 return SetTextColor( HDC_32(hdc), color );
307 /***********************************************************************
308 * SetTextJustification (GDI.10)
310 INT16 WINAPI SetTextJustification16( HDC16 hdc, INT16 extra, INT16 breaks )
312 return SetTextJustification( HDC_32(hdc), extra, breaks );
316 /***********************************************************************
317 * SetWindowOrg (GDI.11)
319 DWORD WINAPI SetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
321 POINT pt;
322 if (!SetWindowOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
323 return MAKELONG( pt.x, pt.y );
327 /***********************************************************************
328 * SetWindowExt (GDI.12)
330 DWORD WINAPI SetWindowExt16( HDC16 hdc, INT16 x, INT16 y )
332 SIZE size;
333 if (!SetWindowExtEx( HDC_32(hdc), x, y, &size )) return 0;
334 return MAKELONG( size.cx, size.cy );
338 /***********************************************************************
339 * SetViewportOrg (GDI.13)
341 DWORD WINAPI SetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
343 POINT pt;
344 if (!SetViewportOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
345 return MAKELONG( pt.x, pt.y );
349 /***********************************************************************
350 * SetViewportExt (GDI.14)
352 DWORD WINAPI SetViewportExt16( HDC16 hdc, INT16 x, INT16 y )
354 SIZE size;
355 if (!SetViewportExtEx( HDC_32(hdc), x, y, &size )) return 0;
356 return MAKELONG( size.cx, size.cy );
360 /***********************************************************************
361 * OffsetWindowOrg (GDI.15)
363 DWORD WINAPI OffsetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
365 POINT pt;
366 if (!OffsetWindowOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
367 return MAKELONG( pt.x, pt.y );
371 /***********************************************************************
372 * ScaleWindowExt (GDI.16)
374 DWORD WINAPI ScaleWindowExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
375 INT16 yNum, INT16 yDenom )
377 SIZE size;
378 if (!ScaleWindowExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom, &size ))
379 return FALSE;
380 return MAKELONG( size.cx, size.cy );
384 /***********************************************************************
385 * OffsetViewportOrg (GDI.17)
387 DWORD WINAPI OffsetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
389 POINT pt;
390 if (!OffsetViewportOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
391 return MAKELONG( pt.x, pt.y );
395 /***********************************************************************
396 * ScaleViewportExt (GDI.18)
398 DWORD WINAPI ScaleViewportExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
399 INT16 yNum, INT16 yDenom )
401 SIZE size;
402 if (!ScaleViewportExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom, &size ))
403 return FALSE;
404 return MAKELONG( size.cx, size.cy );
408 /***********************************************************************
409 * LineTo (GDI.19)
411 BOOL16 WINAPI LineTo16( HDC16 hdc, INT16 x, INT16 y )
413 return LineTo( HDC_32(hdc), x, y );
417 /***********************************************************************
418 * MoveTo (GDI.20)
420 DWORD WINAPI MoveTo16( HDC16 hdc, INT16 x, INT16 y )
422 POINT pt;
424 if (!MoveToEx( HDC_32(hdc), x, y, &pt )) return 0;
425 return MAKELONG(pt.x,pt.y);
429 /***********************************************************************
430 * ExcludeClipRect (GDI.21)
432 INT16 WINAPI ExcludeClipRect16( HDC16 hdc, INT16 left, INT16 top,
433 INT16 right, INT16 bottom )
435 return ExcludeClipRect( HDC_32(hdc), left, top, right, bottom );
439 /***********************************************************************
440 * IntersectClipRect (GDI.22)
442 INT16 WINAPI IntersectClipRect16( HDC16 hdc, INT16 left, INT16 top,
443 INT16 right, INT16 bottom )
445 return IntersectClipRect( HDC_32(hdc), left, top, right, bottom );
449 /***********************************************************************
450 * Arc (GDI.23)
452 BOOL16 WINAPI Arc16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
453 INT16 bottom, INT16 xstart, INT16 ystart,
454 INT16 xend, INT16 yend )
456 return Arc( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
460 /***********************************************************************
461 * Ellipse (GDI.24)
463 BOOL16 WINAPI Ellipse16( HDC16 hdc, INT16 left, INT16 top,
464 INT16 right, INT16 bottom )
466 return Ellipse( HDC_32(hdc), left, top, right, bottom );
470 /**********************************************************************
471 * FloodFill (GDI.25)
473 BOOL16 WINAPI FloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
475 return ExtFloodFill( HDC_32(hdc), x, y, color, FLOODFILLBORDER );
479 /***********************************************************************
480 * Pie (GDI.26)
482 BOOL16 WINAPI Pie16( HDC16 hdc, INT16 left, INT16 top,
483 INT16 right, INT16 bottom, INT16 xstart, INT16 ystart,
484 INT16 xend, INT16 yend )
486 return Pie( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
490 /***********************************************************************
491 * Rectangle (GDI.27)
493 BOOL16 WINAPI Rectangle16( HDC16 hdc, INT16 left, INT16 top,
494 INT16 right, INT16 bottom )
496 return Rectangle( HDC_32(hdc), left, top, right, bottom );
500 /***********************************************************************
501 * RoundRect (GDI.28)
503 BOOL16 WINAPI RoundRect16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
504 INT16 bottom, INT16 ell_width, INT16 ell_height )
506 return RoundRect( HDC_32(hdc), left, top, right, bottom, ell_width, ell_height );
510 /***********************************************************************
511 * PatBlt (GDI.29)
513 BOOL16 WINAPI PatBlt16( HDC16 hdc, INT16 left, INT16 top,
514 INT16 width, INT16 height, DWORD rop)
516 return PatBlt( HDC_32(hdc), left, top, width, height, rop );
520 /***********************************************************************
521 * SaveDC (GDI.30)
523 INT16 WINAPI SaveDC16( HDC16 hdc )
525 return SaveDC( HDC_32(hdc) );
529 /***********************************************************************
530 * SetPixel (GDI.31)
532 COLORREF WINAPI SetPixel16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
534 return SetPixel( HDC_32(hdc), x, y, color );
538 /***********************************************************************
539 * OffsetClipRgn (GDI.32)
541 INT16 WINAPI OffsetClipRgn16( HDC16 hdc, INT16 x, INT16 y )
543 return OffsetClipRgn( HDC_32(hdc), x, y );
547 /***********************************************************************
548 * TextOut (GDI.33)
550 BOOL16 WINAPI TextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR str, INT16 count )
552 return TextOutA( HDC_32(hdc), x, y, str, count );
556 /***********************************************************************
557 * BitBlt (GDI.34)
559 BOOL16 WINAPI BitBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst, INT16 width,
560 INT16 height, HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
561 DWORD rop )
563 return BitBlt( HDC_32(hdcDst), xDst, yDst, width, height, HDC_32(hdcSrc), xSrc, ySrc, rop );
567 /***********************************************************************
568 * StretchBlt (GDI.35)
570 BOOL16 WINAPI StretchBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst,
571 INT16 widthDst, INT16 heightDst,
572 HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
573 INT16 widthSrc, INT16 heightSrc, DWORD rop )
575 return StretchBlt( HDC_32(hdcDst), xDst, yDst, widthDst, heightDst,
576 HDC_32(hdcSrc), xSrc, ySrc, widthSrc, heightSrc, rop );
580 /**********************************************************************
581 * Polygon (GDI.36)
583 BOOL16 WINAPI Polygon16( HDC16 hdc, const POINT16* pt, INT16 count )
585 register int i;
586 BOOL ret;
587 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, count*sizeof(POINT) );
589 if (!pt32) return FALSE;
590 for (i=count;i--;)
592 pt32[i].x = pt[i].x;
593 pt32[i].y = pt[i].y;
595 ret = Polygon(HDC_32(hdc),pt32,count);
596 HeapFree( GetProcessHeap(), 0, pt32 );
597 return ret;
601 /**********************************************************************
602 * Polyline (GDI.37)
604 BOOL16 WINAPI Polyline16( HDC16 hdc, const POINT16* pt, INT16 count )
606 register int i;
607 BOOL16 ret;
608 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, count*sizeof(POINT) );
610 if (!pt32) return FALSE;
611 for (i=count;i--;)
613 pt32[i].x = pt[i].x;
614 pt32[i].y = pt[i].y;
616 ret = Polyline(HDC_32(hdc),pt32,count);
617 HeapFree( GetProcessHeap(), 0, pt32 );
618 return ret;
622 /***********************************************************************
623 * Escape (GDI.38)
625 INT16 WINAPI Escape16( HDC16 hdc, INT16 escape, INT16 in_count, SEGPTR in_data, LPVOID out_data )
627 INT ret;
629 switch(escape)
631 /* Escape(hdc,CLIP_TO_PATH,LPINT16,NULL) */
632 /* Escape(hdc,DRAFTMODE,LPINT16,NULL) */
633 /* Escape(hdc,ENUMPAPERBINS,LPINT16,LPSTR); */
634 /* Escape(hdc,EPSPRINTING,LPINT16,NULL) */
635 /* Escape(hdc,EXT_DEVICE_CAPS,LPINT16,LPDWORD) */
636 /* Escape(hdc,GETCOLORTABLE,LPINT16,LPDWORD) */
637 /* Escape(hdc,MOUSETRAILS,LPINT16,NULL) */
638 /* Escape(hdc,POSTSCRIPT_IGNORE,LPINT16,NULL) */
639 /* Escape(hdc,QUERYESCSUPPORT,LPINT16,NULL) */
640 /* Escape(hdc,SET_ARC_DIRECTION,LPINT16,NULL) */
641 /* Escape(hdc,SET_POLY_MODE,LPINT16,NULL) */
642 /* Escape(hdc,SET_SCREEN_ANGLE,LPINT16,NULL) */
643 /* Escape(hdc,SET_SPREAD,LPINT16,NULL) */
644 case CLIP_TO_PATH:
645 case DRAFTMODE:
646 case ENUMPAPERBINS:
647 case EPSPRINTING:
648 case EXT_DEVICE_CAPS:
649 case GETCOLORTABLE:
650 case MOUSETRAILS:
651 case POSTSCRIPT_IGNORE:
652 case QUERYESCSUPPORT:
653 case SET_ARC_DIRECTION:
654 case SET_POLY_MODE:
655 case SET_SCREEN_ANGLE:
656 case SET_SPREAD:
658 INT16 *ptr = MapSL(in_data);
659 INT data = *ptr;
660 return Escape( HDC_32(hdc), escape, sizeof(data), (LPCSTR)&data, out_data );
663 /* Escape(hdc,ENABLEDUPLEX,LPUINT16,NULL) */
664 case ENABLEDUPLEX:
666 UINT16 *ptr = MapSL(in_data);
667 UINT data = *ptr;
668 return Escape( HDC_32(hdc), escape, sizeof(data), (LPCSTR)&data, NULL );
671 /* Escape(hdc,GETPHYSPAGESIZE,NULL,LPPOINT16) */
672 /* Escape(hdc,GETPRINTINGOFFSET,NULL,LPPOINT16) */
673 /* Escape(hdc,GETSCALINGFACTOR,NULL,LPPOINT16) */
674 case GETPHYSPAGESIZE:
675 case GETPRINTINGOFFSET:
676 case GETSCALINGFACTOR:
678 POINT16 *ptr = out_data;
679 POINT pt32;
680 ret = Escape( HDC_32(hdc), escape, 0, NULL, &pt32 );
681 ptr->x = pt32.x;
682 ptr->y = pt32.y;
683 return ret;
686 /* Escape(hdc,ENABLEPAIRKERNING,LPINT16,LPINT16); */
687 /* Escape(hdc,ENABLERELATIVEWIDTHS,LPINT16,LPINT16); */
688 /* Escape(hdc,SETCOPYCOUNT,LPINT16,LPINT16) */
689 /* Escape(hdc,SETKERNTRACK,LPINT16,LPINT16) */
690 /* Escape(hdc,SETLINECAP,LPINT16,LPINT16) */
691 /* Escape(hdc,SETLINEJOIN,LPINT16,LPINT16) */
692 /* Escape(hdc,SETMITERLIMIT,LPINT16,LPINT16) */
693 case ENABLEPAIRKERNING:
694 case ENABLERELATIVEWIDTHS:
695 case SETCOPYCOUNT:
696 case SETKERNTRACK:
697 case SETLINECAP:
698 case SETLINEJOIN:
699 case SETMITERLIMIT:
701 INT16 *new = MapSL(in_data);
702 INT16 *old = out_data;
703 INT out, in = *new;
704 ret = Escape( HDC_32(hdc), escape, sizeof(in), (LPCSTR)&in, &out );
705 *old = out;
706 return ret;
709 /* Escape(hdc,SETABORTPROC,ABORTPROC,NULL); */
710 case SETABORTPROC:
711 return SetAbortProc16( hdc, (ABORTPROC16)in_data );
713 /* Escape(hdc,STARTDOC,LPSTR,LPDOCINFO16);
714 * lpvOutData is actually a pointer to the DocInfo structure and used as
715 * a second input parameter */
716 case STARTDOC:
717 if (out_data)
719 ret = StartDoc16( hdc, out_data );
720 if (ret > 0) ret = StartPage( HDC_32(hdc) );
721 return ret;
723 return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), NULL );
725 /* Escape(hdc,SET_BOUNDS,LPRECT16,NULL); */
726 /* Escape(hdc,SET_CLIP_BOX,LPRECT16,NULL); */
727 case SET_BOUNDS:
728 case SET_CLIP_BOX:
730 RECT16 *rc16 = MapSL(in_data);
731 RECT rc;
732 rc.left = rc16->left;
733 rc.top = rc16->top;
734 rc.right = rc16->right;
735 rc.bottom = rc16->bottom;
736 return Escape( HDC_32(hdc), escape, sizeof(rc), (LPCSTR)&rc, NULL );
739 /* Escape(hdc,NEXTBAND,NULL,LPRECT16); */
740 case NEXTBAND:
742 RECT rc;
743 RECT16 *rc16 = out_data;
744 ret = Escape( HDC_32(hdc), escape, 0, NULL, &rc );
745 rc16->left = rc.left;
746 rc16->top = rc.top;
747 rc16->right = rc.right;
748 rc16->bottom = rc.bottom;
749 return ret;
751 /* Escape(hdc,DRAWPATTERNRECT,PRECT_STRUCT*,NULL); */
752 case DRAWPATTERNRECT:
754 DRAWPATRECT pr;
755 DRAWPATRECT16 *pr16 = MapSL(in_data);
757 pr.ptPosition.x = pr16->ptPosition.x;
758 pr.ptPosition.y = pr16->ptPosition.y;
759 pr.ptSize.x = pr16->ptSize.x;
760 pr.ptSize.y = pr16->ptSize.y;
761 pr.wStyle = pr16->wStyle;
762 pr.wPattern = pr16->wPattern;
763 return Escape( HDC_32(hdc), escape, sizeof(pr), (LPCSTR)&pr, NULL );
766 /* Escape(hdc,ABORTDOC,NULL,NULL); */
767 /* Escape(hdc,BANDINFO,BANDINFOSTRUCT*,BANDINFOSTRUCT*); */
768 /* Escape(hdc,BEGIN_PATH,NULL,NULL); */
769 /* Escape(hdc,ENDDOC,NULL,NULL); */
770 /* Escape(hdc,END_PATH,PATHINFO,NULL); */
771 /* Escape(hdc,EXTTEXTOUT,EXTTEXT_STRUCT*,NULL); */
772 /* Escape(hdc,FLUSHOUTPUT,NULL,NULL); */
773 /* Escape(hdc,GETFACENAME,NULL,LPSTR); */
774 /* Escape(hdc,GETPAIRKERNTABLE,NULL,KERNPAIR*); */
775 /* Escape(hdc,GETSETPAPERBINS,BinInfo*,BinInfo*); */
776 /* Escape(hdc,GETSETPRINTORIENT,ORIENT*,NULL); */
777 /* Escape(hdc,GETSETSCREENPARAMS,SCREENPARAMS*,SCREENPARAMS*); */
778 /* Escape(hdc,GETTECHNOLOGY,NULL,LPSTR); */
779 /* Escape(hdc,GETTRACKKERNTABLE,NULL,KERNTRACK*); */
780 /* Escape(hdc,MFCOMMENT,LPSTR,NULL); */
781 /* Escape(hdc,NEWFRAME,NULL,NULL); */
782 /* Escape(hdc,PASSTHROUGH,LPSTR,NULL); */
783 /* Escape(hdc,RESTORE_CTM,NULL,NULL); */
784 /* Escape(hdc,SAVE_CTM,NULL,NULL); */
785 /* Escape(hdc,SETALLJUSTVALUES,EXTTEXTDATA*,NULL); */
786 /* Escape(hdc,SETCOLORTABLE,COLORTABLE_STRUCT*,LPDWORD); */
787 /* Escape(hdc,SET_BACKGROUND_COLOR,LPDWORD,LPDWORD); */
788 /* Escape(hdc,TRANSFORM_CTM,LPSTR,NULL); */
789 case ABORTDOC:
790 case BANDINFO:
791 case BEGIN_PATH:
792 case ENDDOC:
793 case END_PATH:
794 case EXTTEXTOUT:
795 case FLUSHOUTPUT:
796 case GETFACENAME:
797 case GETPAIRKERNTABLE:
798 case GETSETPAPERBINS:
799 case GETSETPRINTORIENT:
800 case GETSETSCREENPARAMS:
801 case GETTECHNOLOGY:
802 case GETTRACKKERNTABLE:
803 case MFCOMMENT:
804 case NEWFRAME:
805 case PASSTHROUGH:
806 case RESTORE_CTM:
807 case SAVE_CTM:
808 case SETALLJUSTVALUES:
809 case SETCOLORTABLE:
810 case SET_BACKGROUND_COLOR:
811 case TRANSFORM_CTM:
812 /* pass it unmodified to the 32-bit function */
813 return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), out_data );
815 /* Escape(hdc,ENUMPAPERMETRICS,LPINT16,LPRECT16); */
816 /* Escape(hdc,GETEXTENDEDTEXTMETRICS,LPUINT16,EXTTEXTMETRIC*); */
817 /* Escape(hdc,GETEXTENTTABLE,LPSTR,LPINT16); */
818 /* Escape(hdc,GETSETPAPERMETRICS,LPRECT16,LPRECT16); */
819 /* Escape(hdc,GETVECTORBRUSHSIZE,LPLOGBRUSH16,LPPOINT16); */
820 /* Escape(hdc,GETVECTORPENSIZE,LPLOGPEN16,LPPOINT16); */
821 case ENUMPAPERMETRICS:
822 case GETEXTENDEDTEXTMETRICS:
823 case GETEXTENTTABLE:
824 case GETSETPAPERMETRICS:
825 case GETVECTORBRUSHSIZE:
826 case GETVECTORPENSIZE:
827 default:
828 FIXME("unknown/unsupported 16-bit escape %x (%d,%p,%p\n",
829 escape, in_count, MapSL(in_data), out_data );
830 return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), out_data );
835 /***********************************************************************
836 * RestoreDC (GDI.39)
838 BOOL16 WINAPI RestoreDC16( HDC16 hdc, INT16 level )
840 return RestoreDC( HDC_32(hdc), level );
844 /***********************************************************************
845 * FillRgn (GDI.40)
847 BOOL16 WINAPI FillRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush )
849 return FillRgn( HDC_32(hdc), HRGN_32(hrgn), HBRUSH_32(hbrush) );
853 /***********************************************************************
854 * FrameRgn (GDI.41)
856 BOOL16 WINAPI FrameRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush,
857 INT16 nWidth, INT16 nHeight )
859 return FrameRgn( HDC_32(hdc), HRGN_32(hrgn), HBRUSH_32(hbrush), nWidth, nHeight );
863 /***********************************************************************
864 * InvertRgn (GDI.42)
866 BOOL16 WINAPI InvertRgn16( HDC16 hdc, HRGN16 hrgn )
868 return InvertRgn( HDC_32(hdc), HRGN_32(hrgn) );
872 /***********************************************************************
873 * PaintRgn (GDI.43)
875 BOOL16 WINAPI PaintRgn16( HDC16 hdc, HRGN16 hrgn )
877 return PaintRgn( HDC_32(hdc), HRGN_32(hrgn) );
881 /***********************************************************************
882 * SelectClipRgn (GDI.44)
884 INT16 WINAPI SelectClipRgn16( HDC16 hdc, HRGN16 hrgn )
886 return SelectClipRgn( HDC_32(hdc), HRGN_32(hrgn) );
890 /***********************************************************************
891 * SelectObject (GDI.45)
893 HGDIOBJ16 WINAPI SelectObject16( HDC16 hdc, HGDIOBJ16 handle )
895 return HGDIOBJ_16( SelectObject( HDC_32(hdc), HGDIOBJ_32(handle) ) );
899 /***********************************************************************
900 * CombineRgn (GDI.47)
902 INT16 WINAPI CombineRgn16(HRGN16 hDest, HRGN16 hSrc1, HRGN16 hSrc2, INT16 mode)
904 return CombineRgn( HRGN_32(hDest), HRGN_32(hSrc1), HRGN_32(hSrc2), mode );
908 /***********************************************************************
909 * CreateBitmap (GDI.48)
911 HBITMAP16 WINAPI CreateBitmap16( INT16 width, INT16 height, UINT16 planes,
912 UINT16 bpp, LPCVOID bits )
914 return HBITMAP_16( CreateBitmap( width, height, planes & 0xff, bpp & 0xff, bits ) );
918 /***********************************************************************
919 * CreateBitmapIndirect (GDI.49)
921 HBITMAP16 WINAPI CreateBitmapIndirect16( const BITMAP16 * bmp )
923 return CreateBitmap16( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
924 bmp->bmBitsPixel, MapSL( bmp->bmBits ) );
928 /***********************************************************************
929 * CreateBrushIndirect (GDI.50)
931 HBRUSH16 WINAPI CreateBrushIndirect16( const LOGBRUSH16 * brush )
933 LOGBRUSH brush32;
935 if (brush->lbStyle == BS_DIBPATTERN || brush->lbStyle == BS_DIBPATTERN8X8)
936 return CreateDIBPatternBrush16( brush->lbHatch, brush->lbColor );
938 brush32.lbStyle = brush->lbStyle;
939 brush32.lbColor = brush->lbColor;
940 brush32.lbHatch = brush->lbHatch;
941 return HBRUSH_16( CreateBrushIndirect(&brush32) );
945 /***********************************************************************
946 * CreateCompatibleBitmap (GDI.51)
948 HBITMAP16 WINAPI CreateCompatibleBitmap16( HDC16 hdc, INT16 width, INT16 height )
950 return HBITMAP_16( CreateCompatibleBitmap( HDC_32(hdc), width, height ) );
954 /***********************************************************************
955 * CreateCompatibleDC (GDI.52)
957 HDC16 WINAPI CreateCompatibleDC16( HDC16 hdc )
959 return HDC_16( CreateCompatibleDC( HDC_32(hdc) ) );
963 /***********************************************************************
964 * CreateDC (GDI.53)
966 HDC16 WINAPI CreateDC16( LPCSTR driver, LPCSTR device, LPCSTR output,
967 const DEVMODEA *initData )
969 return HDC_16( CreateDCA( driver, device, output, initData ) );
973 /***********************************************************************
974 * CreateEllipticRgn (GDI.54)
976 HRGN16 WINAPI CreateEllipticRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom )
978 return HRGN_16( CreateEllipticRgn( left, top, right, bottom ) );
982 /***********************************************************************
983 * CreateEllipticRgnIndirect (GDI.55)
985 HRGN16 WINAPI CreateEllipticRgnIndirect16( const RECT16 *rect )
987 return HRGN_16( CreateEllipticRgn( rect->left, rect->top, rect->right, rect->bottom ) );
991 /***********************************************************************
992 * CreateFont (GDI.56)
994 HFONT16 WINAPI CreateFont16(INT16 height, INT16 width, INT16 esc, INT16 orient,
995 INT16 weight, BYTE italic, BYTE underline,
996 BYTE strikeout, BYTE charset, BYTE outpres,
997 BYTE clippres, BYTE quality, BYTE pitch,
998 LPCSTR name )
1000 return HFONT_16( CreateFontA( height, width, esc, orient, weight, italic, underline,
1001 strikeout, charset, outpres, clippres, quality, pitch, name ));
1004 /***********************************************************************
1005 * CreateFontIndirect (GDI.57)
1007 HFONT16 WINAPI CreateFontIndirect16( const LOGFONT16 *plf16 )
1009 HFONT ret;
1011 if (plf16)
1013 LOGFONTW lfW;
1014 logfont_16_to_W( plf16, &lfW );
1015 ret = CreateFontIndirectW( &lfW );
1017 else ret = CreateFontIndirectW( NULL );
1018 return HFONT_16(ret);
1022 /***********************************************************************
1023 * CreateHatchBrush (GDI.58)
1025 HBRUSH16 WINAPI CreateHatchBrush16( INT16 style, COLORREF color )
1027 return HBRUSH_16( CreateHatchBrush( style, color ) );
1031 /***********************************************************************
1032 * CreatePatternBrush (GDI.60)
1034 HBRUSH16 WINAPI CreatePatternBrush16( HBITMAP16 hbitmap )
1036 return HBRUSH_16( CreatePatternBrush( HBITMAP_32(hbitmap) ));
1040 /***********************************************************************
1041 * CreatePen (GDI.61)
1043 HPEN16 WINAPI CreatePen16( INT16 style, INT16 width, COLORREF color )
1045 LOGPEN logpen;
1047 logpen.lopnStyle = style;
1048 logpen.lopnWidth.x = width;
1049 logpen.lopnWidth.y = 0;
1050 logpen.lopnColor = color;
1051 return HPEN_16( CreatePenIndirect( &logpen ) );
1055 /***********************************************************************
1056 * CreatePenIndirect (GDI.62)
1058 HPEN16 WINAPI CreatePenIndirect16( const LOGPEN16 * pen )
1060 LOGPEN logpen;
1062 if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
1063 logpen.lopnStyle = pen->lopnStyle;
1064 logpen.lopnWidth.x = pen->lopnWidth.x;
1065 logpen.lopnWidth.y = pen->lopnWidth.y;
1066 logpen.lopnColor = pen->lopnColor;
1067 return HPEN_16( CreatePenIndirect( &logpen ) );
1071 /***********************************************************************
1072 * CreatePolygonRgn (GDI.63)
1074 HRGN16 WINAPI CreatePolygonRgn16( const POINT16 * points, INT16 count, INT16 mode )
1076 return CreatePolyPolygonRgn16( points, &count, 1, mode );
1080 /***********************************************************************
1081 * CreateRectRgn (GDI.64)
1083 * NOTE: cf. SetRectRgn16
1085 HRGN16 WINAPI CreateRectRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom )
1087 HRGN hrgn;
1089 if (left < right) hrgn = CreateRectRgn( left, top, right, bottom );
1090 else hrgn = CreateRectRgn( 0, 0, 0, 0 );
1091 return HRGN_16(hrgn);
1095 /***********************************************************************
1096 * CreateRectRgnIndirect (GDI.65)
1098 HRGN16 WINAPI CreateRectRgnIndirect16( const RECT16* rect )
1100 return CreateRectRgn16( rect->left, rect->top, rect->right, rect->bottom );
1104 /***********************************************************************
1105 * CreateSolidBrush (GDI.66)
1107 HBRUSH16 WINAPI CreateSolidBrush16( COLORREF color )
1109 return HBRUSH_16( CreateSolidBrush( color ) );
1113 /***********************************************************************
1114 * DeleteDC (GDI.68)
1116 BOOL16 WINAPI DeleteDC16( HDC16 hdc )
1118 return DeleteDC( HDC_32(hdc) );
1122 /***********************************************************************
1123 * DeleteObject (GDI.69)
1124 * SysDeleteObject (GDI.605)
1126 BOOL16 WINAPI DeleteObject16( HGDIOBJ16 obj )
1128 return DeleteObject( HGDIOBJ_32(obj) );
1132 /***********************************************************************
1133 * EnumFonts (GDI.70)
1135 INT16 WINAPI EnumFonts16( HDC16 hDC, LPCSTR lpName, FONTENUMPROC16 efproc,
1136 LPARAM lpData )
1138 return EnumFontFamilies16( hDC, lpName, efproc, lpData );
1142 /***********************************************************************
1143 * EnumObjects (GDI.71)
1145 INT16 WINAPI EnumObjects16( HDC16 hdc, INT16 obj, GOBJENUMPROC16 proc, LPARAM lParam )
1147 struct callback16_info info;
1149 info.proc = (FARPROC16)proc;
1150 info.param = lParam;
1151 switch(obj)
1153 case OBJ_PEN:
1154 return EnumObjects( HDC_32(hdc), OBJ_PEN, enum_pens_callback, (LPARAM)&info );
1155 case OBJ_BRUSH:
1156 return EnumObjects( HDC_32(hdc), OBJ_BRUSH, enum_brushes_callback, (LPARAM)&info );
1158 return 0;
1162 /***********************************************************************
1163 * EqualRgn (GDI.72)
1165 BOOL16 WINAPI EqualRgn16( HRGN16 rgn1, HRGN16 rgn2 )
1167 return EqualRgn( HRGN_32(rgn1), HRGN_32(rgn2) );
1171 /***********************************************************************
1172 * GetBitmapBits (GDI.74)
1174 LONG WINAPI GetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPVOID buffer )
1176 return GetBitmapBits( HBITMAP_32(hbitmap), count, buffer );
1180 /***********************************************************************
1181 * GetBkColor (GDI.75)
1183 COLORREF WINAPI GetBkColor16( HDC16 hdc )
1185 return GetBkColor( HDC_32(hdc) );
1189 /***********************************************************************
1190 * GetBkMode (GDI.76)
1192 INT16 WINAPI GetBkMode16( HDC16 hdc )
1194 return GetBkMode( HDC_32(hdc) );
1198 /***********************************************************************
1199 * GetClipBox (GDI.77)
1201 INT16 WINAPI GetClipBox16( HDC16 hdc, LPRECT16 rect )
1203 RECT rect32;
1204 INT ret = GetClipBox( HDC_32(hdc), &rect32 );
1206 if (ret != ERROR)
1208 rect->left = rect32.left;
1209 rect->top = rect32.top;
1210 rect->right = rect32.right;
1211 rect->bottom = rect32.bottom;
1213 return ret;
1217 /***********************************************************************
1218 * GetCurrentPosition (GDI.78)
1220 DWORD WINAPI GetCurrentPosition16( HDC16 hdc )
1222 POINT pt32;
1223 if (!GetCurrentPositionEx( HDC_32(hdc), &pt32 )) return 0;
1224 return MAKELONG( pt32.x, pt32.y );
1228 /***********************************************************************
1229 * GetDCOrg (GDI.79)
1231 DWORD WINAPI GetDCOrg16( HDC16 hdc )
1233 POINT pt;
1234 if (GetDCOrgEx( HDC_32(hdc), &pt )) return MAKELONG( pt.x, pt.y );
1235 return 0;
1239 /***********************************************************************
1240 * GetDeviceCaps (GDI.80)
1242 INT16 WINAPI GetDeviceCaps16( HDC16 hdc, INT16 cap )
1244 INT16 ret = GetDeviceCaps( HDC_32(hdc), cap );
1245 /* some apps don't expect -1 and think it's a B&W screen */
1246 if ((cap == NUMCOLORS) && (ret == -1)) ret = 2048;
1247 return ret;
1251 /***********************************************************************
1252 * GetMapMode (GDI.81)
1254 INT16 WINAPI GetMapMode16( HDC16 hdc )
1256 return GetMapMode( HDC_32(hdc) );
1260 /***********************************************************************
1261 * GetObject (GDI.82)
1263 INT16 WINAPI GetObject16( HGDIOBJ16 handle16, INT16 count, LPVOID buffer )
1265 HGDIOBJ handle = HGDIOBJ_32( handle16 );
1266 switch( GetObjectType( handle ))
1268 case OBJ_PEN:
1269 if (buffer)
1271 LOGPEN16 *pen16 = buffer;
1272 LOGPEN pen;
1274 if (count < sizeof(LOGPEN16)) return 0;
1275 if (!GetObjectW( handle, sizeof(pen), &pen )) return 0;
1277 pen16->lopnStyle = pen.lopnStyle;
1278 pen16->lopnColor = pen.lopnColor;
1279 pen16->lopnWidth.x = pen.lopnWidth.x;
1280 pen16->lopnWidth.y = pen.lopnWidth.y;
1282 return sizeof(LOGPEN16);
1284 case OBJ_BRUSH:
1285 if (buffer)
1287 LOGBRUSH brush;
1288 LOGBRUSH16 brush16;
1290 if (!GetObjectW( handle, sizeof(brush), &brush )) return 0;
1291 brush16.lbStyle = brush.lbStyle;
1292 brush16.lbColor = brush.lbColor;
1293 brush16.lbHatch = brush.lbHatch;
1294 if (count > sizeof(brush16)) count = sizeof(brush16);
1295 memcpy( buffer, &brush16, count );
1296 return count;
1298 return sizeof(LOGBRUSH16);
1300 case OBJ_PAL:
1301 return GetObjectW( handle, count, buffer );
1303 case OBJ_FONT:
1304 if (buffer)
1306 LOGFONTW font;
1307 LOGFONT16 font16;
1309 if (!GetObjectW( handle, sizeof(font), &font )) return 0;
1310 logfont_W_to_16( &font, &font16 );
1311 if (count > sizeof(font16)) count = sizeof(font16);
1312 memcpy( buffer, &font16, count );
1313 return count;
1315 return sizeof(LOGFONT16);
1317 case OBJ_BITMAP:
1319 DIBSECTION dib;
1320 INT size;
1321 BITMAP16 *bmp16 = buffer;
1323 if (!(size = GetObjectW( handle, sizeof(dib), &dib ))) return 0;
1324 if (size == sizeof(DIBSECTION) && count > sizeof(BITMAP16))
1326 FIXME("not implemented for DIBs: count %d\n", count);
1327 return 0;
1329 else
1331 if (count < sizeof(BITMAP16)) return 0;
1332 bmp16->bmType = dib.dsBm.bmType;
1333 bmp16->bmWidth = dib.dsBm.bmWidth;
1334 bmp16->bmHeight = dib.dsBm.bmHeight;
1335 bmp16->bmWidthBytes = dib.dsBm.bmWidthBytes;
1336 bmp16->bmPlanes = dib.dsBm.bmPlanes;
1337 bmp16->bmBitsPixel = dib.dsBm.bmBitsPixel;
1338 bmp16->bmBits = 0;
1339 return sizeof(BITMAP16);
1343 default:
1344 return 0;
1349 /***********************************************************************
1350 * GetPixel (GDI.83)
1352 COLORREF WINAPI GetPixel16( HDC16 hdc, INT16 x, INT16 y )
1354 return GetPixel( HDC_32(hdc), x, y );
1358 /***********************************************************************
1359 * GetPolyFillMode (GDI.84)
1361 INT16 WINAPI GetPolyFillMode16( HDC16 hdc )
1363 return GetPolyFillMode( HDC_32(hdc) );
1367 /***********************************************************************
1368 * GetROP2 (GDI.85)
1370 INT16 WINAPI GetROP216( HDC16 hdc )
1372 return GetROP2( HDC_32(hdc) );
1376 /***********************************************************************
1377 * GetRelAbs (GDI.86)
1379 INT16 WINAPI GetRelAbs16( HDC16 hdc )
1381 return GetRelAbs( HDC_32(hdc), 0 );
1385 /***********************************************************************
1386 * GetStockObject (GDI.87)
1388 HGDIOBJ16 WINAPI GetStockObject16( INT16 obj )
1390 return HGDIOBJ_16( GetStockObject( obj ) );
1394 /***********************************************************************
1395 * GetStretchBltMode (GDI.88)
1397 INT16 WINAPI GetStretchBltMode16( HDC16 hdc )
1399 return GetStretchBltMode( HDC_32(hdc) );
1403 /***********************************************************************
1404 * GetTextCharacterExtra (GDI.89)
1406 INT16 WINAPI GetTextCharacterExtra16( HDC16 hdc )
1408 return GetTextCharacterExtra( HDC_32(hdc) );
1412 /***********************************************************************
1413 * GetTextColor (GDI.90)
1415 COLORREF WINAPI GetTextColor16( HDC16 hdc )
1417 return GetTextColor( HDC_32(hdc) );
1421 /***********************************************************************
1422 * GetTextExtent (GDI.91)
1424 DWORD WINAPI GetTextExtent16( HDC16 hdc, LPCSTR str, INT16 count )
1426 SIZE size;
1427 if (!GetTextExtentPoint32A( HDC_32(hdc), str, count, &size )) return 0;
1428 return MAKELONG( size.cx, size.cy );
1432 /***********************************************************************
1433 * GetTextFace (GDI.92)
1435 INT16 WINAPI GetTextFace16( HDC16 hdc, INT16 count, LPSTR name )
1437 return GetTextFaceA( HDC_32(hdc), count, name );
1441 /***********************************************************************
1442 * GetTextMetrics (GDI.93)
1444 BOOL16 WINAPI GetTextMetrics16( HDC16 hdc, TEXTMETRIC16 *tm )
1446 TEXTMETRICW tm32;
1448 if (!GetTextMetricsW( HDC_32(hdc), &tm32 )) return FALSE;
1450 tm->tmHeight = tm32.tmHeight;
1451 tm->tmAscent = tm32.tmAscent;
1452 tm->tmDescent = tm32.tmDescent;
1453 tm->tmInternalLeading = tm32.tmInternalLeading;
1454 tm->tmExternalLeading = tm32.tmExternalLeading;
1455 tm->tmAveCharWidth = tm32.tmAveCharWidth;
1456 tm->tmMaxCharWidth = tm32.tmMaxCharWidth;
1457 tm->tmWeight = tm32.tmWeight;
1458 tm->tmOverhang = tm32.tmOverhang;
1459 tm->tmDigitizedAspectX = tm32.tmDigitizedAspectX;
1460 tm->tmDigitizedAspectY = tm32.tmDigitizedAspectY;
1461 tm->tmFirstChar = tm32.tmFirstChar;
1462 tm->tmLastChar = tm32.tmLastChar;
1463 tm->tmDefaultChar = tm32.tmDefaultChar;
1464 tm->tmBreakChar = tm32.tmBreakChar;
1465 tm->tmItalic = tm32.tmItalic;
1466 tm->tmUnderlined = tm32.tmUnderlined;
1467 tm->tmStruckOut = tm32.tmStruckOut;
1468 tm->tmPitchAndFamily = tm32.tmPitchAndFamily;
1469 tm->tmCharSet = tm32.tmCharSet;
1470 return TRUE;
1474 /***********************************************************************
1475 * GetViewportExt (GDI.94)
1477 DWORD WINAPI GetViewportExt16( HDC16 hdc )
1479 SIZE size;
1480 if (!GetViewportExtEx( HDC_32(hdc), &size )) return 0;
1481 return MAKELONG( size.cx, size.cy );
1485 /***********************************************************************
1486 * GetViewportOrg (GDI.95)
1488 DWORD WINAPI GetViewportOrg16( HDC16 hdc )
1490 POINT pt;
1491 if (!GetViewportOrgEx( HDC_32(hdc), &pt )) return 0;
1492 return MAKELONG( pt.x, pt.y );
1496 /***********************************************************************
1497 * GetWindowExt (GDI.96)
1499 DWORD WINAPI GetWindowExt16( HDC16 hdc )
1501 SIZE size;
1502 if (!GetWindowExtEx( HDC_32(hdc), &size )) return 0;
1503 return MAKELONG( size.cx, size.cy );
1507 /***********************************************************************
1508 * GetWindowOrg (GDI.97)
1510 DWORD WINAPI GetWindowOrg16( HDC16 hdc )
1512 POINT pt;
1513 if (!GetWindowOrgEx( HDC_32(hdc), &pt )) return 0;
1514 return MAKELONG( pt.x, pt.y );
1520 /**********************************************************************
1521 * LineDDA (GDI.100)
1523 void WINAPI LineDDA16( INT16 nXStart, INT16 nYStart, INT16 nXEnd,
1524 INT16 nYEnd, LINEDDAPROC16 proc, LPARAM lParam )
1526 struct callback16_info info;
1527 info.proc = (FARPROC16)proc;
1528 info.param = lParam;
1529 LineDDA( nXStart, nYStart, nXEnd, nYEnd, linedda_callback, (LPARAM)&info );
1533 /***********************************************************************
1534 * OffsetRgn (GDI.101)
1536 INT16 WINAPI OffsetRgn16( HRGN16 hrgn, INT16 x, INT16 y )
1538 return OffsetRgn( HRGN_32(hrgn), x, y );
1542 /***********************************************************************
1543 * PtVisible (GDI.103)
1545 BOOL16 WINAPI PtVisible16( HDC16 hdc, INT16 x, INT16 y )
1547 return PtVisible( HDC_32(hdc), x, y );
1551 /***********************************************************************
1552 * SelectVisRgn (GDI.105)
1554 INT16 WINAPI SelectVisRgn16( HDC16 hdc, HRGN16 hrgn )
1556 return SelectVisRgn( HDC_32(hdc), HRGN_32(hrgn) );
1560 /***********************************************************************
1561 * SetBitmapBits (GDI.106)
1563 LONG WINAPI SetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPCVOID buffer )
1565 return SetBitmapBits( HBITMAP_32(hbitmap), count, buffer );
1569 /***********************************************************************
1570 * AddFontResource (GDI.119)
1572 INT16 WINAPI AddFontResource16( LPCSTR filename )
1574 return AddFontResourceA( filename );
1578 /***********************************************************************
1579 * Death (GDI.121)
1581 * Disables GDI, switches back to text mode.
1582 * We don't have to do anything here,
1583 * just let console support handle everything
1585 void WINAPI Death16(HDC16 hdc)
1587 MESSAGE("Death(%04x) called. Application enters text mode...\n", hdc);
1591 /***********************************************************************
1592 * Resurrection (GDI.122)
1594 * Restores GDI functionality
1596 void WINAPI Resurrection16(HDC16 hdc,
1597 WORD w1, WORD w2, WORD w3, WORD w4, WORD w5, WORD w6)
1599 MESSAGE("Resurrection(%04x, %04x, %04x, %04x, %04x, %04x, %04x) called. Application left text mode.\n",
1600 hdc, w1, w2, w3, w4, w5, w6);
1604 /**********************************************************************
1605 * CreateMetaFile (GDI.125)
1607 HDC16 WINAPI CreateMetaFile16( LPCSTR filename )
1609 return HDC_16( CreateMetaFileA( filename ) );
1613 /***********************************************************************
1614 * MulDiv (GDI.128)
1616 INT16 WINAPI MulDiv16( INT16 nMultiplicand, INT16 nMultiplier, INT16 nDivisor)
1618 INT ret;
1619 if (!nDivisor) return -32768;
1620 /* We want to deal with a positive divisor to simplify the logic. */
1621 if (nDivisor < 0)
1623 nMultiplicand = - nMultiplicand;
1624 nDivisor = -nDivisor;
1626 /* If the result is positive, we "add" to round. else,
1627 * we subtract to round. */
1628 if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) ||
1629 ( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
1630 ret = (((int)nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
1631 else
1632 ret = (((int)nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
1633 if ((ret > 32767) || (ret < -32767)) return -32768;
1634 return (INT16) ret;
1638 /***********************************************************************
1639 * GetRgnBox (GDI.134)
1641 INT16 WINAPI GetRgnBox16( HRGN16 hrgn, LPRECT16 rect )
1643 RECT r;
1644 INT16 ret = GetRgnBox( HRGN_32(hrgn), &r );
1645 rect->left = r.left;
1646 rect->top = r.top;
1647 rect->right = r.right;
1648 rect->bottom = r.bottom;
1649 return ret;
1653 /***********************************************************************
1654 * RemoveFontResource (GDI.136)
1656 BOOL16 WINAPI RemoveFontResource16( LPCSTR str )
1658 return RemoveFontResourceA(str);
1662 /***********************************************************************
1663 * SetBrushOrg (GDI.148)
1665 DWORD WINAPI SetBrushOrg16( HDC16 hdc, INT16 x, INT16 y )
1667 POINT pt;
1669 if (!SetBrushOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
1670 return MAKELONG( pt.x, pt.y );
1674 /***********************************************************************
1675 * GetBrushOrg (GDI.149)
1677 DWORD WINAPI GetBrushOrg16( HDC16 hdc )
1679 POINT pt;
1680 if (!GetBrushOrgEx( HDC_32(hdc), &pt )) return 0;
1681 return MAKELONG( pt.x, pt.y );
1685 /***********************************************************************
1686 * UnrealizeObject (GDI.150)
1688 BOOL16 WINAPI UnrealizeObject16( HGDIOBJ16 obj )
1690 return UnrealizeObject( HGDIOBJ_32(obj) );
1694 /***********************************************************************
1695 * CreateIC (GDI.153)
1697 HDC16 WINAPI CreateIC16( LPCSTR driver, LPCSTR device, LPCSTR output,
1698 const DEVMODEA* initData )
1700 return HDC_16( CreateICA( driver, device, output, initData ) );
1704 /***********************************************************************
1705 * GetNearestColor (GDI.154)
1707 COLORREF WINAPI GetNearestColor16( HDC16 hdc, COLORREF color )
1709 return GetNearestColor( HDC_32(hdc), color );
1713 /***********************************************************************
1714 * CreateDiscardableBitmap (GDI.156)
1716 HBITMAP16 WINAPI CreateDiscardableBitmap16( HDC16 hdc, INT16 width, INT16 height )
1718 return HBITMAP_16( CreateDiscardableBitmap( HDC_32(hdc), width, height ) );
1722 /***********************************************************************
1723 * PtInRegion (GDI.161)
1725 BOOL16 WINAPI PtInRegion16( HRGN16 hrgn, INT16 x, INT16 y )
1727 return PtInRegion( HRGN_32(hrgn), x, y );
1731 /***********************************************************************
1732 * GetBitmapDimension (GDI.162)
1734 DWORD WINAPI GetBitmapDimension16( HBITMAP16 hbitmap )
1736 SIZE16 size;
1737 if (!GetBitmapDimensionEx16( hbitmap, &size )) return 0;
1738 return MAKELONG( size.cx, size.cy );
1742 /***********************************************************************
1743 * SetBitmapDimension (GDI.163)
1745 DWORD WINAPI SetBitmapDimension16( HBITMAP16 hbitmap, INT16 x, INT16 y )
1747 SIZE16 size;
1748 if (!SetBitmapDimensionEx16( hbitmap, x, y, &size )) return 0;
1749 return MAKELONG( size.cx, size.cy );
1753 /***********************************************************************
1754 * SetRectRgn (GDI.172)
1756 * NOTE: Win 3.1 sets region to empty if left > right
1758 void WINAPI SetRectRgn16( HRGN16 hrgn, INT16 left, INT16 top, INT16 right, INT16 bottom )
1760 if (left < right) SetRectRgn( HRGN_32(hrgn), left, top, right, bottom );
1761 else SetRectRgn( HRGN_32(hrgn), 0, 0, 0, 0 );
1765 /******************************************************************
1766 * PlayMetaFileRecord (GDI.176)
1768 void WINAPI PlayMetaFileRecord16( HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr, UINT16 handles )
1770 HANDLETABLE *ht32 = HeapAlloc( GetProcessHeap(), 0, handles * sizeof(*ht32) );
1771 unsigned int i;
1773 for (i = 0; i < handles; i++) ht32->objectHandle[i] = HGDIOBJ_32(ht->objectHandle[i]);
1774 PlayMetaFileRecord( HDC_32(hdc), ht32, mr, handles );
1775 for (i = 0; i < handles; i++) ht->objectHandle[i] = HGDIOBJ_16(ht32->objectHandle[i]);
1776 HeapFree( GetProcessHeap(), 0, ht32 );
1780 /***********************************************************************
1781 * SetHookFlags (GDI.192)
1783 WORD WINAPI SetHookFlags16( HDC16 hdc, WORD flags )
1785 return SetHookFlags( HDC_32(hdc), flags );
1789 /***********************************************************************
1790 * SetBoundsRect (GDI.193)
1792 UINT16 WINAPI SetBoundsRect16( HDC16 hdc, const RECT16* rect, UINT16 flags )
1794 if (rect)
1796 RECT rect32;
1797 rect32.left = rect->left;
1798 rect32.top = rect->top;
1799 rect32.right = rect->right;
1800 rect32.bottom = rect->bottom;
1801 return SetBoundsRect( HDC_32( hdc ), &rect32, flags );
1803 else return SetBoundsRect( HDC_32( hdc ), NULL, flags );
1807 /***********************************************************************
1808 * GetBoundsRect (GDI.194)
1810 UINT16 WINAPI GetBoundsRect16( HDC16 hdc, LPRECT16 rect, UINT16 flags)
1812 RECT rect32;
1813 UINT ret = GetBoundsRect( HDC_32( hdc ), &rect32, flags );
1814 if (rect)
1816 rect->left = rect32.left;
1817 rect->top = rect32.top;
1818 rect->right = rect32.right;
1819 rect->bottom = rect32.bottom;
1821 return ret;
1825 /***********************************************************************
1826 * EngineEnumerateFont (GDI.300)
1828 WORD WINAPI EngineEnumerateFont16(LPSTR fontname, FARPROC16 proc, DWORD data )
1830 FIXME("(%s,%p,%x),stub\n",fontname,proc,data);
1831 return 0;
1835 /***********************************************************************
1836 * EngineDeleteFont (GDI.301)
1838 WORD WINAPI EngineDeleteFont16(LPFONTINFO16 lpFontInfo)
1840 WORD handle;
1842 /* untested, don't know if it works.
1843 We seem to access some structure that is located after the
1844 FONTINFO. The FONTINFO documentation says that there may
1845 follow some char-width table or font bitmap or vector info.
1846 I think it is some kind of font bitmap that begins at offset 0x52,
1847 as FONTINFO goes up to 0x51.
1848 If this is correct, everything should be implemented correctly.
1850 if ( ((lpFontInfo->dfType & (RASTER_FONTTYPE|DEVICE_FONTTYPE)) == (RASTER_FONTTYPE|DEVICE_FONTTYPE))
1851 && (LOWORD(lpFontInfo->dfFace) == LOWORD(lpFontInfo)+0x6e)
1852 && (handle = *(WORD *)(lpFontInfo+0x54)) )
1854 *(WORD *)(lpFontInfo+0x54) = 0;
1855 GlobalFree16(handle);
1857 return 1;
1861 /***********************************************************************
1862 * EngineRealizeFont (GDI.302)
1864 WORD WINAPI EngineRealizeFont16(LPLOGFONT16 lplogFont, LPTEXTXFORM16 lptextxform, LPFONTINFO16 lpfontInfo)
1866 FIXME("(%p,%p,%p),stub\n",lplogFont,lptextxform,lpfontInfo);
1868 return 0;
1872 /***********************************************************************
1873 * EngineRealizeFontExt (GDI.315)
1875 WORD WINAPI EngineRealizeFontExt16(LONG l1, LONG l2, LONG l3, LONG l4)
1877 FIXME("(%08x,%08x,%08x,%08x),stub\n",l1,l2,l3,l4);
1879 return 0;
1883 /***********************************************************************
1884 * EngineGetCharWidth (GDI.303)
1886 WORD WINAPI EngineGetCharWidth16(LPFONTINFO16 lpFontInfo, BYTE firstChar, BYTE lastChar, LPINT16 buffer)
1888 int i;
1890 for (i = firstChar; i <= lastChar; i++)
1891 FIXME(" returns font's average width for range %d to %d\n", firstChar, lastChar);
1892 *buffer++ = lpFontInfo->dfAvgWidth; /* insert some charwidth functionality here; use average width for now */
1893 return 1;
1897 /***********************************************************************
1898 * EngineSetFontContext (GDI.304)
1900 WORD WINAPI EngineSetFontContext16(LPFONTINFO16 lpFontInfo, WORD data)
1902 FIXME("stub?\n");
1903 return 0;
1906 /***********************************************************************
1907 * EngineGetGlyphBMP (GDI.305)
1909 WORD WINAPI EngineGetGlyphBMP16(WORD word, LPFONTINFO16 lpFontInfo, WORD w1, WORD w2,
1910 LPSTR string, DWORD dword, /*LPBITMAPMETRICS16*/ LPVOID metrics)
1912 FIXME("stub?\n");
1913 return 0;
1917 /***********************************************************************
1918 * EngineMakeFontDir (GDI.306)
1920 DWORD WINAPI EngineMakeFontDir16(HDC16 hdc, LPFONTDIR16 fontdir, LPCSTR string)
1922 FIXME(" stub! (always fails)\n");
1923 return ~0UL; /* error */
1927 /***********************************************************************
1928 * GetCharABCWidths (GDI.307)
1930 BOOL16 WINAPI GetCharABCWidths16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar, LPABC16 abc )
1932 BOOL ret;
1933 UINT i;
1934 LPABC abc32 = HeapAlloc( GetProcessHeap(), 0, sizeof(ABC) * (lastChar - firstChar + 1) );
1936 if ((ret = GetCharABCWidthsA( HDC_32(hdc), firstChar, lastChar, abc32 )))
1938 for (i = firstChar; i <= lastChar; i++)
1940 abc[i-firstChar].abcA = abc32[i-firstChar].abcA;
1941 abc[i-firstChar].abcB = abc32[i-firstChar].abcB;
1942 abc[i-firstChar].abcC = abc32[i-firstChar].abcC;
1945 HeapFree( GetProcessHeap(), 0, abc32 );
1946 return ret;
1950 /***********************************************************************
1951 * GetOutlineTextMetrics (GDI.308)
1953 * Gets metrics for TrueType fonts.
1955 * PARAMS
1956 * hdc [In] Handle of device context
1957 * cbData [In] Size of metric data array
1958 * lpOTM [Out] Address of metric data array
1960 * RETURNS
1961 * Success: Non-zero or size of required buffer
1962 * Failure: 0
1964 * NOTES
1965 * lpOTM should be LPOUTLINETEXTMETRIC
1967 UINT16 WINAPI GetOutlineTextMetrics16( HDC16 hdc, UINT16 cbData,
1968 LPOUTLINETEXTMETRIC16 lpOTM )
1970 FIXME("(%04x,%04x,%p): stub\n", hdc,cbData,lpOTM);
1971 return 0;
1975 /***********************************************************************
1976 * GetGlyphOutline (GDI.309)
1978 DWORD WINAPI GetGlyphOutline16( HDC16 hdc, UINT16 uChar, UINT16 fuFormat,
1979 LPGLYPHMETRICS16 lpgm, DWORD cbBuffer,
1980 LPVOID lpBuffer, const MAT2 *lpmat2 )
1982 DWORD ret;
1983 GLYPHMETRICS gm32;
1985 ret = GetGlyphOutlineA( HDC_32(hdc), uChar, fuFormat, &gm32, cbBuffer, lpBuffer, lpmat2);
1986 if (ret && ret != GDI_ERROR)
1988 lpgm->gmBlackBoxX = gm32.gmBlackBoxX;
1989 lpgm->gmBlackBoxY = gm32.gmBlackBoxY;
1990 lpgm->gmptGlyphOrigin.x = gm32.gmptGlyphOrigin.x;
1991 lpgm->gmptGlyphOrigin.y = gm32.gmptGlyphOrigin.y;
1992 lpgm->gmCellIncX = gm32.gmCellIncX;
1993 lpgm->gmCellIncY = gm32.gmCellIncY;
1995 return ret;
1999 /***********************************************************************
2000 * CreateScalableFontResource (GDI.310)
2002 BOOL16 WINAPI CreateScalableFontResource16( UINT16 fHidden, LPCSTR lpszResourceFile,
2003 LPCSTR fontFile, LPCSTR path )
2005 return CreateScalableFontResourceA( fHidden, lpszResourceFile, fontFile, path );
2009 /*************************************************************************
2010 * GetFontData (GDI.311)
2013 DWORD WINAPI GetFontData16( HDC16 hdc, DWORD table, DWORD offset, LPVOID buffer, DWORD count )
2015 return GetFontData( HDC_32(hdc), table, offset, buffer, count );
2019 /*************************************************************************
2020 * GetRasterizerCaps (GDI.313)
2022 BOOL16 WINAPI GetRasterizerCaps16( LPRASTERIZER_STATUS lprs, UINT16 cbNumBytes )
2024 return GetRasterizerCaps( lprs, cbNumBytes );
2028 /***********************************************************************
2029 * EnumFontFamilies (GDI.330)
2031 INT16 WINAPI EnumFontFamilies16( HDC16 hDC, LPCSTR lpFamily,
2032 FONTENUMPROC16 efproc, LPARAM lpData )
2034 LOGFONT16 lf, *plf;
2036 if (lpFamily)
2038 if (!*lpFamily) return 1;
2039 lstrcpynA( lf.lfFaceName, lpFamily, LF_FACESIZE );
2040 lf.lfCharSet = DEFAULT_CHARSET;
2041 lf.lfPitchAndFamily = 0;
2042 plf = &lf;
2044 else plf = NULL;
2046 return EnumFontFamiliesEx16( hDC, plf, efproc, lpData, 0 );
2050 /*************************************************************************
2051 * GetKerningPairs (GDI.332)
2054 INT16 WINAPI GetKerningPairs16( HDC16 hdc, INT16 count, LPKERNINGPAIR16 pairs )
2056 KERNINGPAIR *pairs32;
2057 INT i, ret;
2059 if (!count) return 0;
2061 if (!(pairs32 = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*pairs32) ))) return 0;
2062 if ((ret = GetKerningPairsA( HDC_32(hdc), count, pairs32 )))
2064 for (i = 0; i < ret; i++)
2066 pairs->wFirst = pairs32->wFirst;
2067 pairs->wSecond = pairs32->wSecond;
2068 pairs->iKernAmount = pairs32->iKernAmount;
2071 HeapFree( GetProcessHeap(), 0, pairs32 );
2072 return ret;
2077 /***********************************************************************
2078 * GetTextAlign (GDI.345)
2080 UINT16 WINAPI GetTextAlign16( HDC16 hdc )
2082 return GetTextAlign( HDC_32(hdc) );
2086 /***********************************************************************
2087 * SetTextAlign (GDI.346)
2089 UINT16 WINAPI SetTextAlign16( HDC16 hdc, UINT16 align )
2091 return SetTextAlign( HDC_32(hdc), align );
2095 /***********************************************************************
2096 * Chord (GDI.348)
2098 BOOL16 WINAPI Chord16( HDC16 hdc, INT16 left, INT16 top,
2099 INT16 right, INT16 bottom, INT16 xstart, INT16 ystart,
2100 INT16 xend, INT16 yend )
2102 return Chord( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
2106 /***********************************************************************
2107 * SetMapperFlags (GDI.349)
2109 DWORD WINAPI SetMapperFlags16( HDC16 hdc, DWORD flags )
2111 return SetMapperFlags( HDC_32(hdc), flags );
2115 /***********************************************************************
2116 * GetCharWidth (GDI.350)
2118 BOOL16 WINAPI GetCharWidth16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar, LPINT16 buffer )
2120 BOOL retVal = FALSE;
2122 if( firstChar != lastChar )
2124 LPINT buf32 = HeapAlloc(GetProcessHeap(), 0, sizeof(INT)*(1 + (lastChar - firstChar)));
2125 if( buf32 )
2127 LPINT obuf32 = buf32;
2128 int i;
2130 retVal = GetCharWidth32A( HDC_32(hdc), firstChar, lastChar, buf32);
2131 if (retVal)
2133 for (i = firstChar; i <= lastChar; i++) *buffer++ = *buf32++;
2135 HeapFree(GetProcessHeap(), 0, obuf32);
2138 else /* happens quite often to warrant a special treatment */
2140 INT chWidth;
2141 retVal = GetCharWidth32A( HDC_32(hdc), firstChar, lastChar, &chWidth );
2142 *buffer = chWidth;
2144 return retVal;
2148 /***********************************************************************
2149 * ExtTextOut (GDI.351)
2151 BOOL16 WINAPI ExtTextOut16( HDC16 hdc, INT16 x, INT16 y, UINT16 flags,
2152 const RECT16 *lprect, LPCSTR str, UINT16 count,
2153 const INT16 *lpDx )
2155 BOOL ret;
2156 int i;
2157 RECT rect32;
2158 LPINT lpdx32 = NULL;
2160 if (lpDx) {
2161 lpdx32 = HeapAlloc( GetProcessHeap(),0, sizeof(INT)*count );
2162 if(lpdx32 == NULL) return FALSE;
2163 for (i=count;i--;) lpdx32[i]=lpDx[i];
2165 if (lprect)
2167 rect32.left = lprect->left;
2168 rect32.top = lprect->top;
2169 rect32.right = lprect->right;
2170 rect32.bottom = lprect->bottom;
2172 ret = ExtTextOutA(HDC_32(hdc),x,y,flags,lprect?&rect32:NULL,str,count,lpdx32);
2173 HeapFree( GetProcessHeap(), 0, lpdx32 );
2174 return ret;
2178 /***********************************************************************
2179 * CreatePalette (GDI.360)
2181 HPALETTE16 WINAPI CreatePalette16( const LOGPALETTE* palette )
2183 return HPALETTE_16( CreatePalette( palette ) );
2187 /***********************************************************************
2188 * GDISelectPalette (GDI.361)
2190 HPALETTE16 WINAPI GDISelectPalette16( HDC16 hdc, HPALETTE16 hpalette, WORD wBkg )
2192 return HPALETTE_16( GDISelectPalette( HDC_32(hdc), HPALETTE_32(hpalette), wBkg ));
2196 /***********************************************************************
2197 * GDIRealizePalette (GDI.362)
2199 UINT16 WINAPI GDIRealizePalette16( HDC16 hdc )
2201 return GDIRealizePalette( HDC_32(hdc) );
2205 /***********************************************************************
2206 * GetPaletteEntries (GDI.363)
2208 UINT16 WINAPI GetPaletteEntries16( HPALETTE16 hpalette, UINT16 start,
2209 UINT16 count, LPPALETTEENTRY entries )
2211 return GetPaletteEntries( HPALETTE_32(hpalette), start, count, entries );
2215 /***********************************************************************
2216 * SetPaletteEntries (GDI.364)
2218 UINT16 WINAPI SetPaletteEntries16( HPALETTE16 hpalette, UINT16 start,
2219 UINT16 count, const PALETTEENTRY *entries )
2221 return SetPaletteEntries( HPALETTE_32(hpalette), start, count, entries );
2225 /**********************************************************************
2226 * UpdateColors (GDI.366)
2228 INT16 WINAPI UpdateColors16( HDC16 hdc )
2230 UpdateColors( HDC_32(hdc) );
2231 return TRUE;
2235 /***********************************************************************
2236 * AnimatePalette (GDI.367)
2238 void WINAPI AnimatePalette16( HPALETTE16 hpalette, UINT16 StartIndex,
2239 UINT16 NumEntries, const PALETTEENTRY* PaletteColors)
2241 AnimatePalette( HPALETTE_32(hpalette), StartIndex, NumEntries, PaletteColors );
2245 /***********************************************************************
2246 * ResizePalette (GDI.368)
2248 BOOL16 WINAPI ResizePalette16( HPALETTE16 hpalette, UINT16 cEntries )
2250 return ResizePalette( HPALETTE_32(hpalette), cEntries );
2254 /***********************************************************************
2255 * GetNearestPaletteIndex (GDI.370)
2257 UINT16 WINAPI GetNearestPaletteIndex16( HPALETTE16 hpalette, COLORREF color )
2259 return GetNearestPaletteIndex( HPALETTE_32(hpalette), color );
2263 /**********************************************************************
2264 * ExtFloodFill (GDI.372)
2266 BOOL16 WINAPI ExtFloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color,
2267 UINT16 fillType )
2269 return ExtFloodFill( HDC_32(hdc), x, y, color, fillType );
2273 /***********************************************************************
2274 * SetSystemPaletteUse (GDI.373)
2276 UINT16 WINAPI SetSystemPaletteUse16( HDC16 hdc, UINT16 use )
2278 return SetSystemPaletteUse( HDC_32(hdc), use );
2282 /***********************************************************************
2283 * GetSystemPaletteUse (GDI.374)
2285 UINT16 WINAPI GetSystemPaletteUse16( HDC16 hdc )
2287 return GetSystemPaletteUse( HDC_32(hdc) );
2291 /***********************************************************************
2292 * GetSystemPaletteEntries (GDI.375)
2294 UINT16 WINAPI GetSystemPaletteEntries16( HDC16 hdc, UINT16 start, UINT16 count,
2295 LPPALETTEENTRY entries )
2297 return GetSystemPaletteEntries( HDC_32(hdc), start, count, entries );
2301 /***********************************************************************
2302 * ResetDC (GDI.376)
2304 HDC16 WINAPI ResetDC16( HDC16 hdc, const DEVMODEA *devmode )
2306 return HDC_16( ResetDCA(HDC_32(hdc), devmode) );
2310 /******************************************************************
2311 * StartDoc (GDI.377)
2313 INT16 WINAPI StartDoc16( HDC16 hdc, const DOCINFO16 *lpdoc )
2315 DOCINFOA docA;
2317 docA.cbSize = lpdoc->cbSize;
2318 docA.lpszDocName = MapSL(lpdoc->lpszDocName);
2319 docA.lpszOutput = MapSL(lpdoc->lpszOutput);
2320 if(lpdoc->cbSize > offsetof(DOCINFO16,lpszDatatype))
2321 docA.lpszDatatype = MapSL(lpdoc->lpszDatatype);
2322 else
2323 docA.lpszDatatype = NULL;
2324 if(lpdoc->cbSize > offsetof(DOCINFO16,fwType))
2325 docA.fwType = lpdoc->fwType;
2326 else
2327 docA.fwType = 0;
2328 return StartDocA( HDC_32(hdc), &docA );
2332 /******************************************************************
2333 * EndDoc (GDI.378)
2335 INT16 WINAPI EndDoc16( HDC16 hdc )
2337 return EndDoc( HDC_32(hdc) );
2341 /******************************************************************
2342 * StartPage (GDI.379)
2344 INT16 WINAPI StartPage16( HDC16 hdc )
2346 return StartPage( HDC_32(hdc) );
2350 /******************************************************************
2351 * EndPage (GDI.380)
2353 INT16 WINAPI EndPage16( HDC16 hdc )
2355 return EndPage( HDC_32(hdc) );
2359 /******************************************************************************
2360 * AbortDoc (GDI.382)
2362 INT16 WINAPI AbortDoc16( HDC16 hdc )
2364 return AbortDoc( HDC_32(hdc) );
2368 /***********************************************************************
2369 * FastWindowFrame (GDI.400)
2371 BOOL16 WINAPI FastWindowFrame16( HDC16 hdc, const RECT16 *rect,
2372 INT16 width, INT16 height, DWORD rop )
2374 HDC hdc32 = HDC_32(hdc);
2375 HBRUSH hbrush = SelectObject( hdc32, GetStockObject( GRAY_BRUSH ) );
2376 PatBlt( hdc32, rect->left, rect->top,
2377 rect->right - rect->left - width, height, rop );
2378 PatBlt( hdc32, rect->left, rect->top + height, width,
2379 rect->bottom - rect->top - height, rop );
2380 PatBlt( hdc32, rect->left + width, rect->bottom - 1,
2381 rect->right - rect->left - width, -height, rop );
2382 PatBlt( hdc32, rect->right - 1, rect->top, -width,
2383 rect->bottom - rect->top - height, rop );
2384 SelectObject( hdc32, hbrush );
2385 return TRUE;
2389 /***********************************************************************
2390 * GdiInit2 (GDI.403)
2392 * See "Undocumented Windows"
2394 * PARAMS
2395 * h1 [I] GDI object
2396 * h2 [I] global data
2398 HANDLE16 WINAPI GdiInit216( HANDLE16 h1, HANDLE16 h2 )
2400 FIXME("(%04x, %04x), stub.\n", h1, h2);
2401 if (h2 == 0xffff) return 0xffff; /* undefined return value */
2402 return h1; /* FIXME: should be the memory handle of h1 */
2406 /***********************************************************************
2407 * FinalGdiInit (GDI.405)
2409 void WINAPI FinalGdiInit16( HBRUSH16 hPattern /* [in] fill pattern of desktop */ )
2414 /***********************************************************************
2415 * CreateUserBitmap (GDI.407)
2417 HBITMAP16 WINAPI CreateUserBitmap16( INT16 width, INT16 height, UINT16 planes,
2418 UINT16 bpp, LPCVOID bits )
2420 return CreateBitmap16( width, height, planes, bpp, bits );
2424 /***********************************************************************
2425 * CreateUserDiscardableBitmap (GDI.409)
2427 HBITMAP16 WINAPI CreateUserDiscardableBitmap16( WORD dummy, INT16 width, INT16 height )
2429 HDC hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
2430 HBITMAP ret = CreateCompatibleBitmap( hdc, width, height );
2431 DeleteDC( hdc );
2432 return HBITMAP_16(ret);
2436 /***********************************************************************
2437 * GetCurLogFont (GDI.411)
2439 HFONT16 WINAPI GetCurLogFont16( HDC16 hdc )
2441 return HFONT_16( GetCurrentObject( HDC_32(hdc), OBJ_FONT ) );
2445 /***********************************************************************
2446 * StretchDIBits (GDI.439)
2448 INT16 WINAPI StretchDIBits16( HDC16 hdc, INT16 xDst, INT16 yDst, INT16 widthDst,
2449 INT16 heightDst, INT16 xSrc, INT16 ySrc, INT16 widthSrc,
2450 INT16 heightSrc, const VOID *bits,
2451 const BITMAPINFO *info, UINT16 wUsage, DWORD dwRop )
2453 return StretchDIBits( HDC_32(hdc), xDst, yDst, widthDst, heightDst,
2454 xSrc, ySrc, widthSrc, heightSrc, bits,
2455 info, wUsage, dwRop );
2459 /***********************************************************************
2460 * SetDIBits (GDI.440)
2462 INT16 WINAPI SetDIBits16( HDC16 hdc, HBITMAP16 hbitmap, UINT16 startscan,
2463 UINT16 lines, LPCVOID bits, const BITMAPINFO *info,
2464 UINT16 coloruse )
2466 return SetDIBits( HDC_32(hdc), HBITMAP_32(hbitmap), startscan, lines, bits, info, coloruse );
2470 /***********************************************************************
2471 * GetDIBits (GDI.441)
2473 INT16 WINAPI GetDIBits16( HDC16 hdc, HBITMAP16 hbitmap, UINT16 startscan,
2474 UINT16 lines, LPVOID bits, BITMAPINFO * info,
2475 UINT16 coloruse )
2477 return GetDIBits( HDC_32(hdc), HBITMAP_32(hbitmap), startscan, lines, bits, info, coloruse );
2481 /***********************************************************************
2482 * CreateDIBitmap (GDI.442)
2484 HBITMAP16 WINAPI CreateDIBitmap16( HDC16 hdc, const BITMAPINFOHEADER * header,
2485 DWORD init, LPCVOID bits, const BITMAPINFO * data,
2486 UINT16 coloruse )
2488 return HBITMAP_16( CreateDIBitmap( HDC_32(hdc), header, init, bits, data, coloruse ) );
2492 /***********************************************************************
2493 * SetDIBitsToDevice (GDI.443)
2495 INT16 WINAPI SetDIBitsToDevice16( HDC16 hdc, INT16 xDest, INT16 yDest, INT16 cx,
2496 INT16 cy, INT16 xSrc, INT16 ySrc, UINT16 startscan,
2497 UINT16 lines, LPCVOID bits, const BITMAPINFO *info,
2498 UINT16 coloruse )
2500 return SetDIBitsToDevice( HDC_32(hdc), xDest, yDest, cx, cy, xSrc, ySrc,
2501 startscan, lines, bits, info, coloruse );
2505 /***********************************************************************
2506 * CreateRoundRectRgn (GDI.444)
2508 * If either ellipse dimension is zero we call CreateRectRgn16 for its
2509 * `special' behaviour. -ve ellipse dimensions can result in GPFs under win3.1
2510 * we just let CreateRoundRectRgn convert them to +ve values.
2513 HRGN16 WINAPI CreateRoundRectRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom,
2514 INT16 ellipse_width, INT16 ellipse_height )
2516 if( ellipse_width == 0 || ellipse_height == 0 )
2517 return CreateRectRgn16( left, top, right, bottom );
2518 else
2519 return HRGN_16( CreateRoundRectRgn( left, top, right, bottom,
2520 ellipse_width, ellipse_height ));
2524 /***********************************************************************
2525 * CreateDIBPatternBrush (GDI.445)
2527 HBRUSH16 WINAPI CreateDIBPatternBrush16( HGLOBAL16 hbitmap, UINT16 coloruse )
2529 BITMAPINFO *bmi;
2530 HBRUSH16 ret;
2532 if (!(bmi = GlobalLock16( hbitmap ))) return 0;
2533 ret = HBRUSH_16( CreateDIBPatternBrushPt( bmi, coloruse ));
2534 GlobalUnlock16( hbitmap );
2535 return ret;
2539 /**********************************************************************
2540 * PolyPolygon (GDI.450)
2542 BOOL16 WINAPI PolyPolygon16( HDC16 hdc, const POINT16* pt, const INT16* counts,
2543 UINT16 polygons )
2545 int i,nrpts;
2546 LPPOINT pt32;
2547 LPINT counts32;
2548 BOOL16 ret;
2550 nrpts=0;
2551 for (i=polygons;i--;)
2552 nrpts+=counts[i];
2553 pt32 = HeapAlloc( GetProcessHeap(), 0, sizeof(POINT)*nrpts);
2554 if(pt32 == NULL) return FALSE;
2555 for (i=nrpts;i--;)
2557 pt32[i].x = pt[i].x;
2558 pt32[i].y = pt[i].y;
2560 counts32 = HeapAlloc( GetProcessHeap(), 0, polygons*sizeof(INT) );
2561 if(counts32 == NULL) {
2562 HeapFree( GetProcessHeap(), 0, pt32 );
2563 return FALSE;
2565 for (i=polygons;i--;) counts32[i]=counts[i];
2567 ret = PolyPolygon(HDC_32(hdc),pt32,counts32,polygons);
2568 HeapFree( GetProcessHeap(), 0, counts32 );
2569 HeapFree( GetProcessHeap(), 0, pt32 );
2570 return ret;
2574 /***********************************************************************
2575 * CreatePolyPolygonRgn (GDI.451)
2577 HRGN16 WINAPI CreatePolyPolygonRgn16( const POINT16 *points,
2578 const INT16 *count, INT16 nbpolygons, INT16 mode )
2580 HRGN hrgn;
2581 int i, npts = 0;
2582 INT *count32;
2583 POINT *points32;
2585 for (i = 0; i < nbpolygons; i++) npts += count[i];
2586 points32 = HeapAlloc( GetProcessHeap(), 0, npts * sizeof(POINT) );
2587 for (i = 0; i < npts; i++)
2589 points32[i].x = points[i].x;
2590 points32[i].y = points[i].y;
2593 count32 = HeapAlloc( GetProcessHeap(), 0, nbpolygons * sizeof(INT) );
2594 for (i = 0; i < nbpolygons; i++) count32[i] = count[i];
2595 hrgn = CreatePolyPolygonRgn( points32, count32, nbpolygons, mode );
2596 HeapFree( GetProcessHeap(), 0, count32 );
2597 HeapFree( GetProcessHeap(), 0, points32 );
2598 return HRGN_16(hrgn);
2602 /***********************************************************************
2603 * GdiSeeGdiDo (GDI.452)
2605 DWORD WINAPI GdiSeeGdiDo16( WORD wReqType, WORD wParam1, WORD wParam2,
2606 WORD wParam3 )
2608 DWORD ret = ~0U;
2610 switch (wReqType)
2612 case 0x0001: /* LocalAlloc */
2613 WARN("LocalAlloc16(%x, %x): ignoring\n", wParam1, wParam3);
2614 ret = 0;
2615 break;
2616 case 0x0002: /* LocalFree */
2617 WARN("LocalFree16(%x): ignoring\n", wParam1);
2618 ret = 0;
2619 break;
2620 case 0x0003: /* LocalCompact */
2621 WARN("LocalCompact16(%x): ignoring\n", wParam3);
2622 ret = 65000; /* lie about the amount of free space */
2623 break;
2624 case 0x0103: /* LocalHeap */
2625 WARN("LocalHeap16(): ignoring\n");
2626 break;
2627 default:
2628 WARN("(wReqType=%04x): Unknown\n", wReqType);
2629 break;
2631 return ret;
2635 /***********************************************************************
2636 * SetObjectOwner (GDI.461)
2638 void WINAPI SetObjectOwner16( HGDIOBJ16 handle, HANDLE16 owner )
2640 /* Nothing to do */
2644 /***********************************************************************
2645 * IsGDIObject (GDI.462)
2647 * returns type of object if valid (W95 system programming secrets p. 264-5)
2649 BOOL16 WINAPI IsGDIObject16( HGDIOBJ16 handle16 )
2651 static const BYTE type_map[] =
2653 0, /* bad */
2654 1, /* OBJ_PEN */
2655 2, /* OBJ_BRUSH */
2656 7, /* OBJ_DC */
2657 9, /* OBJ_METADC */
2658 4, /* OBJ_PAL */
2659 3, /* OBJ_FONT */
2660 5, /* OBJ_BITMAP */
2661 6, /* OBJ_REGION */
2662 10, /* OBJ_METAFILE */
2663 7, /* OBJ_MEMDC */
2664 0, /* OBJ_EXTPEN */
2665 9, /* OBJ_ENHMETADC */
2666 12, /* OBJ_ENHMETAFILE */
2667 0 /* OBJ_COLORSPACE */
2670 UINT type = GetObjectType( HGDIOBJ_32( handle16 ));
2672 if (type >= sizeof(type_map)/sizeof(type_map[0])) return 0;
2673 return type_map[type];
2677 /***********************************************************************
2678 * RectVisible (GDI.465)
2679 * RectVisibleOld (GDI.104)
2681 BOOL16 WINAPI RectVisible16( HDC16 hdc, const RECT16* rect16 )
2683 RECT rect;
2685 rect.left = rect16->left;
2686 rect.top = rect16->top;
2687 rect.right = rect16->right;
2688 rect.bottom = rect16->bottom;
2689 return RectVisible( HDC_32(hdc), &rect );
2693 /***********************************************************************
2694 * RectInRegion (GDI.466)
2695 * RectInRegionOld (GDI.181)
2697 BOOL16 WINAPI RectInRegion16( HRGN16 hrgn, const RECT16 *rect )
2699 RECT r32;
2701 r32.left = rect->left;
2702 r32.top = rect->top;
2703 r32.right = rect->right;
2704 r32.bottom = rect->bottom;
2705 return RectInRegion( HRGN_32(hrgn), &r32 );
2709 /***********************************************************************
2710 * GetBitmapDimensionEx (GDI.468)
2712 BOOL16 WINAPI GetBitmapDimensionEx16( HBITMAP16 hbitmap, LPSIZE16 size )
2714 SIZE size32;
2715 BOOL ret = GetBitmapDimensionEx( HBITMAP_32(hbitmap), &size32 );
2717 if (ret)
2719 size->cx = size32.cx;
2720 size->cy = size32.cy;
2722 return ret;
2726 /***********************************************************************
2727 * GetBrushOrgEx (GDI.469)
2729 BOOL16 WINAPI GetBrushOrgEx16( HDC16 hdc, LPPOINT16 pt )
2731 POINT pt32;
2732 if (!GetBrushOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
2733 pt->x = pt32.x;
2734 pt->y = pt32.y;
2735 return TRUE;
2739 /***********************************************************************
2740 * GetCurrentPositionEx (GDI.470)
2742 BOOL16 WINAPI GetCurrentPositionEx16( HDC16 hdc, LPPOINT16 pt )
2744 POINT pt32;
2745 if (!GetCurrentPositionEx( HDC_32(hdc), &pt32 )) return FALSE;
2746 pt->x = pt32.x;
2747 pt->y = pt32.y;
2748 return TRUE;
2752 /***********************************************************************
2753 * GetTextExtentPoint (GDI.471)
2755 * FIXME: Should this have a bug for compatibility?
2756 * Original Windows versions of GetTextExtentPoint{A,W} have documented
2757 * bugs (-> MSDN KB q147647.txt).
2759 BOOL16 WINAPI GetTextExtentPoint16( HDC16 hdc, LPCSTR str, INT16 count, LPSIZE16 size )
2761 SIZE size32;
2762 BOOL ret = GetTextExtentPoint32A( HDC_32(hdc), str, count, &size32 );
2764 if (ret)
2766 size->cx = size32.cx;
2767 size->cy = size32.cy;
2769 return ret;
2773 /***********************************************************************
2774 * GetViewportExtEx (GDI.472)
2776 BOOL16 WINAPI GetViewportExtEx16( HDC16 hdc, LPSIZE16 size )
2778 SIZE size32;
2779 if (!GetViewportExtEx( HDC_32(hdc), &size32 )) return FALSE;
2780 size->cx = size32.cx;
2781 size->cy = size32.cy;
2782 return TRUE;
2786 /***********************************************************************
2787 * GetViewportOrgEx (GDI.473)
2789 BOOL16 WINAPI GetViewportOrgEx16( HDC16 hdc, LPPOINT16 pt )
2791 POINT pt32;
2792 if (!GetViewportOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
2793 pt->x = pt32.x;
2794 pt->y = pt32.y;
2795 return TRUE;
2799 /***********************************************************************
2800 * GetWindowExtEx (GDI.474)
2802 BOOL16 WINAPI GetWindowExtEx16( HDC16 hdc, LPSIZE16 size )
2804 SIZE size32;
2805 if (!GetWindowExtEx( HDC_32(hdc), &size32 )) return FALSE;
2806 size->cx = size32.cx;
2807 size->cy = size32.cy;
2808 return TRUE;
2812 /***********************************************************************
2813 * GetWindowOrgEx (GDI.475)
2815 BOOL16 WINAPI GetWindowOrgEx16( HDC16 hdc, LPPOINT16 pt )
2817 POINT pt32;
2818 if (!GetWindowOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
2819 pt->x = pt32.x;
2820 pt->y = pt32.y;
2821 return TRUE;
2825 /***********************************************************************
2826 * OffsetViewportOrgEx (GDI.476)
2828 BOOL16 WINAPI OffsetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt)
2830 POINT pt32;
2831 BOOL16 ret = OffsetViewportOrgEx( HDC_32(hdc), x, y, &pt32 );
2832 if (pt)
2834 pt->x = pt32.x;
2835 pt->y = pt32.y;
2837 return ret;
2841 /***********************************************************************
2842 * OffsetWindowOrgEx (GDI.477)
2844 BOOL16 WINAPI OffsetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
2846 POINT pt32;
2847 BOOL16 ret = OffsetWindowOrgEx( HDC_32(hdc), x, y, &pt32 );
2848 if (pt)
2850 pt->x = pt32.x;
2851 pt->y = pt32.y;
2853 return ret;
2857 /***********************************************************************
2858 * SetBitmapDimensionEx (GDI.478)
2860 BOOL16 WINAPI SetBitmapDimensionEx16( HBITMAP16 hbitmap, INT16 x, INT16 y, LPSIZE16 prevSize )
2862 SIZE size32;
2863 BOOL ret = SetBitmapDimensionEx( HBITMAP_32(hbitmap), x, y, &size32 );
2865 if (ret && prevSize)
2867 prevSize->cx = size32.cx;
2868 prevSize->cy = size32.cy;
2870 return ret;
2874 /***********************************************************************
2875 * SetViewportExtEx (GDI.479)
2877 BOOL16 WINAPI SetViewportExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
2879 SIZE size32;
2880 BOOL16 ret = SetViewportExtEx( HDC_32(hdc), x, y, &size32 );
2881 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
2882 return ret;
2886 /***********************************************************************
2887 * SetViewportOrgEx (GDI.480)
2889 BOOL16 WINAPI SetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
2891 POINT pt32;
2892 BOOL16 ret = SetViewportOrgEx( HDC_32(hdc), x, y, &pt32 );
2893 if (pt)
2895 pt->x = pt32.x;
2896 pt->y = pt32.y;
2898 return ret;
2902 /***********************************************************************
2903 * SetWindowExtEx (GDI.481)
2905 BOOL16 WINAPI SetWindowExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
2907 SIZE size32;
2908 BOOL16 ret = SetWindowExtEx( HDC_32(hdc), x, y, &size32 );
2909 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
2910 return ret;
2914 /***********************************************************************
2915 * SetWindowOrgEx (GDI.482)
2917 BOOL16 WINAPI SetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
2919 POINT pt32;
2920 BOOL16 ret = SetWindowOrgEx( HDC_32(hdc), x, y, &pt32 );
2921 if (pt)
2923 pt->x = pt32.x;
2924 pt->y = pt32.y;
2926 return ret;
2930 /***********************************************************************
2931 * MoveToEx (GDI.483)
2933 BOOL16 WINAPI MoveToEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
2935 POINT pt32;
2937 if (!MoveToEx( HDC_32(hdc), x, y, &pt32 )) return FALSE;
2938 if (pt)
2940 pt->x = pt32.x;
2941 pt->y = pt32.y;
2943 return TRUE;
2947 /***********************************************************************
2948 * ScaleViewportExtEx (GDI.484)
2950 BOOL16 WINAPI ScaleViewportExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
2951 INT16 yNum, INT16 yDenom, LPSIZE16 size )
2953 SIZE size32;
2954 BOOL16 ret = ScaleViewportExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom,
2955 &size32 );
2956 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
2957 return ret;
2961 /***********************************************************************
2962 * ScaleWindowExtEx (GDI.485)
2964 BOOL16 WINAPI ScaleWindowExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
2965 INT16 yNum, INT16 yDenom, LPSIZE16 size )
2967 SIZE size32;
2968 BOOL16 ret = ScaleWindowExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom,
2969 &size32 );
2970 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
2971 return ret;
2975 /***********************************************************************
2976 * GetAspectRatioFilterEx (GDI.486)
2978 BOOL16 WINAPI GetAspectRatioFilterEx16( HDC16 hdc, LPSIZE16 pAspectRatio )
2980 FIXME("(%04x, %p): -- Empty Stub !\n", hdc, pAspectRatio);
2981 return FALSE;
2985 /******************************************************************************
2986 * PolyBezier (GDI.502)
2988 BOOL16 WINAPI PolyBezier16( HDC16 hdc, const POINT16* lppt, INT16 cPoints )
2990 int i;
2991 BOOL16 ret;
2992 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, cPoints*sizeof(POINT) );
2993 if(!pt32) return FALSE;
2994 for (i=cPoints;i--;)
2996 pt32[i].x = lppt[i].x;
2997 pt32[i].y = lppt[i].y;
2999 ret= PolyBezier(HDC_32(hdc), pt32, cPoints);
3000 HeapFree( GetProcessHeap(), 0, pt32 );
3001 return ret;
3005 /******************************************************************************
3006 * PolyBezierTo (GDI.503)
3008 BOOL16 WINAPI PolyBezierTo16( HDC16 hdc, const POINT16* lppt, INT16 cPoints )
3010 int i;
3011 BOOL16 ret;
3012 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0,
3013 cPoints*sizeof(POINT) );
3014 if(!pt32) return FALSE;
3015 for (i=cPoints;i--;)
3017 pt32[i].x = lppt[i].x;
3018 pt32[i].y = lppt[i].y;
3020 ret= PolyBezierTo(HDC_32(hdc), pt32, cPoints);
3021 HeapFree( GetProcessHeap(), 0, pt32 );
3022 return ret;
3026 /******************************************************************************
3027 * ExtSelectClipRgn (GDI.508)
3029 INT16 WINAPI ExtSelectClipRgn16( HDC16 hdc, HRGN16 hrgn, INT16 fnMode )
3031 return ExtSelectClipRgn( HDC_32(hdc), HRGN_32(hrgn), fnMode);
3035 /***********************************************************************
3036 * AbortPath (GDI.511)
3038 BOOL16 WINAPI AbortPath16(HDC16 hdc)
3040 return AbortPath( HDC_32(hdc) );
3044 /***********************************************************************
3045 * BeginPath (GDI.512)
3047 BOOL16 WINAPI BeginPath16(HDC16 hdc)
3049 return BeginPath( HDC_32(hdc) );
3053 /***********************************************************************
3054 * CloseFigure (GDI.513)
3056 BOOL16 WINAPI CloseFigure16(HDC16 hdc)
3058 return CloseFigure( HDC_32(hdc) );
3062 /***********************************************************************
3063 * EndPath (GDI.514)
3065 BOOL16 WINAPI EndPath16(HDC16 hdc)
3067 return EndPath( HDC_32(hdc) );
3071 /***********************************************************************
3072 * FillPath (GDI.515)
3074 BOOL16 WINAPI FillPath16(HDC16 hdc)
3076 return FillPath( HDC_32(hdc) );
3080 /*******************************************************************
3081 * FlattenPath (GDI.516)
3083 BOOL16 WINAPI FlattenPath16(HDC16 hdc)
3085 return FlattenPath( HDC_32(hdc) );
3089 /***********************************************************************
3090 * GetPath (GDI.517)
3092 INT16 WINAPI GetPath16(HDC16 hdc, LPPOINT16 pPoints, LPBYTE pTypes, INT16 nSize)
3094 FIXME("(%d,%p,%p): stub\n",hdc,pPoints,pTypes);
3095 return 0;
3099 /***********************************************************************
3100 * PathToRegion (GDI.518)
3102 HRGN16 WINAPI PathToRegion16(HDC16 hdc)
3104 return HRGN_16( PathToRegion( HDC_32(hdc) ));
3108 /***********************************************************************
3109 * SelectClipPath (GDI.519)
3111 BOOL16 WINAPI SelectClipPath16(HDC16 hdc, INT16 iMode)
3113 return SelectClipPath( HDC_32(hdc), iMode );
3117 /*******************************************************************
3118 * StrokeAndFillPath (GDI.520)
3120 BOOL16 WINAPI StrokeAndFillPath16(HDC16 hdc)
3122 return StrokeAndFillPath( HDC_32(hdc) );
3126 /*******************************************************************
3127 * StrokePath (GDI.521)
3129 BOOL16 WINAPI StrokePath16(HDC16 hdc)
3131 return StrokePath( HDC_32(hdc) );
3135 /*******************************************************************
3136 * WidenPath (GDI.522)
3138 BOOL16 WINAPI WidenPath16(HDC16 hdc)
3140 return WidenPath( HDC_32(hdc) );
3144 /***********************************************************************
3145 * GetArcDirection (GDI.524)
3147 INT16 WINAPI GetArcDirection16( HDC16 hdc )
3149 return GetArcDirection( HDC_32(hdc) );
3153 /***********************************************************************
3154 * SetArcDirection (GDI.525)
3156 INT16 WINAPI SetArcDirection16( HDC16 hdc, INT16 nDirection )
3158 return SetArcDirection( HDC_32(hdc), (INT)nDirection );
3162 /***********************************************************************
3163 * CreateHalftonePalette (GDI.529)
3165 HPALETTE16 WINAPI CreateHalftonePalette16( HDC16 hdc )
3167 return HPALETTE_16( CreateHalftonePalette( HDC_32(hdc) ));
3171 /***********************************************************************
3172 * SetDIBColorTable (GDI.602)
3174 UINT16 WINAPI SetDIBColorTable16( HDC16 hdc, UINT16 startpos, UINT16 entries, RGBQUAD *colors )
3176 return SetDIBColorTable( HDC_32(hdc), startpos, entries, colors );
3180 /***********************************************************************
3181 * GetDIBColorTable (GDI.603)
3183 UINT16 WINAPI GetDIBColorTable16( HDC16 hdc, UINT16 startpos, UINT16 entries, RGBQUAD *colors )
3185 return GetDIBColorTable( HDC_32(hdc), startpos, entries, colors );
3189 /***********************************************************************
3190 * GetRegionData (GDI.607)
3192 * FIXME: is LPRGNDATA the same in Win16 and Win32 ?
3194 DWORD WINAPI GetRegionData16( HRGN16 hrgn, DWORD count, LPRGNDATA rgndata )
3196 return GetRegionData( HRGN_32(hrgn), count, rgndata );
3200 /***********************************************************************
3201 * GdiFreeResources (GDI.609)
3203 WORD WINAPI GdiFreeResources16( DWORD reserve )
3205 return 90; /* lie about it, it shouldn't matter */
3209 /***********************************************************************
3210 * GdiSignalProc32 (GDI.610)
3212 WORD WINAPI GdiSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
3213 DWORD dwFlags, HMODULE16 hModule )
3215 return 0;
3219 /***********************************************************************
3220 * GetTextCharset (GDI.612)
3222 UINT16 WINAPI GetTextCharset16( HDC16 hdc )
3224 return GetTextCharset( HDC_32(hdc) );
3228 /***********************************************************************
3229 * EnumFontFamiliesEx (GDI.613)
3231 INT16 WINAPI EnumFontFamiliesEx16( HDC16 hdc, LPLOGFONT16 plf,
3232 FONTENUMPROC16 proc, LPARAM lParam,
3233 DWORD dwFlags)
3235 struct callback16_info info;
3236 LOGFONTW lfW, *plfW;
3238 info.proc = (FARPROC16)proc;
3239 info.param = lParam;
3241 if (plf)
3243 logfont_16_to_W(plf, &lfW);
3244 plfW = &lfW;
3246 else plfW = NULL;
3248 return EnumFontFamiliesExW( HDC_32(hdc), plfW, enum_font_callback,
3249 (LPARAM)&info, dwFlags );
3253 /*************************************************************************
3254 * GetFontLanguageInfo (GDI.616)
3256 DWORD WINAPI GetFontLanguageInfo16( HDC16 hdc )
3258 return GetFontLanguageInfo( HDC_32(hdc) );
3262 /***********************************************************************
3263 * SetLayout (GDI.1000)
3265 * Sets left->right or right->left text layout flags of a dc.
3267 BOOL16 WINAPI SetLayout16( HDC16 hdc, DWORD layout )
3269 return SetLayout( HDC_32(hdc), layout );
3273 /***********************************************************************
3274 * SetSolidBrush (GDI.604)
3276 * Change the color of a solid brush.
3278 * PARAMS
3279 * hBrush [I] Brush to change the color of
3280 * newColor [I] New color for hBrush
3282 * RETURNS
3283 * Success: TRUE. The color of hBrush is set to newColor.
3284 * Failure: FALSE.
3286 * FIXME
3287 * This function is undocumented and untested. The implementation may
3288 * not be correct.
3290 BOOL16 WINAPI SetSolidBrush16(HBRUSH16 hBrush, COLORREF newColor )
3292 TRACE("(hBrush %04x, newColor %08x)\n", hBrush, newColor);
3294 return BRUSH_SetSolid( HBRUSH_32(hBrush), newColor );
3298 /***********************************************************************
3299 * Copy (GDI.250)
3301 void WINAPI Copy16( LPVOID src, LPVOID dst, WORD size )
3303 memcpy( dst, src, size );
3306 /***********************************************************************
3307 * RealizeDefaultPalette (GDI.365)
3309 UINT16 WINAPI RealizeDefaultPalette16( HDC16 hdc )
3311 UINT16 ret = 0;
3312 DC *dc;
3314 TRACE("%04x\n", hdc );
3316 if (!(dc = get_dc_ptr( HDC_32(hdc) ))) return 0;
3318 if (dc->funcs->pRealizeDefaultPalette) ret = dc->funcs->pRealizeDefaultPalette( dc->physDev );
3319 release_dc_ptr( dc );
3320 return ret;
3323 /***********************************************************************
3324 * IsDCCurrentPalette (GDI.412)
3326 BOOL16 WINAPI IsDCCurrentPalette16(HDC16 hDC)
3328 DC *dc = get_dc_ptr( HDC_32(hDC) );
3329 if (dc)
3331 BOOL bRet = dc->hPalette == hPrimaryPalette;
3332 release_dc_ptr( dc );
3333 return bRet;
3335 return FALSE;
3338 /*********************************************************************
3339 * SetMagicColors (GDI.606)
3341 VOID WINAPI SetMagicColors16(HDC16 hDC, COLORREF color, UINT16 index)
3343 FIXME("(hDC %04x, color %04x, index %04x): stub\n", hDC, (int)color, index);
3348 /***********************************************************************
3349 * DPtoLP (GDI.67)
3351 BOOL16 WINAPI DPtoLP16( HDC16 hdc, LPPOINT16 points, INT16 count )
3353 DC * dc = get_dc_ptr( HDC_32(hdc) );
3354 if (!dc) return FALSE;
3356 while (count--)
3358 points->x = MulDiv( points->x - dc->vportOrgX, dc->wndExtX, dc->vportExtX ) + dc->wndOrgX;
3359 points->y = MulDiv( points->y - dc->vportOrgY, dc->wndExtY, dc->vportExtY ) + dc->wndOrgY;
3360 points++;
3362 release_dc_ptr( dc );
3363 return TRUE;
3367 /***********************************************************************
3368 * LPtoDP (GDI.99)
3370 BOOL16 WINAPI LPtoDP16( HDC16 hdc, LPPOINT16 points, INT16 count )
3372 DC * dc = get_dc_ptr( HDC_32(hdc) );
3373 if (!dc) return FALSE;
3375 while (count--)
3377 points->x = MulDiv( points->x - dc->wndOrgX, dc->vportExtX, dc->wndExtX ) + dc->vportOrgX;
3378 points->y = MulDiv( points->y - dc->wndOrgY, dc->vportExtY, dc->wndExtY ) + dc->vportOrgY;
3379 points++;
3381 release_dc_ptr( dc );
3382 return TRUE;
3386 /***********************************************************************
3387 * GetDCState (GDI.179)
3389 HDC16 WINAPI GetDCState16( HDC16 hdc )
3391 return HDC_16( get_dc_state( HDC_32(hdc) ));
3395 /***********************************************************************
3396 * SetDCState (GDI.180)
3398 void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs )
3400 set_dc_state( HDC_32(hdc), HDC_32(hdcs) );
3403 /***********************************************************************
3404 * SetDCOrg (GDI.117)
3406 DWORD WINAPI SetDCOrg16( HDC16 hdc16, INT16 x, INT16 y )
3408 DWORD prevOrg = 0;
3409 HDC hdc = HDC_32( hdc16 );
3410 DC *dc = get_dc_ptr( hdc );
3411 if (!dc) return 0;
3412 if (dc->funcs->pSetDCOrg) prevOrg = dc->funcs->pSetDCOrg( dc->physDev, x, y );
3413 release_dc_ptr( dc );
3414 return prevOrg;
3418 /***********************************************************************
3419 * InquireVisRgn (GDI.131)
3421 HRGN16 WINAPI InquireVisRgn16( HDC16 hdc )
3423 HRGN16 ret = 0;
3424 DC * dc = get_dc_ptr( HDC_32(hdc) );
3425 if (dc)
3427 ret = HRGN_16(dc->hVisRgn);
3428 release_dc_ptr( dc );
3430 return ret;
3434 /***********************************************************************
3435 * OffsetVisRgn (GDI.102)
3437 INT16 WINAPI OffsetVisRgn16( HDC16 hdc16, INT16 x, INT16 y )
3439 INT16 retval;
3440 HDC hdc = HDC_32( hdc16 );
3441 DC * dc = get_dc_ptr( hdc );
3443 if (!dc) return ERROR;
3444 TRACE("%p %d,%d\n", hdc, x, y );
3445 update_dc( dc );
3446 retval = OffsetRgn( dc->hVisRgn, x, y );
3447 CLIPPING_UpdateGCRegion( dc );
3448 release_dc_ptr( dc );
3449 return retval;
3453 /***********************************************************************
3454 * ExcludeVisRect (GDI.73)
3456 INT16 WINAPI ExcludeVisRect16( HDC16 hdc16, INT16 left, INT16 top, INT16 right, INT16 bottom )
3458 HRGN tempRgn;
3459 INT16 ret;
3460 POINT pt[2];
3461 HDC hdc = HDC_32( hdc16 );
3462 DC * dc = get_dc_ptr( hdc );
3463 if (!dc) return ERROR;
3465 pt[0].x = left;
3466 pt[0].y = top;
3467 pt[1].x = right;
3468 pt[1].y = bottom;
3470 LPtoDP( hdc, pt, 2 );
3472 TRACE("%p %d,%d - %d,%d\n", hdc, pt[0].x, pt[0].y, pt[1].x, pt[1].y);
3474 if (!(tempRgn = CreateRectRgn( pt[0].x, pt[0].y, pt[1].x, pt[1].y ))) ret = ERROR;
3475 else
3477 update_dc( dc );
3478 ret = CombineRgn( dc->hVisRgn, dc->hVisRgn, tempRgn, RGN_DIFF );
3479 DeleteObject( tempRgn );
3481 if (ret != ERROR) CLIPPING_UpdateGCRegion( dc );
3482 release_dc_ptr( dc );
3483 return ret;
3487 /***********************************************************************
3488 * IntersectVisRect (GDI.98)
3490 INT16 WINAPI IntersectVisRect16( HDC16 hdc16, INT16 left, INT16 top, INT16 right, INT16 bottom )
3492 HRGN tempRgn;
3493 INT16 ret;
3494 POINT pt[2];
3495 HDC hdc = HDC_32( hdc16 );
3496 DC * dc = get_dc_ptr( hdc );
3497 if (!dc) return ERROR;
3499 pt[0].x = left;
3500 pt[0].y = top;
3501 pt[1].x = right;
3502 pt[1].y = bottom;
3504 LPtoDP( hdc, pt, 2 );
3506 TRACE("%p %d,%d - %d,%d\n", hdc, pt[0].x, pt[0].y, pt[1].x, pt[1].y);
3508 if (!(tempRgn = CreateRectRgn( pt[0].x, pt[0].y, pt[1].x, pt[1].y ))) ret = ERROR;
3509 else
3511 update_dc( dc );
3512 ret = CombineRgn( dc->hVisRgn, dc->hVisRgn, tempRgn, RGN_AND );
3513 DeleteObject( tempRgn );
3515 if (ret != ERROR) CLIPPING_UpdateGCRegion( dc );
3516 release_dc_ptr( dc );
3517 return ret;
3521 /***********************************************************************
3522 * SaveVisRgn (GDI.129)
3524 HRGN16 WINAPI SaveVisRgn16( HDC16 hdc16 )
3526 struct saved_visrgn *saved;
3527 HDC hdc = HDC_32( hdc16 );
3528 DC *dc = get_dc_ptr( hdc );
3530 if (!dc) return 0;
3531 TRACE("%p\n", hdc );
3533 update_dc( dc );
3534 if (!(saved = HeapAlloc( GetProcessHeap(), 0, sizeof(*saved) ))) goto error;
3535 if (!(saved->hrgn = CreateRectRgn( 0, 0, 0, 0 ))) goto error;
3536 CombineRgn( saved->hrgn, dc->hVisRgn, 0, RGN_COPY );
3537 saved->next = dc->saved_visrgn;
3538 dc->saved_visrgn = saved;
3539 release_dc_ptr( dc );
3540 return HRGN_16(saved->hrgn);
3542 error:
3543 release_dc_ptr( dc );
3544 HeapFree( GetProcessHeap(), 0, saved );
3545 return 0;
3549 /***********************************************************************
3550 * RestoreVisRgn (GDI.130)
3552 INT16 WINAPI RestoreVisRgn16( HDC16 hdc16 )
3554 struct saved_visrgn *saved;
3555 HDC hdc = HDC_32( hdc16 );
3556 DC *dc = get_dc_ptr( hdc );
3557 INT16 ret = ERROR;
3559 if (!dc) return ERROR;
3561 TRACE("%p\n", hdc );
3563 if (!(saved = dc->saved_visrgn)) goto done;
3565 ret = CombineRgn( dc->hVisRgn, saved->hrgn, 0, RGN_COPY );
3566 dc->saved_visrgn = saved->next;
3567 DeleteObject( saved->hrgn );
3568 HeapFree( GetProcessHeap(), 0, saved );
3569 CLIPPING_UpdateGCRegion( dc );
3570 done:
3571 release_dc_ptr( dc );
3572 return ret;
3576 /***********************************************************************
3577 * GetClipRgn (GDI.173)
3579 HRGN16 WINAPI GetClipRgn16( HDC16 hdc )
3581 HRGN16 ret = 0;
3582 DC * dc = get_dc_ptr( HDC_32(hdc) );
3583 if (dc)
3585 ret = HRGN_16(dc->hClipRgn);
3586 release_dc_ptr( dc );
3588 return ret;
3592 /***********************************************************************
3593 * MakeObjectPrivate (GDI.463)
3595 * What does that mean ?
3596 * Some little docu can be found in "Undocumented Windows",
3597 * but this is basically useless.
3599 void WINAPI MakeObjectPrivate16( HGDIOBJ16 handle16, BOOL16 private )
3601 FIXME( "stub: %x %u\n", handle16, private );
3604 /***********************************************************************
3605 * CreateDIBSection (GDI.489)
3607 HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, const BITMAPINFO *bmi, UINT16 usage,
3608 SEGPTR *bits16, HANDLE section, DWORD offset)
3610 LPVOID bits32;
3611 HBITMAP hbitmap;
3613 hbitmap = CreateDIBSection( HDC_32(hdc), bmi, usage, &bits32, section, offset );
3614 if (hbitmap)
3616 BITMAPOBJ *bmp = GDI_GetObjPtr(hbitmap, OBJ_BITMAP);
3617 if (bmp && bmp->dib && bits32)
3619 const BITMAPINFOHEADER *bi = &bmi->bmiHeader;
3620 LONG width, height;
3621 WORD planes, bpp;
3622 DWORD compr, size;
3623 INT width_bytes;
3624 WORD count, sel;
3625 int i;
3627 DIB_GetBitmapInfo(bi, &width, &height, &planes, &bpp, &compr, &size);
3629 height = height >= 0 ? height : -height;
3630 width_bytes = DIB_GetDIBWidthBytes(width, bpp);
3632 if (!size || (compr != BI_RLE4 && compr != BI_RLE8)) size = width_bytes * height;
3634 /* calculate number of sel's needed for size with 64K steps */
3635 count = (size + 0xffff) / 0x10000;
3636 sel = AllocSelectorArray16(count);
3638 for (i = 0; i < count; i++)
3640 SetSelectorBase(sel + (i << __AHSHIFT), (DWORD)bits32 + i * 0x10000);
3641 SetSelectorLimit16(sel + (i << __AHSHIFT), size - 1); /* yep, limit is correct */
3642 size -= 0x10000;
3644 bmp->segptr_bits = MAKESEGPTR( sel, 0 );
3645 if (bits16) *bits16 = bmp->segptr_bits;
3647 if (bmp) GDI_ReleaseObj( hbitmap );
3649 return HBITMAP_16(hbitmap);