push 1ed4e5956a5d0a6aba708879f14c79a139542468
[wine/hacks.git] / dlls / gdi32 / gdi16.c
blobe62b711111c709d087a7f55e74258d35b519d3de
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 "wine/list.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 saved_visrgn
38 struct list entry;
39 HDC hdc;
40 HRGN hrgn;
43 static struct list saved_regions = LIST_INIT( saved_regions );
45 static HPALETTE16 hPrimaryPalette;
48 * ############################################################################
51 #include <pshpack1.h>
52 #define GDI_MAX_THUNKS 32
54 static struct gdi_thunk
56 BYTE popl_eax; /* popl %eax (return address) */
57 BYTE pushl_pfn16; /* pushl pfn16 */
58 DWORD pfn16; /* pfn16 */
59 BYTE pushl_eax; /* pushl %eax */
60 BYTE jmp; /* ljmp GDI_Callback3216 */
61 DWORD callback;
62 HDC16 hdc;
63 } *GDI_Thunks;
65 #include <poppack.h>
67 /**********************************************************************
68 * GDI_Callback3216
70 static BOOL CALLBACK GDI_Callback3216( DWORD pfn16, HDC hdc, INT code )
72 if (pfn16)
74 WORD args[2];
75 DWORD ret;
77 args[1] = HDC_16(hdc);
78 args[0] = code;
79 WOWCallback16Ex( pfn16, WCB16_PASCAL, sizeof(args), args, &ret );
80 return LOWORD(ret);
82 return TRUE;
86 /******************************************************************
87 * GDI_AddThunk
90 static struct gdi_thunk* GDI_AddThunk(HDC16 dc16, ABORTPROC16 pfn16)
92 struct gdi_thunk* thunk;
94 if (!GDI_Thunks)
96 GDI_Thunks = VirtualAlloc(NULL, GDI_MAX_THUNKS * sizeof(*GDI_Thunks),
97 MEM_COMMIT, PAGE_EXECUTE_READWRITE);
98 if (!GDI_Thunks)
100 return NULL;
102 for (thunk = GDI_Thunks; thunk < &GDI_Thunks[GDI_MAX_THUNKS]; thunk++)
104 thunk->popl_eax = 0x58; /* popl %eax */
105 thunk->pushl_pfn16 = 0x68; /* pushl pfn16 */
106 thunk->pfn16 = 0;
107 thunk->pushl_eax = 0x50; /* pushl %eax */
108 thunk->jmp = 0xe9; /* jmp GDI_Callback3216 */
109 thunk->callback = (char *)GDI_Callback3216 - (char *)(&thunk->callback + 1);
112 for (thunk = GDI_Thunks; thunk < &GDI_Thunks[GDI_MAX_THUNKS]; thunk++)
114 if (thunk->pfn16 == 0)
116 thunk->pfn16 = (DWORD)pfn16;
117 thunk->hdc = dc16;
118 return thunk;
121 FIXME("Out of mmdrv-thunks. Bump GDI_MAX_THUNKS\n");
122 return NULL;
125 /******************************************************************
126 * GDI_DeleteThunk
128 static void GDI_DeleteThunk(struct gdi_thunk* thunk)
130 thunk->pfn16 = 0;
133 /******************************************************************
134 * GDI_FindThunk
136 static struct gdi_thunk* GDI_FindThunk(HDC16 hdc)
138 struct gdi_thunk* thunk;
140 if (!GDI_Thunks) return NULL;
141 for (thunk = GDI_Thunks; thunk < &GDI_Thunks[GDI_MAX_THUNKS]; thunk++)
143 if (thunk->hdc == hdc) return thunk;
145 return NULL;
148 /**********************************************************************
149 * QueryAbort (GDI.155)
151 * Calls the app's AbortProc function if avail.
153 * RETURNS
154 * TRUE if no AbortProc avail or AbortProc wants to continue printing.
155 * FALSE if AbortProc wants to abort printing.
157 BOOL16 WINAPI QueryAbort16(HDC16 hdc16, INT16 reserved)
159 struct gdi_thunk* thunk = GDI_FindThunk(hdc16);
161 if (!thunk) {
162 ERR("Invalid hdc 0x%x\n", hdc16);
163 return FALSE;
165 return GDI_Callback3216( thunk->pfn16, HDC_32(hdc16), 0 );
169 /**********************************************************************
170 * SetAbortProc (GDI.381)
172 INT16 WINAPI SetAbortProc16(HDC16 hdc16, ABORTPROC16 abrtprc)
174 struct gdi_thunk* thunk;
176 thunk = GDI_AddThunk(hdc16, abrtprc);
177 if (!thunk) return FALSE;
178 if (!SetAbortProc(HDC_32( hdc16 ), (ABORTPROC)thunk))
180 GDI_DeleteThunk(thunk);
181 return FALSE;
183 return TRUE;
187 * ############################################################################
190 struct callback16_info
192 FARPROC16 proc;
193 LPARAM param;
196 /* callback for LineDDA16 */
197 static void CALLBACK linedda_callback( INT x, INT y, LPARAM param )
199 const struct callback16_info *info = (struct callback16_info *)param;
200 WORD args[4];
202 args[3] = x;
203 args[2] = y;
204 args[1] = HIWORD(info->param);
205 args[0] = LOWORD(info->param);
206 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, NULL );
209 /* callback for EnumObjects16 */
210 static INT CALLBACK enum_pens_callback( void *ptr, LPARAM param )
212 const struct callback16_info *info = (struct callback16_info *)param;
213 LOGPEN *pen = ptr;
214 LOGPEN16 pen16;
215 SEGPTR segptr;
216 DWORD ret;
217 WORD args[4];
219 pen16.lopnStyle = pen->lopnStyle;
220 pen16.lopnWidth.x = pen->lopnWidth.x;
221 pen16.lopnWidth.y = pen->lopnWidth.y;
222 pen16.lopnColor = pen->lopnColor;
223 segptr = MapLS( &pen16 );
224 args[3] = SELECTOROF(segptr);
225 args[2] = OFFSETOF(segptr);
226 args[1] = HIWORD(info->param);
227 args[0] = LOWORD(info->param);
228 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
229 UnMapLS( segptr );
230 return LOWORD(ret);
233 /* callback for EnumObjects16 */
234 static INT CALLBACK enum_brushes_callback( void *ptr, LPARAM param )
236 const struct callback16_info *info = (struct callback16_info *)param;
237 LOGBRUSH *brush = ptr;
238 LOGBRUSH16 brush16;
239 SEGPTR segptr;
240 DWORD ret;
241 WORD args[4];
243 brush16.lbStyle = brush->lbStyle;
244 brush16.lbColor = brush->lbColor;
245 brush16.lbHatch = brush->lbHatch;
246 segptr = MapLS( &brush16 );
247 args[3] = SELECTOROF(segptr);
248 args[2] = OFFSETOF(segptr);
249 args[1] = HIWORD(info->param);
250 args[0] = LOWORD(info->param);
251 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
252 UnMapLS( segptr );
253 return ret;
256 /* convert a LOGFONT16 to a LOGFONTW */
257 static void logfont_16_to_W( const LOGFONT16 *font16, LPLOGFONTW font32 )
259 font32->lfHeight = font16->lfHeight;
260 font32->lfWidth = font16->lfWidth;
261 font32->lfEscapement = font16->lfEscapement;
262 font32->lfOrientation = font16->lfOrientation;
263 font32->lfWeight = font16->lfWeight;
264 font32->lfItalic = font16->lfItalic;
265 font32->lfUnderline = font16->lfUnderline;
266 font32->lfStrikeOut = font16->lfStrikeOut;
267 font32->lfCharSet = font16->lfCharSet;
268 font32->lfOutPrecision = font16->lfOutPrecision;
269 font32->lfClipPrecision = font16->lfClipPrecision;
270 font32->lfQuality = font16->lfQuality;
271 font32->lfPitchAndFamily = font16->lfPitchAndFamily;
272 MultiByteToWideChar( CP_ACP, 0, font16->lfFaceName, -1, font32->lfFaceName, LF_FACESIZE );
273 font32->lfFaceName[LF_FACESIZE-1] = 0;
276 /* convert a LOGFONTW to a LOGFONT16 */
277 static void logfont_W_to_16( const LOGFONTW* font32, LPLOGFONT16 font16 )
279 font16->lfHeight = font32->lfHeight;
280 font16->lfWidth = font32->lfWidth;
281 font16->lfEscapement = font32->lfEscapement;
282 font16->lfOrientation = font32->lfOrientation;
283 font16->lfWeight = font32->lfWeight;
284 font16->lfItalic = font32->lfItalic;
285 font16->lfUnderline = font32->lfUnderline;
286 font16->lfStrikeOut = font32->lfStrikeOut;
287 font16->lfCharSet = font32->lfCharSet;
288 font16->lfOutPrecision = font32->lfOutPrecision;
289 font16->lfClipPrecision = font32->lfClipPrecision;
290 font16->lfQuality = font32->lfQuality;
291 font16->lfPitchAndFamily = font32->lfPitchAndFamily;
292 WideCharToMultiByte( CP_ACP, 0, font32->lfFaceName, -1, font16->lfFaceName, LF_FACESIZE, NULL, NULL );
293 font16->lfFaceName[LF_FACESIZE-1] = 0;
296 /* convert a ENUMLOGFONTEXW to a ENUMLOGFONTEX16 */
297 static void enumlogfontex_W_to_16( const ENUMLOGFONTEXW *fontW,
298 LPENUMLOGFONTEX16 font16 )
300 logfont_W_to_16( (const LOGFONTW *)fontW, (LPLOGFONT16)font16);
302 WideCharToMultiByte( CP_ACP, 0, fontW->elfFullName, -1,
303 (LPSTR) font16->elfFullName, LF_FULLFACESIZE, NULL, NULL );
304 font16->elfFullName[LF_FULLFACESIZE-1] = '\0';
305 WideCharToMultiByte( CP_ACP, 0, fontW->elfStyle, -1,
306 (LPSTR) font16->elfStyle, LF_FACESIZE, NULL, NULL );
307 font16->elfStyle[LF_FACESIZE-1] = '\0';
308 WideCharToMultiByte( CP_ACP, 0, fontW->elfScript, -1,
309 (LPSTR) font16->elfScript, LF_FACESIZE, NULL, NULL );
310 font16->elfScript[LF_FACESIZE-1] = '\0';
313 /* convert a NEWTEXTMETRICEXW to a NEWTEXTMETRICEX16 */
314 static void newtextmetricex_W_to_16( const NEWTEXTMETRICEXW *ptmW,
315 LPNEWTEXTMETRICEX16 ptm16 )
317 ptm16->ntmTm.tmHeight = ptmW->ntmTm.tmHeight;
318 ptm16->ntmTm.tmAscent = ptmW->ntmTm.tmAscent;
319 ptm16->ntmTm.tmDescent = ptmW->ntmTm.tmDescent;
320 ptm16->ntmTm.tmInternalLeading = ptmW->ntmTm.tmInternalLeading;
321 ptm16->ntmTm.tmExternalLeading = ptmW->ntmTm.tmExternalLeading;
322 ptm16->ntmTm.tmAveCharWidth = ptmW->ntmTm.tmAveCharWidth;
323 ptm16->ntmTm.tmMaxCharWidth = ptmW->ntmTm.tmMaxCharWidth;
324 ptm16->ntmTm.tmWeight = ptmW->ntmTm.tmWeight;
325 ptm16->ntmTm.tmOverhang = ptmW->ntmTm.tmOverhang;
326 ptm16->ntmTm.tmDigitizedAspectX = ptmW->ntmTm.tmDigitizedAspectX;
327 ptm16->ntmTm.tmDigitizedAspectY = ptmW->ntmTm.tmDigitizedAspectY;
328 ptm16->ntmTm.tmFirstChar = ptmW->ntmTm.tmFirstChar > 255 ? 255 : ptmW->ntmTm.tmFirstChar;
329 ptm16->ntmTm.tmLastChar = ptmW->ntmTm.tmLastChar > 255 ? 255 : ptmW->ntmTm.tmLastChar;
330 ptm16->ntmTm.tmDefaultChar = ptmW->ntmTm.tmDefaultChar > 255 ? 255 : ptmW->ntmTm.tmDefaultChar;
331 ptm16->ntmTm.tmBreakChar = ptmW->ntmTm.tmBreakChar > 255 ? 255 : ptmW->ntmTm.tmBreakChar;
332 ptm16->ntmTm.tmItalic = ptmW->ntmTm.tmItalic;
333 ptm16->ntmTm.tmUnderlined = ptmW->ntmTm.tmUnderlined;
334 ptm16->ntmTm.tmStruckOut = ptmW->ntmTm.tmStruckOut;
335 ptm16->ntmTm.tmPitchAndFamily = ptmW->ntmTm.tmPitchAndFamily;
336 ptm16->ntmTm.tmCharSet = ptmW->ntmTm.tmCharSet;
337 ptm16->ntmTm.ntmFlags = ptmW->ntmTm.ntmFlags;
338 ptm16->ntmTm.ntmSizeEM = ptmW->ntmTm.ntmSizeEM;
339 ptm16->ntmTm.ntmCellHeight = ptmW->ntmTm.ntmCellHeight;
340 ptm16->ntmTm.ntmAvgWidth = ptmW->ntmTm.ntmAvgWidth;
341 ptm16->ntmFontSig = ptmW->ntmFontSig;
345 * callback for EnumFontFamiliesEx16
346 * Note: plf is really an ENUMLOGFONTEXW, and ptm is a NEWTEXTMETRICEXW.
347 * We have to use other types because of the FONTENUMPROCW definition.
349 static INT CALLBACK enum_font_callback( const LOGFONTW *plf,
350 const TEXTMETRICW *ptm, DWORD fType,
351 LPARAM param )
353 const struct callback16_info *info = (struct callback16_info *)param;
354 ENUMLOGFONTEX16 elfe16;
355 NEWTEXTMETRICEX16 ntm16;
356 SEGPTR segelfe16;
357 SEGPTR segntm16;
358 WORD args[7];
359 DWORD ret;
361 enumlogfontex_W_to_16((const ENUMLOGFONTEXW *)plf, &elfe16);
362 newtextmetricex_W_to_16((const NEWTEXTMETRICEXW *)ptm, &ntm16);
363 segelfe16 = MapLS( &elfe16 );
364 segntm16 = MapLS( &ntm16 );
365 args[6] = SELECTOROF(segelfe16);
366 args[5] = OFFSETOF(segelfe16);
367 args[4] = SELECTOROF(segntm16);
368 args[3] = OFFSETOF(segntm16);
369 args[2] = fType;
370 args[1] = HIWORD(info->param);
371 args[0] = LOWORD(info->param);
373 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
374 UnMapLS( segelfe16 );
375 UnMapLS( segntm16 );
376 return LOWORD(ret);
379 struct dib_segptr_bits
381 struct list entry;
382 HBITMAP16 bmp;
383 WORD sel;
384 WORD count;
387 static struct list dib_segptr_list = LIST_INIT( dib_segptr_list );
389 static SEGPTR alloc_segptr_bits( HBITMAP bmp, void *bits32 )
391 DIBSECTION dib;
392 unsigned int i, size;
393 struct dib_segptr_bits *bits;
395 if (!(bits = HeapAlloc( GetProcessHeap(), 0, sizeof(*bits) ))) return 0;
397 GetObjectW( bmp, sizeof(dib), &dib );
398 size = dib.dsBm.bmHeight * dib.dsBm.bmWidthBytes;
400 /* calculate number of sel's needed for size with 64K steps */
401 bits->bmp = HBITMAP_16( bmp );
402 bits->count = (size + 0xffff) / 0x10000;
403 bits->sel = AllocSelectorArray16( bits->count );
405 for (i = 0; i < bits->count; i++)
407 SetSelectorBase(bits->sel + (i << __AHSHIFT), (DWORD)bits32 + i * 0x10000);
408 SetSelectorLimit16(bits->sel + (i << __AHSHIFT), size - 1); /* yep, limit is correct */
409 size -= 0x10000;
411 list_add_head( &dib_segptr_list, &bits->entry );
412 return MAKESEGPTR( bits->sel, 0 );
415 static void free_segptr_bits( HBITMAP16 bmp )
417 unsigned int i;
418 struct dib_segptr_bits *bits;
420 LIST_FOR_EACH_ENTRY( bits, &dib_segptr_list, struct dib_segptr_bits, entry )
422 if (bits->bmp != bmp) continue;
423 for (i = 0; i < bits->count; i++) FreeSelector16( bits->sel + (i << __AHSHIFT) );
425 list_remove( &bits->entry );
426 HeapFree( GetProcessHeap(), 0, bits );
427 return;
431 /***********************************************************************
432 * SetBkColor (GDI.1)
434 COLORREF WINAPI SetBkColor16( HDC16 hdc, COLORREF color )
436 return SetBkColor( HDC_32(hdc), color );
440 /***********************************************************************
441 * SetBkMode (GDI.2)
443 INT16 WINAPI SetBkMode16( HDC16 hdc, INT16 mode )
445 return SetBkMode( HDC_32(hdc), mode );
449 /***********************************************************************
450 * SetMapMode (GDI.3)
452 INT16 WINAPI SetMapMode16( HDC16 hdc, INT16 mode )
454 return SetMapMode( HDC_32(hdc), mode );
458 /***********************************************************************
459 * SetROP2 (GDI.4)
461 INT16 WINAPI SetROP216( HDC16 hdc, INT16 mode )
463 return SetROP2( HDC_32(hdc), mode );
467 /***********************************************************************
468 * SetRelAbs (GDI.5)
470 INT16 WINAPI SetRelAbs16( HDC16 hdc, INT16 mode )
472 return SetRelAbs( HDC_32(hdc), mode );
476 /***********************************************************************
477 * SetPolyFillMode (GDI.6)
479 INT16 WINAPI SetPolyFillMode16( HDC16 hdc, INT16 mode )
481 return SetPolyFillMode( HDC_32(hdc), mode );
485 /***********************************************************************
486 * SetStretchBltMode (GDI.7)
488 INT16 WINAPI SetStretchBltMode16( HDC16 hdc, INT16 mode )
490 return SetStretchBltMode( HDC_32(hdc), mode );
494 /***********************************************************************
495 * SetTextCharacterExtra (GDI.8)
497 INT16 WINAPI SetTextCharacterExtra16( HDC16 hdc, INT16 extra )
499 return SetTextCharacterExtra( HDC_32(hdc), extra );
503 /***********************************************************************
504 * SetTextColor (GDI.9)
506 COLORREF WINAPI SetTextColor16( HDC16 hdc, COLORREF color )
508 return SetTextColor( HDC_32(hdc), color );
512 /***********************************************************************
513 * SetTextJustification (GDI.10)
515 INT16 WINAPI SetTextJustification16( HDC16 hdc, INT16 extra, INT16 breaks )
517 return SetTextJustification( HDC_32(hdc), extra, breaks );
521 /***********************************************************************
522 * SetWindowOrg (GDI.11)
524 DWORD WINAPI SetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
526 POINT pt;
527 if (!SetWindowOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
528 return MAKELONG( pt.x, pt.y );
532 /***********************************************************************
533 * SetWindowExt (GDI.12)
535 DWORD WINAPI SetWindowExt16( HDC16 hdc, INT16 x, INT16 y )
537 SIZE size;
538 if (!SetWindowExtEx( HDC_32(hdc), x, y, &size )) return 0;
539 return MAKELONG( size.cx, size.cy );
543 /***********************************************************************
544 * SetViewportOrg (GDI.13)
546 DWORD WINAPI SetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
548 POINT pt;
549 if (!SetViewportOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
550 return MAKELONG( pt.x, pt.y );
554 /***********************************************************************
555 * SetViewportExt (GDI.14)
557 DWORD WINAPI SetViewportExt16( HDC16 hdc, INT16 x, INT16 y )
559 SIZE size;
560 if (!SetViewportExtEx( HDC_32(hdc), x, y, &size )) return 0;
561 return MAKELONG( size.cx, size.cy );
565 /***********************************************************************
566 * OffsetWindowOrg (GDI.15)
568 DWORD WINAPI OffsetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
570 POINT pt;
571 if (!OffsetWindowOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
572 return MAKELONG( pt.x, pt.y );
576 /***********************************************************************
577 * ScaleWindowExt (GDI.16)
579 DWORD WINAPI ScaleWindowExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
580 INT16 yNum, INT16 yDenom )
582 SIZE size;
583 if (!ScaleWindowExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom, &size ))
584 return FALSE;
585 return MAKELONG( size.cx, size.cy );
589 /***********************************************************************
590 * OffsetViewportOrg (GDI.17)
592 DWORD WINAPI OffsetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
594 POINT pt;
595 if (!OffsetViewportOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
596 return MAKELONG( pt.x, pt.y );
600 /***********************************************************************
601 * ScaleViewportExt (GDI.18)
603 DWORD WINAPI ScaleViewportExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
604 INT16 yNum, INT16 yDenom )
606 SIZE size;
607 if (!ScaleViewportExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom, &size ))
608 return FALSE;
609 return MAKELONG( size.cx, size.cy );
613 /***********************************************************************
614 * LineTo (GDI.19)
616 BOOL16 WINAPI LineTo16( HDC16 hdc, INT16 x, INT16 y )
618 return LineTo( HDC_32(hdc), x, y );
622 /***********************************************************************
623 * MoveTo (GDI.20)
625 DWORD WINAPI MoveTo16( HDC16 hdc, INT16 x, INT16 y )
627 POINT pt;
629 if (!MoveToEx( HDC_32(hdc), x, y, &pt )) return 0;
630 return MAKELONG(pt.x,pt.y);
634 /***********************************************************************
635 * ExcludeClipRect (GDI.21)
637 INT16 WINAPI ExcludeClipRect16( HDC16 hdc, INT16 left, INT16 top,
638 INT16 right, INT16 bottom )
640 return ExcludeClipRect( HDC_32(hdc), left, top, right, bottom );
644 /***********************************************************************
645 * IntersectClipRect (GDI.22)
647 INT16 WINAPI IntersectClipRect16( HDC16 hdc, INT16 left, INT16 top,
648 INT16 right, INT16 bottom )
650 return IntersectClipRect( HDC_32(hdc), left, top, right, bottom );
654 /***********************************************************************
655 * Arc (GDI.23)
657 BOOL16 WINAPI Arc16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
658 INT16 bottom, INT16 xstart, INT16 ystart,
659 INT16 xend, INT16 yend )
661 return Arc( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
665 /***********************************************************************
666 * Ellipse (GDI.24)
668 BOOL16 WINAPI Ellipse16( HDC16 hdc, INT16 left, INT16 top,
669 INT16 right, INT16 bottom )
671 return Ellipse( HDC_32(hdc), left, top, right, bottom );
675 /**********************************************************************
676 * FloodFill (GDI.25)
678 BOOL16 WINAPI FloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
680 return ExtFloodFill( HDC_32(hdc), x, y, color, FLOODFILLBORDER );
684 /***********************************************************************
685 * Pie (GDI.26)
687 BOOL16 WINAPI Pie16( HDC16 hdc, INT16 left, INT16 top,
688 INT16 right, INT16 bottom, INT16 xstart, INT16 ystart,
689 INT16 xend, INT16 yend )
691 return Pie( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
695 /***********************************************************************
696 * Rectangle (GDI.27)
698 BOOL16 WINAPI Rectangle16( HDC16 hdc, INT16 left, INT16 top,
699 INT16 right, INT16 bottom )
701 return Rectangle( HDC_32(hdc), left, top, right, bottom );
705 /***********************************************************************
706 * RoundRect (GDI.28)
708 BOOL16 WINAPI RoundRect16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
709 INT16 bottom, INT16 ell_width, INT16 ell_height )
711 return RoundRect( HDC_32(hdc), left, top, right, bottom, ell_width, ell_height );
715 /***********************************************************************
716 * PatBlt (GDI.29)
718 BOOL16 WINAPI PatBlt16( HDC16 hdc, INT16 left, INT16 top,
719 INT16 width, INT16 height, DWORD rop)
721 return PatBlt( HDC_32(hdc), left, top, width, height, rop );
725 /***********************************************************************
726 * SaveDC (GDI.30)
728 INT16 WINAPI SaveDC16( HDC16 hdc )
730 return SaveDC( HDC_32(hdc) );
734 /***********************************************************************
735 * SetPixel (GDI.31)
737 COLORREF WINAPI SetPixel16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
739 return SetPixel( HDC_32(hdc), x, y, color );
743 /***********************************************************************
744 * OffsetClipRgn (GDI.32)
746 INT16 WINAPI OffsetClipRgn16( HDC16 hdc, INT16 x, INT16 y )
748 return OffsetClipRgn( HDC_32(hdc), x, y );
752 /***********************************************************************
753 * TextOut (GDI.33)
755 BOOL16 WINAPI TextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR str, INT16 count )
757 return TextOutA( HDC_32(hdc), x, y, str, count );
761 /***********************************************************************
762 * BitBlt (GDI.34)
764 BOOL16 WINAPI BitBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst, INT16 width,
765 INT16 height, HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
766 DWORD rop )
768 return BitBlt( HDC_32(hdcDst), xDst, yDst, width, height, HDC_32(hdcSrc), xSrc, ySrc, rop );
772 /***********************************************************************
773 * StretchBlt (GDI.35)
775 BOOL16 WINAPI StretchBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst,
776 INT16 widthDst, INT16 heightDst,
777 HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
778 INT16 widthSrc, INT16 heightSrc, DWORD rop )
780 return StretchBlt( HDC_32(hdcDst), xDst, yDst, widthDst, heightDst,
781 HDC_32(hdcSrc), xSrc, ySrc, widthSrc, heightSrc, rop );
785 /**********************************************************************
786 * Polygon (GDI.36)
788 BOOL16 WINAPI Polygon16( HDC16 hdc, const POINT16* pt, INT16 count )
790 register int i;
791 BOOL ret;
792 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, count*sizeof(POINT) );
794 if (!pt32) return FALSE;
795 for (i=count;i--;)
797 pt32[i].x = pt[i].x;
798 pt32[i].y = pt[i].y;
800 ret = Polygon(HDC_32(hdc),pt32,count);
801 HeapFree( GetProcessHeap(), 0, pt32 );
802 return ret;
806 /**********************************************************************
807 * Polyline (GDI.37)
809 BOOL16 WINAPI Polyline16( HDC16 hdc, const POINT16* pt, INT16 count )
811 register int i;
812 BOOL16 ret;
813 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, count*sizeof(POINT) );
815 if (!pt32) return FALSE;
816 for (i=count;i--;)
818 pt32[i].x = pt[i].x;
819 pt32[i].y = pt[i].y;
821 ret = Polyline(HDC_32(hdc),pt32,count);
822 HeapFree( GetProcessHeap(), 0, pt32 );
823 return ret;
827 /***********************************************************************
828 * Escape (GDI.38)
830 INT16 WINAPI Escape16( HDC16 hdc, INT16 escape, INT16 in_count, SEGPTR in_data, LPVOID out_data )
832 INT ret;
834 switch(escape)
836 /* Escape(hdc,CLIP_TO_PATH,LPINT16,NULL) */
837 /* Escape(hdc,DRAFTMODE,LPINT16,NULL) */
838 /* Escape(hdc,ENUMPAPERBINS,LPINT16,LPSTR); */
839 /* Escape(hdc,EPSPRINTING,LPINT16,NULL) */
840 /* Escape(hdc,EXT_DEVICE_CAPS,LPINT16,LPDWORD) */
841 /* Escape(hdc,GETCOLORTABLE,LPINT16,LPDWORD) */
842 /* Escape(hdc,MOUSETRAILS,LPINT16,NULL) */
843 /* Escape(hdc,POSTSCRIPT_IGNORE,LPINT16,NULL) */
844 /* Escape(hdc,QUERYESCSUPPORT,LPINT16,NULL) */
845 /* Escape(hdc,SET_ARC_DIRECTION,LPINT16,NULL) */
846 /* Escape(hdc,SET_POLY_MODE,LPINT16,NULL) */
847 /* Escape(hdc,SET_SCREEN_ANGLE,LPINT16,NULL) */
848 /* Escape(hdc,SET_SPREAD,LPINT16,NULL) */
849 case CLIP_TO_PATH:
850 case DRAFTMODE:
851 case ENUMPAPERBINS:
852 case EPSPRINTING:
853 case EXT_DEVICE_CAPS:
854 case GETCOLORTABLE:
855 case MOUSETRAILS:
856 case POSTSCRIPT_IGNORE:
857 case QUERYESCSUPPORT:
858 case SET_ARC_DIRECTION:
859 case SET_POLY_MODE:
860 case SET_SCREEN_ANGLE:
861 case SET_SPREAD:
863 INT16 *ptr = MapSL(in_data);
864 INT data = *ptr;
865 return Escape( HDC_32(hdc), escape, sizeof(data), (LPCSTR)&data, out_data );
868 /* Escape(hdc,ENABLEDUPLEX,LPUINT16,NULL) */
869 case ENABLEDUPLEX:
871 UINT16 *ptr = MapSL(in_data);
872 UINT data = *ptr;
873 return Escape( HDC_32(hdc), escape, sizeof(data), (LPCSTR)&data, NULL );
876 /* Escape(hdc,GETPHYSPAGESIZE,NULL,LPPOINT16) */
877 /* Escape(hdc,GETPRINTINGOFFSET,NULL,LPPOINT16) */
878 /* Escape(hdc,GETSCALINGFACTOR,NULL,LPPOINT16) */
879 case GETPHYSPAGESIZE:
880 case GETPRINTINGOFFSET:
881 case GETSCALINGFACTOR:
883 POINT16 *ptr = out_data;
884 POINT pt32;
885 ret = Escape( HDC_32(hdc), escape, 0, NULL, &pt32 );
886 ptr->x = pt32.x;
887 ptr->y = pt32.y;
888 return ret;
891 /* Escape(hdc,ENABLEPAIRKERNING,LPINT16,LPINT16); */
892 /* Escape(hdc,ENABLERELATIVEWIDTHS,LPINT16,LPINT16); */
893 /* Escape(hdc,SETCOPYCOUNT,LPINT16,LPINT16) */
894 /* Escape(hdc,SETKERNTRACK,LPINT16,LPINT16) */
895 /* Escape(hdc,SETLINECAP,LPINT16,LPINT16) */
896 /* Escape(hdc,SETLINEJOIN,LPINT16,LPINT16) */
897 /* Escape(hdc,SETMITERLIMIT,LPINT16,LPINT16) */
898 case ENABLEPAIRKERNING:
899 case ENABLERELATIVEWIDTHS:
900 case SETCOPYCOUNT:
901 case SETKERNTRACK:
902 case SETLINECAP:
903 case SETLINEJOIN:
904 case SETMITERLIMIT:
906 INT16 *new = MapSL(in_data);
907 INT16 *old = out_data;
908 INT out, in = *new;
909 ret = Escape( HDC_32(hdc), escape, sizeof(in), (LPCSTR)&in, &out );
910 *old = out;
911 return ret;
914 /* Escape(hdc,SETABORTPROC,ABORTPROC,NULL); */
915 case SETABORTPROC:
916 return SetAbortProc16( hdc, (ABORTPROC16)in_data );
918 /* Escape(hdc,STARTDOC,LPSTR,LPDOCINFO16);
919 * lpvOutData is actually a pointer to the DocInfo structure and used as
920 * a second input parameter */
921 case STARTDOC:
922 if (out_data)
924 ret = StartDoc16( hdc, out_data );
925 if (ret > 0) ret = StartPage( HDC_32(hdc) );
926 return ret;
928 return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), NULL );
930 /* Escape(hdc,SET_BOUNDS,LPRECT16,NULL); */
931 /* Escape(hdc,SET_CLIP_BOX,LPRECT16,NULL); */
932 case SET_BOUNDS:
933 case SET_CLIP_BOX:
935 RECT16 *rc16 = MapSL(in_data);
936 RECT rc;
937 rc.left = rc16->left;
938 rc.top = rc16->top;
939 rc.right = rc16->right;
940 rc.bottom = rc16->bottom;
941 return Escape( HDC_32(hdc), escape, sizeof(rc), (LPCSTR)&rc, NULL );
944 /* Escape(hdc,NEXTBAND,NULL,LPRECT16); */
945 case NEXTBAND:
947 RECT rc;
948 RECT16 *rc16 = out_data;
949 ret = Escape( HDC_32(hdc), escape, 0, NULL, &rc );
950 rc16->left = rc.left;
951 rc16->top = rc.top;
952 rc16->right = rc.right;
953 rc16->bottom = rc.bottom;
954 return ret;
956 /* Escape(hdc,DRAWPATTERNRECT,PRECT_STRUCT*,NULL); */
957 case DRAWPATTERNRECT:
959 DRAWPATRECT pr;
960 DRAWPATRECT16 *pr16 = MapSL(in_data);
962 pr.ptPosition.x = pr16->ptPosition.x;
963 pr.ptPosition.y = pr16->ptPosition.y;
964 pr.ptSize.x = pr16->ptSize.x;
965 pr.ptSize.y = pr16->ptSize.y;
966 pr.wStyle = pr16->wStyle;
967 pr.wPattern = pr16->wPattern;
968 return Escape( HDC_32(hdc), escape, sizeof(pr), (LPCSTR)&pr, NULL );
971 /* Escape(hdc,ABORTDOC,NULL,NULL); */
972 /* Escape(hdc,BANDINFO,BANDINFOSTRUCT*,BANDINFOSTRUCT*); */
973 /* Escape(hdc,BEGIN_PATH,NULL,NULL); */
974 /* Escape(hdc,ENDDOC,NULL,NULL); */
975 /* Escape(hdc,END_PATH,PATHINFO,NULL); */
976 /* Escape(hdc,EXTTEXTOUT,EXTTEXT_STRUCT*,NULL); */
977 /* Escape(hdc,FLUSHOUTPUT,NULL,NULL); */
978 /* Escape(hdc,GETFACENAME,NULL,LPSTR); */
979 /* Escape(hdc,GETPAIRKERNTABLE,NULL,KERNPAIR*); */
980 /* Escape(hdc,GETSETPAPERBINS,BinInfo*,BinInfo*); */
981 /* Escape(hdc,GETSETPRINTORIENT,ORIENT*,NULL); */
982 /* Escape(hdc,GETSETSCREENPARAMS,SCREENPARAMS*,SCREENPARAMS*); */
983 /* Escape(hdc,GETTECHNOLOGY,NULL,LPSTR); */
984 /* Escape(hdc,GETTRACKKERNTABLE,NULL,KERNTRACK*); */
985 /* Escape(hdc,MFCOMMENT,LPSTR,NULL); */
986 /* Escape(hdc,NEWFRAME,NULL,NULL); */
987 /* Escape(hdc,PASSTHROUGH,LPSTR,NULL); */
988 /* Escape(hdc,RESTORE_CTM,NULL,NULL); */
989 /* Escape(hdc,SAVE_CTM,NULL,NULL); */
990 /* Escape(hdc,SETALLJUSTVALUES,EXTTEXTDATA*,NULL); */
991 /* Escape(hdc,SETCOLORTABLE,COLORTABLE_STRUCT*,LPDWORD); */
992 /* Escape(hdc,SET_BACKGROUND_COLOR,LPDWORD,LPDWORD); */
993 /* Escape(hdc,TRANSFORM_CTM,LPSTR,NULL); */
994 case ABORTDOC:
995 case BANDINFO:
996 case BEGIN_PATH:
997 case ENDDOC:
998 case END_PATH:
999 case EXTTEXTOUT:
1000 case FLUSHOUTPUT:
1001 case GETFACENAME:
1002 case GETPAIRKERNTABLE:
1003 case GETSETPAPERBINS:
1004 case GETSETPRINTORIENT:
1005 case GETSETSCREENPARAMS:
1006 case GETTECHNOLOGY:
1007 case GETTRACKKERNTABLE:
1008 case MFCOMMENT:
1009 case NEWFRAME:
1010 case PASSTHROUGH:
1011 case RESTORE_CTM:
1012 case SAVE_CTM:
1013 case SETALLJUSTVALUES:
1014 case SETCOLORTABLE:
1015 case SET_BACKGROUND_COLOR:
1016 case TRANSFORM_CTM:
1017 /* pass it unmodified to the 32-bit function */
1018 return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), out_data );
1020 /* Escape(hdc,ENUMPAPERMETRICS,LPINT16,LPRECT16); */
1021 /* Escape(hdc,GETEXTENDEDTEXTMETRICS,LPUINT16,EXTTEXTMETRIC*); */
1022 /* Escape(hdc,GETEXTENTTABLE,LPSTR,LPINT16); */
1023 /* Escape(hdc,GETSETPAPERMETRICS,LPRECT16,LPRECT16); */
1024 /* Escape(hdc,GETVECTORBRUSHSIZE,LPLOGBRUSH16,LPPOINT16); */
1025 /* Escape(hdc,GETVECTORPENSIZE,LPLOGPEN16,LPPOINT16); */
1026 case ENUMPAPERMETRICS:
1027 case GETEXTENDEDTEXTMETRICS:
1028 case GETEXTENTTABLE:
1029 case GETSETPAPERMETRICS:
1030 case GETVECTORBRUSHSIZE:
1031 case GETVECTORPENSIZE:
1032 default:
1033 FIXME("unknown/unsupported 16-bit escape %x (%d,%p,%p\n",
1034 escape, in_count, MapSL(in_data), out_data );
1035 return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), out_data );
1040 /***********************************************************************
1041 * RestoreDC (GDI.39)
1043 BOOL16 WINAPI RestoreDC16( HDC16 hdc, INT16 level )
1045 return RestoreDC( HDC_32(hdc), level );
1049 /***********************************************************************
1050 * FillRgn (GDI.40)
1052 BOOL16 WINAPI FillRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush )
1054 return FillRgn( HDC_32(hdc), HRGN_32(hrgn), HBRUSH_32(hbrush) );
1058 /***********************************************************************
1059 * FrameRgn (GDI.41)
1061 BOOL16 WINAPI FrameRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush,
1062 INT16 nWidth, INT16 nHeight )
1064 return FrameRgn( HDC_32(hdc), HRGN_32(hrgn), HBRUSH_32(hbrush), nWidth, nHeight );
1068 /***********************************************************************
1069 * InvertRgn (GDI.42)
1071 BOOL16 WINAPI InvertRgn16( HDC16 hdc, HRGN16 hrgn )
1073 return InvertRgn( HDC_32(hdc), HRGN_32(hrgn) );
1077 /***********************************************************************
1078 * PaintRgn (GDI.43)
1080 BOOL16 WINAPI PaintRgn16( HDC16 hdc, HRGN16 hrgn )
1082 return PaintRgn( HDC_32(hdc), HRGN_32(hrgn) );
1086 /***********************************************************************
1087 * SelectClipRgn (GDI.44)
1089 INT16 WINAPI SelectClipRgn16( HDC16 hdc, HRGN16 hrgn )
1091 return SelectClipRgn( HDC_32(hdc), HRGN_32(hrgn) );
1095 /***********************************************************************
1096 * SelectObject (GDI.45)
1098 HGDIOBJ16 WINAPI SelectObject16( HDC16 hdc, HGDIOBJ16 handle )
1100 return HGDIOBJ_16( SelectObject( HDC_32(hdc), HGDIOBJ_32(handle) ) );
1104 /***********************************************************************
1105 * CombineRgn (GDI.47)
1107 INT16 WINAPI CombineRgn16(HRGN16 hDest, HRGN16 hSrc1, HRGN16 hSrc2, INT16 mode)
1109 return CombineRgn( HRGN_32(hDest), HRGN_32(hSrc1), HRGN_32(hSrc2), mode );
1113 /***********************************************************************
1114 * CreateBitmap (GDI.48)
1116 HBITMAP16 WINAPI CreateBitmap16( INT16 width, INT16 height, UINT16 planes,
1117 UINT16 bpp, LPCVOID bits )
1119 return HBITMAP_16( CreateBitmap( width, height, planes & 0xff, bpp & 0xff, bits ) );
1123 /***********************************************************************
1124 * CreateBitmapIndirect (GDI.49)
1126 HBITMAP16 WINAPI CreateBitmapIndirect16( const BITMAP16 * bmp )
1128 return CreateBitmap16( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
1129 bmp->bmBitsPixel, MapSL( bmp->bmBits ) );
1133 /***********************************************************************
1134 * CreateBrushIndirect (GDI.50)
1136 HBRUSH16 WINAPI CreateBrushIndirect16( const LOGBRUSH16 * brush )
1138 LOGBRUSH brush32;
1140 if (brush->lbStyle == BS_DIBPATTERN || brush->lbStyle == BS_DIBPATTERN8X8)
1141 return CreateDIBPatternBrush16( brush->lbHatch, brush->lbColor );
1143 brush32.lbStyle = brush->lbStyle;
1144 brush32.lbColor = brush->lbColor;
1145 brush32.lbHatch = brush->lbHatch;
1146 return HBRUSH_16( CreateBrushIndirect(&brush32) );
1150 /***********************************************************************
1151 * CreateCompatibleBitmap (GDI.51)
1153 HBITMAP16 WINAPI CreateCompatibleBitmap16( HDC16 hdc, INT16 width, INT16 height )
1155 return HBITMAP_16( CreateCompatibleBitmap( HDC_32(hdc), width, height ) );
1159 /***********************************************************************
1160 * CreateCompatibleDC (GDI.52)
1162 HDC16 WINAPI CreateCompatibleDC16( HDC16 hdc )
1164 return HDC_16( CreateCompatibleDC( HDC_32(hdc) ) );
1168 /***********************************************************************
1169 * CreateDC (GDI.53)
1171 HDC16 WINAPI CreateDC16( LPCSTR driver, LPCSTR device, LPCSTR output,
1172 const DEVMODEA *initData )
1174 return HDC_16( CreateDCA( driver, device, output, initData ) );
1178 /***********************************************************************
1179 * CreateEllipticRgn (GDI.54)
1181 HRGN16 WINAPI CreateEllipticRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom )
1183 return HRGN_16( CreateEllipticRgn( left, top, right, bottom ) );
1187 /***********************************************************************
1188 * CreateEllipticRgnIndirect (GDI.55)
1190 HRGN16 WINAPI CreateEllipticRgnIndirect16( const RECT16 *rect )
1192 return HRGN_16( CreateEllipticRgn( rect->left, rect->top, rect->right, rect->bottom ) );
1196 /***********************************************************************
1197 * CreateFont (GDI.56)
1199 HFONT16 WINAPI CreateFont16(INT16 height, INT16 width, INT16 esc, INT16 orient,
1200 INT16 weight, BYTE italic, BYTE underline,
1201 BYTE strikeout, BYTE charset, BYTE outpres,
1202 BYTE clippres, BYTE quality, BYTE pitch,
1203 LPCSTR name )
1205 return HFONT_16( CreateFontA( height, width, esc, orient, weight, italic, underline,
1206 strikeout, charset, outpres, clippres, quality, pitch, name ));
1209 /***********************************************************************
1210 * CreateFontIndirect (GDI.57)
1212 HFONT16 WINAPI CreateFontIndirect16( const LOGFONT16 *plf16 )
1214 HFONT ret;
1216 if (plf16)
1218 LOGFONTW lfW;
1219 logfont_16_to_W( plf16, &lfW );
1220 ret = CreateFontIndirectW( &lfW );
1222 else ret = CreateFontIndirectW( NULL );
1223 return HFONT_16(ret);
1227 /***********************************************************************
1228 * CreateHatchBrush (GDI.58)
1230 HBRUSH16 WINAPI CreateHatchBrush16( INT16 style, COLORREF color )
1232 return HBRUSH_16( CreateHatchBrush( style, color ) );
1236 /***********************************************************************
1237 * CreatePatternBrush (GDI.60)
1239 HBRUSH16 WINAPI CreatePatternBrush16( HBITMAP16 hbitmap )
1241 return HBRUSH_16( CreatePatternBrush( HBITMAP_32(hbitmap) ));
1245 /***********************************************************************
1246 * CreatePen (GDI.61)
1248 HPEN16 WINAPI CreatePen16( INT16 style, INT16 width, COLORREF color )
1250 LOGPEN logpen;
1252 logpen.lopnStyle = style;
1253 logpen.lopnWidth.x = width;
1254 logpen.lopnWidth.y = 0;
1255 logpen.lopnColor = color;
1256 return HPEN_16( CreatePenIndirect( &logpen ) );
1260 /***********************************************************************
1261 * CreatePenIndirect (GDI.62)
1263 HPEN16 WINAPI CreatePenIndirect16( const LOGPEN16 * pen )
1265 LOGPEN logpen;
1267 if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
1268 logpen.lopnStyle = pen->lopnStyle;
1269 logpen.lopnWidth.x = pen->lopnWidth.x;
1270 logpen.lopnWidth.y = pen->lopnWidth.y;
1271 logpen.lopnColor = pen->lopnColor;
1272 return HPEN_16( CreatePenIndirect( &logpen ) );
1276 /***********************************************************************
1277 * CreatePolygonRgn (GDI.63)
1279 HRGN16 WINAPI CreatePolygonRgn16( const POINT16 * points, INT16 count, INT16 mode )
1281 return CreatePolyPolygonRgn16( points, &count, 1, mode );
1285 /***********************************************************************
1286 * CreateRectRgn (GDI.64)
1288 * NOTE: cf. SetRectRgn16
1290 HRGN16 WINAPI CreateRectRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom )
1292 HRGN hrgn;
1294 if (left < right) hrgn = CreateRectRgn( left, top, right, bottom );
1295 else hrgn = CreateRectRgn( 0, 0, 0, 0 );
1296 return HRGN_16(hrgn);
1300 /***********************************************************************
1301 * CreateRectRgnIndirect (GDI.65)
1303 HRGN16 WINAPI CreateRectRgnIndirect16( const RECT16* rect )
1305 return CreateRectRgn16( rect->left, rect->top, rect->right, rect->bottom );
1309 /***********************************************************************
1310 * CreateSolidBrush (GDI.66)
1312 HBRUSH16 WINAPI CreateSolidBrush16( COLORREF color )
1314 return HBRUSH_16( CreateSolidBrush( color ) );
1318 /***********************************************************************
1319 * DeleteDC (GDI.68)
1321 BOOL16 WINAPI DeleteDC16( HDC16 hdc )
1323 if (DeleteDC( HDC_32(hdc) ))
1325 struct saved_visrgn *saved, *next;
1326 struct gdi_thunk* thunk;
1328 if ((thunk = GDI_FindThunk(hdc))) GDI_DeleteThunk(thunk);
1330 LIST_FOR_EACH_ENTRY_SAFE( saved, next, &saved_regions, struct saved_visrgn, entry )
1332 if (saved->hdc != HDC_32(hdc)) continue;
1333 list_remove( &saved->entry );
1334 DeleteObject( saved->hrgn );
1335 HeapFree( GetProcessHeap(), 0, saved );
1337 return TRUE;
1339 return FALSE;
1343 /***********************************************************************
1344 * DeleteObject (GDI.69)
1345 * SysDeleteObject (GDI.605)
1347 BOOL16 WINAPI DeleteObject16( HGDIOBJ16 obj )
1349 if (GetObjectType( HGDIOBJ_32(obj) ) == OBJ_BITMAP) free_segptr_bits( obj );
1350 return DeleteObject( HGDIOBJ_32(obj) );
1354 /***********************************************************************
1355 * EnumFonts (GDI.70)
1357 INT16 WINAPI EnumFonts16( HDC16 hDC, LPCSTR lpName, FONTENUMPROC16 efproc,
1358 LPARAM lpData )
1360 return EnumFontFamilies16( hDC, lpName, efproc, lpData );
1364 /***********************************************************************
1365 * EnumObjects (GDI.71)
1367 INT16 WINAPI EnumObjects16( HDC16 hdc, INT16 obj, GOBJENUMPROC16 proc, LPARAM lParam )
1369 struct callback16_info info;
1371 info.proc = (FARPROC16)proc;
1372 info.param = lParam;
1373 switch(obj)
1375 case OBJ_PEN:
1376 return EnumObjects( HDC_32(hdc), OBJ_PEN, enum_pens_callback, (LPARAM)&info );
1377 case OBJ_BRUSH:
1378 return EnumObjects( HDC_32(hdc), OBJ_BRUSH, enum_brushes_callback, (LPARAM)&info );
1380 return 0;
1384 /***********************************************************************
1385 * EqualRgn (GDI.72)
1387 BOOL16 WINAPI EqualRgn16( HRGN16 rgn1, HRGN16 rgn2 )
1389 return EqualRgn( HRGN_32(rgn1), HRGN_32(rgn2) );
1393 /***********************************************************************
1394 * GetBitmapBits (GDI.74)
1396 LONG WINAPI GetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPVOID buffer )
1398 return GetBitmapBits( HBITMAP_32(hbitmap), count, buffer );
1402 /***********************************************************************
1403 * GetBkColor (GDI.75)
1405 COLORREF WINAPI GetBkColor16( HDC16 hdc )
1407 return GetBkColor( HDC_32(hdc) );
1411 /***********************************************************************
1412 * GetBkMode (GDI.76)
1414 INT16 WINAPI GetBkMode16( HDC16 hdc )
1416 return GetBkMode( HDC_32(hdc) );
1420 /***********************************************************************
1421 * GetClipBox (GDI.77)
1423 INT16 WINAPI GetClipBox16( HDC16 hdc, LPRECT16 rect )
1425 RECT rect32;
1426 INT ret = GetClipBox( HDC_32(hdc), &rect32 );
1428 if (ret != ERROR)
1430 rect->left = rect32.left;
1431 rect->top = rect32.top;
1432 rect->right = rect32.right;
1433 rect->bottom = rect32.bottom;
1435 return ret;
1439 /***********************************************************************
1440 * GetCurrentPosition (GDI.78)
1442 DWORD WINAPI GetCurrentPosition16( HDC16 hdc )
1444 POINT pt32;
1445 if (!GetCurrentPositionEx( HDC_32(hdc), &pt32 )) return 0;
1446 return MAKELONG( pt32.x, pt32.y );
1450 /***********************************************************************
1451 * GetDCOrg (GDI.79)
1453 DWORD WINAPI GetDCOrg16( HDC16 hdc )
1455 POINT pt;
1456 if (GetDCOrgEx( HDC_32(hdc), &pt )) return MAKELONG( pt.x, pt.y );
1457 return 0;
1461 /***********************************************************************
1462 * GetDeviceCaps (GDI.80)
1464 INT16 WINAPI GetDeviceCaps16( HDC16 hdc, INT16 cap )
1466 INT16 ret = GetDeviceCaps( HDC_32(hdc), cap );
1467 /* some apps don't expect -1 and think it's a B&W screen */
1468 if ((cap == NUMCOLORS) && (ret == -1)) ret = 2048;
1469 return ret;
1473 /***********************************************************************
1474 * GetMapMode (GDI.81)
1476 INT16 WINAPI GetMapMode16( HDC16 hdc )
1478 return GetMapMode( HDC_32(hdc) );
1482 /***********************************************************************
1483 * GetObject (GDI.82)
1485 INT16 WINAPI GetObject16( HGDIOBJ16 handle16, INT16 count, LPVOID buffer )
1487 HGDIOBJ handle = HGDIOBJ_32( handle16 );
1488 switch( GetObjectType( handle ))
1490 case OBJ_PEN:
1491 if (buffer)
1493 LOGPEN16 *pen16 = buffer;
1494 LOGPEN pen;
1496 if (count < sizeof(LOGPEN16)) return 0;
1497 if (!GetObjectW( handle, sizeof(pen), &pen )) return 0;
1499 pen16->lopnStyle = pen.lopnStyle;
1500 pen16->lopnColor = pen.lopnColor;
1501 pen16->lopnWidth.x = pen.lopnWidth.x;
1502 pen16->lopnWidth.y = pen.lopnWidth.y;
1504 return sizeof(LOGPEN16);
1506 case OBJ_BRUSH:
1507 if (buffer)
1509 LOGBRUSH brush;
1510 LOGBRUSH16 brush16;
1512 if (!GetObjectW( handle, sizeof(brush), &brush )) return 0;
1513 brush16.lbStyle = brush.lbStyle;
1514 brush16.lbColor = brush.lbColor;
1515 brush16.lbHatch = brush.lbHatch;
1516 if (count > sizeof(brush16)) count = sizeof(brush16);
1517 memcpy( buffer, &brush16, count );
1518 return count;
1520 return sizeof(LOGBRUSH16);
1522 case OBJ_PAL:
1523 return GetObjectW( handle, count, buffer );
1525 case OBJ_FONT:
1526 if (buffer)
1528 LOGFONTW font;
1529 LOGFONT16 font16;
1531 if (!GetObjectW( handle, sizeof(font), &font )) return 0;
1532 logfont_W_to_16( &font, &font16 );
1533 if (count > sizeof(font16)) count = sizeof(font16);
1534 memcpy( buffer, &font16, count );
1535 return count;
1537 return sizeof(LOGFONT16);
1539 case OBJ_BITMAP:
1541 DIBSECTION dib;
1542 INT size;
1543 BITMAP16 *bmp16 = buffer;
1545 if (!(size = GetObjectW( handle, sizeof(dib), &dib ))) return 0;
1546 if (size == sizeof(DIBSECTION) && count > sizeof(BITMAP16))
1548 FIXME("not implemented for DIBs: count %d\n", count);
1549 return 0;
1551 else
1553 if (count < sizeof(BITMAP16)) return 0;
1554 bmp16->bmType = dib.dsBm.bmType;
1555 bmp16->bmWidth = dib.dsBm.bmWidth;
1556 bmp16->bmHeight = dib.dsBm.bmHeight;
1557 bmp16->bmWidthBytes = dib.dsBm.bmWidthBytes;
1558 bmp16->bmPlanes = dib.dsBm.bmPlanes;
1559 bmp16->bmBitsPixel = dib.dsBm.bmBitsPixel;
1560 bmp16->bmBits = 0;
1561 return sizeof(BITMAP16);
1565 default:
1566 return 0;
1571 /***********************************************************************
1572 * GetPixel (GDI.83)
1574 COLORREF WINAPI GetPixel16( HDC16 hdc, INT16 x, INT16 y )
1576 return GetPixel( HDC_32(hdc), x, y );
1580 /***********************************************************************
1581 * GetPolyFillMode (GDI.84)
1583 INT16 WINAPI GetPolyFillMode16( HDC16 hdc )
1585 return GetPolyFillMode( HDC_32(hdc) );
1589 /***********************************************************************
1590 * GetROP2 (GDI.85)
1592 INT16 WINAPI GetROP216( HDC16 hdc )
1594 return GetROP2( HDC_32(hdc) );
1598 /***********************************************************************
1599 * GetRelAbs (GDI.86)
1601 INT16 WINAPI GetRelAbs16( HDC16 hdc )
1603 return GetRelAbs( HDC_32(hdc), 0 );
1607 /***********************************************************************
1608 * GetStockObject (GDI.87)
1610 HGDIOBJ16 WINAPI GetStockObject16( INT16 obj )
1612 return HGDIOBJ_16( GetStockObject( obj ) );
1616 /***********************************************************************
1617 * GetStretchBltMode (GDI.88)
1619 INT16 WINAPI GetStretchBltMode16( HDC16 hdc )
1621 return GetStretchBltMode( HDC_32(hdc) );
1625 /***********************************************************************
1626 * GetTextCharacterExtra (GDI.89)
1628 INT16 WINAPI GetTextCharacterExtra16( HDC16 hdc )
1630 return GetTextCharacterExtra( HDC_32(hdc) );
1634 /***********************************************************************
1635 * GetTextColor (GDI.90)
1637 COLORREF WINAPI GetTextColor16( HDC16 hdc )
1639 return GetTextColor( HDC_32(hdc) );
1643 /***********************************************************************
1644 * GetTextExtent (GDI.91)
1646 DWORD WINAPI GetTextExtent16( HDC16 hdc, LPCSTR str, INT16 count )
1648 SIZE size;
1649 if (!GetTextExtentPoint32A( HDC_32(hdc), str, count, &size )) return 0;
1650 return MAKELONG( size.cx, size.cy );
1654 /***********************************************************************
1655 * GetTextFace (GDI.92)
1657 INT16 WINAPI GetTextFace16( HDC16 hdc, INT16 count, LPSTR name )
1659 return GetTextFaceA( HDC_32(hdc), count, name );
1663 /***********************************************************************
1664 * GetTextMetrics (GDI.93)
1666 BOOL16 WINAPI GetTextMetrics16( HDC16 hdc, TEXTMETRIC16 *tm )
1668 TEXTMETRICW tm32;
1670 if (!GetTextMetricsW( HDC_32(hdc), &tm32 )) return FALSE;
1672 tm->tmHeight = tm32.tmHeight;
1673 tm->tmAscent = tm32.tmAscent;
1674 tm->tmDescent = tm32.tmDescent;
1675 tm->tmInternalLeading = tm32.tmInternalLeading;
1676 tm->tmExternalLeading = tm32.tmExternalLeading;
1677 tm->tmAveCharWidth = tm32.tmAveCharWidth;
1678 tm->tmMaxCharWidth = tm32.tmMaxCharWidth;
1679 tm->tmWeight = tm32.tmWeight;
1680 tm->tmOverhang = tm32.tmOverhang;
1681 tm->tmDigitizedAspectX = tm32.tmDigitizedAspectX;
1682 tm->tmDigitizedAspectY = tm32.tmDigitizedAspectY;
1683 tm->tmFirstChar = tm32.tmFirstChar;
1684 tm->tmLastChar = tm32.tmLastChar;
1685 tm->tmDefaultChar = tm32.tmDefaultChar;
1686 tm->tmBreakChar = tm32.tmBreakChar;
1687 tm->tmItalic = tm32.tmItalic;
1688 tm->tmUnderlined = tm32.tmUnderlined;
1689 tm->tmStruckOut = tm32.tmStruckOut;
1690 tm->tmPitchAndFamily = tm32.tmPitchAndFamily;
1691 tm->tmCharSet = tm32.tmCharSet;
1692 return TRUE;
1696 /***********************************************************************
1697 * GetViewportExt (GDI.94)
1699 DWORD WINAPI GetViewportExt16( HDC16 hdc )
1701 SIZE size;
1702 if (!GetViewportExtEx( HDC_32(hdc), &size )) return 0;
1703 return MAKELONG( size.cx, size.cy );
1707 /***********************************************************************
1708 * GetViewportOrg (GDI.95)
1710 DWORD WINAPI GetViewportOrg16( HDC16 hdc )
1712 POINT pt;
1713 if (!GetViewportOrgEx( HDC_32(hdc), &pt )) return 0;
1714 return MAKELONG( pt.x, pt.y );
1718 /***********************************************************************
1719 * GetWindowExt (GDI.96)
1721 DWORD WINAPI GetWindowExt16( HDC16 hdc )
1723 SIZE size;
1724 if (!GetWindowExtEx( HDC_32(hdc), &size )) return 0;
1725 return MAKELONG( size.cx, size.cy );
1729 /***********************************************************************
1730 * GetWindowOrg (GDI.97)
1732 DWORD WINAPI GetWindowOrg16( HDC16 hdc )
1734 POINT pt;
1735 if (!GetWindowOrgEx( HDC_32(hdc), &pt )) return 0;
1736 return MAKELONG( pt.x, pt.y );
1742 /**********************************************************************
1743 * LineDDA (GDI.100)
1745 void WINAPI LineDDA16( INT16 nXStart, INT16 nYStart, INT16 nXEnd,
1746 INT16 nYEnd, LINEDDAPROC16 proc, LPARAM lParam )
1748 struct callback16_info info;
1749 info.proc = (FARPROC16)proc;
1750 info.param = lParam;
1751 LineDDA( nXStart, nYStart, nXEnd, nYEnd, linedda_callback, (LPARAM)&info );
1755 /***********************************************************************
1756 * OffsetRgn (GDI.101)
1758 INT16 WINAPI OffsetRgn16( HRGN16 hrgn, INT16 x, INT16 y )
1760 return OffsetRgn( HRGN_32(hrgn), x, y );
1764 /***********************************************************************
1765 * PtVisible (GDI.103)
1767 BOOL16 WINAPI PtVisible16( HDC16 hdc, INT16 x, INT16 y )
1769 return PtVisible( HDC_32(hdc), x, y );
1773 /***********************************************************************
1774 * SelectVisRgn (GDI.105)
1776 INT16 WINAPI SelectVisRgn16( HDC16 hdc, HRGN16 hrgn )
1778 return SelectVisRgn( HDC_32(hdc), HRGN_32(hrgn) );
1782 /***********************************************************************
1783 * SetBitmapBits (GDI.106)
1785 LONG WINAPI SetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPCVOID buffer )
1787 return SetBitmapBits( HBITMAP_32(hbitmap), count, buffer );
1791 /***********************************************************************
1792 * AddFontResource (GDI.119)
1794 INT16 WINAPI AddFontResource16( LPCSTR filename )
1796 return AddFontResourceA( filename );
1800 /***********************************************************************
1801 * Death (GDI.121)
1803 * Disables GDI, switches back to text mode.
1804 * We don't have to do anything here,
1805 * just let console support handle everything
1807 void WINAPI Death16(HDC16 hdc)
1809 MESSAGE("Death(%04x) called. Application enters text mode...\n", hdc);
1813 /***********************************************************************
1814 * Resurrection (GDI.122)
1816 * Restores GDI functionality
1818 void WINAPI Resurrection16(HDC16 hdc,
1819 WORD w1, WORD w2, WORD w3, WORD w4, WORD w5, WORD w6)
1821 MESSAGE("Resurrection(%04x, %04x, %04x, %04x, %04x, %04x, %04x) called. Application left text mode.\n",
1822 hdc, w1, w2, w3, w4, w5, w6);
1826 /***********************************************************************
1827 * MulDiv (GDI.128)
1829 INT16 WINAPI MulDiv16( INT16 nMultiplicand, INT16 nMultiplier, INT16 nDivisor)
1831 INT ret;
1832 if (!nDivisor) return -32768;
1833 /* We want to deal with a positive divisor to simplify the logic. */
1834 if (nDivisor < 0)
1836 nMultiplicand = - nMultiplicand;
1837 nDivisor = -nDivisor;
1839 /* If the result is positive, we "add" to round. else,
1840 * we subtract to round. */
1841 if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) ||
1842 ( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
1843 ret = (((int)nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
1844 else
1845 ret = (((int)nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
1846 if ((ret > 32767) || (ret < -32767)) return -32768;
1847 return (INT16) ret;
1851 /***********************************************************************
1852 * GetRgnBox (GDI.134)
1854 INT16 WINAPI GetRgnBox16( HRGN16 hrgn, LPRECT16 rect )
1856 RECT r;
1857 INT16 ret = GetRgnBox( HRGN_32(hrgn), &r );
1858 rect->left = r.left;
1859 rect->top = r.top;
1860 rect->right = r.right;
1861 rect->bottom = r.bottom;
1862 return ret;
1866 /***********************************************************************
1867 * RemoveFontResource (GDI.136)
1869 BOOL16 WINAPI RemoveFontResource16( LPCSTR str )
1871 return RemoveFontResourceA(str);
1875 /***********************************************************************
1876 * SetBrushOrg (GDI.148)
1878 DWORD WINAPI SetBrushOrg16( HDC16 hdc, INT16 x, INT16 y )
1880 POINT pt;
1882 if (!SetBrushOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
1883 return MAKELONG( pt.x, pt.y );
1887 /***********************************************************************
1888 * GetBrushOrg (GDI.149)
1890 DWORD WINAPI GetBrushOrg16( HDC16 hdc )
1892 POINT pt;
1893 if (!GetBrushOrgEx( HDC_32(hdc), &pt )) return 0;
1894 return MAKELONG( pt.x, pt.y );
1898 /***********************************************************************
1899 * UnrealizeObject (GDI.150)
1901 BOOL16 WINAPI UnrealizeObject16( HGDIOBJ16 obj )
1903 return UnrealizeObject( HGDIOBJ_32(obj) );
1907 /***********************************************************************
1908 * CreateIC (GDI.153)
1910 HDC16 WINAPI CreateIC16( LPCSTR driver, LPCSTR device, LPCSTR output,
1911 const DEVMODEA* initData )
1913 return HDC_16( CreateICA( driver, device, output, initData ) );
1917 /***********************************************************************
1918 * GetNearestColor (GDI.154)
1920 COLORREF WINAPI GetNearestColor16( HDC16 hdc, COLORREF color )
1922 return GetNearestColor( HDC_32(hdc), color );
1926 /***********************************************************************
1927 * CreateDiscardableBitmap (GDI.156)
1929 HBITMAP16 WINAPI CreateDiscardableBitmap16( HDC16 hdc, INT16 width, INT16 height )
1931 return HBITMAP_16( CreateDiscardableBitmap( HDC_32(hdc), width, height ) );
1935 /***********************************************************************
1936 * PtInRegion (GDI.161)
1938 BOOL16 WINAPI PtInRegion16( HRGN16 hrgn, INT16 x, INT16 y )
1940 return PtInRegion( HRGN_32(hrgn), x, y );
1944 /***********************************************************************
1945 * GetBitmapDimension (GDI.162)
1947 DWORD WINAPI GetBitmapDimension16( HBITMAP16 hbitmap )
1949 SIZE16 size;
1950 if (!GetBitmapDimensionEx16( hbitmap, &size )) return 0;
1951 return MAKELONG( size.cx, size.cy );
1955 /***********************************************************************
1956 * SetBitmapDimension (GDI.163)
1958 DWORD WINAPI SetBitmapDimension16( HBITMAP16 hbitmap, INT16 x, INT16 y )
1960 SIZE16 size;
1961 if (!SetBitmapDimensionEx16( hbitmap, x, y, &size )) return 0;
1962 return MAKELONG( size.cx, size.cy );
1966 /***********************************************************************
1967 * SetRectRgn (GDI.172)
1969 * NOTE: Win 3.1 sets region to empty if left > right
1971 void WINAPI SetRectRgn16( HRGN16 hrgn, INT16 left, INT16 top, INT16 right, INT16 bottom )
1973 if (left < right) SetRectRgn( HRGN_32(hrgn), left, top, right, bottom );
1974 else SetRectRgn( HRGN_32(hrgn), 0, 0, 0, 0 );
1978 /******************************************************************
1979 * PlayMetaFileRecord (GDI.176)
1981 void WINAPI PlayMetaFileRecord16( HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr, UINT16 handles )
1983 HANDLETABLE *ht32 = HeapAlloc( GetProcessHeap(), 0, handles * sizeof(*ht32) );
1984 unsigned int i;
1986 for (i = 0; i < handles; i++) ht32->objectHandle[i] = HGDIOBJ_32(ht->objectHandle[i]);
1987 PlayMetaFileRecord( HDC_32(hdc), ht32, mr, handles );
1988 for (i = 0; i < handles; i++) ht->objectHandle[i] = HGDIOBJ_16(ht32->objectHandle[i]);
1989 HeapFree( GetProcessHeap(), 0, ht32 );
1993 /***********************************************************************
1994 * SetDCHook (GDI.190)
1996 BOOL16 WINAPI SetDCHook16( HDC16 hdc16, FARPROC16 hookProc, DWORD dwHookData )
1998 FIXME( "%04x %p %x: not supported\n", hdc16, hookProc, dwHookData );
1999 return FALSE;
2003 /***********************************************************************
2004 * GetDCHook (GDI.191)
2006 DWORD WINAPI GetDCHook16( HDC16 hdc16, FARPROC16 *phookProc )
2008 FIXME( "%04x: not supported\n", hdc16 );
2009 return 0;
2013 /***********************************************************************
2014 * SetHookFlags (GDI.192)
2016 WORD WINAPI SetHookFlags16( HDC16 hdc, WORD flags )
2018 return SetHookFlags( HDC_32(hdc), flags );
2022 /***********************************************************************
2023 * SetBoundsRect (GDI.193)
2025 UINT16 WINAPI SetBoundsRect16( HDC16 hdc, const RECT16* rect, UINT16 flags )
2027 if (rect)
2029 RECT rect32;
2030 rect32.left = rect->left;
2031 rect32.top = rect->top;
2032 rect32.right = rect->right;
2033 rect32.bottom = rect->bottom;
2034 return SetBoundsRect( HDC_32( hdc ), &rect32, flags );
2036 else return SetBoundsRect( HDC_32( hdc ), NULL, flags );
2040 /***********************************************************************
2041 * GetBoundsRect (GDI.194)
2043 UINT16 WINAPI GetBoundsRect16( HDC16 hdc, LPRECT16 rect, UINT16 flags)
2045 RECT rect32;
2046 UINT ret = GetBoundsRect( HDC_32( hdc ), &rect32, flags );
2047 if (rect)
2049 rect->left = rect32.left;
2050 rect->top = rect32.top;
2051 rect->right = rect32.right;
2052 rect->bottom = rect32.bottom;
2054 return ret;
2058 /***********************************************************************
2059 * EngineEnumerateFont (GDI.300)
2061 WORD WINAPI EngineEnumerateFont16(LPSTR fontname, FARPROC16 proc, DWORD data )
2063 FIXME("(%s,%p,%x),stub\n",fontname,proc,data);
2064 return 0;
2068 /***********************************************************************
2069 * EngineDeleteFont (GDI.301)
2071 WORD WINAPI EngineDeleteFont16(LPFONTINFO16 lpFontInfo)
2073 WORD handle;
2075 /* untested, don't know if it works.
2076 We seem to access some structure that is located after the
2077 FONTINFO. The FONTINFO documentation says that there may
2078 follow some char-width table or font bitmap or vector info.
2079 I think it is some kind of font bitmap that begins at offset 0x52,
2080 as FONTINFO goes up to 0x51.
2081 If this is correct, everything should be implemented correctly.
2083 if ( ((lpFontInfo->dfType & (RASTER_FONTTYPE|DEVICE_FONTTYPE)) == (RASTER_FONTTYPE|DEVICE_FONTTYPE))
2084 && (LOWORD(lpFontInfo->dfFace) == LOWORD(lpFontInfo)+0x6e)
2085 && (handle = *(WORD *)(lpFontInfo+0x54)) )
2087 *(WORD *)(lpFontInfo+0x54) = 0;
2088 GlobalFree16(handle);
2090 return 1;
2094 /***********************************************************************
2095 * EngineRealizeFont (GDI.302)
2097 WORD WINAPI EngineRealizeFont16(LPLOGFONT16 lplogFont, LPTEXTXFORM16 lptextxform, LPFONTINFO16 lpfontInfo)
2099 FIXME("(%p,%p,%p),stub\n",lplogFont,lptextxform,lpfontInfo);
2101 return 0;
2105 /***********************************************************************
2106 * EngineRealizeFontExt (GDI.315)
2108 WORD WINAPI EngineRealizeFontExt16(LONG l1, LONG l2, LONG l3, LONG l4)
2110 FIXME("(%08x,%08x,%08x,%08x),stub\n",l1,l2,l3,l4);
2112 return 0;
2116 /***********************************************************************
2117 * EngineGetCharWidth (GDI.303)
2119 WORD WINAPI EngineGetCharWidth16(LPFONTINFO16 lpFontInfo, BYTE firstChar, BYTE lastChar, LPINT16 buffer)
2121 int i;
2123 for (i = firstChar; i <= lastChar; i++)
2124 FIXME(" returns font's average width for range %d to %d\n", firstChar, lastChar);
2125 *buffer++ = lpFontInfo->dfAvgWidth; /* insert some charwidth functionality here; use average width for now */
2126 return 1;
2130 /***********************************************************************
2131 * EngineSetFontContext (GDI.304)
2133 WORD WINAPI EngineSetFontContext16(LPFONTINFO16 lpFontInfo, WORD data)
2135 FIXME("stub?\n");
2136 return 0;
2139 /***********************************************************************
2140 * EngineGetGlyphBMP (GDI.305)
2142 WORD WINAPI EngineGetGlyphBMP16(WORD word, LPFONTINFO16 lpFontInfo, WORD w1, WORD w2,
2143 LPSTR string, DWORD dword, /*LPBITMAPMETRICS16*/ LPVOID metrics)
2145 FIXME("stub?\n");
2146 return 0;
2150 /***********************************************************************
2151 * EngineMakeFontDir (GDI.306)
2153 DWORD WINAPI EngineMakeFontDir16(HDC16 hdc, LPFONTDIR16 fontdir, LPCSTR string)
2155 FIXME(" stub! (always fails)\n");
2156 return ~0UL; /* error */
2160 /***********************************************************************
2161 * GetCharABCWidths (GDI.307)
2163 BOOL16 WINAPI GetCharABCWidths16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar, LPABC16 abc )
2165 BOOL ret;
2166 UINT i;
2167 LPABC abc32 = HeapAlloc( GetProcessHeap(), 0, sizeof(ABC) * (lastChar - firstChar + 1) );
2169 if ((ret = GetCharABCWidthsA( HDC_32(hdc), firstChar, lastChar, abc32 )))
2171 for (i = firstChar; i <= lastChar; i++)
2173 abc[i-firstChar].abcA = abc32[i-firstChar].abcA;
2174 abc[i-firstChar].abcB = abc32[i-firstChar].abcB;
2175 abc[i-firstChar].abcC = abc32[i-firstChar].abcC;
2178 HeapFree( GetProcessHeap(), 0, abc32 );
2179 return ret;
2183 /***********************************************************************
2184 * GetOutlineTextMetrics (GDI.308)
2186 * Gets metrics for TrueType fonts.
2188 * PARAMS
2189 * hdc [In] Handle of device context
2190 * cbData [In] Size of metric data array
2191 * lpOTM [Out] Address of metric data array
2193 * RETURNS
2194 * Success: Non-zero or size of required buffer
2195 * Failure: 0
2197 * NOTES
2198 * lpOTM should be LPOUTLINETEXTMETRIC
2200 UINT16 WINAPI GetOutlineTextMetrics16( HDC16 hdc, UINT16 cbData,
2201 LPOUTLINETEXTMETRIC16 lpOTM )
2203 FIXME("(%04x,%04x,%p): stub\n", hdc,cbData,lpOTM);
2204 return 0;
2208 /***********************************************************************
2209 * GetGlyphOutline (GDI.309)
2211 DWORD WINAPI GetGlyphOutline16( HDC16 hdc, UINT16 uChar, UINT16 fuFormat,
2212 LPGLYPHMETRICS16 lpgm, DWORD cbBuffer,
2213 LPVOID lpBuffer, const MAT2 *lpmat2 )
2215 DWORD ret;
2216 GLYPHMETRICS gm32;
2218 ret = GetGlyphOutlineA( HDC_32(hdc), uChar, fuFormat, &gm32, cbBuffer, lpBuffer, lpmat2);
2219 if (ret && ret != GDI_ERROR)
2221 lpgm->gmBlackBoxX = gm32.gmBlackBoxX;
2222 lpgm->gmBlackBoxY = gm32.gmBlackBoxY;
2223 lpgm->gmptGlyphOrigin.x = gm32.gmptGlyphOrigin.x;
2224 lpgm->gmptGlyphOrigin.y = gm32.gmptGlyphOrigin.y;
2225 lpgm->gmCellIncX = gm32.gmCellIncX;
2226 lpgm->gmCellIncY = gm32.gmCellIncY;
2228 return ret;
2232 /***********************************************************************
2233 * CreateScalableFontResource (GDI.310)
2235 BOOL16 WINAPI CreateScalableFontResource16( UINT16 fHidden, LPCSTR lpszResourceFile,
2236 LPCSTR fontFile, LPCSTR path )
2238 return CreateScalableFontResourceA( fHidden, lpszResourceFile, fontFile, path );
2242 /*************************************************************************
2243 * GetFontData (GDI.311)
2246 DWORD WINAPI GetFontData16( HDC16 hdc, DWORD table, DWORD offset, LPVOID buffer, DWORD count )
2248 return GetFontData( HDC_32(hdc), table, offset, buffer, count );
2252 /*************************************************************************
2253 * GetRasterizerCaps (GDI.313)
2255 BOOL16 WINAPI GetRasterizerCaps16( LPRASTERIZER_STATUS lprs, UINT16 cbNumBytes )
2257 return GetRasterizerCaps( lprs, cbNumBytes );
2261 /***********************************************************************
2262 * EnumFontFamilies (GDI.330)
2264 INT16 WINAPI EnumFontFamilies16( HDC16 hDC, LPCSTR lpFamily,
2265 FONTENUMPROC16 efproc, LPARAM lpData )
2267 LOGFONT16 lf, *plf;
2269 if (lpFamily)
2271 if (!*lpFamily) return 1;
2272 lstrcpynA( lf.lfFaceName, lpFamily, LF_FACESIZE );
2273 lf.lfCharSet = DEFAULT_CHARSET;
2274 lf.lfPitchAndFamily = 0;
2275 plf = &lf;
2277 else plf = NULL;
2279 return EnumFontFamiliesEx16( hDC, plf, efproc, lpData, 0 );
2283 /*************************************************************************
2284 * GetKerningPairs (GDI.332)
2287 INT16 WINAPI GetKerningPairs16( HDC16 hdc, INT16 count, LPKERNINGPAIR16 pairs )
2289 KERNINGPAIR *pairs32;
2290 INT i, ret;
2292 if (!count) return 0;
2294 if (!(pairs32 = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*pairs32) ))) return 0;
2295 if ((ret = GetKerningPairsA( HDC_32(hdc), count, pairs32 )))
2297 for (i = 0; i < ret; i++)
2299 pairs->wFirst = pairs32->wFirst;
2300 pairs->wSecond = pairs32->wSecond;
2301 pairs->iKernAmount = pairs32->iKernAmount;
2304 HeapFree( GetProcessHeap(), 0, pairs32 );
2305 return ret;
2310 /***********************************************************************
2311 * GetTextAlign (GDI.345)
2313 UINT16 WINAPI GetTextAlign16( HDC16 hdc )
2315 return GetTextAlign( HDC_32(hdc) );
2319 /***********************************************************************
2320 * SetTextAlign (GDI.346)
2322 UINT16 WINAPI SetTextAlign16( HDC16 hdc, UINT16 align )
2324 return SetTextAlign( HDC_32(hdc), align );
2328 /***********************************************************************
2329 * Chord (GDI.348)
2331 BOOL16 WINAPI Chord16( HDC16 hdc, INT16 left, INT16 top,
2332 INT16 right, INT16 bottom, INT16 xstart, INT16 ystart,
2333 INT16 xend, INT16 yend )
2335 return Chord( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
2339 /***********************************************************************
2340 * SetMapperFlags (GDI.349)
2342 DWORD WINAPI SetMapperFlags16( HDC16 hdc, DWORD flags )
2344 return SetMapperFlags( HDC_32(hdc), flags );
2348 /***********************************************************************
2349 * GetCharWidth (GDI.350)
2351 BOOL16 WINAPI GetCharWidth16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar, LPINT16 buffer )
2353 BOOL retVal = FALSE;
2355 if( firstChar != lastChar )
2357 LPINT buf32 = HeapAlloc(GetProcessHeap(), 0, sizeof(INT)*(1 + (lastChar - firstChar)));
2358 if( buf32 )
2360 LPINT obuf32 = buf32;
2361 int i;
2363 retVal = GetCharWidth32A( HDC_32(hdc), firstChar, lastChar, buf32);
2364 if (retVal)
2366 for (i = firstChar; i <= lastChar; i++) *buffer++ = *buf32++;
2368 HeapFree(GetProcessHeap(), 0, obuf32);
2371 else /* happens quite often to warrant a special treatment */
2373 INT chWidth;
2374 retVal = GetCharWidth32A( HDC_32(hdc), firstChar, lastChar, &chWidth );
2375 *buffer = chWidth;
2377 return retVal;
2381 /***********************************************************************
2382 * ExtTextOut (GDI.351)
2384 BOOL16 WINAPI ExtTextOut16( HDC16 hdc, INT16 x, INT16 y, UINT16 flags,
2385 const RECT16 *lprect, LPCSTR str, UINT16 count,
2386 const INT16 *lpDx )
2388 BOOL ret;
2389 int i;
2390 RECT rect32;
2391 LPINT lpdx32 = NULL;
2393 if (lpDx) {
2394 lpdx32 = HeapAlloc( GetProcessHeap(),0, sizeof(INT)*count );
2395 if(lpdx32 == NULL) return FALSE;
2396 for (i=count;i--;) lpdx32[i]=lpDx[i];
2398 if (lprect)
2400 rect32.left = lprect->left;
2401 rect32.top = lprect->top;
2402 rect32.right = lprect->right;
2403 rect32.bottom = lprect->bottom;
2405 ret = ExtTextOutA(HDC_32(hdc),x,y,flags,lprect?&rect32:NULL,str,count,lpdx32);
2406 HeapFree( GetProcessHeap(), 0, lpdx32 );
2407 return ret;
2411 /***********************************************************************
2412 * CreatePalette (GDI.360)
2414 HPALETTE16 WINAPI CreatePalette16( const LOGPALETTE* palette )
2416 return HPALETTE_16( CreatePalette( palette ) );
2420 /***********************************************************************
2421 * GDISelectPalette (GDI.361)
2423 HPALETTE16 WINAPI GDISelectPalette16( HDC16 hdc, HPALETTE16 hpalette, WORD wBkg )
2425 HPALETTE16 ret = HPALETTE_16( SelectPalette( HDC_32(hdc), HPALETTE_32(hpalette), wBkg ));
2426 if (ret && !wBkg) hPrimaryPalette = hpalette;
2427 return ret;
2431 /***********************************************************************
2432 * GDIRealizePalette (GDI.362)
2434 UINT16 WINAPI GDIRealizePalette16( HDC16 hdc )
2436 return RealizePalette( HDC_32(hdc) );
2440 /***********************************************************************
2441 * GetPaletteEntries (GDI.363)
2443 UINT16 WINAPI GetPaletteEntries16( HPALETTE16 hpalette, UINT16 start,
2444 UINT16 count, LPPALETTEENTRY entries )
2446 return GetPaletteEntries( HPALETTE_32(hpalette), start, count, entries );
2450 /***********************************************************************
2451 * SetPaletteEntries (GDI.364)
2453 UINT16 WINAPI SetPaletteEntries16( HPALETTE16 hpalette, UINT16 start,
2454 UINT16 count, const PALETTEENTRY *entries )
2456 return SetPaletteEntries( HPALETTE_32(hpalette), start, count, entries );
2460 /**********************************************************************
2461 * UpdateColors (GDI.366)
2463 INT16 WINAPI UpdateColors16( HDC16 hdc )
2465 UpdateColors( HDC_32(hdc) );
2466 return TRUE;
2470 /***********************************************************************
2471 * AnimatePalette (GDI.367)
2473 void WINAPI AnimatePalette16( HPALETTE16 hpalette, UINT16 StartIndex,
2474 UINT16 NumEntries, const PALETTEENTRY* PaletteColors)
2476 AnimatePalette( HPALETTE_32(hpalette), StartIndex, NumEntries, PaletteColors );
2480 /***********************************************************************
2481 * ResizePalette (GDI.368)
2483 BOOL16 WINAPI ResizePalette16( HPALETTE16 hpalette, UINT16 cEntries )
2485 return ResizePalette( HPALETTE_32(hpalette), cEntries );
2489 /***********************************************************************
2490 * GetNearestPaletteIndex (GDI.370)
2492 UINT16 WINAPI GetNearestPaletteIndex16( HPALETTE16 hpalette, COLORREF color )
2494 return GetNearestPaletteIndex( HPALETTE_32(hpalette), color );
2498 /**********************************************************************
2499 * ExtFloodFill (GDI.372)
2501 BOOL16 WINAPI ExtFloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color,
2502 UINT16 fillType )
2504 return ExtFloodFill( HDC_32(hdc), x, y, color, fillType );
2508 /***********************************************************************
2509 * SetSystemPaletteUse (GDI.373)
2511 UINT16 WINAPI SetSystemPaletteUse16( HDC16 hdc, UINT16 use )
2513 return SetSystemPaletteUse( HDC_32(hdc), use );
2517 /***********************************************************************
2518 * GetSystemPaletteUse (GDI.374)
2520 UINT16 WINAPI GetSystemPaletteUse16( HDC16 hdc )
2522 return GetSystemPaletteUse( HDC_32(hdc) );
2526 /***********************************************************************
2527 * GetSystemPaletteEntries (GDI.375)
2529 UINT16 WINAPI GetSystemPaletteEntries16( HDC16 hdc, UINT16 start, UINT16 count,
2530 LPPALETTEENTRY entries )
2532 return GetSystemPaletteEntries( HDC_32(hdc), start, count, entries );
2536 /***********************************************************************
2537 * ResetDC (GDI.376)
2539 HDC16 WINAPI ResetDC16( HDC16 hdc, const DEVMODEA *devmode )
2541 return HDC_16( ResetDCA(HDC_32(hdc), devmode) );
2545 /******************************************************************
2546 * StartDoc (GDI.377)
2548 INT16 WINAPI StartDoc16( HDC16 hdc, const DOCINFO16 *lpdoc )
2550 DOCINFOA docA;
2552 docA.cbSize = lpdoc->cbSize;
2553 docA.lpszDocName = MapSL(lpdoc->lpszDocName);
2554 docA.lpszOutput = MapSL(lpdoc->lpszOutput);
2555 if(lpdoc->cbSize > offsetof(DOCINFO16,lpszDatatype))
2556 docA.lpszDatatype = MapSL(lpdoc->lpszDatatype);
2557 else
2558 docA.lpszDatatype = NULL;
2559 if(lpdoc->cbSize > offsetof(DOCINFO16,fwType))
2560 docA.fwType = lpdoc->fwType;
2561 else
2562 docA.fwType = 0;
2563 return StartDocA( HDC_32(hdc), &docA );
2567 /******************************************************************
2568 * EndDoc (GDI.378)
2570 INT16 WINAPI EndDoc16( HDC16 hdc )
2572 return EndDoc( HDC_32(hdc) );
2576 /******************************************************************
2577 * StartPage (GDI.379)
2579 INT16 WINAPI StartPage16( HDC16 hdc )
2581 return StartPage( HDC_32(hdc) );
2585 /******************************************************************
2586 * EndPage (GDI.380)
2588 INT16 WINAPI EndPage16( HDC16 hdc )
2590 return EndPage( HDC_32(hdc) );
2594 /******************************************************************************
2595 * AbortDoc (GDI.382)
2597 INT16 WINAPI AbortDoc16( HDC16 hdc )
2599 return AbortDoc( HDC_32(hdc) );
2603 /***********************************************************************
2604 * FastWindowFrame (GDI.400)
2606 BOOL16 WINAPI FastWindowFrame16( HDC16 hdc, const RECT16 *rect,
2607 INT16 width, INT16 height, DWORD rop )
2609 HDC hdc32 = HDC_32(hdc);
2610 HBRUSH hbrush = SelectObject( hdc32, GetStockObject( GRAY_BRUSH ) );
2611 PatBlt( hdc32, rect->left, rect->top,
2612 rect->right - rect->left - width, height, rop );
2613 PatBlt( hdc32, rect->left, rect->top + height, width,
2614 rect->bottom - rect->top - height, rop );
2615 PatBlt( hdc32, rect->left + width, rect->bottom - 1,
2616 rect->right - rect->left - width, -height, rop );
2617 PatBlt( hdc32, rect->right - 1, rect->top, -width,
2618 rect->bottom - rect->top - height, rop );
2619 SelectObject( hdc32, hbrush );
2620 return TRUE;
2624 /***********************************************************************
2625 * GdiInit2 (GDI.403)
2627 * See "Undocumented Windows"
2629 * PARAMS
2630 * h1 [I] GDI object
2631 * h2 [I] global data
2633 HANDLE16 WINAPI GdiInit216( HANDLE16 h1, HANDLE16 h2 )
2635 FIXME("(%04x, %04x), stub.\n", h1, h2);
2636 if (h2 == 0xffff) return 0xffff; /* undefined return value */
2637 return h1; /* FIXME: should be the memory handle of h1 */
2641 /***********************************************************************
2642 * FinalGdiInit (GDI.405)
2644 void WINAPI FinalGdiInit16( HBRUSH16 hPattern /* [in] fill pattern of desktop */ )
2649 /***********************************************************************
2650 * CreateUserBitmap (GDI.407)
2652 HBITMAP16 WINAPI CreateUserBitmap16( INT16 width, INT16 height, UINT16 planes,
2653 UINT16 bpp, LPCVOID bits )
2655 return CreateBitmap16( width, height, planes, bpp, bits );
2659 /***********************************************************************
2660 * CreateUserDiscardableBitmap (GDI.409)
2662 HBITMAP16 WINAPI CreateUserDiscardableBitmap16( WORD dummy, INT16 width, INT16 height )
2664 HDC hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
2665 HBITMAP ret = CreateCompatibleBitmap( hdc, width, height );
2666 DeleteDC( hdc );
2667 return HBITMAP_16(ret);
2671 /***********************************************************************
2672 * GetCurLogFont (GDI.411)
2674 HFONT16 WINAPI GetCurLogFont16( HDC16 hdc )
2676 return HFONT_16( GetCurrentObject( HDC_32(hdc), OBJ_FONT ) );
2680 /***********************************************************************
2681 * StretchDIBits (GDI.439)
2683 INT16 WINAPI StretchDIBits16( HDC16 hdc, INT16 xDst, INT16 yDst, INT16 widthDst,
2684 INT16 heightDst, INT16 xSrc, INT16 ySrc, INT16 widthSrc,
2685 INT16 heightSrc, const VOID *bits,
2686 const BITMAPINFO *info, UINT16 wUsage, DWORD dwRop )
2688 return StretchDIBits( HDC_32(hdc), xDst, yDst, widthDst, heightDst,
2689 xSrc, ySrc, widthSrc, heightSrc, bits,
2690 info, wUsage, dwRop );
2694 /***********************************************************************
2695 * SetDIBits (GDI.440)
2697 INT16 WINAPI SetDIBits16( HDC16 hdc, HBITMAP16 hbitmap, UINT16 startscan,
2698 UINT16 lines, LPCVOID bits, const BITMAPINFO *info,
2699 UINT16 coloruse )
2701 return SetDIBits( HDC_32(hdc), HBITMAP_32(hbitmap), startscan, lines, bits, info, coloruse );
2705 /***********************************************************************
2706 * GetDIBits (GDI.441)
2708 INT16 WINAPI GetDIBits16( HDC16 hdc, HBITMAP16 hbitmap, UINT16 startscan,
2709 UINT16 lines, LPVOID bits, BITMAPINFO * info,
2710 UINT16 coloruse )
2712 return GetDIBits( HDC_32(hdc), HBITMAP_32(hbitmap), startscan, lines, bits, info, coloruse );
2716 /***********************************************************************
2717 * CreateDIBitmap (GDI.442)
2719 HBITMAP16 WINAPI CreateDIBitmap16( HDC16 hdc, const BITMAPINFOHEADER * header,
2720 DWORD init, LPCVOID bits, const BITMAPINFO * data,
2721 UINT16 coloruse )
2723 return HBITMAP_16( CreateDIBitmap( HDC_32(hdc), header, init, bits, data, coloruse ) );
2727 /***********************************************************************
2728 * SetDIBitsToDevice (GDI.443)
2730 INT16 WINAPI SetDIBitsToDevice16( HDC16 hdc, INT16 xDest, INT16 yDest, INT16 cx,
2731 INT16 cy, INT16 xSrc, INT16 ySrc, UINT16 startscan,
2732 UINT16 lines, LPCVOID bits, const BITMAPINFO *info,
2733 UINT16 coloruse )
2735 return SetDIBitsToDevice( HDC_32(hdc), xDest, yDest, cx, cy, xSrc, ySrc,
2736 startscan, lines, bits, info, coloruse );
2740 /***********************************************************************
2741 * CreateRoundRectRgn (GDI.444)
2743 * If either ellipse dimension is zero we call CreateRectRgn16 for its
2744 * `special' behaviour. -ve ellipse dimensions can result in GPFs under win3.1
2745 * we just let CreateRoundRectRgn convert them to +ve values.
2748 HRGN16 WINAPI CreateRoundRectRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom,
2749 INT16 ellipse_width, INT16 ellipse_height )
2751 if( ellipse_width == 0 || ellipse_height == 0 )
2752 return CreateRectRgn16( left, top, right, bottom );
2753 else
2754 return HRGN_16( CreateRoundRectRgn( left, top, right, bottom,
2755 ellipse_width, ellipse_height ));
2759 /***********************************************************************
2760 * CreateDIBPatternBrush (GDI.445)
2762 HBRUSH16 WINAPI CreateDIBPatternBrush16( HGLOBAL16 hbitmap, UINT16 coloruse )
2764 BITMAPINFO *bmi;
2765 HBRUSH16 ret;
2767 if (!(bmi = GlobalLock16( hbitmap ))) return 0;
2768 ret = HBRUSH_16( CreateDIBPatternBrushPt( bmi, coloruse ));
2769 GlobalUnlock16( hbitmap );
2770 return ret;
2774 /**********************************************************************
2775 * PolyPolygon (GDI.450)
2777 BOOL16 WINAPI PolyPolygon16( HDC16 hdc, const POINT16* pt, const INT16* counts,
2778 UINT16 polygons )
2780 int i,nrpts;
2781 LPPOINT pt32;
2782 LPINT counts32;
2783 BOOL16 ret;
2785 nrpts=0;
2786 for (i=polygons;i--;)
2787 nrpts+=counts[i];
2788 pt32 = HeapAlloc( GetProcessHeap(), 0, sizeof(POINT)*nrpts);
2789 if(pt32 == NULL) return FALSE;
2790 for (i=nrpts;i--;)
2792 pt32[i].x = pt[i].x;
2793 pt32[i].y = pt[i].y;
2795 counts32 = HeapAlloc( GetProcessHeap(), 0, polygons*sizeof(INT) );
2796 if(counts32 == NULL) {
2797 HeapFree( GetProcessHeap(), 0, pt32 );
2798 return FALSE;
2800 for (i=polygons;i--;) counts32[i]=counts[i];
2802 ret = PolyPolygon(HDC_32(hdc),pt32,counts32,polygons);
2803 HeapFree( GetProcessHeap(), 0, counts32 );
2804 HeapFree( GetProcessHeap(), 0, pt32 );
2805 return ret;
2809 /***********************************************************************
2810 * CreatePolyPolygonRgn (GDI.451)
2812 HRGN16 WINAPI CreatePolyPolygonRgn16( const POINT16 *points,
2813 const INT16 *count, INT16 nbpolygons, INT16 mode )
2815 HRGN hrgn;
2816 int i, npts = 0;
2817 INT *count32;
2818 POINT *points32;
2820 for (i = 0; i < nbpolygons; i++) npts += count[i];
2821 points32 = HeapAlloc( GetProcessHeap(), 0, npts * sizeof(POINT) );
2822 for (i = 0; i < npts; i++)
2824 points32[i].x = points[i].x;
2825 points32[i].y = points[i].y;
2828 count32 = HeapAlloc( GetProcessHeap(), 0, nbpolygons * sizeof(INT) );
2829 for (i = 0; i < nbpolygons; i++) count32[i] = count[i];
2830 hrgn = CreatePolyPolygonRgn( points32, count32, nbpolygons, mode );
2831 HeapFree( GetProcessHeap(), 0, count32 );
2832 HeapFree( GetProcessHeap(), 0, points32 );
2833 return HRGN_16(hrgn);
2837 /***********************************************************************
2838 * GdiSeeGdiDo (GDI.452)
2840 DWORD WINAPI GdiSeeGdiDo16( WORD wReqType, WORD wParam1, WORD wParam2,
2841 WORD wParam3 )
2843 DWORD ret = ~0U;
2845 switch (wReqType)
2847 case 0x0001: /* LocalAlloc */
2848 WARN("LocalAlloc16(%x, %x): ignoring\n", wParam1, wParam3);
2849 ret = 0;
2850 break;
2851 case 0x0002: /* LocalFree */
2852 WARN("LocalFree16(%x): ignoring\n", wParam1);
2853 ret = 0;
2854 break;
2855 case 0x0003: /* LocalCompact */
2856 WARN("LocalCompact16(%x): ignoring\n", wParam3);
2857 ret = 65000; /* lie about the amount of free space */
2858 break;
2859 case 0x0103: /* LocalHeap */
2860 WARN("LocalHeap16(): ignoring\n");
2861 break;
2862 default:
2863 WARN("(wReqType=%04x): Unknown\n", wReqType);
2864 break;
2866 return ret;
2870 /***********************************************************************
2871 * SetObjectOwner (GDI.461)
2873 void WINAPI SetObjectOwner16( HGDIOBJ16 handle, HANDLE16 owner )
2875 /* Nothing to do */
2879 /***********************************************************************
2880 * IsGDIObject (GDI.462)
2882 * returns type of object if valid (W95 system programming secrets p. 264-5)
2884 BOOL16 WINAPI IsGDIObject16( HGDIOBJ16 handle16 )
2886 static const BYTE type_map[] =
2888 0, /* bad */
2889 1, /* OBJ_PEN */
2890 2, /* OBJ_BRUSH */
2891 7, /* OBJ_DC */
2892 9, /* OBJ_METADC */
2893 4, /* OBJ_PAL */
2894 3, /* OBJ_FONT */
2895 5, /* OBJ_BITMAP */
2896 6, /* OBJ_REGION */
2897 10, /* OBJ_METAFILE */
2898 7, /* OBJ_MEMDC */
2899 0, /* OBJ_EXTPEN */
2900 9, /* OBJ_ENHMETADC */
2901 12, /* OBJ_ENHMETAFILE */
2902 0 /* OBJ_COLORSPACE */
2905 UINT type = GetObjectType( HGDIOBJ_32( handle16 ));
2907 if (type >= sizeof(type_map)/sizeof(type_map[0])) return 0;
2908 return type_map[type];
2912 /***********************************************************************
2913 * RectVisible (GDI.465)
2914 * RectVisibleOld (GDI.104)
2916 BOOL16 WINAPI RectVisible16( HDC16 hdc, const RECT16* rect16 )
2918 RECT rect;
2920 rect.left = rect16->left;
2921 rect.top = rect16->top;
2922 rect.right = rect16->right;
2923 rect.bottom = rect16->bottom;
2924 return RectVisible( HDC_32(hdc), &rect );
2928 /***********************************************************************
2929 * RectInRegion (GDI.466)
2930 * RectInRegionOld (GDI.181)
2932 BOOL16 WINAPI RectInRegion16( HRGN16 hrgn, const RECT16 *rect )
2934 RECT r32;
2936 r32.left = rect->left;
2937 r32.top = rect->top;
2938 r32.right = rect->right;
2939 r32.bottom = rect->bottom;
2940 return RectInRegion( HRGN_32(hrgn), &r32 );
2944 /***********************************************************************
2945 * GetBitmapDimensionEx (GDI.468)
2947 BOOL16 WINAPI GetBitmapDimensionEx16( HBITMAP16 hbitmap, LPSIZE16 size )
2949 SIZE size32;
2950 BOOL ret = GetBitmapDimensionEx( HBITMAP_32(hbitmap), &size32 );
2952 if (ret)
2954 size->cx = size32.cx;
2955 size->cy = size32.cy;
2957 return ret;
2961 /***********************************************************************
2962 * GetBrushOrgEx (GDI.469)
2964 BOOL16 WINAPI GetBrushOrgEx16( HDC16 hdc, LPPOINT16 pt )
2966 POINT pt32;
2967 if (!GetBrushOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
2968 pt->x = pt32.x;
2969 pt->y = pt32.y;
2970 return TRUE;
2974 /***********************************************************************
2975 * GetCurrentPositionEx (GDI.470)
2977 BOOL16 WINAPI GetCurrentPositionEx16( HDC16 hdc, LPPOINT16 pt )
2979 POINT pt32;
2980 if (!GetCurrentPositionEx( HDC_32(hdc), &pt32 )) return FALSE;
2981 pt->x = pt32.x;
2982 pt->y = pt32.y;
2983 return TRUE;
2987 /***********************************************************************
2988 * GetTextExtentPoint (GDI.471)
2990 * FIXME: Should this have a bug for compatibility?
2991 * Original Windows versions of GetTextExtentPoint{A,W} have documented
2992 * bugs (-> MSDN KB q147647.txt).
2994 BOOL16 WINAPI GetTextExtentPoint16( HDC16 hdc, LPCSTR str, INT16 count, LPSIZE16 size )
2996 SIZE size32;
2997 BOOL ret = GetTextExtentPoint32A( HDC_32(hdc), str, count, &size32 );
2999 if (ret)
3001 size->cx = size32.cx;
3002 size->cy = size32.cy;
3004 return ret;
3008 /***********************************************************************
3009 * GetViewportExtEx (GDI.472)
3011 BOOL16 WINAPI GetViewportExtEx16( HDC16 hdc, LPSIZE16 size )
3013 SIZE size32;
3014 if (!GetViewportExtEx( HDC_32(hdc), &size32 )) return FALSE;
3015 size->cx = size32.cx;
3016 size->cy = size32.cy;
3017 return TRUE;
3021 /***********************************************************************
3022 * GetViewportOrgEx (GDI.473)
3024 BOOL16 WINAPI GetViewportOrgEx16( HDC16 hdc, LPPOINT16 pt )
3026 POINT pt32;
3027 if (!GetViewportOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
3028 pt->x = pt32.x;
3029 pt->y = pt32.y;
3030 return TRUE;
3034 /***********************************************************************
3035 * GetWindowExtEx (GDI.474)
3037 BOOL16 WINAPI GetWindowExtEx16( HDC16 hdc, LPSIZE16 size )
3039 SIZE size32;
3040 if (!GetWindowExtEx( HDC_32(hdc), &size32 )) return FALSE;
3041 size->cx = size32.cx;
3042 size->cy = size32.cy;
3043 return TRUE;
3047 /***********************************************************************
3048 * GetWindowOrgEx (GDI.475)
3050 BOOL16 WINAPI GetWindowOrgEx16( HDC16 hdc, LPPOINT16 pt )
3052 POINT pt32;
3053 if (!GetWindowOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
3054 pt->x = pt32.x;
3055 pt->y = pt32.y;
3056 return TRUE;
3060 /***********************************************************************
3061 * OffsetViewportOrgEx (GDI.476)
3063 BOOL16 WINAPI OffsetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt)
3065 POINT pt32;
3066 BOOL16 ret = OffsetViewportOrgEx( HDC_32(hdc), x, y, &pt32 );
3067 if (pt)
3069 pt->x = pt32.x;
3070 pt->y = pt32.y;
3072 return ret;
3076 /***********************************************************************
3077 * OffsetWindowOrgEx (GDI.477)
3079 BOOL16 WINAPI OffsetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
3081 POINT pt32;
3082 BOOL16 ret = OffsetWindowOrgEx( HDC_32(hdc), x, y, &pt32 );
3083 if (pt)
3085 pt->x = pt32.x;
3086 pt->y = pt32.y;
3088 return ret;
3092 /***********************************************************************
3093 * SetBitmapDimensionEx (GDI.478)
3095 BOOL16 WINAPI SetBitmapDimensionEx16( HBITMAP16 hbitmap, INT16 x, INT16 y, LPSIZE16 prevSize )
3097 SIZE size32;
3098 BOOL ret = SetBitmapDimensionEx( HBITMAP_32(hbitmap), x, y, &size32 );
3100 if (ret && prevSize)
3102 prevSize->cx = size32.cx;
3103 prevSize->cy = size32.cy;
3105 return ret;
3109 /***********************************************************************
3110 * SetViewportExtEx (GDI.479)
3112 BOOL16 WINAPI SetViewportExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
3114 SIZE size32;
3115 BOOL16 ret = SetViewportExtEx( HDC_32(hdc), x, y, &size32 );
3116 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
3117 return ret;
3121 /***********************************************************************
3122 * SetViewportOrgEx (GDI.480)
3124 BOOL16 WINAPI SetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
3126 POINT pt32;
3127 BOOL16 ret = SetViewportOrgEx( HDC_32(hdc), x, y, &pt32 );
3128 if (pt)
3130 pt->x = pt32.x;
3131 pt->y = pt32.y;
3133 return ret;
3137 /***********************************************************************
3138 * SetWindowExtEx (GDI.481)
3140 BOOL16 WINAPI SetWindowExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
3142 SIZE size32;
3143 BOOL16 ret = SetWindowExtEx( HDC_32(hdc), x, y, &size32 );
3144 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
3145 return ret;
3149 /***********************************************************************
3150 * SetWindowOrgEx (GDI.482)
3152 BOOL16 WINAPI SetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
3154 POINT pt32;
3155 BOOL16 ret = SetWindowOrgEx( HDC_32(hdc), x, y, &pt32 );
3156 if (pt)
3158 pt->x = pt32.x;
3159 pt->y = pt32.y;
3161 return ret;
3165 /***********************************************************************
3166 * MoveToEx (GDI.483)
3168 BOOL16 WINAPI MoveToEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
3170 POINT pt32;
3172 if (!MoveToEx( HDC_32(hdc), x, y, &pt32 )) return FALSE;
3173 if (pt)
3175 pt->x = pt32.x;
3176 pt->y = pt32.y;
3178 return TRUE;
3182 /***********************************************************************
3183 * ScaleViewportExtEx (GDI.484)
3185 BOOL16 WINAPI ScaleViewportExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
3186 INT16 yNum, INT16 yDenom, LPSIZE16 size )
3188 SIZE size32;
3189 BOOL16 ret = ScaleViewportExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom,
3190 &size32 );
3191 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
3192 return ret;
3196 /***********************************************************************
3197 * ScaleWindowExtEx (GDI.485)
3199 BOOL16 WINAPI ScaleWindowExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
3200 INT16 yNum, INT16 yDenom, LPSIZE16 size )
3202 SIZE size32;
3203 BOOL16 ret = ScaleWindowExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom,
3204 &size32 );
3205 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
3206 return ret;
3210 /***********************************************************************
3211 * GetAspectRatioFilterEx (GDI.486)
3213 BOOL16 WINAPI GetAspectRatioFilterEx16( HDC16 hdc, LPSIZE16 pAspectRatio )
3215 FIXME("(%04x, %p): -- Empty Stub !\n", hdc, pAspectRatio);
3216 return FALSE;
3220 /******************************************************************************
3221 * PolyBezier (GDI.502)
3223 BOOL16 WINAPI PolyBezier16( HDC16 hdc, const POINT16* lppt, INT16 cPoints )
3225 int i;
3226 BOOL16 ret;
3227 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, cPoints*sizeof(POINT) );
3228 if(!pt32) return FALSE;
3229 for (i=cPoints;i--;)
3231 pt32[i].x = lppt[i].x;
3232 pt32[i].y = lppt[i].y;
3234 ret= PolyBezier(HDC_32(hdc), pt32, cPoints);
3235 HeapFree( GetProcessHeap(), 0, pt32 );
3236 return ret;
3240 /******************************************************************************
3241 * PolyBezierTo (GDI.503)
3243 BOOL16 WINAPI PolyBezierTo16( HDC16 hdc, const POINT16* lppt, INT16 cPoints )
3245 int i;
3246 BOOL16 ret;
3247 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0,
3248 cPoints*sizeof(POINT) );
3249 if(!pt32) return FALSE;
3250 for (i=cPoints;i--;)
3252 pt32[i].x = lppt[i].x;
3253 pt32[i].y = lppt[i].y;
3255 ret= PolyBezierTo(HDC_32(hdc), pt32, cPoints);
3256 HeapFree( GetProcessHeap(), 0, pt32 );
3257 return ret;
3261 /******************************************************************************
3262 * ExtSelectClipRgn (GDI.508)
3264 INT16 WINAPI ExtSelectClipRgn16( HDC16 hdc, HRGN16 hrgn, INT16 fnMode )
3266 return ExtSelectClipRgn( HDC_32(hdc), HRGN_32(hrgn), fnMode);
3270 /***********************************************************************
3271 * AbortPath (GDI.511)
3273 BOOL16 WINAPI AbortPath16(HDC16 hdc)
3275 return AbortPath( HDC_32(hdc) );
3279 /***********************************************************************
3280 * BeginPath (GDI.512)
3282 BOOL16 WINAPI BeginPath16(HDC16 hdc)
3284 return BeginPath( HDC_32(hdc) );
3288 /***********************************************************************
3289 * CloseFigure (GDI.513)
3291 BOOL16 WINAPI CloseFigure16(HDC16 hdc)
3293 return CloseFigure( HDC_32(hdc) );
3297 /***********************************************************************
3298 * EndPath (GDI.514)
3300 BOOL16 WINAPI EndPath16(HDC16 hdc)
3302 return EndPath( HDC_32(hdc) );
3306 /***********************************************************************
3307 * FillPath (GDI.515)
3309 BOOL16 WINAPI FillPath16(HDC16 hdc)
3311 return FillPath( HDC_32(hdc) );
3315 /*******************************************************************
3316 * FlattenPath (GDI.516)
3318 BOOL16 WINAPI FlattenPath16(HDC16 hdc)
3320 return FlattenPath( HDC_32(hdc) );
3324 /***********************************************************************
3325 * GetPath (GDI.517)
3327 INT16 WINAPI GetPath16(HDC16 hdc, LPPOINT16 pPoints, LPBYTE pTypes, INT16 nSize)
3329 FIXME("(%d,%p,%p): stub\n",hdc,pPoints,pTypes);
3330 return 0;
3334 /***********************************************************************
3335 * PathToRegion (GDI.518)
3337 HRGN16 WINAPI PathToRegion16(HDC16 hdc)
3339 return HRGN_16( PathToRegion( HDC_32(hdc) ));
3343 /***********************************************************************
3344 * SelectClipPath (GDI.519)
3346 BOOL16 WINAPI SelectClipPath16(HDC16 hdc, INT16 iMode)
3348 return SelectClipPath( HDC_32(hdc), iMode );
3352 /*******************************************************************
3353 * StrokeAndFillPath (GDI.520)
3355 BOOL16 WINAPI StrokeAndFillPath16(HDC16 hdc)
3357 return StrokeAndFillPath( HDC_32(hdc) );
3361 /*******************************************************************
3362 * StrokePath (GDI.521)
3364 BOOL16 WINAPI StrokePath16(HDC16 hdc)
3366 return StrokePath( HDC_32(hdc) );
3370 /*******************************************************************
3371 * WidenPath (GDI.522)
3373 BOOL16 WINAPI WidenPath16(HDC16 hdc)
3375 return WidenPath( HDC_32(hdc) );
3379 /***********************************************************************
3380 * GetArcDirection (GDI.524)
3382 INT16 WINAPI GetArcDirection16( HDC16 hdc )
3384 return GetArcDirection( HDC_32(hdc) );
3388 /***********************************************************************
3389 * SetArcDirection (GDI.525)
3391 INT16 WINAPI SetArcDirection16( HDC16 hdc, INT16 nDirection )
3393 return SetArcDirection( HDC_32(hdc), (INT)nDirection );
3397 /***********************************************************************
3398 * CreateHalftonePalette (GDI.529)
3400 HPALETTE16 WINAPI CreateHalftonePalette16( HDC16 hdc )
3402 return HPALETTE_16( CreateHalftonePalette( HDC_32(hdc) ));
3406 /***********************************************************************
3407 * SetDIBColorTable (GDI.602)
3409 UINT16 WINAPI SetDIBColorTable16( HDC16 hdc, UINT16 startpos, UINT16 entries, RGBQUAD *colors )
3411 return SetDIBColorTable( HDC_32(hdc), startpos, entries, colors );
3415 /***********************************************************************
3416 * GetDIBColorTable (GDI.603)
3418 UINT16 WINAPI GetDIBColorTable16( HDC16 hdc, UINT16 startpos, UINT16 entries, RGBQUAD *colors )
3420 return GetDIBColorTable( HDC_32(hdc), startpos, entries, colors );
3424 /***********************************************************************
3425 * GetRegionData (GDI.607)
3427 * FIXME: is LPRGNDATA the same in Win16 and Win32 ?
3429 DWORD WINAPI GetRegionData16( HRGN16 hrgn, DWORD count, LPRGNDATA rgndata )
3431 return GetRegionData( HRGN_32(hrgn), count, rgndata );
3435 /***********************************************************************
3436 * GdiFreeResources (GDI.609)
3438 WORD WINAPI GdiFreeResources16( DWORD reserve )
3440 return 90; /* lie about it, it shouldn't matter */
3444 /***********************************************************************
3445 * GdiSignalProc32 (GDI.610)
3447 WORD WINAPI GdiSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
3448 DWORD dwFlags, HMODULE16 hModule )
3450 return 0;
3454 /***********************************************************************
3455 * GetTextCharset (GDI.612)
3457 UINT16 WINAPI GetTextCharset16( HDC16 hdc )
3459 return GetTextCharset( HDC_32(hdc) );
3463 /***********************************************************************
3464 * EnumFontFamiliesEx (GDI.613)
3466 INT16 WINAPI EnumFontFamiliesEx16( HDC16 hdc, LPLOGFONT16 plf,
3467 FONTENUMPROC16 proc, LPARAM lParam,
3468 DWORD dwFlags)
3470 struct callback16_info info;
3471 LOGFONTW lfW, *plfW;
3473 info.proc = (FARPROC16)proc;
3474 info.param = lParam;
3476 if (plf)
3478 logfont_16_to_W(plf, &lfW);
3479 plfW = &lfW;
3481 else plfW = NULL;
3483 return EnumFontFamiliesExW( HDC_32(hdc), plfW, enum_font_callback,
3484 (LPARAM)&info, dwFlags );
3488 /*************************************************************************
3489 * GetFontLanguageInfo (GDI.616)
3491 DWORD WINAPI GetFontLanguageInfo16( HDC16 hdc )
3493 return GetFontLanguageInfo( HDC_32(hdc) );
3497 /***********************************************************************
3498 * SetLayout (GDI.1000)
3500 * Sets left->right or right->left text layout flags of a dc.
3502 BOOL16 WINAPI SetLayout16( HDC16 hdc, DWORD layout )
3504 return SetLayout( HDC_32(hdc), layout );
3508 /***********************************************************************
3509 * SetSolidBrush (GDI.604)
3511 * Change the color of a solid brush.
3513 * PARAMS
3514 * hBrush [I] Brush to change the color of
3515 * newColor [I] New color for hBrush
3517 * RETURNS
3518 * Success: TRUE. The color of hBrush is set to newColor.
3519 * Failure: FALSE.
3521 * FIXME
3522 * This function is undocumented and untested. The implementation may
3523 * not be correct.
3525 BOOL16 WINAPI SetSolidBrush16(HBRUSH16 hBrush, COLORREF newColor )
3527 FIXME( "%04x %08x no longer supported\n", hBrush, newColor );
3528 return FALSE;
3532 /***********************************************************************
3533 * Copy (GDI.250)
3535 void WINAPI Copy16( LPVOID src, LPVOID dst, WORD size )
3537 memcpy( dst, src, size );
3540 /***********************************************************************
3541 * RealizeDefaultPalette (GDI.365)
3543 UINT16 WINAPI RealizeDefaultPalette16( HDC16 hdc )
3545 FIXME( "%04x semi-stub\n", hdc );
3546 return GDIRealizePalette16( hdc );
3549 /***********************************************************************
3550 * IsDCCurrentPalette (GDI.412)
3552 BOOL16 WINAPI IsDCCurrentPalette16(HDC16 hDC)
3554 return HPALETTE_16( GetCurrentObject( HDC_32(hDC), OBJ_PAL )) == hPrimaryPalette;
3557 /*********************************************************************
3558 * SetMagicColors (GDI.606)
3560 VOID WINAPI SetMagicColors16(HDC16 hDC, COLORREF color, UINT16 index)
3562 FIXME("(hDC %04x, color %04x, index %04x): stub\n", hDC, (int)color, index);
3567 /***********************************************************************
3568 * DPtoLP (GDI.67)
3570 BOOL16 WINAPI DPtoLP16( HDC16 hdc, LPPOINT16 points, INT16 count )
3572 POINT points32[8], *pt32 = points32;
3573 int i;
3574 BOOL ret;
3576 if (count > 8)
3578 if (!(pt32 = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*pt32) ))) return FALSE;
3580 for (i = 0; i < count; i++)
3582 pt32[i].x = points[i].x;
3583 pt32[i].y = points[i].y;
3585 if ((ret = DPtoLP( HDC_32(hdc), pt32, count )))
3587 for (i = 0; i < count; i++)
3589 points[i].x = pt32[i].x;
3590 points[i].y = pt32[i].y;
3593 if (pt32 != points32) HeapFree( GetProcessHeap(), 0, pt32 );
3594 return ret;
3598 /***********************************************************************
3599 * LPtoDP (GDI.99)
3601 BOOL16 WINAPI LPtoDP16( HDC16 hdc, LPPOINT16 points, INT16 count )
3603 POINT points32[8], *pt32 = points32;
3604 int i;
3605 BOOL ret;
3607 if (count > 8)
3609 if (!(pt32 = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*pt32) ))) return FALSE;
3611 for (i = 0; i < count; i++)
3613 pt32[i].x = points[i].x;
3614 pt32[i].y = points[i].y;
3616 if ((ret = LPtoDP( HDC_32(hdc), pt32, count )))
3618 for (i = 0; i < count; i++)
3620 points[i].x = pt32[i].x;
3621 points[i].y = pt32[i].y;
3624 if (pt32 != points32) HeapFree( GetProcessHeap(), 0, pt32 );
3625 return ret;
3629 /***********************************************************************
3630 * GetDCState (GDI.179)
3632 HDC16 WINAPI GetDCState16( HDC16 hdc )
3634 ERR( "no longer supported\n" );
3635 return 0;
3639 /***********************************************************************
3640 * SetDCState (GDI.180)
3642 void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs )
3644 ERR( "no longer supported\n" );
3647 /***********************************************************************
3648 * SetDCOrg (GDI.117)
3650 DWORD WINAPI SetDCOrg16( HDC16 hdc16, INT16 x, INT16 y )
3652 FIXME( "%04x %d,%d no longer supported\n", hdc16, x, y );
3653 return 0;
3657 /***********************************************************************
3658 * InquireVisRgn (GDI.131)
3660 HRGN16 WINAPI InquireVisRgn16( HDC16 hdc )
3662 static HRGN hrgn;
3664 if (!hrgn) hrgn = CreateRectRgn( 0, 0, 0, 0 );
3665 GetRandomRgn( HDC_32(hdc), hrgn, SYSRGN );
3666 return HRGN_16(hrgn);
3670 /***********************************************************************
3671 * OffsetVisRgn (GDI.102)
3673 INT16 WINAPI OffsetVisRgn16( HDC16 hdc16, INT16 x, INT16 y )
3675 FIXME( "%04x %d,%d no longer supported\n", hdc16, x, y );
3676 return ERROR;
3680 /***********************************************************************
3681 * ExcludeVisRect (GDI.73)
3683 INT16 WINAPI ExcludeVisRect16( HDC16 hdc16, INT16 left, INT16 top, INT16 right, INT16 bottom )
3685 FIXME( "%04x %d,%d-%d,%d no longer supported\n", hdc16, left, top, right, bottom );
3686 return ERROR;
3690 /***********************************************************************
3691 * IntersectVisRect (GDI.98)
3693 INT16 WINAPI IntersectVisRect16( HDC16 hdc16, INT16 left, INT16 top, INT16 right, INT16 bottom )
3695 FIXME( "%04x %d,%d-%d,%d no longer supported\n", hdc16, left, top, right, bottom );
3696 return ERROR;
3700 /***********************************************************************
3701 * SaveVisRgn (GDI.129)
3703 HRGN16 WINAPI SaveVisRgn16( HDC16 hdc16 )
3705 struct saved_visrgn *saved;
3706 HDC hdc = HDC_32( hdc16 );
3708 TRACE("%p\n", hdc );
3710 if (!(saved = HeapAlloc( GetProcessHeap(), 0, sizeof(*saved) ))) return 0;
3711 if (!(saved->hrgn = CreateRectRgn( 0, 0, 0, 0 )))
3713 HeapFree( GetProcessHeap(), 0, saved );
3714 return 0;
3716 saved->hdc = hdc;
3717 GetRandomRgn( hdc, saved->hrgn, SYSRGN );
3718 list_add_head( &saved_regions, &saved->entry );
3719 return HRGN_16(saved->hrgn);
3723 /***********************************************************************
3724 * RestoreVisRgn (GDI.130)
3726 INT16 WINAPI RestoreVisRgn16( HDC16 hdc16 )
3728 struct saved_visrgn *saved;
3729 HDC hdc = HDC_32( hdc16 );
3730 INT16 ret = ERROR;
3732 TRACE("%p\n", hdc );
3734 LIST_FOR_EACH_ENTRY( saved, &saved_regions, struct saved_visrgn, entry )
3736 if (saved->hdc != hdc) continue;
3737 ret = SelectVisRgn( hdc, saved->hrgn );
3738 list_remove( &saved->entry );
3739 DeleteObject( saved->hrgn );
3740 HeapFree( GetProcessHeap(), 0, saved );
3741 break;
3743 return ret;
3747 /***********************************************************************
3748 * GetClipRgn (GDI.173)
3750 HRGN16 WINAPI GetClipRgn16( HDC16 hdc )
3752 static HRGN hrgn;
3754 if (!hrgn) hrgn = CreateRectRgn( 0, 0, 0, 0 );
3755 GetClipRgn( HDC_32(hdc), hrgn );
3756 return HRGN_16(hrgn);
3760 /***********************************************************************
3761 * MakeObjectPrivate (GDI.463)
3763 * What does that mean ?
3764 * Some little docu can be found in "Undocumented Windows",
3765 * but this is basically useless.
3767 void WINAPI MakeObjectPrivate16( HGDIOBJ16 handle16, BOOL16 private )
3769 FIXME( "stub: %x %u\n", handle16, private );
3772 /***********************************************************************
3773 * CreateDIBSection (GDI.489)
3775 HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, const BITMAPINFO *bmi, UINT16 usage,
3776 SEGPTR *bits16, HANDLE section, DWORD offset)
3778 LPVOID bits32;
3779 HBITMAP hbitmap;
3781 hbitmap = CreateDIBSection( HDC_32(hdc), bmi, usage, &bits32, section, offset );
3782 if (hbitmap && bits32 && bits16) *bits16 = alloc_segptr_bits( hbitmap, bits32 );
3783 return HBITMAP_16(hbitmap);