win32u: Use NtGdiDdDDICreateDCFromMemory for gdi16 DIBDRV.
[wine.git] / dlls / gdi.exe16 / gdi.c
blobc634f0739c7e0eadd6ca70276477b2001885203e
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>
22 #include <stdlib.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "ntgdi.h"
27 #include "wownt32.h"
28 #include "wine/wingdi16.h"
29 #include "wine/list.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
34 #define HGDIOBJ_32(handle16) ((HGDIOBJ)(ULONG_PTR)(handle16))
35 #define HGDIOBJ_16(handle32) ((HGDIOBJ16)(ULONG_PTR)(handle32))
37 struct saved_visrgn
39 struct list entry;
40 HDC hdc;
41 HRGN hrgn;
44 static struct list saved_regions = LIST_INIT( saved_regions );
46 struct saved_bitmap
48 struct list entry;
49 HDC hdc;
50 HBITMAP hbitmap;
53 static struct list saved_bitmaps = LIST_INIT( saved_bitmaps );
55 static HPALETTE16 hPrimaryPalette;
58 * ############################################################################
61 #include <pshpack1.h>
62 #define GDI_MAX_THUNKS 32
64 static struct gdi_thunk
66 BYTE popl_eax; /* popl %eax (return address) */
67 BYTE pushl_pfn16; /* pushl pfn16 */
68 DWORD pfn16; /* pfn16 */
69 BYTE pushl_eax; /* pushl %eax */
70 BYTE jmp; /* ljmp GDI_Callback3216 */
71 DWORD callback;
72 HDC16 hdc;
73 } *GDI_Thunks;
75 #include <poppack.h>
77 /**********************************************************************
78 * GDI_Callback3216
80 static BOOL CALLBACK GDI_Callback3216( DWORD pfn16, HDC hdc, INT code )
82 if (pfn16)
84 WORD args[2];
85 DWORD ret;
87 args[1] = HDC_16(hdc);
88 args[0] = code;
89 WOWCallback16Ex( pfn16, WCB16_PASCAL, sizeof(args), args, &ret );
90 return LOWORD(ret);
92 return TRUE;
96 /******************************************************************
97 * GDI_AddThunk
100 static struct gdi_thunk* GDI_AddThunk(HDC16 dc16, ABORTPROC16 pfn16)
102 struct gdi_thunk* thunk;
104 if (!GDI_Thunks)
106 GDI_Thunks = VirtualAlloc(NULL, GDI_MAX_THUNKS * sizeof(*GDI_Thunks),
107 MEM_COMMIT, PAGE_EXECUTE_READWRITE);
108 if (!GDI_Thunks)
110 return NULL;
112 for (thunk = GDI_Thunks; thunk < &GDI_Thunks[GDI_MAX_THUNKS]; thunk++)
114 thunk->popl_eax = 0x58; /* popl %eax */
115 thunk->pushl_pfn16 = 0x68; /* pushl pfn16 */
116 thunk->pfn16 = 0;
117 thunk->pushl_eax = 0x50; /* pushl %eax */
118 thunk->jmp = 0xe9; /* jmp GDI_Callback3216 */
119 thunk->callback = (char *)GDI_Callback3216 - (char *)(&thunk->callback + 1);
122 for (thunk = GDI_Thunks; thunk < &GDI_Thunks[GDI_MAX_THUNKS]; thunk++)
124 if (thunk->pfn16 == 0)
126 thunk->pfn16 = (DWORD)pfn16;
127 thunk->hdc = dc16;
128 return thunk;
131 FIXME("Out of mmdrv-thunks. Bump GDI_MAX_THUNKS\n");
132 return NULL;
135 /******************************************************************
136 * GDI_DeleteThunk
138 static void GDI_DeleteThunk(struct gdi_thunk* thunk)
140 thunk->pfn16 = 0;
143 /******************************************************************
144 * GDI_FindThunk
146 static struct gdi_thunk* GDI_FindThunk(HDC16 hdc)
148 struct gdi_thunk* thunk;
150 if (!GDI_Thunks) return NULL;
151 for (thunk = GDI_Thunks; thunk < &GDI_Thunks[GDI_MAX_THUNKS]; thunk++)
153 if (thunk->hdc == hdc) return thunk;
155 return NULL;
158 /**********************************************************************
159 * QueryAbort (GDI.155)
161 * Calls the app's AbortProc function if avail.
163 * RETURNS
164 * TRUE if no AbortProc avail or AbortProc wants to continue printing.
165 * FALSE if AbortProc wants to abort printing.
167 BOOL16 WINAPI QueryAbort16(HDC16 hdc16, INT16 reserved)
169 struct gdi_thunk* thunk = GDI_FindThunk(hdc16);
171 if (!thunk) {
172 ERR("Invalid hdc 0x%x\n", hdc16);
173 return FALSE;
175 return GDI_Callback3216( thunk->pfn16, HDC_32(hdc16), 0 );
179 /**********************************************************************
180 * SetAbortProc (GDI.381)
182 INT16 WINAPI SetAbortProc16(HDC16 hdc16, ABORTPROC16 abrtprc)
184 struct gdi_thunk* thunk;
186 thunk = GDI_AddThunk(hdc16, abrtprc);
187 if (!thunk) return FALSE;
188 if (!SetAbortProc(HDC_32( hdc16 ), (ABORTPROC)thunk))
190 GDI_DeleteThunk(thunk);
191 return FALSE;
193 return TRUE;
197 * ############################################################################
200 struct callback16_info
202 FARPROC16 proc;
203 LPARAM param;
206 /* callback for LineDDA16 */
207 static void CALLBACK linedda_callback( INT x, INT y, LPARAM param )
209 const struct callback16_info *info = (struct callback16_info *)param;
210 WORD args[4];
212 args[3] = x;
213 args[2] = y;
214 args[1] = HIWORD(info->param);
215 args[0] = LOWORD(info->param);
216 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, NULL );
219 /* callback for EnumObjects16 */
220 static INT CALLBACK enum_pens_callback( void *ptr, LPARAM param )
222 const struct callback16_info *info = (struct callback16_info *)param;
223 LOGPEN *pen = ptr;
224 LOGPEN16 pen16;
225 SEGPTR segptr;
226 DWORD ret;
227 WORD args[4];
229 pen16.lopnStyle = pen->lopnStyle;
230 pen16.lopnWidth.x = pen->lopnWidth.x;
231 pen16.lopnWidth.y = pen->lopnWidth.y;
232 pen16.lopnColor = pen->lopnColor;
233 segptr = MapLS( &pen16 );
234 args[3] = SELECTOROF(segptr);
235 args[2] = OFFSETOF(segptr);
236 args[1] = HIWORD(info->param);
237 args[0] = LOWORD(info->param);
238 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
239 UnMapLS( segptr );
240 return LOWORD(ret);
243 /* callback for EnumObjects16 */
244 static INT CALLBACK enum_brushes_callback( void *ptr, LPARAM param )
246 const struct callback16_info *info = (struct callback16_info *)param;
247 LOGBRUSH *brush = ptr;
248 LOGBRUSH16 brush16;
249 SEGPTR segptr;
250 DWORD ret;
251 WORD args[4];
253 brush16.lbStyle = brush->lbStyle;
254 brush16.lbColor = brush->lbColor;
255 brush16.lbHatch = brush->lbHatch;
256 segptr = MapLS( &brush16 );
257 args[3] = SELECTOROF(segptr);
258 args[2] = OFFSETOF(segptr);
259 args[1] = HIWORD(info->param);
260 args[0] = LOWORD(info->param);
261 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
262 UnMapLS( segptr );
263 return ret;
266 /* convert a LOGFONT16 to a LOGFONTW */
267 static void logfont_16_to_W( const LOGFONT16 *font16, LPLOGFONTW font32 )
269 font32->lfHeight = font16->lfHeight;
270 font32->lfWidth = font16->lfWidth;
271 font32->lfEscapement = font16->lfEscapement;
272 font32->lfOrientation = font16->lfOrientation;
273 font32->lfWeight = font16->lfWeight;
274 font32->lfItalic = font16->lfItalic;
275 font32->lfUnderline = font16->lfUnderline;
276 font32->lfStrikeOut = font16->lfStrikeOut;
277 font32->lfCharSet = font16->lfCharSet;
278 font32->lfOutPrecision = font16->lfOutPrecision;
279 font32->lfClipPrecision = font16->lfClipPrecision;
280 font32->lfQuality = font16->lfQuality;
281 font32->lfPitchAndFamily = font16->lfPitchAndFamily;
282 MultiByteToWideChar( CP_ACP, 0, font16->lfFaceName, -1, font32->lfFaceName, LF_FACESIZE );
283 font32->lfFaceName[LF_FACESIZE-1] = 0;
286 /* convert a LOGFONTW to a LOGFONT16 */
287 static void logfont_W_to_16( const LOGFONTW* font32, LPLOGFONT16 font16 )
289 font16->lfHeight = font32->lfHeight;
290 font16->lfWidth = font32->lfWidth;
291 font16->lfEscapement = font32->lfEscapement;
292 font16->lfOrientation = font32->lfOrientation;
293 font16->lfWeight = font32->lfWeight;
294 font16->lfItalic = font32->lfItalic;
295 font16->lfUnderline = font32->lfUnderline;
296 font16->lfStrikeOut = font32->lfStrikeOut;
297 font16->lfCharSet = font32->lfCharSet;
298 font16->lfOutPrecision = font32->lfOutPrecision;
299 font16->lfClipPrecision = font32->lfClipPrecision;
300 font16->lfQuality = font32->lfQuality;
301 font16->lfPitchAndFamily = font32->lfPitchAndFamily;
302 WideCharToMultiByte( CP_ACP, 0, font32->lfFaceName, -1, font16->lfFaceName, LF_FACESIZE, NULL, NULL );
303 font16->lfFaceName[LF_FACESIZE-1] = 0;
306 /* convert a ENUMLOGFONTEXW to a ENUMLOGFONTEX16 */
307 static void enumlogfontex_W_to_16( const ENUMLOGFONTEXW *fontW,
308 LPENUMLOGFONTEX16 font16 )
310 logfont_W_to_16( (const LOGFONTW *)fontW, (LPLOGFONT16)font16);
312 WideCharToMultiByte( CP_ACP, 0, fontW->elfFullName, -1,
313 (LPSTR) font16->elfFullName, LF_FULLFACESIZE, NULL, NULL );
314 font16->elfFullName[LF_FULLFACESIZE-1] = '\0';
315 WideCharToMultiByte( CP_ACP, 0, fontW->elfStyle, -1,
316 (LPSTR) font16->elfStyle, LF_FACESIZE, NULL, NULL );
317 font16->elfStyle[LF_FACESIZE-1] = '\0';
318 WideCharToMultiByte( CP_ACP, 0, fontW->elfScript, -1,
319 (LPSTR) font16->elfScript, LF_FACESIZE, NULL, NULL );
320 font16->elfScript[LF_FACESIZE-1] = '\0';
323 /* convert a NEWTEXTMETRICEXW to a NEWTEXTMETRICEX16 */
324 static void newtextmetricex_W_to_16( const NEWTEXTMETRICEXW *ptmW,
325 LPNEWTEXTMETRICEX16 ptm16 )
327 ptm16->ntmTm.tmHeight = ptmW->ntmTm.tmHeight;
328 ptm16->ntmTm.tmAscent = ptmW->ntmTm.tmAscent;
329 ptm16->ntmTm.tmDescent = ptmW->ntmTm.tmDescent;
330 ptm16->ntmTm.tmInternalLeading = ptmW->ntmTm.tmInternalLeading;
331 ptm16->ntmTm.tmExternalLeading = ptmW->ntmTm.tmExternalLeading;
332 ptm16->ntmTm.tmAveCharWidth = ptmW->ntmTm.tmAveCharWidth;
333 ptm16->ntmTm.tmMaxCharWidth = ptmW->ntmTm.tmMaxCharWidth;
334 ptm16->ntmTm.tmWeight = ptmW->ntmTm.tmWeight;
335 ptm16->ntmTm.tmOverhang = ptmW->ntmTm.tmOverhang;
336 ptm16->ntmTm.tmDigitizedAspectX = ptmW->ntmTm.tmDigitizedAspectX;
337 ptm16->ntmTm.tmDigitizedAspectY = ptmW->ntmTm.tmDigitizedAspectY;
338 ptm16->ntmTm.tmFirstChar = ptmW->ntmTm.tmFirstChar > 255 ? 255 : ptmW->ntmTm.tmFirstChar;
339 ptm16->ntmTm.tmLastChar = ptmW->ntmTm.tmLastChar > 255 ? 255 : ptmW->ntmTm.tmLastChar;
340 ptm16->ntmTm.tmDefaultChar = ptmW->ntmTm.tmDefaultChar > 255 ? 255 : ptmW->ntmTm.tmDefaultChar;
341 ptm16->ntmTm.tmBreakChar = ptmW->ntmTm.tmBreakChar > 255 ? 255 : ptmW->ntmTm.tmBreakChar;
342 ptm16->ntmTm.tmItalic = ptmW->ntmTm.tmItalic;
343 ptm16->ntmTm.tmUnderlined = ptmW->ntmTm.tmUnderlined;
344 ptm16->ntmTm.tmStruckOut = ptmW->ntmTm.tmStruckOut;
345 ptm16->ntmTm.tmPitchAndFamily = ptmW->ntmTm.tmPitchAndFamily;
346 ptm16->ntmTm.tmCharSet = ptmW->ntmTm.tmCharSet;
347 ptm16->ntmTm.ntmFlags = ptmW->ntmTm.ntmFlags;
348 ptm16->ntmTm.ntmSizeEM = ptmW->ntmTm.ntmSizeEM;
349 ptm16->ntmTm.ntmCellHeight = ptmW->ntmTm.ntmCellHeight;
350 ptm16->ntmTm.ntmAvgWidth = ptmW->ntmTm.ntmAvgWidth;
351 ptm16->ntmFontSig = ptmW->ntmFontSig;
355 * callback for EnumFontFamiliesEx16
356 * Note: plf is really an ENUMLOGFONTEXW, and ptm is a NEWTEXTMETRICEXW.
357 * We have to use other types because of the FONTENUMPROCW definition.
359 static INT CALLBACK enum_font_callback( const LOGFONTW *plf,
360 const TEXTMETRICW *ptm, DWORD fType,
361 LPARAM param )
363 const struct callback16_info *info = (struct callback16_info *)param;
364 ENUMLOGFONTEX16 elfe16;
365 NEWTEXTMETRICEX16 ntm16;
366 SEGPTR segelfe16;
367 SEGPTR segntm16;
368 WORD args[7];
369 DWORD ret;
371 enumlogfontex_W_to_16((const ENUMLOGFONTEXW *)plf, &elfe16);
372 newtextmetricex_W_to_16((const NEWTEXTMETRICEXW *)ptm, &ntm16);
373 segelfe16 = MapLS( &elfe16 );
374 segntm16 = MapLS( &ntm16 );
375 args[6] = SELECTOROF(segelfe16);
376 args[5] = OFFSETOF(segelfe16);
377 args[4] = SELECTOROF(segntm16);
378 args[3] = OFFSETOF(segntm16);
379 args[2] = fType;
380 args[1] = HIWORD(info->param);
381 args[0] = LOWORD(info->param);
383 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
384 UnMapLS( segelfe16 );
385 UnMapLS( segntm16 );
386 return LOWORD(ret);
389 struct dib_segptr_bits
391 struct list entry;
392 HBITMAP16 bmp;
393 WORD sel;
394 WORD count;
397 static struct list dib_segptr_list = LIST_INIT( dib_segptr_list );
399 static SEGPTR alloc_segptr_bits( HBITMAP bmp, void *bits32 )
401 DIBSECTION dib;
402 unsigned int i, size;
403 struct dib_segptr_bits *bits;
405 if (!(bits = HeapAlloc( GetProcessHeap(), 0, sizeof(*bits) ))) return 0;
407 GetObjectW( bmp, sizeof(dib), &dib );
408 size = dib.dsBm.bmHeight * dib.dsBm.bmWidthBytes;
410 /* calculate number of sel's needed for size with 64K steps */
411 bits->bmp = HBITMAP_16( bmp );
412 bits->count = (size + 0xffff) / 0x10000;
413 bits->sel = AllocSelectorArray16( bits->count );
415 for (i = 0; i < bits->count; i++)
417 SetSelectorBase(bits->sel + (i << __AHSHIFT), (DWORD)bits32 + i * 0x10000);
418 SetSelectorLimit16(bits->sel + (i << __AHSHIFT), size - 1); /* yep, limit is correct */
419 size -= 0x10000;
421 list_add_head( &dib_segptr_list, &bits->entry );
422 return MAKESEGPTR( bits->sel, 0 );
425 static void free_segptr_bits( HBITMAP16 bmp )
427 unsigned int i;
428 struct dib_segptr_bits *bits;
430 LIST_FOR_EACH_ENTRY( bits, &dib_segptr_list, struct dib_segptr_bits, entry )
432 if (bits->bmp != bmp) continue;
433 for (i = 0; i < bits->count; i++) FreeSelector16( bits->sel + (i << __AHSHIFT) );
435 list_remove( &bits->entry );
436 HeapFree( GetProcessHeap(), 0, bits );
437 return;
442 /***********************************************************************
443 * SetBkColor (GDI.1)
445 COLORREF WINAPI SetBkColor16( HDC16 hdc, COLORREF color )
447 return SetBkColor( HDC_32(hdc), color );
451 /***********************************************************************
452 * SetBkMode (GDI.2)
454 INT16 WINAPI SetBkMode16( HDC16 hdc, INT16 mode )
456 return SetBkMode( HDC_32(hdc), mode );
460 /***********************************************************************
461 * SetMapMode (GDI.3)
463 INT16 WINAPI SetMapMode16( HDC16 hdc, INT16 mode )
465 return SetMapMode( HDC_32(hdc), mode );
469 /***********************************************************************
470 * SetROP2 (GDI.4)
472 INT16 WINAPI SetROP216( HDC16 hdc, INT16 mode )
474 return SetROP2( HDC_32(hdc), mode );
478 /***********************************************************************
479 * SetRelAbs (GDI.5)
481 INT16 WINAPI SetRelAbs16( HDC16 hdc, INT16 mode )
483 return SetRelAbs( HDC_32(hdc), mode );
487 /***********************************************************************
488 * SetPolyFillMode (GDI.6)
490 INT16 WINAPI SetPolyFillMode16( HDC16 hdc, INT16 mode )
492 return SetPolyFillMode( HDC_32(hdc), mode );
496 /***********************************************************************
497 * SetStretchBltMode (GDI.7)
499 INT16 WINAPI SetStretchBltMode16( HDC16 hdc, INT16 mode )
501 return SetStretchBltMode( HDC_32(hdc), mode );
505 /***********************************************************************
506 * SetTextCharacterExtra (GDI.8)
508 INT16 WINAPI SetTextCharacterExtra16( HDC16 hdc, INT16 extra )
510 return SetTextCharacterExtra( HDC_32(hdc), extra );
514 /***********************************************************************
515 * SetTextColor (GDI.9)
517 COLORREF WINAPI SetTextColor16( HDC16 hdc, COLORREF color )
519 return SetTextColor( HDC_32(hdc), color );
523 /***********************************************************************
524 * SetTextJustification (GDI.10)
526 INT16 WINAPI SetTextJustification16( HDC16 hdc, INT16 extra, INT16 breaks )
528 return SetTextJustification( HDC_32(hdc), extra, breaks );
532 /***********************************************************************
533 * SetWindowOrg (GDI.11)
535 DWORD WINAPI SetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
537 POINT pt;
538 if (!SetWindowOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
539 return MAKELONG( pt.x, pt.y );
543 /***********************************************************************
544 * SetWindowExt (GDI.12)
546 DWORD WINAPI SetWindowExt16( HDC16 hdc, INT16 x, INT16 y )
548 SIZE size;
549 if (!SetWindowExtEx( HDC_32(hdc), x, y, &size )) return 0;
550 return MAKELONG( size.cx, size.cy );
554 /***********************************************************************
555 * SetViewportOrg (GDI.13)
557 DWORD WINAPI SetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
559 POINT pt;
560 if (!SetViewportOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
561 return MAKELONG( pt.x, pt.y );
565 /***********************************************************************
566 * SetViewportExt (GDI.14)
568 DWORD WINAPI SetViewportExt16( HDC16 hdc, INT16 x, INT16 y )
570 SIZE size;
571 if (!SetViewportExtEx( HDC_32(hdc), x, y, &size )) return 0;
572 return MAKELONG( size.cx, size.cy );
576 /***********************************************************************
577 * OffsetWindowOrg (GDI.15)
579 DWORD WINAPI OffsetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
581 POINT pt;
582 if (!OffsetWindowOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
583 return MAKELONG( pt.x, pt.y );
587 /***********************************************************************
588 * ScaleWindowExt (GDI.16)
590 DWORD WINAPI ScaleWindowExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
591 INT16 yNum, INT16 yDenom )
593 SIZE size;
594 if (!ScaleWindowExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom, &size ))
595 return FALSE;
596 return MAKELONG( size.cx, size.cy );
600 /***********************************************************************
601 * OffsetViewportOrg (GDI.17)
603 DWORD WINAPI OffsetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
605 POINT pt;
606 if (!OffsetViewportOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
607 return MAKELONG( pt.x, pt.y );
611 /***********************************************************************
612 * ScaleViewportExt (GDI.18)
614 DWORD WINAPI ScaleViewportExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
615 INT16 yNum, INT16 yDenom )
617 SIZE size;
618 if (!ScaleViewportExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom, &size ))
619 return FALSE;
620 return MAKELONG( size.cx, size.cy );
624 /***********************************************************************
625 * LineTo (GDI.19)
627 BOOL16 WINAPI LineTo16( HDC16 hdc, INT16 x, INT16 y )
629 return LineTo( HDC_32(hdc), x, y );
633 /***********************************************************************
634 * MoveTo (GDI.20)
636 DWORD WINAPI MoveTo16( HDC16 hdc, INT16 x, INT16 y )
638 POINT pt;
640 if (!MoveToEx( HDC_32(hdc), x, y, &pt )) return 0;
641 return MAKELONG(pt.x,pt.y);
645 /***********************************************************************
646 * ExcludeClipRect (GDI.21)
648 INT16 WINAPI ExcludeClipRect16( HDC16 hdc, INT16 left, INT16 top,
649 INT16 right, INT16 bottom )
651 return ExcludeClipRect( HDC_32(hdc), left, top, right, bottom );
655 /***********************************************************************
656 * IntersectClipRect (GDI.22)
658 INT16 WINAPI IntersectClipRect16( HDC16 hdc, INT16 left, INT16 top,
659 INT16 right, INT16 bottom )
661 return IntersectClipRect( HDC_32(hdc), left, top, right, bottom );
665 /***********************************************************************
666 * Arc (GDI.23)
668 BOOL16 WINAPI Arc16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
669 INT16 bottom, INT16 xstart, INT16 ystart,
670 INT16 xend, INT16 yend )
672 return Arc( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
676 /***********************************************************************
677 * Ellipse (GDI.24)
679 BOOL16 WINAPI Ellipse16( HDC16 hdc, INT16 left, INT16 top,
680 INT16 right, INT16 bottom )
682 return Ellipse( HDC_32(hdc), left, top, right, bottom );
686 /**********************************************************************
687 * FloodFill (GDI.25)
689 BOOL16 WINAPI FloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
691 return ExtFloodFill( HDC_32(hdc), x, y, color, FLOODFILLBORDER );
695 /***********************************************************************
696 * Pie (GDI.26)
698 BOOL16 WINAPI Pie16( HDC16 hdc, INT16 left, INT16 top,
699 INT16 right, INT16 bottom, INT16 xstart, INT16 ystart,
700 INT16 xend, INT16 yend )
702 return Pie( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
706 /***********************************************************************
707 * Rectangle (GDI.27)
709 BOOL16 WINAPI Rectangle16( HDC16 hdc, INT16 left, INT16 top,
710 INT16 right, INT16 bottom )
712 return Rectangle( HDC_32(hdc), left, top, right, bottom );
716 /***********************************************************************
717 * RoundRect (GDI.28)
719 BOOL16 WINAPI RoundRect16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
720 INT16 bottom, INT16 ell_width, INT16 ell_height )
722 return RoundRect( HDC_32(hdc), left, top, right, bottom, ell_width, ell_height );
726 /***********************************************************************
727 * PatBlt (GDI.29)
729 BOOL16 WINAPI PatBlt16( HDC16 hdc, INT16 left, INT16 top,
730 INT16 width, INT16 height, DWORD rop)
732 return PatBlt( HDC_32(hdc), left, top, width, height, rop );
736 /***********************************************************************
737 * SaveDC (GDI.30)
739 INT16 WINAPI SaveDC16( HDC16 hdc )
741 return SaveDC( HDC_32(hdc) );
745 /***********************************************************************
746 * SetPixel (GDI.31)
748 COLORREF WINAPI SetPixel16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
750 return SetPixel( HDC_32(hdc), x, y, color );
754 /***********************************************************************
755 * OffsetClipRgn (GDI.32)
757 INT16 WINAPI OffsetClipRgn16( HDC16 hdc, INT16 x, INT16 y )
759 return OffsetClipRgn( HDC_32(hdc), x, y );
763 /***********************************************************************
764 * TextOut (GDI.33)
766 BOOL16 WINAPI TextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR str, INT16 count )
768 return TextOutA( HDC_32(hdc), x, y, str, count );
772 /***********************************************************************
773 * BitBlt (GDI.34)
775 BOOL16 WINAPI BitBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst, INT16 width,
776 INT16 height, HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
777 DWORD rop )
779 return BitBlt( HDC_32(hdcDst), xDst, yDst, width, height, HDC_32(hdcSrc), xSrc, ySrc, rop );
783 /***********************************************************************
784 * StretchBlt (GDI.35)
786 BOOL16 WINAPI StretchBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst,
787 INT16 widthDst, INT16 heightDst,
788 HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
789 INT16 widthSrc, INT16 heightSrc, DWORD rop )
791 return StretchBlt( HDC_32(hdcDst), xDst, yDst, widthDst, heightDst,
792 HDC_32(hdcSrc), xSrc, ySrc, widthSrc, heightSrc, rop );
796 /**********************************************************************
797 * Polygon (GDI.36)
799 BOOL16 WINAPI Polygon16( HDC16 hdc, const POINT16* pt, INT16 count )
801 int i;
802 BOOL ret;
803 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, count*sizeof(POINT) );
805 if (!pt32) return FALSE;
806 for (i=count;i--;)
808 pt32[i].x = pt[i].x;
809 pt32[i].y = pt[i].y;
811 ret = Polygon(HDC_32(hdc),pt32,count);
812 HeapFree( GetProcessHeap(), 0, pt32 );
813 return ret;
817 /**********************************************************************
818 * Polyline (GDI.37)
820 BOOL16 WINAPI Polyline16( HDC16 hdc, const POINT16* pt, INT16 count )
822 int i;
823 BOOL16 ret;
824 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, count*sizeof(POINT) );
826 if (!pt32) return FALSE;
827 for (i=count;i--;)
829 pt32[i].x = pt[i].x;
830 pt32[i].y = pt[i].y;
832 ret = Polyline(HDC_32(hdc),pt32,count);
833 HeapFree( GetProcessHeap(), 0, pt32 );
834 return ret;
838 /***********************************************************************
839 * Escape (GDI.38)
841 INT16 WINAPI Escape16( HDC16 hdc, INT16 escape, INT16 in_count, SEGPTR in_data, LPVOID out_data )
843 INT ret;
845 switch(escape)
847 /* Escape(hdc,CLIP_TO_PATH,LPINT16,NULL) */
848 /* Escape(hdc,DRAFTMODE,LPINT16,NULL) */
849 /* Escape(hdc,ENUMPAPERBINS,LPINT16,LPSTR); */
850 /* Escape(hdc,EPSPRINTING,LPINT16,NULL) */
851 /* Escape(hdc,EXT_DEVICE_CAPS,LPINT16,LPDWORD) */
852 /* Escape(hdc,GETCOLORTABLE,LPINT16,LPDWORD) */
853 /* Escape(hdc,MOUSETRAILS,LPINT16,NULL) */
854 /* Escape(hdc,POSTSCRIPT_IGNORE,LPINT16,NULL) */
855 /* Escape(hdc,QUERYESCSUPPORT,LPINT16,NULL) */
856 /* Escape(hdc,SET_ARC_DIRECTION,LPINT16,NULL) */
857 /* Escape(hdc,SET_POLY_MODE,LPINT16,NULL) */
858 /* Escape(hdc,SET_SCREEN_ANGLE,LPINT16,NULL) */
859 /* Escape(hdc,SET_SPREAD,LPINT16,NULL) */
860 case CLIP_TO_PATH:
861 case DRAFTMODE:
862 case ENUMPAPERBINS:
863 case EPSPRINTING:
864 case EXT_DEVICE_CAPS:
865 case GETCOLORTABLE:
866 case MOUSETRAILS:
867 case POSTSCRIPT_IGNORE:
868 case QUERYESCSUPPORT:
869 case SET_ARC_DIRECTION:
870 case SET_POLY_MODE:
871 case SET_SCREEN_ANGLE:
872 case SET_SPREAD:
874 INT16 *ptr = MapSL(in_data);
875 INT data = *ptr;
876 return Escape( HDC_32(hdc), escape, sizeof(data), (LPCSTR)&data, out_data );
879 /* Escape(hdc,ENABLEDUPLEX,LPUINT16,NULL) */
880 case ENABLEDUPLEX:
882 UINT16 *ptr = MapSL(in_data);
883 UINT data = *ptr;
884 return Escape( HDC_32(hdc), escape, sizeof(data), (LPCSTR)&data, NULL );
887 /* Escape(hdc,GETPHYSPAGESIZE,NULL,LPPOINT16) */
888 /* Escape(hdc,GETPRINTINGOFFSET,NULL,LPPOINT16) */
889 /* Escape(hdc,GETSCALINGFACTOR,NULL,LPPOINT16) */
890 case GETPHYSPAGESIZE:
891 case GETPRINTINGOFFSET:
892 case GETSCALINGFACTOR:
894 POINT16 *ptr = out_data;
895 POINT pt32;
896 ret = Escape( HDC_32(hdc), escape, 0, NULL, &pt32 );
897 ptr->x = pt32.x;
898 ptr->y = pt32.y;
899 return ret;
902 /* Escape(hdc,ENABLEPAIRKERNING,LPINT16,LPINT16); */
903 /* Escape(hdc,ENABLERELATIVEWIDTHS,LPINT16,LPINT16); */
904 /* Escape(hdc,SETCOPYCOUNT,LPINT16,LPINT16) */
905 /* Escape(hdc,SETKERNTRACK,LPINT16,LPINT16) */
906 /* Escape(hdc,SETLINECAP,LPINT16,LPINT16) */
907 /* Escape(hdc,SETLINEJOIN,LPINT16,LPINT16) */
908 /* Escape(hdc,SETMITERLIMIT,LPINT16,LPINT16) */
909 case ENABLEPAIRKERNING:
910 case ENABLERELATIVEWIDTHS:
911 case SETCOPYCOUNT:
912 case SETKERNTRACK:
913 case SETLINECAP:
914 case SETLINEJOIN:
915 case SETMITERLIMIT:
917 INT16 *new = MapSL(in_data);
918 INT16 *old = out_data;
919 INT out, in = *new;
920 ret = Escape( HDC_32(hdc), escape, sizeof(in), (LPCSTR)&in, &out );
921 *old = out;
922 return ret;
925 /* Escape(hdc,SETABORTPROC,ABORTPROC,NULL); */
926 case SETABORTPROC:
927 return SetAbortProc16( hdc, (ABORTPROC16)in_data );
929 /* Escape(hdc,STARTDOC,LPSTR,LPDOCINFO16);
930 * lpvOutData is actually a pointer to the DocInfo structure and used as
931 * a second input parameter */
932 case STARTDOC:
933 if (out_data)
935 ret = StartDoc16( hdc, out_data );
936 if (ret > 0) ret = StartPage( HDC_32(hdc) );
937 return ret;
939 return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), NULL );
941 /* Escape(hdc,SET_BOUNDS,LPRECT16,NULL); */
942 /* Escape(hdc,SET_CLIP_BOX,LPRECT16,NULL); */
943 case SET_BOUNDS:
944 case SET_CLIP_BOX:
946 RECT16 *rc16 = MapSL(in_data);
947 RECT rc;
948 rc.left = rc16->left;
949 rc.top = rc16->top;
950 rc.right = rc16->right;
951 rc.bottom = rc16->bottom;
952 return Escape( HDC_32(hdc), escape, sizeof(rc), (LPCSTR)&rc, NULL );
955 /* Escape(hdc,NEXTBAND,NULL,LPRECT16); */
956 case NEXTBAND:
958 RECT rc;
959 RECT16 *rc16 = out_data;
960 ret = Escape( HDC_32(hdc), escape, 0, NULL, &rc );
961 rc16->left = rc.left;
962 rc16->top = rc.top;
963 rc16->right = rc.right;
964 rc16->bottom = rc.bottom;
965 return ret;
967 /* Escape(hdc,DRAWPATTERNRECT,PRECT_STRUCT*,NULL); */
968 case DRAWPATTERNRECT:
970 DRAWPATRECT pr;
971 DRAWPATRECT16 *pr16 = MapSL(in_data);
973 pr.ptPosition.x = pr16->ptPosition.x;
974 pr.ptPosition.y = pr16->ptPosition.y;
975 pr.ptSize.x = pr16->ptSize.x;
976 pr.ptSize.y = pr16->ptSize.y;
977 pr.wStyle = pr16->wStyle;
978 pr.wPattern = pr16->wPattern;
979 return Escape( HDC_32(hdc), escape, sizeof(pr), (LPCSTR)&pr, NULL );
982 /* Escape(hdc,ABORTDOC,NULL,NULL); */
983 /* Escape(hdc,BANDINFO,BANDINFOSTRUCT*,BANDINFOSTRUCT*); */
984 /* Escape(hdc,BEGIN_PATH,NULL,NULL); */
985 /* Escape(hdc,ENDDOC,NULL,NULL); */
986 /* Escape(hdc,END_PATH,PATHINFO,NULL); */
987 /* Escape(hdc,EXTTEXTOUT,EXTTEXT_STRUCT*,NULL); */
988 /* Escape(hdc,FLUSHOUTPUT,NULL,NULL); */
989 /* Escape(hdc,GETFACENAME,NULL,LPSTR); */
990 /* Escape(hdc,GETPAIRKERNTABLE,NULL,KERNPAIR*); */
991 /* Escape(hdc,GETSETPAPERBINS,BinInfo*,BinInfo*); */
992 /* Escape(hdc,GETSETPRINTORIENT,ORIENT*,NULL); */
993 /* Escape(hdc,GETSETSCREENPARAMS,SCREENPARAMS*,SCREENPARAMS*); */
994 /* Escape(hdc,GETTECHNOLOGY,NULL,LPSTR); */
995 /* Escape(hdc,GETTRACKKERNTABLE,NULL,KERNTRACK*); */
996 /* Escape(hdc,MFCOMMENT,LPSTR,NULL); */
997 /* Escape(hdc,NEWFRAME,NULL,NULL); */
998 /* Escape(hdc,PASSTHROUGH,LPSTR,NULL); */
999 /* Escape(hdc,RESTORE_CTM,NULL,NULL); */
1000 /* Escape(hdc,SAVE_CTM,NULL,NULL); */
1001 /* Escape(hdc,SETALLJUSTVALUES,EXTTEXTDATA*,NULL); */
1002 /* Escape(hdc,SETCOLORTABLE,COLORTABLE_STRUCT*,LPDWORD); */
1003 /* Escape(hdc,SET_BACKGROUND_COLOR,LPDWORD,LPDWORD); */
1004 /* Escape(hdc,TRANSFORM_CTM,LPSTR,NULL); */
1005 case ABORTDOC:
1006 case BANDINFO:
1007 case BEGIN_PATH:
1008 case ENDDOC:
1009 case END_PATH:
1010 case EXTTEXTOUT:
1011 case FLUSHOUTPUT:
1012 case GETFACENAME:
1013 case GETPAIRKERNTABLE:
1014 case GETSETPAPERBINS:
1015 case GETSETPRINTORIENT:
1016 case GETSETSCREENPARAMS:
1017 case GETTECHNOLOGY:
1018 case GETTRACKKERNTABLE:
1019 case MFCOMMENT:
1020 case NEWFRAME:
1021 case PASSTHROUGH:
1022 case RESTORE_CTM:
1023 case SAVE_CTM:
1024 case SETALLJUSTVALUES:
1025 case SETCOLORTABLE:
1026 case SET_BACKGROUND_COLOR:
1027 case TRANSFORM_CTM:
1028 /* pass it unmodified to the 32-bit function */
1029 return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), out_data );
1031 /* Escape(hdc,ENUMPAPERMETRICS,LPINT16,LPRECT16); */
1032 /* Escape(hdc,GETEXTENDEDTEXTMETRICS,LPUINT16,EXTTEXTMETRIC*); */
1033 /* Escape(hdc,GETEXTENTTABLE,LPSTR,LPINT16); */
1034 /* Escape(hdc,GETSETPAPERMETRICS,LPRECT16,LPRECT16); */
1035 /* Escape(hdc,GETVECTORBRUSHSIZE,LPLOGBRUSH16,LPPOINT16); */
1036 /* Escape(hdc,GETVECTORPENSIZE,LPLOGPEN16,LPPOINT16); */
1037 case ENUMPAPERMETRICS:
1038 case GETEXTENDEDTEXTMETRICS:
1039 case GETEXTENTTABLE:
1040 case GETSETPAPERMETRICS:
1041 case GETVECTORBRUSHSIZE:
1042 case GETVECTORPENSIZE:
1043 default:
1044 FIXME("unknown/unsupported 16-bit escape %x (%d,%p,%p\n",
1045 escape, in_count, MapSL(in_data), out_data );
1046 return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), out_data );
1051 /***********************************************************************
1052 * RestoreDC (GDI.39)
1054 BOOL16 WINAPI RestoreDC16( HDC16 hdc, INT16 level )
1056 return RestoreDC( HDC_32(hdc), level );
1060 /***********************************************************************
1061 * FillRgn (GDI.40)
1063 BOOL16 WINAPI FillRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush )
1065 return FillRgn( HDC_32(hdc), HRGN_32(hrgn), HBRUSH_32(hbrush) );
1069 /***********************************************************************
1070 * FrameRgn (GDI.41)
1072 BOOL16 WINAPI FrameRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush,
1073 INT16 nWidth, INT16 nHeight )
1075 return FrameRgn( HDC_32(hdc), HRGN_32(hrgn), HBRUSH_32(hbrush), nWidth, nHeight );
1079 /***********************************************************************
1080 * InvertRgn (GDI.42)
1082 BOOL16 WINAPI InvertRgn16( HDC16 hdc, HRGN16 hrgn )
1084 return InvertRgn( HDC_32(hdc), HRGN_32(hrgn) );
1088 /***********************************************************************
1089 * PaintRgn (GDI.43)
1091 BOOL16 WINAPI PaintRgn16( HDC16 hdc, HRGN16 hrgn )
1093 return PaintRgn( HDC_32(hdc), HRGN_32(hrgn) );
1097 /***********************************************************************
1098 * SelectClipRgn (GDI.44)
1100 INT16 WINAPI SelectClipRgn16( HDC16 hdc, HRGN16 hrgn )
1102 return SelectClipRgn( HDC_32(hdc), HRGN_32(hrgn) );
1106 /***********************************************************************
1107 * SelectObject (GDI.45)
1109 HGDIOBJ16 WINAPI SelectObject16( HDC16 hdc, HGDIOBJ16 handle )
1111 return HGDIOBJ_16( SelectObject( HDC_32(hdc), HGDIOBJ_32(handle) ) );
1115 /***********************************************************************
1116 * CombineRgn (GDI.47)
1118 INT16 WINAPI CombineRgn16(HRGN16 hDest, HRGN16 hSrc1, HRGN16 hSrc2, INT16 mode)
1120 return CombineRgn( HRGN_32(hDest), HRGN_32(hSrc1), HRGN_32(hSrc2), mode );
1124 /***********************************************************************
1125 * CreateBitmap (GDI.48)
1127 HBITMAP16 WINAPI CreateBitmap16( INT16 width, INT16 height, UINT16 planes,
1128 UINT16 bpp, LPCVOID bits )
1130 return HBITMAP_16( CreateBitmap( width, height, planes & 0xff, bpp & 0xff, bits ) );
1134 /***********************************************************************
1135 * CreateBitmapIndirect (GDI.49)
1137 HBITMAP16 WINAPI CreateBitmapIndirect16( const BITMAP16 * bmp )
1139 return CreateBitmap16( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
1140 bmp->bmBitsPixel, MapSL( bmp->bmBits ) );
1144 /***********************************************************************
1145 * CreateBrushIndirect (GDI.50)
1147 HBRUSH16 WINAPI CreateBrushIndirect16( const LOGBRUSH16 * brush )
1149 LOGBRUSH brush32;
1151 if (brush->lbStyle == BS_DIBPATTERN || brush->lbStyle == BS_DIBPATTERN8X8)
1152 return CreateDIBPatternBrush16( brush->lbHatch, brush->lbColor );
1154 brush32.lbStyle = brush->lbStyle;
1155 brush32.lbColor = brush->lbColor;
1156 brush32.lbHatch = brush->lbHatch;
1157 return HBRUSH_16( CreateBrushIndirect(&brush32) );
1161 /***********************************************************************
1162 * CreateCompatibleBitmap (GDI.51)
1164 HBITMAP16 WINAPI CreateCompatibleBitmap16( HDC16 hdc, INT16 width, INT16 height )
1166 return HBITMAP_16( CreateCompatibleBitmap( HDC_32(hdc), width, height ) );
1170 /***********************************************************************
1171 * CreateCompatibleDC (GDI.52)
1173 HDC16 WINAPI CreateCompatibleDC16( HDC16 hdc )
1175 return HDC_16( CreateCompatibleDC( HDC_32(hdc) ) );
1179 /***********************************************************************
1180 * CreateDC (GDI.53)
1182 HDC16 WINAPI CreateDC16( LPCSTR driver, LPCSTR device, LPCSTR output,
1183 const DEVMODEA *initData )
1185 if (!lstrcmpiA( driver, "dib" ) || !lstrcmpiA( driver, "dirdib" ))
1187 PALETTEENTRY palette[256];
1188 BITMAPINFO *info = (BITMAPINFO *)initData;
1189 D3DKMT_CREATEDCFROMMEMORY desc =
1191 .Width = info->bmiHeader.biWidth,
1192 .Height = info->bmiHeader.biHeight,
1193 .Pitch = info->bmiHeader.biWidth * info->bmiHeader.biBitCount / 8,
1195 struct saved_bitmap *bitmap;
1196 int color;
1198 if (info->bmiHeader.biBitCount <= 8)
1200 if (info->bmiHeader.biClrUsed)
1202 for (color = 0; color < info->bmiHeader.biClrUsed; color++)
1204 palette[color].peBlue = info->bmiColors[color].rgbBlue;
1205 palette[color].peGreen = info->bmiColors[color].rgbGreen;
1206 palette[color].peRed = info->bmiColors[color].rgbRed;
1209 else
1211 for (color = 0; color < (1 << info->bmiHeader.biBitCount); color++)
1213 palette[color].peBlue = color;
1214 palette[color].peGreen = color;
1215 palette[color].peRed = color;
1218 desc.pColorTable = palette;
1219 desc.Format = D3DDDIFMT_P8;
1220 desc.pMemory = &info->bmiColors[color];
1222 else if (info->bmiHeader.biCompression == BI_BITFIELDS)
1224 desc.Format = D3DDDIFMT_R5G6B5;
1225 desc.pMemory = &info->bmiColors[3];
1227 else
1229 desc.Format = info->bmiHeader.biBitCount == 24 ? D3DDDIFMT_R8G8B8 : D3DDDIFMT_X8R8G8B8;
1230 desc.pMemory = &info->bmiColors[0];
1233 if (NtGdiDdDDICreateDCFromMemory( &desc )) return 0;
1235 if ((bitmap = HeapAlloc( GetProcessHeap(), 0, sizeof(*bitmap) )))
1237 bitmap->hdc = desc.hDc;
1238 bitmap->hbitmap = desc.hBitmap;
1239 list_add_tail( &saved_bitmaps, &bitmap->entry );
1242 return HDC_16( desc.hDc );
1244 return HDC_16( CreateDCA( driver, device, output, initData ) );
1248 /***********************************************************************
1249 * CreateEllipticRgn (GDI.54)
1251 HRGN16 WINAPI CreateEllipticRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom )
1253 return HRGN_16( CreateEllipticRgn( left, top, right, bottom ) );
1257 /***********************************************************************
1258 * CreateEllipticRgnIndirect (GDI.55)
1260 HRGN16 WINAPI CreateEllipticRgnIndirect16( const RECT16 *rect )
1262 return HRGN_16( CreateEllipticRgn( rect->left, rect->top, rect->right, rect->bottom ) );
1266 /***********************************************************************
1267 * CreateFont (GDI.56)
1269 HFONT16 WINAPI CreateFont16(INT16 height, INT16 width, INT16 esc, INT16 orient,
1270 INT16 weight, BYTE italic, BYTE underline,
1271 BYTE strikeout, BYTE charset, BYTE outpres,
1272 BYTE clippres, BYTE quality, BYTE pitch,
1273 LPCSTR name )
1275 return HFONT_16( CreateFontA( height, width, esc, orient, weight, italic, underline,
1276 strikeout, charset, outpres, clippres, quality, pitch, name ));
1279 /***********************************************************************
1280 * CreateFontIndirect (GDI.57)
1282 HFONT16 WINAPI CreateFontIndirect16( const LOGFONT16 *plf16 )
1284 HFONT ret;
1286 if (plf16)
1288 LOGFONTW lfW;
1289 logfont_16_to_W( plf16, &lfW );
1290 ret = CreateFontIndirectW( &lfW );
1292 else ret = CreateFontIndirectW( NULL );
1293 return HFONT_16(ret);
1297 /***********************************************************************
1298 * CreateHatchBrush (GDI.58)
1300 HBRUSH16 WINAPI CreateHatchBrush16( INT16 style, COLORREF color )
1302 return HBRUSH_16( CreateHatchBrush( style, color ) );
1306 /***********************************************************************
1307 * CreatePatternBrush (GDI.60)
1309 HBRUSH16 WINAPI CreatePatternBrush16( HBITMAP16 hbitmap )
1311 return HBRUSH_16( CreatePatternBrush( HBITMAP_32(hbitmap) ));
1315 /***********************************************************************
1316 * CreatePen (GDI.61)
1318 HPEN16 WINAPI CreatePen16( INT16 style, INT16 width, COLORREF color )
1320 LOGPEN logpen;
1322 logpen.lopnStyle = style;
1323 logpen.lopnWidth.x = width;
1324 logpen.lopnWidth.y = 0;
1325 logpen.lopnColor = color;
1326 return HPEN_16( CreatePenIndirect( &logpen ) );
1330 /***********************************************************************
1331 * CreatePenIndirect (GDI.62)
1333 HPEN16 WINAPI CreatePenIndirect16( const LOGPEN16 * pen )
1335 LOGPEN logpen;
1337 if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
1338 logpen.lopnStyle = pen->lopnStyle;
1339 logpen.lopnWidth.x = pen->lopnWidth.x;
1340 logpen.lopnWidth.y = pen->lopnWidth.y;
1341 logpen.lopnColor = pen->lopnColor;
1342 return HPEN_16( CreatePenIndirect( &logpen ) );
1346 /***********************************************************************
1347 * CreatePolygonRgn (GDI.63)
1349 HRGN16 WINAPI CreatePolygonRgn16( const POINT16 * points, INT16 count, INT16 mode )
1351 return CreatePolyPolygonRgn16( points, &count, 1, mode );
1355 /***********************************************************************
1356 * CreateRectRgn (GDI.64)
1358 * NOTE: cf. SetRectRgn16
1360 HRGN16 WINAPI CreateRectRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom )
1362 HRGN hrgn;
1364 if (left < right) hrgn = CreateRectRgn( left, top, right, bottom );
1365 else hrgn = CreateRectRgn( 0, 0, 0, 0 );
1366 return HRGN_16(hrgn);
1370 /***********************************************************************
1371 * CreateRectRgnIndirect (GDI.65)
1373 HRGN16 WINAPI CreateRectRgnIndirect16( const RECT16* rect )
1375 return CreateRectRgn16( rect->left, rect->top, rect->right, rect->bottom );
1379 /***********************************************************************
1380 * CreateSolidBrush (GDI.66)
1382 HBRUSH16 WINAPI CreateSolidBrush16( COLORREF color )
1384 return HBRUSH_16( CreateSolidBrush( color ) );
1388 /***********************************************************************
1389 * DeleteDC (GDI.68)
1391 BOOL16 WINAPI DeleteDC16( HDC16 hdc )
1393 if (DeleteDC( HDC_32(hdc) ))
1395 struct saved_visrgn *saved;
1396 struct saved_bitmap *bitmap;
1397 struct gdi_thunk* thunk;
1398 void *next;
1400 if ((thunk = GDI_FindThunk(hdc))) GDI_DeleteThunk(thunk);
1402 LIST_FOR_EACH_ENTRY_SAFE( saved, next, &saved_regions, struct saved_visrgn, entry )
1404 if (saved->hdc != HDC_32(hdc)) continue;
1405 list_remove( &saved->entry );
1406 DeleteObject( saved->hrgn );
1407 HeapFree( GetProcessHeap(), 0, saved );
1410 LIST_FOR_EACH_ENTRY_SAFE( bitmap, next, &saved_bitmaps, struct saved_bitmap, entry )
1412 if (bitmap->hdc != HDC_32(hdc)) continue;
1413 list_remove( &bitmap->entry );
1414 DeleteObject( bitmap->hbitmap );
1415 HeapFree( GetProcessHeap(), 0, bitmap );
1418 return TRUE;
1420 return FALSE;
1424 /***********************************************************************
1425 * DeleteObject (GDI.69)
1426 * SysDeleteObject (GDI.605)
1428 BOOL16 WINAPI DeleteObject16( HGDIOBJ16 obj )
1430 if (GetObjectType( HGDIOBJ_32(obj) ) == OBJ_BITMAP) free_segptr_bits( obj );
1431 return DeleteObject( HGDIOBJ_32(obj) );
1435 /***********************************************************************
1436 * EnumFonts (GDI.70)
1438 INT16 WINAPI EnumFonts16( HDC16 hDC, LPCSTR lpName, FONTENUMPROC16 efproc,
1439 LPARAM lpData )
1441 return EnumFontFamilies16( hDC, lpName, efproc, lpData );
1445 /***********************************************************************
1446 * EnumObjects (GDI.71)
1448 INT16 WINAPI EnumObjects16( HDC16 hdc, INT16 obj, GOBJENUMPROC16 proc, LPARAM lParam )
1450 struct callback16_info info;
1452 info.proc = (FARPROC16)proc;
1453 info.param = lParam;
1454 switch(obj)
1456 case OBJ_PEN:
1457 return EnumObjects( HDC_32(hdc), OBJ_PEN, enum_pens_callback, (LPARAM)&info );
1458 case OBJ_BRUSH:
1459 return EnumObjects( HDC_32(hdc), OBJ_BRUSH, enum_brushes_callback, (LPARAM)&info );
1461 return 0;
1465 /***********************************************************************
1466 * EqualRgn (GDI.72)
1468 BOOL16 WINAPI EqualRgn16( HRGN16 rgn1, HRGN16 rgn2 )
1470 return EqualRgn( HRGN_32(rgn1), HRGN_32(rgn2) );
1474 /***********************************************************************
1475 * GetBitmapBits (GDI.74)
1477 LONG WINAPI GetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPVOID buffer )
1479 return GetBitmapBits( HBITMAP_32(hbitmap), count, buffer );
1483 /***********************************************************************
1484 * GetBkColor (GDI.75)
1486 COLORREF WINAPI GetBkColor16( HDC16 hdc )
1488 return GetBkColor( HDC_32(hdc) );
1492 /***********************************************************************
1493 * GetBkMode (GDI.76)
1495 INT16 WINAPI GetBkMode16( HDC16 hdc )
1497 return GetBkMode( HDC_32(hdc) );
1501 /***********************************************************************
1502 * GetClipBox (GDI.77)
1504 INT16 WINAPI GetClipBox16( HDC16 hdc, LPRECT16 rect )
1506 RECT rect32;
1507 INT ret = GetClipBox( HDC_32(hdc), &rect32 );
1509 if (ret != ERROR)
1511 rect->left = rect32.left;
1512 rect->top = rect32.top;
1513 rect->right = rect32.right;
1514 rect->bottom = rect32.bottom;
1516 return ret;
1520 /***********************************************************************
1521 * GetCurrentPosition (GDI.78)
1523 DWORD WINAPI GetCurrentPosition16( HDC16 hdc )
1525 POINT pt32;
1526 if (!GetCurrentPositionEx( HDC_32(hdc), &pt32 )) return 0;
1527 return MAKELONG( pt32.x, pt32.y );
1531 /***********************************************************************
1532 * GetDCOrg (GDI.79)
1534 DWORD WINAPI GetDCOrg16( HDC16 hdc )
1536 POINT pt;
1537 if (GetDCOrgEx( HDC_32(hdc), &pt )) return MAKELONG( pt.x, pt.y );
1538 return 0;
1542 /***********************************************************************
1543 * GetDeviceCaps (GDI.80)
1545 INT16 WINAPI GetDeviceCaps16( HDC16 hdc, INT16 cap )
1547 INT16 ret = GetDeviceCaps( HDC_32(hdc), cap );
1548 /* some apps don't expect -1 and think it's a B&W screen */
1549 if ((cap == NUMCOLORS) && (ret == -1)) ret = 2048;
1550 return ret;
1554 /***********************************************************************
1555 * GetMapMode (GDI.81)
1557 INT16 WINAPI GetMapMode16( HDC16 hdc )
1559 return GetMapMode( HDC_32(hdc) );
1563 /***********************************************************************
1564 * GetObject (GDI.82)
1566 INT16 WINAPI GetObject16( HGDIOBJ16 handle16, INT16 count, LPVOID buffer )
1568 HGDIOBJ handle = HGDIOBJ_32( handle16 );
1569 switch( GetObjectType( handle ))
1571 case OBJ_PEN:
1572 if (buffer)
1574 LOGPEN16 *pen16 = buffer;
1575 LOGPEN pen;
1577 if (count < sizeof(LOGPEN16)) return 0;
1578 if (!GetObjectW( handle, sizeof(pen), &pen )) return 0;
1580 pen16->lopnStyle = pen.lopnStyle;
1581 pen16->lopnColor = pen.lopnColor;
1582 pen16->lopnWidth.x = pen.lopnWidth.x;
1583 pen16->lopnWidth.y = pen.lopnWidth.y;
1585 return sizeof(LOGPEN16);
1587 case OBJ_BRUSH:
1588 if (buffer)
1590 LOGBRUSH brush;
1591 LOGBRUSH16 brush16;
1593 if (!GetObjectW( handle, sizeof(brush), &brush )) return 0;
1594 brush16.lbStyle = brush.lbStyle;
1595 brush16.lbColor = brush.lbColor;
1596 brush16.lbHatch = brush.lbHatch;
1597 if (count > sizeof(brush16)) count = sizeof(brush16);
1598 memcpy( buffer, &brush16, count );
1599 return count;
1601 return sizeof(LOGBRUSH16);
1603 case OBJ_PAL:
1604 return GetObjectW( handle, count, buffer );
1606 case OBJ_FONT:
1607 if (buffer)
1609 LOGFONTW font;
1610 LOGFONT16 font16;
1612 if (!GetObjectW( handle, sizeof(font), &font )) return 0;
1613 logfont_W_to_16( &font, &font16 );
1614 if (count > sizeof(font16)) count = sizeof(font16);
1615 memcpy( buffer, &font16, count );
1616 return count;
1618 return sizeof(LOGFONT16);
1620 case OBJ_BITMAP:
1622 DIBSECTION dib;
1623 INT size;
1624 BITMAP16 *bmp16 = buffer;
1626 if (!(size = GetObjectW( handle, sizeof(dib), &dib ))) return 0;
1627 if (size == sizeof(DIBSECTION) && count > sizeof(BITMAP16))
1629 FIXME("not implemented for DIBs: count %d\n", count);
1630 return 0;
1632 else
1634 if (count < sizeof(BITMAP16)) return 0;
1635 bmp16->bmType = dib.dsBm.bmType;
1636 bmp16->bmWidth = dib.dsBm.bmWidth;
1637 bmp16->bmHeight = dib.dsBm.bmHeight;
1638 bmp16->bmWidthBytes = dib.dsBm.bmWidthBytes;
1639 bmp16->bmPlanes = dib.dsBm.bmPlanes;
1640 bmp16->bmBitsPixel = dib.dsBm.bmBitsPixel;
1641 bmp16->bmBits = 0;
1642 return sizeof(BITMAP16);
1646 default:
1647 return 0;
1652 /***********************************************************************
1653 * GetPixel (GDI.83)
1655 COLORREF WINAPI GetPixel16( HDC16 hdc, INT16 x, INT16 y )
1657 return GetPixel( HDC_32(hdc), x, y );
1661 /***********************************************************************
1662 * GetPolyFillMode (GDI.84)
1664 INT16 WINAPI GetPolyFillMode16( HDC16 hdc )
1666 return GetPolyFillMode( HDC_32(hdc) );
1670 /***********************************************************************
1671 * GetROP2 (GDI.85)
1673 INT16 WINAPI GetROP216( HDC16 hdc )
1675 return GetROP2( HDC_32(hdc) );
1679 /***********************************************************************
1680 * GetRelAbs (GDI.86)
1682 INT16 WINAPI GetRelAbs16( HDC16 hdc )
1684 return GetRelAbs( HDC_32(hdc), 0 );
1688 /***********************************************************************
1689 * GetStockObject (GDI.87)
1691 HGDIOBJ16 WINAPI GetStockObject16( INT16 obj )
1693 return HGDIOBJ_16( GetStockObject( obj ) );
1697 /***********************************************************************
1698 * GetStretchBltMode (GDI.88)
1700 INT16 WINAPI GetStretchBltMode16( HDC16 hdc )
1702 return GetStretchBltMode( HDC_32(hdc) );
1706 /***********************************************************************
1707 * GetTextCharacterExtra (GDI.89)
1709 INT16 WINAPI GetTextCharacterExtra16( HDC16 hdc )
1711 return GetTextCharacterExtra( HDC_32(hdc) );
1715 /***********************************************************************
1716 * GetTextColor (GDI.90)
1718 COLORREF WINAPI GetTextColor16( HDC16 hdc )
1720 return GetTextColor( HDC_32(hdc) );
1724 /***********************************************************************
1725 * GetTextExtent (GDI.91)
1727 DWORD WINAPI GetTextExtent16( HDC16 hdc, LPCSTR str, INT16 count )
1729 SIZE size;
1730 if (!GetTextExtentPoint32A( HDC_32(hdc), str, count, &size )) return 0;
1731 return MAKELONG( size.cx, size.cy );
1735 /***********************************************************************
1736 * GetTextFace (GDI.92)
1738 INT16 WINAPI GetTextFace16( HDC16 hdc, INT16 count, LPSTR name )
1740 return GetTextFaceA( HDC_32(hdc), count, name );
1744 /***********************************************************************
1745 * GetTextMetrics (GDI.93)
1747 BOOL16 WINAPI GetTextMetrics16( HDC16 hdc, TEXTMETRIC16 *tm )
1749 TEXTMETRICW tm32;
1751 if (!GetTextMetricsW( HDC_32(hdc), &tm32 )) return FALSE;
1753 tm->tmHeight = tm32.tmHeight;
1754 tm->tmAscent = tm32.tmAscent;
1755 tm->tmDescent = tm32.tmDescent;
1756 tm->tmInternalLeading = tm32.tmInternalLeading;
1757 tm->tmExternalLeading = tm32.tmExternalLeading;
1758 tm->tmAveCharWidth = tm32.tmAveCharWidth;
1759 tm->tmMaxCharWidth = tm32.tmMaxCharWidth;
1760 tm->tmWeight = tm32.tmWeight;
1761 tm->tmOverhang = tm32.tmOverhang;
1762 tm->tmDigitizedAspectX = tm32.tmDigitizedAspectX;
1763 tm->tmDigitizedAspectY = tm32.tmDigitizedAspectY;
1764 tm->tmFirstChar = tm32.tmFirstChar;
1765 tm->tmLastChar = tm32.tmLastChar;
1766 tm->tmDefaultChar = tm32.tmDefaultChar;
1767 tm->tmBreakChar = tm32.tmBreakChar;
1768 tm->tmItalic = tm32.tmItalic;
1769 tm->tmUnderlined = tm32.tmUnderlined;
1770 tm->tmStruckOut = tm32.tmStruckOut;
1771 tm->tmPitchAndFamily = tm32.tmPitchAndFamily;
1772 tm->tmCharSet = tm32.tmCharSet;
1773 return TRUE;
1777 /***********************************************************************
1778 * GetViewportExt (GDI.94)
1780 DWORD WINAPI GetViewportExt16( HDC16 hdc )
1782 SIZE size;
1783 if (!GetViewportExtEx( HDC_32(hdc), &size )) return 0;
1784 return MAKELONG( size.cx, size.cy );
1788 /***********************************************************************
1789 * GetViewportOrg (GDI.95)
1791 DWORD WINAPI GetViewportOrg16( HDC16 hdc )
1793 POINT pt;
1794 if (!GetViewportOrgEx( HDC_32(hdc), &pt )) return 0;
1795 return MAKELONG( pt.x, pt.y );
1799 /***********************************************************************
1800 * GetWindowExt (GDI.96)
1802 DWORD WINAPI GetWindowExt16( HDC16 hdc )
1804 SIZE size;
1805 if (!GetWindowExtEx( HDC_32(hdc), &size )) return 0;
1806 return MAKELONG( size.cx, size.cy );
1810 /***********************************************************************
1811 * GetWindowOrg (GDI.97)
1813 DWORD WINAPI GetWindowOrg16( HDC16 hdc )
1815 POINT pt;
1816 if (!GetWindowOrgEx( HDC_32(hdc), &pt )) return 0;
1817 return MAKELONG( pt.x, pt.y );
1823 /**********************************************************************
1824 * LineDDA (GDI.100)
1826 void WINAPI LineDDA16( INT16 nXStart, INT16 nYStart, INT16 nXEnd,
1827 INT16 nYEnd, LINEDDAPROC16 proc, LPARAM lParam )
1829 struct callback16_info info;
1830 info.proc = (FARPROC16)proc;
1831 info.param = lParam;
1832 LineDDA( nXStart, nYStart, nXEnd, nYEnd, linedda_callback, (LPARAM)&info );
1836 /***********************************************************************
1837 * OffsetRgn (GDI.101)
1839 INT16 WINAPI OffsetRgn16( HRGN16 hrgn, INT16 x, INT16 y )
1841 return OffsetRgn( HRGN_32(hrgn), x, y );
1845 /***********************************************************************
1846 * PtVisible (GDI.103)
1848 BOOL16 WINAPI PtVisible16( HDC16 hdc, INT16 x, INT16 y )
1850 return PtVisible( HDC_32(hdc), x, y );
1854 /***********************************************************************
1855 * SelectVisRgn (GDI.105)
1857 INT16 WINAPI SelectVisRgn16( HDC16 hdc, HRGN16 hrgn )
1859 FIXME( "%04x %04x no longer supported\n", hdc, hrgn );
1860 return ERROR;
1864 /***********************************************************************
1865 * SetBitmapBits (GDI.106)
1867 LONG WINAPI SetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPCVOID buffer )
1869 return SetBitmapBits( HBITMAP_32(hbitmap), count, buffer );
1873 /***********************************************************************
1874 * AddFontResource (GDI.119)
1876 INT16 WINAPI AddFontResource16( LPCSTR filename )
1878 return AddFontResourceA( filename );
1882 /***********************************************************************
1883 * Death (GDI.121)
1885 * Disables GDI, switches back to text mode.
1886 * We don't have to do anything here,
1887 * just let console support handle everything
1889 void WINAPI Death16(HDC16 hdc)
1891 MESSAGE("Death(%04x) called. Application enters text mode...\n", hdc);
1895 /***********************************************************************
1896 * Resurrection (GDI.122)
1898 * Restores GDI functionality
1900 void WINAPI Resurrection16(HDC16 hdc,
1901 WORD w1, WORD w2, WORD w3, WORD w4, WORD w5, WORD w6)
1903 MESSAGE("Resurrection(%04x, %04x, %04x, %04x, %04x, %04x, %04x) called. Application left text mode.\n",
1904 hdc, w1, w2, w3, w4, w5, w6);
1908 /***********************************************************************
1909 * MulDiv (GDI.128)
1911 INT16 WINAPI MulDiv16( INT16 nMultiplicand, INT16 nMultiplier, INT16 nDivisor)
1913 INT ret;
1914 if (!nDivisor) return -32768;
1915 /* We want to deal with a positive divisor to simplify the logic. */
1916 if (nDivisor < 0)
1918 nMultiplicand = - nMultiplicand;
1919 nDivisor = -nDivisor;
1921 /* If the result is positive, we "add" to round. else,
1922 * we subtract to round. */
1923 if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) ||
1924 ( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
1925 ret = (((int)nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
1926 else
1927 ret = (((int)nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
1928 if ((ret > 32767) || (ret < -32767)) return -32768;
1929 return (INT16) ret;
1933 /***********************************************************************
1934 * GetRgnBox (GDI.134)
1936 INT16 WINAPI GetRgnBox16( HRGN16 hrgn, LPRECT16 rect )
1938 RECT r;
1939 INT16 ret = GetRgnBox( HRGN_32(hrgn), &r );
1940 rect->left = r.left;
1941 rect->top = r.top;
1942 rect->right = r.right;
1943 rect->bottom = r.bottom;
1944 return ret;
1948 /***********************************************************************
1949 * RemoveFontResource (GDI.136)
1951 BOOL16 WINAPI RemoveFontResource16( LPCSTR str )
1953 return RemoveFontResourceA(str);
1957 /***********************************************************************
1958 * SetBrushOrg (GDI.148)
1960 DWORD WINAPI SetBrushOrg16( HDC16 hdc, INT16 x, INT16 y )
1962 POINT pt;
1964 if (!SetBrushOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
1965 return MAKELONG( pt.x, pt.y );
1969 /***********************************************************************
1970 * GetBrushOrg (GDI.149)
1972 DWORD WINAPI GetBrushOrg16( HDC16 hdc )
1974 POINT pt;
1975 if (!GetBrushOrgEx( HDC_32(hdc), &pt )) return 0;
1976 return MAKELONG( pt.x, pt.y );
1980 /***********************************************************************
1981 * UnrealizeObject (GDI.150)
1983 BOOL16 WINAPI UnrealizeObject16( HGDIOBJ16 obj )
1985 return UnrealizeObject( HGDIOBJ_32(obj) );
1989 /***********************************************************************
1990 * CreateIC (GDI.153)
1992 HDC16 WINAPI CreateIC16( LPCSTR driver, LPCSTR device, LPCSTR output,
1993 const DEVMODEA* initData )
1995 return HDC_16( CreateICA( driver, device, output, initData ) );
1999 /***********************************************************************
2000 * GetNearestColor (GDI.154)
2002 COLORREF WINAPI GetNearestColor16( HDC16 hdc, COLORREF color )
2004 return GetNearestColor( HDC_32(hdc), color );
2008 /***********************************************************************
2009 * CreateDiscardableBitmap (GDI.156)
2011 HBITMAP16 WINAPI CreateDiscardableBitmap16( HDC16 hdc, INT16 width, INT16 height )
2013 return HBITMAP_16( CreateDiscardableBitmap( HDC_32(hdc), width, height ) );
2017 /***********************************************************************
2018 * PtInRegion (GDI.161)
2020 BOOL16 WINAPI PtInRegion16( HRGN16 hrgn, INT16 x, INT16 y )
2022 return PtInRegion( HRGN_32(hrgn), x, y );
2026 /***********************************************************************
2027 * GetBitmapDimension (GDI.162)
2029 DWORD WINAPI GetBitmapDimension16( HBITMAP16 hbitmap )
2031 SIZE16 size;
2032 if (!GetBitmapDimensionEx16( hbitmap, &size )) return 0;
2033 return MAKELONG( size.cx, size.cy );
2037 /***********************************************************************
2038 * SetBitmapDimension (GDI.163)
2040 DWORD WINAPI SetBitmapDimension16( HBITMAP16 hbitmap, INT16 x, INT16 y )
2042 SIZE16 size;
2043 if (!SetBitmapDimensionEx16( hbitmap, x, y, &size )) return 0;
2044 return MAKELONG( size.cx, size.cy );
2048 /***********************************************************************
2049 * SetRectRgn (GDI.172)
2051 * NOTE: Win 3.1 sets region to empty if left > right
2053 void WINAPI SetRectRgn16( HRGN16 hrgn, INT16 left, INT16 top, INT16 right, INT16 bottom )
2055 if (left < right) SetRectRgn( HRGN_32(hrgn), left, top, right, bottom );
2056 else SetRectRgn( HRGN_32(hrgn), 0, 0, 0, 0 );
2060 /******************************************************************
2061 * PlayMetaFileRecord (GDI.176)
2063 void WINAPI PlayMetaFileRecord16( HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr, UINT16 handles )
2065 HANDLETABLE *ht32 = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET(HANDLETABLE, objectHandle[handles] ));
2066 unsigned int i;
2068 for (i = 0; i < handles; i++) ht32->objectHandle[i] = HGDIOBJ_32(ht->objectHandle[i]);
2069 PlayMetaFileRecord( HDC_32(hdc), ht32, mr, handles );
2070 for (i = 0; i < handles; i++) ht->objectHandle[i] = HGDIOBJ_16(ht32->objectHandle[i]);
2071 HeapFree( GetProcessHeap(), 0, ht32 );
2075 /***********************************************************************
2076 * SetDCHook (GDI.190)
2078 BOOL16 WINAPI SetDCHook16( HDC16 hdc16, FARPROC16 hookProc, DWORD dwHookData )
2080 FIXME( "%04x %p %lx: not supported\n", hdc16, hookProc, dwHookData );
2081 return FALSE;
2085 /***********************************************************************
2086 * GetDCHook (GDI.191)
2088 DWORD WINAPI GetDCHook16( HDC16 hdc16, FARPROC16 *phookProc )
2090 FIXME( "%04x: not supported\n", hdc16 );
2091 return 0;
2095 /***********************************************************************
2096 * SetHookFlags (GDI.192)
2098 WORD WINAPI SetHookFlags16( HDC16 hdc, WORD flags )
2100 FIXME( "%04x %x: not supported\n", hdc, flags );
2101 return 0;
2105 /***********************************************************************
2106 * SetBoundsRect (GDI.193)
2108 UINT16 WINAPI SetBoundsRect16( HDC16 hdc, const RECT16* rect, UINT16 flags )
2110 if (rect)
2112 RECT rect32;
2113 rect32.left = rect->left;
2114 rect32.top = rect->top;
2115 rect32.right = rect->right;
2116 rect32.bottom = rect->bottom;
2117 return SetBoundsRect( HDC_32( hdc ), &rect32, flags );
2119 else return SetBoundsRect( HDC_32( hdc ), NULL, flags );
2123 /***********************************************************************
2124 * GetBoundsRect (GDI.194)
2126 UINT16 WINAPI GetBoundsRect16( HDC16 hdc, LPRECT16 rect, UINT16 flags)
2128 RECT rect32;
2129 UINT ret = GetBoundsRect( HDC_32( hdc ), &rect32, flags );
2130 if (rect)
2132 rect->left = rect32.left;
2133 rect->top = rect32.top;
2134 rect->right = rect32.right;
2135 rect->bottom = rect32.bottom;
2137 return ret;
2141 /***********************************************************************
2142 * EngineEnumerateFont (GDI.300)
2144 WORD WINAPI EngineEnumerateFont16(LPSTR fontname, FARPROC16 proc, DWORD data )
2146 FIXME("(%s,%p,%lx),stub\n",fontname,proc,data);
2147 return 0;
2151 /***********************************************************************
2152 * EngineDeleteFont (GDI.301)
2154 WORD WINAPI EngineDeleteFont16(LPFONTINFO16 lpFontInfo)
2156 WORD handle;
2158 /* untested, don't know if it works.
2159 We seem to access some structure that is located after the
2160 FONTINFO. The FONTINFO documentation says that there may
2161 follow some char-width table or font bitmap or vector info.
2162 I think it is some kind of font bitmap that begins at offset 0x52,
2163 as FONTINFO goes up to 0x51.
2164 If this is correct, everything should be implemented correctly.
2166 if ( ((lpFontInfo->dfType & (RASTER_FONTTYPE|DEVICE_FONTTYPE)) == (RASTER_FONTTYPE|DEVICE_FONTTYPE))
2167 && (LOWORD(lpFontInfo->dfFace) == LOWORD(lpFontInfo)+0x6e)
2168 && (handle = *(WORD *)(lpFontInfo+0x54)) )
2170 *(WORD *)(lpFontInfo+0x54) = 0;
2171 GlobalFree16(handle);
2173 return 1;
2177 /***********************************************************************
2178 * EngineRealizeFont (GDI.302)
2180 WORD WINAPI EngineRealizeFont16(LPLOGFONT16 lplogFont, LPTEXTXFORM16 lptextxform, LPFONTINFO16 lpfontInfo)
2182 FIXME("(%p,%p,%p),stub\n",lplogFont,lptextxform,lpfontInfo);
2184 return 0;
2188 /***********************************************************************
2189 * EngineRealizeFontExt (GDI.315)
2191 WORD WINAPI EngineRealizeFontExt16(LONG l1, LONG l2, LONG l3, LONG l4)
2193 FIXME("(%08lx,%08lx,%08lx,%08lx),stub\n",l1,l2,l3,l4);
2195 return 0;
2199 /***********************************************************************
2200 * EngineGetCharWidth (GDI.303)
2202 WORD WINAPI EngineGetCharWidth16(LPFONTINFO16 lpFontInfo, BYTE firstChar, BYTE lastChar, LPINT16 buffer)
2204 int i;
2206 for (i = firstChar; i <= lastChar; i++)
2207 FIXME(" returns font's average width for range %d to %d\n", firstChar, lastChar);
2208 *buffer++ = lpFontInfo->dfAvgWidth; /* insert some charwidth functionality here; use average width for now */
2209 return 1;
2213 /***********************************************************************
2214 * EngineSetFontContext (GDI.304)
2216 WORD WINAPI EngineSetFontContext16(LPFONTINFO16 lpFontInfo, WORD data)
2218 FIXME("stub?\n");
2219 return 0;
2222 /***********************************************************************
2223 * EngineGetGlyphBMP (GDI.305)
2225 WORD WINAPI EngineGetGlyphBMP16(WORD word, LPFONTINFO16 lpFontInfo, WORD w1, WORD w2,
2226 LPSTR string, DWORD dword, /*LPBITMAPMETRICS16*/ LPVOID metrics)
2228 FIXME("stub?\n");
2229 return 0;
2233 /***********************************************************************
2234 * EngineMakeFontDir (GDI.306)
2236 DWORD WINAPI EngineMakeFontDir16(HDC16 hdc, LPFONTDIR16 fontdir, LPCSTR string)
2238 FIXME(" stub! (always fails)\n");
2239 return ~0UL; /* error */
2243 /***********************************************************************
2244 * GetCharABCWidths (GDI.307)
2246 BOOL16 WINAPI GetCharABCWidths16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar, LPABC16 abc )
2248 BOOL ret;
2249 UINT i;
2250 LPABC abc32 = HeapAlloc( GetProcessHeap(), 0, sizeof(ABC) * (lastChar - firstChar + 1) );
2252 if ((ret = GetCharABCWidthsA( HDC_32(hdc), firstChar, lastChar, abc32 )))
2254 for (i = firstChar; i <= lastChar; i++)
2256 abc[i-firstChar].abcA = abc32[i-firstChar].abcA;
2257 abc[i-firstChar].abcB = abc32[i-firstChar].abcB;
2258 abc[i-firstChar].abcC = abc32[i-firstChar].abcC;
2261 HeapFree( GetProcessHeap(), 0, abc32 );
2262 return ret;
2266 /***********************************************************************
2267 * GetOutlineTextMetrics (GDI.308)
2269 * Gets metrics for TrueType fonts.
2271 * PARAMS
2272 * hdc [In] Handle of device context
2273 * cbData [In] Size of metric data array
2274 * lpOTM [Out] Address of metric data array
2276 * RETURNS
2277 * Success: Non-zero or size of required buffer
2278 * Failure: 0
2280 * NOTES
2281 * lpOTM should be LPOUTLINETEXTMETRIC
2283 UINT16 WINAPI GetOutlineTextMetrics16( HDC16 hdc, UINT16 cbData,
2284 LPOUTLINETEXTMETRIC16 lpOTM )
2286 FIXME("(%04x,%04x,%p): stub\n", hdc,cbData,lpOTM);
2287 return 0;
2291 /***********************************************************************
2292 * GetGlyphOutline (GDI.309)
2294 DWORD WINAPI GetGlyphOutline16( HDC16 hdc, UINT16 uChar, UINT16 fuFormat,
2295 LPGLYPHMETRICS16 lpgm, DWORD cbBuffer,
2296 LPVOID lpBuffer, const MAT2 *lpmat2 )
2298 DWORD ret;
2299 GLYPHMETRICS gm32;
2301 ret = GetGlyphOutlineA( HDC_32(hdc), uChar, fuFormat, &gm32, cbBuffer, lpBuffer, lpmat2);
2302 if (ret && ret != GDI_ERROR)
2304 lpgm->gmBlackBoxX = gm32.gmBlackBoxX;
2305 lpgm->gmBlackBoxY = gm32.gmBlackBoxY;
2306 lpgm->gmptGlyphOrigin.x = gm32.gmptGlyphOrigin.x;
2307 lpgm->gmptGlyphOrigin.y = gm32.gmptGlyphOrigin.y;
2308 lpgm->gmCellIncX = gm32.gmCellIncX;
2309 lpgm->gmCellIncY = gm32.gmCellIncY;
2311 return ret;
2315 /***********************************************************************
2316 * CreateScalableFontResource (GDI.310)
2318 BOOL16 WINAPI CreateScalableFontResource16( UINT16 fHidden, LPCSTR lpszResourceFile,
2319 LPCSTR fontFile, LPCSTR path )
2321 return CreateScalableFontResourceA( fHidden, lpszResourceFile, fontFile, path );
2325 /*************************************************************************
2326 * GetFontData (GDI.311)
2329 DWORD WINAPI GetFontData16( HDC16 hdc, DWORD table, DWORD offset, LPVOID buffer, DWORD count )
2331 return GetFontData( HDC_32(hdc), table, offset, buffer, count );
2335 /*************************************************************************
2336 * GetRasterizerCaps (GDI.313)
2338 BOOL16 WINAPI GetRasterizerCaps16( LPRASTERIZER_STATUS lprs, UINT16 cbNumBytes )
2340 return GetRasterizerCaps( lprs, cbNumBytes );
2344 /***********************************************************************
2345 * EnumFontFamilies (GDI.330)
2347 INT16 WINAPI EnumFontFamilies16( HDC16 hDC, LPCSTR lpFamily,
2348 FONTENUMPROC16 efproc, LPARAM lpData )
2350 LOGFONT16 lf, *plf;
2352 if (lpFamily)
2354 if (!*lpFamily) return 1;
2355 lstrcpynA( lf.lfFaceName, lpFamily, LF_FACESIZE );
2356 lf.lfCharSet = DEFAULT_CHARSET;
2357 lf.lfPitchAndFamily = 0;
2358 plf = &lf;
2360 else plf = NULL;
2362 return EnumFontFamiliesEx16( hDC, plf, efproc, lpData, 0 );
2366 /*************************************************************************
2367 * GetKerningPairs (GDI.332)
2370 INT16 WINAPI GetKerningPairs16( HDC16 hdc, INT16 count, LPKERNINGPAIR16 pairs )
2372 KERNINGPAIR *pairs32;
2373 INT i, ret;
2375 if (!count) return 0;
2377 if (!(pairs32 = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*pairs32) ))) return 0;
2378 if ((ret = GetKerningPairsA( HDC_32(hdc), count, pairs32 )))
2380 for (i = 0; i < ret; i++)
2382 pairs->wFirst = pairs32->wFirst;
2383 pairs->wSecond = pairs32->wSecond;
2384 pairs->iKernAmount = pairs32->iKernAmount;
2387 HeapFree( GetProcessHeap(), 0, pairs32 );
2388 return ret;
2393 /***********************************************************************
2394 * GetTextAlign (GDI.345)
2396 UINT16 WINAPI GetTextAlign16( HDC16 hdc )
2398 return GetTextAlign( HDC_32(hdc) );
2402 /***********************************************************************
2403 * SetTextAlign (GDI.346)
2405 UINT16 WINAPI SetTextAlign16( HDC16 hdc, UINT16 align )
2407 return SetTextAlign( HDC_32(hdc), align );
2411 /***********************************************************************
2412 * Chord (GDI.348)
2414 BOOL16 WINAPI Chord16( HDC16 hdc, INT16 left, INT16 top,
2415 INT16 right, INT16 bottom, INT16 xstart, INT16 ystart,
2416 INT16 xend, INT16 yend )
2418 return Chord( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
2422 /***********************************************************************
2423 * SetMapperFlags (GDI.349)
2425 DWORD WINAPI SetMapperFlags16( HDC16 hdc, DWORD flags )
2427 return SetMapperFlags( HDC_32(hdc), flags );
2431 /***********************************************************************
2432 * GetCharWidth (GDI.350)
2434 BOOL16 WINAPI GetCharWidth16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar, LPINT16 buffer )
2436 BOOL retVal = FALSE;
2438 if( firstChar != lastChar )
2440 LPINT buf32 = HeapAlloc(GetProcessHeap(), 0, sizeof(INT)*(1 + (lastChar - firstChar)));
2441 if( buf32 )
2443 LPINT obuf32 = buf32;
2444 UINT i;
2446 retVal = GetCharWidth32A( HDC_32(hdc), firstChar, lastChar, buf32);
2447 if (retVal)
2449 for (i = firstChar; i <= lastChar; i++) *buffer++ = *buf32++;
2451 HeapFree(GetProcessHeap(), 0, obuf32);
2454 else /* happens quite often to warrant a special treatment */
2456 INT chWidth;
2457 retVal = GetCharWidth32A( HDC_32(hdc), firstChar, lastChar, &chWidth );
2458 *buffer = chWidth;
2460 return retVal;
2464 /***********************************************************************
2465 * ExtTextOut (GDI.351)
2467 BOOL16 WINAPI ExtTextOut16( HDC16 hdc, INT16 x, INT16 y, UINT16 flags,
2468 const RECT16 *lprect, LPCSTR str, UINT16 count,
2469 const INT16 *lpDx )
2471 BOOL ret;
2472 int i;
2473 RECT rect32;
2474 LPINT lpdx32 = NULL;
2476 if (lpDx) {
2477 lpdx32 = HeapAlloc( GetProcessHeap(),0, sizeof(INT)*count );
2478 if(lpdx32 == NULL) return FALSE;
2479 for (i=count;i--;) lpdx32[i]=lpDx[i];
2481 if (lprect)
2483 rect32.left = lprect->left;
2484 rect32.top = lprect->top;
2485 rect32.right = lprect->right;
2486 rect32.bottom = lprect->bottom;
2488 ret = ExtTextOutA(HDC_32(hdc),x,y,flags,lprect?&rect32:NULL,str,count,lpdx32);
2489 HeapFree( GetProcessHeap(), 0, lpdx32 );
2490 return ret;
2494 /***********************************************************************
2495 * CreatePalette (GDI.360)
2497 HPALETTE16 WINAPI CreatePalette16( const LOGPALETTE* palette )
2499 return HPALETTE_16( CreatePalette( palette ) );
2503 /***********************************************************************
2504 * GDISelectPalette (GDI.361)
2506 HPALETTE16 WINAPI GDISelectPalette16( HDC16 hdc, HPALETTE16 hpalette, WORD wBkg )
2508 HPALETTE16 ret = HPALETTE_16( SelectPalette( HDC_32(hdc), HPALETTE_32(hpalette), wBkg ));
2509 if (ret && !wBkg) hPrimaryPalette = hpalette;
2510 return ret;
2514 /***********************************************************************
2515 * GDIRealizePalette (GDI.362)
2517 UINT16 WINAPI GDIRealizePalette16( HDC16 hdc )
2519 return RealizePalette( HDC_32(hdc) );
2523 /***********************************************************************
2524 * GetPaletteEntries (GDI.363)
2526 UINT16 WINAPI GetPaletteEntries16( HPALETTE16 hpalette, UINT16 start,
2527 UINT16 count, LPPALETTEENTRY entries )
2529 return GetPaletteEntries( HPALETTE_32(hpalette), start, count, entries );
2533 /***********************************************************************
2534 * SetPaletteEntries (GDI.364)
2536 UINT16 WINAPI SetPaletteEntries16( HPALETTE16 hpalette, UINT16 start,
2537 UINT16 count, const PALETTEENTRY *entries )
2539 return SetPaletteEntries( HPALETTE_32(hpalette), start, count, entries );
2543 /**********************************************************************
2544 * UpdateColors (GDI.366)
2546 INT16 WINAPI UpdateColors16( HDC16 hdc )
2548 UpdateColors( HDC_32(hdc) );
2549 return TRUE;
2553 /***********************************************************************
2554 * AnimatePalette (GDI.367)
2556 void WINAPI AnimatePalette16( HPALETTE16 hpalette, UINT16 StartIndex,
2557 UINT16 NumEntries, const PALETTEENTRY* PaletteColors)
2559 AnimatePalette( HPALETTE_32(hpalette), StartIndex, NumEntries, PaletteColors );
2563 /***********************************************************************
2564 * ResizePalette (GDI.368)
2566 BOOL16 WINAPI ResizePalette16( HPALETTE16 hpalette, UINT16 cEntries )
2568 return ResizePalette( HPALETTE_32(hpalette), cEntries );
2572 /***********************************************************************
2573 * GetNearestPaletteIndex (GDI.370)
2575 UINT16 WINAPI GetNearestPaletteIndex16( HPALETTE16 hpalette, COLORREF color )
2577 return GetNearestPaletteIndex( HPALETTE_32(hpalette), color );
2581 /**********************************************************************
2582 * ExtFloodFill (GDI.372)
2584 BOOL16 WINAPI ExtFloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color,
2585 UINT16 fillType )
2587 return ExtFloodFill( HDC_32(hdc), x, y, color, fillType );
2591 /***********************************************************************
2592 * SetSystemPaletteUse (GDI.373)
2594 UINT16 WINAPI SetSystemPaletteUse16( HDC16 hdc, UINT16 use )
2596 return SetSystemPaletteUse( HDC_32(hdc), use );
2600 /***********************************************************************
2601 * GetSystemPaletteUse (GDI.374)
2603 UINT16 WINAPI GetSystemPaletteUse16( HDC16 hdc )
2605 return GetSystemPaletteUse( HDC_32(hdc) );
2609 /***********************************************************************
2610 * GetSystemPaletteEntries (GDI.375)
2612 UINT16 WINAPI GetSystemPaletteEntries16( HDC16 hdc, UINT16 start, UINT16 count,
2613 LPPALETTEENTRY entries )
2615 return GetSystemPaletteEntries( HDC_32(hdc), start, count, entries );
2619 /***********************************************************************
2620 * ResetDC (GDI.376)
2622 HDC16 WINAPI ResetDC16( HDC16 hdc, const DEVMODEA *devmode )
2624 return HDC_16( ResetDCA(HDC_32(hdc), devmode) );
2628 /******************************************************************
2629 * StartDoc (GDI.377)
2631 INT16 WINAPI StartDoc16( HDC16 hdc, const DOCINFO16 *lpdoc )
2633 DOCINFOA docA;
2635 docA.cbSize = lpdoc->cbSize;
2636 docA.lpszDocName = MapSL(lpdoc->lpszDocName);
2637 docA.lpszOutput = MapSL(lpdoc->lpszOutput);
2638 if(lpdoc->cbSize > offsetof(DOCINFO16,lpszDatatype))
2639 docA.lpszDatatype = MapSL(lpdoc->lpszDatatype);
2640 else
2641 docA.lpszDatatype = NULL;
2642 if(lpdoc->cbSize > offsetof(DOCINFO16,fwType))
2643 docA.fwType = lpdoc->fwType;
2644 else
2645 docA.fwType = 0;
2646 return StartDocA( HDC_32(hdc), &docA );
2650 /******************************************************************
2651 * EndDoc (GDI.378)
2653 INT16 WINAPI EndDoc16( HDC16 hdc )
2655 return EndDoc( HDC_32(hdc) );
2659 /******************************************************************
2660 * StartPage (GDI.379)
2662 INT16 WINAPI StartPage16( HDC16 hdc )
2664 return StartPage( HDC_32(hdc) );
2668 /******************************************************************
2669 * EndPage (GDI.380)
2671 INT16 WINAPI EndPage16( HDC16 hdc )
2673 return EndPage( HDC_32(hdc) );
2677 /******************************************************************************
2678 * AbortDoc (GDI.382)
2680 INT16 WINAPI AbortDoc16( HDC16 hdc )
2682 return AbortDoc( HDC_32(hdc) );
2686 /***********************************************************************
2687 * FastWindowFrame (GDI.400)
2689 BOOL16 WINAPI FastWindowFrame16( HDC16 hdc, const RECT16 *rect,
2690 INT16 width, INT16 height, DWORD rop )
2692 HDC hdc32 = HDC_32(hdc);
2693 HBRUSH hbrush = SelectObject( hdc32, GetStockObject( GRAY_BRUSH ) );
2694 PatBlt( hdc32, rect->left, rect->top,
2695 rect->right - rect->left - width, height, rop );
2696 PatBlt( hdc32, rect->left, rect->top + height, width,
2697 rect->bottom - rect->top - height, rop );
2698 PatBlt( hdc32, rect->left + width, rect->bottom - 1,
2699 rect->right - rect->left - width, -height, rop );
2700 PatBlt( hdc32, rect->right - 1, rect->top, -width,
2701 rect->bottom - rect->top - height, rop );
2702 SelectObject( hdc32, hbrush );
2703 return TRUE;
2707 /***********************************************************************
2708 * GdiInit2 (GDI.403)
2710 * See "Undocumented Windows"
2712 * PARAMS
2713 * h1 [I] GDI object
2714 * h2 [I] global data
2716 HANDLE16 WINAPI GdiInit216( HANDLE16 h1, HANDLE16 h2 )
2718 FIXME("(%04x, %04x), stub.\n", h1, h2);
2719 if (h2 == 0xffff) return 0xffff; /* undefined return value */
2720 return h1; /* FIXME: should be the memory handle of h1 */
2724 /***********************************************************************
2725 * FinalGdiInit (GDI.405)
2727 void WINAPI FinalGdiInit16( HBRUSH16 hPattern /* [in] fill pattern of desktop */ )
2732 /***********************************************************************
2733 * CreateUserBitmap (GDI.407)
2735 HBITMAP16 WINAPI CreateUserBitmap16( INT16 width, INT16 height, UINT16 planes,
2736 UINT16 bpp, LPCVOID bits )
2738 return CreateBitmap16( width, height, planes, bpp, bits );
2742 /***********************************************************************
2743 * CreateUserDiscardableBitmap (GDI.409)
2745 HBITMAP16 WINAPI CreateUserDiscardableBitmap16( WORD dummy, INT16 width, INT16 height )
2747 HDC hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
2748 HBITMAP ret = CreateCompatibleBitmap( hdc, width, height );
2749 DeleteDC( hdc );
2750 return HBITMAP_16(ret);
2754 /***********************************************************************
2755 * GetCurLogFont (GDI.411)
2757 HFONT16 WINAPI GetCurLogFont16( HDC16 hdc )
2759 return HFONT_16( GetCurrentObject( HDC_32(hdc), OBJ_FONT ) );
2763 /***********************************************************************
2764 * StretchDIBits (GDI.439)
2766 INT16 WINAPI StretchDIBits16( HDC16 hdc, INT16 xDst, INT16 yDst, INT16 widthDst,
2767 INT16 heightDst, INT16 xSrc, INT16 ySrc, INT16 widthSrc,
2768 INT16 heightSrc, const VOID *bits,
2769 const BITMAPINFO *info, UINT16 wUsage, DWORD dwRop )
2771 return StretchDIBits( HDC_32(hdc), xDst, yDst, widthDst, heightDst,
2772 xSrc, ySrc, widthSrc, heightSrc, bits,
2773 info, wUsage, dwRop );
2777 /***********************************************************************
2778 * SetDIBits (GDI.440)
2780 INT16 WINAPI SetDIBits16( HDC16 hdc, HBITMAP16 hbitmap, UINT16 startscan,
2781 UINT16 lines, LPCVOID bits, const BITMAPINFO *info,
2782 UINT16 coloruse )
2784 return SetDIBits( HDC_32(hdc), HBITMAP_32(hbitmap), startscan, lines, bits, info, coloruse );
2788 /***********************************************************************
2789 * GetDIBits (GDI.441)
2791 INT16 WINAPI GetDIBits16( HDC16 hdc, HBITMAP16 hbitmap, UINT16 startscan,
2792 UINT16 lines, LPVOID bits, BITMAPINFO * info,
2793 UINT16 coloruse )
2795 return GetDIBits( HDC_32(hdc), HBITMAP_32(hbitmap), startscan, lines, bits, info, coloruse );
2799 /***********************************************************************
2800 * CreateDIBitmap (GDI.442)
2802 HBITMAP16 WINAPI CreateDIBitmap16( HDC16 hdc, const BITMAPINFOHEADER * header,
2803 DWORD init, LPCVOID bits, const BITMAPINFO * data,
2804 UINT16 coloruse )
2806 return HBITMAP_16( CreateDIBitmap( HDC_32(hdc), header, init, bits, data, coloruse ) );
2810 /***********************************************************************
2811 * SetDIBitsToDevice (GDI.443)
2813 INT16 WINAPI SetDIBitsToDevice16( HDC16 hdc, INT16 xDest, INT16 yDest, INT16 cx,
2814 INT16 cy, INT16 xSrc, INT16 ySrc, UINT16 startscan,
2815 UINT16 lines, LPCVOID bits, const BITMAPINFO *info,
2816 UINT16 coloruse )
2818 return SetDIBitsToDevice( HDC_32(hdc), xDest, yDest, cx, cy, xSrc, ySrc,
2819 startscan, lines, bits, info, coloruse );
2823 /***********************************************************************
2824 * CreateRoundRectRgn (GDI.444)
2826 * If either ellipse dimension is zero we call CreateRectRgn16 for its
2827 * `special' behaviour. -ve ellipse dimensions can result in GPFs under win3.1
2828 * we just let CreateRoundRectRgn convert them to +ve values.
2831 HRGN16 WINAPI CreateRoundRectRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom,
2832 INT16 ellipse_width, INT16 ellipse_height )
2834 if( ellipse_width == 0 || ellipse_height == 0 )
2835 return CreateRectRgn16( left, top, right, bottom );
2836 else
2837 return HRGN_16( CreateRoundRectRgn( left, top, right, bottom,
2838 ellipse_width, ellipse_height ));
2842 /***********************************************************************
2843 * CreateDIBPatternBrush (GDI.445)
2845 HBRUSH16 WINAPI CreateDIBPatternBrush16( HGLOBAL16 hbitmap, UINT16 coloruse )
2847 BITMAPINFO *bmi;
2848 HBRUSH16 ret;
2850 if (!(bmi = GlobalLock16( hbitmap ))) return 0;
2851 ret = HBRUSH_16( CreateDIBPatternBrushPt( bmi, coloruse ));
2852 GlobalUnlock16( hbitmap );
2853 return ret;
2857 /**********************************************************************
2858 * PolyPolygon (GDI.450)
2860 BOOL16 WINAPI PolyPolygon16( HDC16 hdc, const POINT16* pt, const INT16* counts,
2861 UINT16 polygons )
2863 int i,nrpts;
2864 LPPOINT pt32;
2865 LPINT counts32;
2866 BOOL16 ret;
2868 nrpts=0;
2869 for (i=polygons;i--;)
2870 nrpts+=counts[i];
2871 pt32 = HeapAlloc( GetProcessHeap(), 0, sizeof(POINT)*nrpts);
2872 if(pt32 == NULL) return FALSE;
2873 for (i=nrpts;i--;)
2875 pt32[i].x = pt[i].x;
2876 pt32[i].y = pt[i].y;
2878 counts32 = HeapAlloc( GetProcessHeap(), 0, polygons*sizeof(INT) );
2879 if(counts32 == NULL) {
2880 HeapFree( GetProcessHeap(), 0, pt32 );
2881 return FALSE;
2883 for (i=polygons;i--;) counts32[i]=counts[i];
2885 ret = PolyPolygon(HDC_32(hdc),pt32,counts32,polygons);
2886 HeapFree( GetProcessHeap(), 0, counts32 );
2887 HeapFree( GetProcessHeap(), 0, pt32 );
2888 return ret;
2892 /***********************************************************************
2893 * CreatePolyPolygonRgn (GDI.451)
2895 HRGN16 WINAPI CreatePolyPolygonRgn16( const POINT16 *points,
2896 const INT16 *count, INT16 nbpolygons, INT16 mode )
2898 HRGN hrgn;
2899 int i, npts = 0;
2900 INT *count32;
2901 POINT *points32;
2903 for (i = 0; i < nbpolygons; i++) npts += count[i];
2904 points32 = HeapAlloc( GetProcessHeap(), 0, npts * sizeof(POINT) );
2905 for (i = 0; i < npts; i++)
2907 points32[i].x = points[i].x;
2908 points32[i].y = points[i].y;
2911 count32 = HeapAlloc( GetProcessHeap(), 0, nbpolygons * sizeof(INT) );
2912 for (i = 0; i < nbpolygons; i++) count32[i] = count[i];
2913 hrgn = CreatePolyPolygonRgn( points32, count32, nbpolygons, mode );
2914 HeapFree( GetProcessHeap(), 0, count32 );
2915 HeapFree( GetProcessHeap(), 0, points32 );
2916 return HRGN_16(hrgn);
2920 /***********************************************************************
2921 * GdiSeeGdiDo (GDI.452)
2923 DWORD WINAPI GdiSeeGdiDo16( WORD wReqType, WORD wParam1, WORD wParam2,
2924 WORD wParam3 )
2926 DWORD ret = ~0U;
2928 switch (wReqType)
2930 case 0x0001: /* LocalAlloc */
2931 WARN("LocalAlloc16(%x, %x): ignoring\n", wParam1, wParam3);
2932 ret = 0;
2933 break;
2934 case 0x0002: /* LocalFree */
2935 WARN("LocalFree16(%x): ignoring\n", wParam1);
2936 ret = 0;
2937 break;
2938 case 0x0003: /* LocalCompact */
2939 WARN("LocalCompact16(%x): ignoring\n", wParam3);
2940 ret = 65000; /* lie about the amount of free space */
2941 break;
2942 case 0x0103: /* LocalHeap */
2943 WARN("LocalHeap16(): ignoring\n");
2944 break;
2945 default:
2946 WARN("(wReqType=%04x): Unknown\n", wReqType);
2947 break;
2949 return ret;
2953 /***********************************************************************
2954 * SetObjectOwner (GDI.461)
2956 void WINAPI SetObjectOwner16( HGDIOBJ16 handle, HANDLE16 owner )
2958 /* Nothing to do */
2962 /***********************************************************************
2963 * IsGDIObject (GDI.462)
2965 * returns type of object if valid (W95 system programming secrets p. 264-5)
2967 BOOL16 WINAPI IsGDIObject16( HGDIOBJ16 handle16 )
2969 static const BYTE type_map[] =
2971 0, /* bad */
2972 1, /* OBJ_PEN */
2973 2, /* OBJ_BRUSH */
2974 7, /* OBJ_DC */
2975 9, /* OBJ_METADC */
2976 4, /* OBJ_PAL */
2977 3, /* OBJ_FONT */
2978 5, /* OBJ_BITMAP */
2979 6, /* OBJ_REGION */
2980 10, /* OBJ_METAFILE */
2981 7, /* OBJ_MEMDC */
2982 0, /* OBJ_EXTPEN */
2983 9, /* OBJ_ENHMETADC */
2984 12, /* OBJ_ENHMETAFILE */
2985 0 /* OBJ_COLORSPACE */
2988 UINT type = GetObjectType( HGDIOBJ_32( handle16 ));
2990 if (type >= ARRAY_SIZE(type_map)) return FALSE;
2991 return type_map[type];
2995 /***********************************************************************
2996 * RectVisible (GDI.465)
2997 * RectVisibleOld (GDI.104)
2999 BOOL16 WINAPI RectVisible16( HDC16 hdc, const RECT16* rect16 )
3001 RECT rect;
3003 rect.left = rect16->left;
3004 rect.top = rect16->top;
3005 rect.right = rect16->right;
3006 rect.bottom = rect16->bottom;
3007 return RectVisible( HDC_32(hdc), &rect );
3011 /***********************************************************************
3012 * RectInRegion (GDI.466)
3013 * RectInRegionOld (GDI.181)
3015 BOOL16 WINAPI RectInRegion16( HRGN16 hrgn, const RECT16 *rect )
3017 RECT r32;
3019 r32.left = rect->left;
3020 r32.top = rect->top;
3021 r32.right = rect->right;
3022 r32.bottom = rect->bottom;
3023 return RectInRegion( HRGN_32(hrgn), &r32 );
3027 /***********************************************************************
3028 * GetBitmapDimensionEx (GDI.468)
3030 BOOL16 WINAPI GetBitmapDimensionEx16( HBITMAP16 hbitmap, LPSIZE16 size )
3032 SIZE size32;
3033 BOOL ret = GetBitmapDimensionEx( HBITMAP_32(hbitmap), &size32 );
3035 if (ret)
3037 size->cx = size32.cx;
3038 size->cy = size32.cy;
3040 return ret;
3044 /***********************************************************************
3045 * GetBrushOrgEx (GDI.469)
3047 BOOL16 WINAPI GetBrushOrgEx16( HDC16 hdc, LPPOINT16 pt )
3049 POINT pt32;
3050 if (!GetBrushOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
3051 pt->x = pt32.x;
3052 pt->y = pt32.y;
3053 return TRUE;
3057 /***********************************************************************
3058 * GetCurrentPositionEx (GDI.470)
3060 BOOL16 WINAPI GetCurrentPositionEx16( HDC16 hdc, LPPOINT16 pt )
3062 POINT pt32;
3063 if (!GetCurrentPositionEx( HDC_32(hdc), &pt32 )) return FALSE;
3064 pt->x = pt32.x;
3065 pt->y = pt32.y;
3066 return TRUE;
3070 /***********************************************************************
3071 * GetTextExtentPoint (GDI.471)
3073 * FIXME: Should this have a bug for compatibility?
3074 * Original Windows versions of GetTextExtentPoint{A,W} have documented
3075 * bugs (-> MSDN KB q147647.txt).
3077 BOOL16 WINAPI GetTextExtentPoint16( HDC16 hdc, LPCSTR str, INT16 count, LPSIZE16 size )
3079 SIZE size32;
3080 BOOL ret = GetTextExtentPoint32A( HDC_32(hdc), str, count, &size32 );
3082 if (ret)
3084 size->cx = size32.cx;
3085 size->cy = size32.cy;
3087 return ret;
3091 /***********************************************************************
3092 * GetViewportExtEx (GDI.472)
3094 BOOL16 WINAPI GetViewportExtEx16( HDC16 hdc, LPSIZE16 size )
3096 SIZE size32;
3097 if (!GetViewportExtEx( HDC_32(hdc), &size32 )) return FALSE;
3098 size->cx = size32.cx;
3099 size->cy = size32.cy;
3100 return TRUE;
3104 /***********************************************************************
3105 * GetViewportOrgEx (GDI.473)
3107 BOOL16 WINAPI GetViewportOrgEx16( HDC16 hdc, LPPOINT16 pt )
3109 POINT pt32;
3110 if (!GetViewportOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
3111 pt->x = pt32.x;
3112 pt->y = pt32.y;
3113 return TRUE;
3117 /***********************************************************************
3118 * GetWindowExtEx (GDI.474)
3120 BOOL16 WINAPI GetWindowExtEx16( HDC16 hdc, LPSIZE16 size )
3122 SIZE size32;
3123 if (!GetWindowExtEx( HDC_32(hdc), &size32 )) return FALSE;
3124 size->cx = size32.cx;
3125 size->cy = size32.cy;
3126 return TRUE;
3130 /***********************************************************************
3131 * GetWindowOrgEx (GDI.475)
3133 BOOL16 WINAPI GetWindowOrgEx16( HDC16 hdc, LPPOINT16 pt )
3135 POINT pt32;
3136 if (!GetWindowOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
3137 pt->x = pt32.x;
3138 pt->y = pt32.y;
3139 return TRUE;
3143 /***********************************************************************
3144 * OffsetViewportOrgEx (GDI.476)
3146 BOOL16 WINAPI OffsetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt)
3148 POINT pt32;
3149 BOOL16 ret = OffsetViewportOrgEx( HDC_32(hdc), x, y, &pt32 );
3150 if (pt)
3152 pt->x = pt32.x;
3153 pt->y = pt32.y;
3155 return ret;
3159 /***********************************************************************
3160 * OffsetWindowOrgEx (GDI.477)
3162 BOOL16 WINAPI OffsetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
3164 POINT pt32;
3165 BOOL16 ret = OffsetWindowOrgEx( HDC_32(hdc), x, y, &pt32 );
3166 if (pt)
3168 pt->x = pt32.x;
3169 pt->y = pt32.y;
3171 return ret;
3175 /***********************************************************************
3176 * SetBitmapDimensionEx (GDI.478)
3178 BOOL16 WINAPI SetBitmapDimensionEx16( HBITMAP16 hbitmap, INT16 x, INT16 y, LPSIZE16 prevSize )
3180 SIZE size32;
3181 BOOL ret = SetBitmapDimensionEx( HBITMAP_32(hbitmap), x, y, &size32 );
3183 if (ret && prevSize)
3185 prevSize->cx = size32.cx;
3186 prevSize->cy = size32.cy;
3188 return ret;
3192 /***********************************************************************
3193 * SetViewportExtEx (GDI.479)
3195 BOOL16 WINAPI SetViewportExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
3197 SIZE size32;
3198 BOOL16 ret = SetViewportExtEx( HDC_32(hdc), x, y, &size32 );
3199 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
3200 return ret;
3204 /***********************************************************************
3205 * SetViewportOrgEx (GDI.480)
3207 BOOL16 WINAPI SetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
3209 POINT pt32;
3210 BOOL16 ret = SetViewportOrgEx( HDC_32(hdc), x, y, &pt32 );
3211 if (pt)
3213 pt->x = pt32.x;
3214 pt->y = pt32.y;
3216 return ret;
3220 /***********************************************************************
3221 * SetWindowExtEx (GDI.481)
3223 BOOL16 WINAPI SetWindowExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
3225 SIZE size32;
3226 BOOL16 ret = SetWindowExtEx( HDC_32(hdc), x, y, &size32 );
3227 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
3228 return ret;
3232 /***********************************************************************
3233 * SetWindowOrgEx (GDI.482)
3235 BOOL16 WINAPI SetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
3237 POINT pt32;
3238 BOOL16 ret = SetWindowOrgEx( HDC_32(hdc), x, y, &pt32 );
3239 if (pt)
3241 pt->x = pt32.x;
3242 pt->y = pt32.y;
3244 return ret;
3248 /***********************************************************************
3249 * MoveToEx (GDI.483)
3251 BOOL16 WINAPI MoveToEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
3253 POINT pt32;
3255 if (!MoveToEx( HDC_32(hdc), x, y, &pt32 )) return FALSE;
3256 if (pt)
3258 pt->x = pt32.x;
3259 pt->y = pt32.y;
3261 return TRUE;
3265 /***********************************************************************
3266 * ScaleViewportExtEx (GDI.484)
3268 BOOL16 WINAPI ScaleViewportExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
3269 INT16 yNum, INT16 yDenom, LPSIZE16 size )
3271 SIZE size32;
3272 BOOL16 ret = ScaleViewportExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom,
3273 &size32 );
3274 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
3275 return ret;
3279 /***********************************************************************
3280 * ScaleWindowExtEx (GDI.485)
3282 BOOL16 WINAPI ScaleWindowExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
3283 INT16 yNum, INT16 yDenom, LPSIZE16 size )
3285 SIZE size32;
3286 BOOL16 ret = ScaleWindowExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom,
3287 &size32 );
3288 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
3289 return ret;
3293 /***********************************************************************
3294 * GetAspectRatioFilterEx (GDI.486)
3296 BOOL16 WINAPI GetAspectRatioFilterEx16( HDC16 hdc, LPSIZE16 pAspectRatio )
3298 FIXME("(%04x, %p): -- Empty Stub !\n", hdc, pAspectRatio);
3299 return FALSE;
3303 /******************************************************************************
3304 * PolyBezier (GDI.502)
3306 BOOL16 WINAPI PolyBezier16( HDC16 hdc, const POINT16* lppt, INT16 cPoints )
3308 int i;
3309 BOOL16 ret;
3310 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, cPoints*sizeof(POINT) );
3311 if(!pt32) return FALSE;
3312 for (i=cPoints;i--;)
3314 pt32[i].x = lppt[i].x;
3315 pt32[i].y = lppt[i].y;
3317 ret= PolyBezier(HDC_32(hdc), pt32, cPoints);
3318 HeapFree( GetProcessHeap(), 0, pt32 );
3319 return ret;
3323 /******************************************************************************
3324 * PolyBezierTo (GDI.503)
3326 BOOL16 WINAPI PolyBezierTo16( HDC16 hdc, const POINT16* lppt, INT16 cPoints )
3328 int i;
3329 BOOL16 ret;
3330 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0,
3331 cPoints*sizeof(POINT) );
3332 if(!pt32) return FALSE;
3333 for (i=cPoints;i--;)
3335 pt32[i].x = lppt[i].x;
3336 pt32[i].y = lppt[i].y;
3338 ret= PolyBezierTo(HDC_32(hdc), pt32, cPoints);
3339 HeapFree( GetProcessHeap(), 0, pt32 );
3340 return ret;
3344 /******************************************************************************
3345 * ExtSelectClipRgn (GDI.508)
3347 INT16 WINAPI ExtSelectClipRgn16( HDC16 hdc, HRGN16 hrgn, INT16 fnMode )
3349 return ExtSelectClipRgn( HDC_32(hdc), HRGN_32(hrgn), fnMode);
3353 /***********************************************************************
3354 * AbortPath (GDI.511)
3356 BOOL16 WINAPI AbortPath16(HDC16 hdc)
3358 return AbortPath( HDC_32(hdc) );
3362 /***********************************************************************
3363 * BeginPath (GDI.512)
3365 BOOL16 WINAPI BeginPath16(HDC16 hdc)
3367 return BeginPath( HDC_32(hdc) );
3371 /***********************************************************************
3372 * CloseFigure (GDI.513)
3374 BOOL16 WINAPI CloseFigure16(HDC16 hdc)
3376 return CloseFigure( HDC_32(hdc) );
3380 /***********************************************************************
3381 * EndPath (GDI.514)
3383 BOOL16 WINAPI EndPath16(HDC16 hdc)
3385 return EndPath( HDC_32(hdc) );
3389 /***********************************************************************
3390 * FillPath (GDI.515)
3392 BOOL16 WINAPI FillPath16(HDC16 hdc)
3394 return FillPath( HDC_32(hdc) );
3398 /*******************************************************************
3399 * FlattenPath (GDI.516)
3401 BOOL16 WINAPI FlattenPath16(HDC16 hdc)
3403 return FlattenPath( HDC_32(hdc) );
3407 /***********************************************************************
3408 * GetPath (GDI.517)
3410 INT16 WINAPI GetPath16(HDC16 hdc, LPPOINT16 pPoints, LPBYTE pTypes, INT16 nSize)
3412 FIXME("(%d,%p,%p): stub\n",hdc,pPoints,pTypes);
3413 return 0;
3417 /***********************************************************************
3418 * PathToRegion (GDI.518)
3420 HRGN16 WINAPI PathToRegion16(HDC16 hdc)
3422 return HRGN_16( PathToRegion( HDC_32(hdc) ));
3426 /***********************************************************************
3427 * SelectClipPath (GDI.519)
3429 BOOL16 WINAPI SelectClipPath16(HDC16 hdc, INT16 iMode)
3431 return SelectClipPath( HDC_32(hdc), iMode );
3435 /*******************************************************************
3436 * StrokeAndFillPath (GDI.520)
3438 BOOL16 WINAPI StrokeAndFillPath16(HDC16 hdc)
3440 return StrokeAndFillPath( HDC_32(hdc) );
3444 /*******************************************************************
3445 * StrokePath (GDI.521)
3447 BOOL16 WINAPI StrokePath16(HDC16 hdc)
3449 return StrokePath( HDC_32(hdc) );
3453 /*******************************************************************
3454 * WidenPath (GDI.522)
3456 BOOL16 WINAPI WidenPath16(HDC16 hdc)
3458 return WidenPath( HDC_32(hdc) );
3462 /***********************************************************************
3463 * GetArcDirection (GDI.524)
3465 INT16 WINAPI GetArcDirection16( HDC16 hdc )
3467 return GetArcDirection( HDC_32(hdc) );
3471 /***********************************************************************
3472 * SetArcDirection (GDI.525)
3474 INT16 WINAPI SetArcDirection16( HDC16 hdc, INT16 nDirection )
3476 return SetArcDirection( HDC_32(hdc), (INT)nDirection );
3480 /***********************************************************************
3481 * CreateHalftonePalette (GDI.529)
3483 HPALETTE16 WINAPI CreateHalftonePalette16( HDC16 hdc )
3485 return HPALETTE_16( CreateHalftonePalette( HDC_32(hdc) ));
3489 /***********************************************************************
3490 * SetDIBColorTable (GDI.602)
3492 UINT16 WINAPI SetDIBColorTable16( HDC16 hdc, UINT16 startpos, UINT16 entries, RGBQUAD *colors )
3494 return SetDIBColorTable( HDC_32(hdc), startpos, entries, colors );
3498 /***********************************************************************
3499 * GetDIBColorTable (GDI.603)
3501 UINT16 WINAPI GetDIBColorTable16( HDC16 hdc, UINT16 startpos, UINT16 entries, RGBQUAD *colors )
3503 return GetDIBColorTable( HDC_32(hdc), startpos, entries, colors );
3507 /***********************************************************************
3508 * GetRegionData (GDI.607)
3510 * FIXME: is LPRGNDATA the same in Win16 and Win32 ?
3512 DWORD WINAPI GetRegionData16( HRGN16 hrgn, DWORD count, LPRGNDATA rgndata )
3514 return GetRegionData( HRGN_32(hrgn), count, rgndata );
3518 /***********************************************************************
3519 * GdiFreeResources (GDI.609)
3521 WORD WINAPI GdiFreeResources16( DWORD reserve )
3523 return 90; /* lie about it, it shouldn't matter */
3527 /***********************************************************************
3528 * GdiSignalProc32 (GDI.610)
3530 WORD WINAPI GdiSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
3531 DWORD dwFlags, HMODULE16 hModule )
3533 return 0;
3537 /***********************************************************************
3538 * GetTextCharset (GDI.612)
3540 UINT16 WINAPI GetTextCharset16( HDC16 hdc )
3542 return GetTextCharset( HDC_32(hdc) );
3546 /***********************************************************************
3547 * EnumFontFamiliesEx (GDI.613)
3549 INT16 WINAPI EnumFontFamiliesEx16( HDC16 hdc, LPLOGFONT16 plf,
3550 FONTENUMPROC16 proc, LPARAM lParam,
3551 DWORD dwFlags)
3553 struct callback16_info info;
3554 LOGFONTW lfW, *plfW;
3556 info.proc = (FARPROC16)proc;
3557 info.param = lParam;
3559 if (plf)
3561 logfont_16_to_W(plf, &lfW);
3562 plfW = &lfW;
3564 else plfW = NULL;
3566 return EnumFontFamiliesExW( HDC_32(hdc), plfW, enum_font_callback,
3567 (LPARAM)&info, dwFlags );
3571 /*************************************************************************
3572 * GetFontLanguageInfo (GDI.616)
3574 DWORD WINAPI GetFontLanguageInfo16( HDC16 hdc )
3576 return GetFontLanguageInfo( HDC_32(hdc) );
3580 /***********************************************************************
3581 * SetLayout (GDI.1000)
3583 * Sets left->right or right->left text layout flags of a dc.
3585 BOOL16 WINAPI SetLayout16( HDC16 hdc, DWORD layout )
3587 return SetLayout( HDC_32(hdc), layout );
3591 /***********************************************************************
3592 * SetSolidBrush (GDI.604)
3594 * Change the color of a solid brush.
3596 * PARAMS
3597 * hBrush [I] Brush to change the color of
3598 * newColor [I] New color for hBrush
3600 * RETURNS
3601 * Success: TRUE. The color of hBrush is set to newColor.
3602 * Failure: FALSE.
3604 * FIXME
3605 * This function is undocumented and untested. The implementation may
3606 * not be correct.
3608 BOOL16 WINAPI SetSolidBrush16(HBRUSH16 hBrush, COLORREF newColor )
3610 FIXME( "%04x %08lx no longer supported\n", hBrush, newColor );
3611 return FALSE;
3615 /***********************************************************************
3616 * Copy (GDI.250)
3618 void WINAPI Copy16( LPVOID src, LPVOID dst, WORD size )
3620 memcpy( dst, src, size );
3623 /***********************************************************************
3624 * RealizeDefaultPalette (GDI.365)
3626 UINT16 WINAPI RealizeDefaultPalette16( HDC16 hdc )
3628 FIXME( "%04x semi-stub\n", hdc );
3629 return GDIRealizePalette16( hdc );
3632 /***********************************************************************
3633 * IsDCCurrentPalette (GDI.412)
3635 BOOL16 WINAPI IsDCCurrentPalette16(HDC16 hDC)
3637 return HPALETTE_16( GetCurrentObject( HDC_32(hDC), OBJ_PAL )) == hPrimaryPalette;
3640 /*********************************************************************
3641 * SetMagicColors (GDI.606)
3643 VOID WINAPI SetMagicColors16(HDC16 hDC, COLORREF color, UINT16 index)
3645 FIXME("(hDC %04x, color %04x, index %04x): stub\n", hDC, (int)color, index);
3650 /***********************************************************************
3651 * DPtoLP (GDI.67)
3653 BOOL16 WINAPI DPtoLP16( HDC16 hdc, LPPOINT16 points, INT16 count )
3655 POINT points32[8], *pt32 = points32;
3656 int i;
3657 BOOL ret;
3659 if (count > 8)
3661 if (!(pt32 = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*pt32) ))) return FALSE;
3663 for (i = 0; i < count; i++)
3665 pt32[i].x = points[i].x;
3666 pt32[i].y = points[i].y;
3668 if ((ret = DPtoLP( HDC_32(hdc), pt32, count )))
3670 for (i = 0; i < count; i++)
3672 points[i].x = pt32[i].x;
3673 points[i].y = pt32[i].y;
3676 if (pt32 != points32) HeapFree( GetProcessHeap(), 0, pt32 );
3677 return ret;
3681 /***********************************************************************
3682 * LPtoDP (GDI.99)
3684 BOOL16 WINAPI LPtoDP16( HDC16 hdc, LPPOINT16 points, INT16 count )
3686 POINT points32[8], *pt32 = points32;
3687 int i;
3688 BOOL ret;
3690 if (count > 8)
3692 if (!(pt32 = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*pt32) ))) return FALSE;
3694 for (i = 0; i < count; i++)
3696 pt32[i].x = points[i].x;
3697 pt32[i].y = points[i].y;
3699 if ((ret = LPtoDP( HDC_32(hdc), pt32, count )))
3701 for (i = 0; i < count; i++)
3703 points[i].x = pt32[i].x;
3704 points[i].y = pt32[i].y;
3707 if (pt32 != points32) HeapFree( GetProcessHeap(), 0, pt32 );
3708 return ret;
3712 /***********************************************************************
3713 * GetDCState (GDI.179)
3715 HDC16 WINAPI GetDCState16( HDC16 hdc )
3717 ERR( "no longer supported\n" );
3718 return 0;
3722 /***********************************************************************
3723 * SetDCState (GDI.180)
3725 void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs )
3727 ERR( "no longer supported\n" );
3730 /***********************************************************************
3731 * SetDCOrg (GDI.117)
3733 DWORD WINAPI SetDCOrg16( HDC16 hdc16, INT16 x, INT16 y )
3735 FIXME( "%04x %d,%d no longer supported\n", hdc16, x, y );
3736 return 0;
3740 /***********************************************************************
3741 * InquireVisRgn (GDI.131)
3743 HRGN16 WINAPI InquireVisRgn16( HDC16 hdc )
3745 static HRGN hrgn;
3747 if (!hrgn) hrgn = CreateRectRgn( 0, 0, 0, 0 );
3748 GetRandomRgn( HDC_32(hdc), hrgn, SYSRGN );
3749 return HRGN_16(hrgn);
3753 /***********************************************************************
3754 * OffsetVisRgn (GDI.102)
3756 INT16 WINAPI OffsetVisRgn16( HDC16 hdc16, INT16 x, INT16 y )
3758 FIXME( "%04x %d,%d no longer supported\n", hdc16, x, y );
3759 return ERROR;
3763 /***********************************************************************
3764 * ExcludeVisRect (GDI.73)
3766 INT16 WINAPI ExcludeVisRect16( HDC16 hdc16, INT16 left, INT16 top, INT16 right, INT16 bottom )
3768 FIXME( "%04x %d,%d-%d,%d no longer supported\n", hdc16, left, top, right, bottom );
3769 return ERROR;
3773 /***********************************************************************
3774 * IntersectVisRect (GDI.98)
3776 INT16 WINAPI IntersectVisRect16( HDC16 hdc16, INT16 left, INT16 top, INT16 right, INT16 bottom )
3778 FIXME( "%04x %d,%d-%d,%d no longer supported\n", hdc16, left, top, right, bottom );
3779 return ERROR;
3783 /***********************************************************************
3784 * SaveVisRgn (GDI.129)
3786 HRGN16 WINAPI SaveVisRgn16( HDC16 hdc16 )
3788 FIXME( "%04x no longer supported\n", hdc16 );
3789 return 0;
3793 /***********************************************************************
3794 * RestoreVisRgn (GDI.130)
3796 INT16 WINAPI RestoreVisRgn16( HDC16 hdc16 )
3798 FIXME( "%04x no longer supported\n", hdc16 );
3799 return ERROR;
3803 /***********************************************************************
3804 * GetClipRgn (GDI.173)
3806 HRGN16 WINAPI GetClipRgn16( HDC16 hdc )
3808 static HRGN hrgn;
3810 if (!hrgn) hrgn = CreateRectRgn( 0, 0, 0, 0 );
3811 GetClipRgn( HDC_32(hdc), hrgn );
3812 return HRGN_16(hrgn);
3816 /***********************************************************************
3817 * MakeObjectPrivate (GDI.463)
3819 * What does that mean ?
3820 * Some little docu can be found in "Undocumented Windows",
3821 * but this is basically useless.
3823 void WINAPI MakeObjectPrivate16( HGDIOBJ16 handle16, BOOL16 private )
3825 FIXME( "stub: %x %u\n", handle16, private );
3828 /***********************************************************************
3829 * CreateDIBSection (GDI.489)
3831 HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, const BITMAPINFO *bmi, UINT16 usage,
3832 SEGPTR *bits16, HANDLE section, DWORD offset)
3834 LPVOID bits32;
3835 HBITMAP hbitmap;
3837 hbitmap = CreateDIBSection( HDC_32(hdc), bmi, usage, &bits32, section, offset );
3838 if (hbitmap && bits32 && bits16) *bits16 = alloc_segptr_bits( hbitmap, bits32 );
3839 return HBITMAP_16(hbitmap);