wined3d: Pass a wined3d_device_context to wined3d_cs_emit_blt_sub_resource().
[wine/zf.git] / dlls / gdi.exe16 / gdi.c
blob9afa4532fdee90d4527974881b3c4248783f4f46
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 "wingdi.h"
27 #include "wownt32.h"
28 #include "wine/wingdi16.h"
29 #include "wine/list.h"
30 #include "wine/gdi_driver.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
35 #define HGDIOBJ_32(handle16) ((HGDIOBJ)(ULONG_PTR)(handle16))
36 #define HGDIOBJ_16(handle32) ((HGDIOBJ16)(ULONG_PTR)(handle32))
38 struct saved_visrgn
40 struct list entry;
41 HDC hdc;
42 HRGN hrgn;
45 static struct list saved_regions = LIST_INIT( saved_regions );
47 static HPALETTE16 hPrimaryPalette;
50 * ############################################################################
53 #include <pshpack1.h>
54 #define GDI_MAX_THUNKS 32
56 static struct gdi_thunk
58 BYTE popl_eax; /* popl %eax (return address) */
59 BYTE pushl_pfn16; /* pushl pfn16 */
60 DWORD pfn16; /* pfn16 */
61 BYTE pushl_eax; /* pushl %eax */
62 BYTE jmp; /* ljmp GDI_Callback3216 */
63 DWORD callback;
64 HDC16 hdc;
65 } *GDI_Thunks;
67 #include <poppack.h>
69 /**********************************************************************
70 * GDI_Callback3216
72 static BOOL CALLBACK GDI_Callback3216( DWORD pfn16, HDC hdc, INT code )
74 if (pfn16)
76 WORD args[2];
77 DWORD ret;
79 args[1] = HDC_16(hdc);
80 args[0] = code;
81 WOWCallback16Ex( pfn16, WCB16_PASCAL, sizeof(args), args, &ret );
82 return LOWORD(ret);
84 return TRUE;
88 /******************************************************************
89 * GDI_AddThunk
92 static struct gdi_thunk* GDI_AddThunk(HDC16 dc16, ABORTPROC16 pfn16)
94 struct gdi_thunk* thunk;
96 if (!GDI_Thunks)
98 GDI_Thunks = VirtualAlloc(NULL, GDI_MAX_THUNKS * sizeof(*GDI_Thunks),
99 MEM_COMMIT, PAGE_EXECUTE_READWRITE);
100 if (!GDI_Thunks)
102 return NULL;
104 for (thunk = GDI_Thunks; thunk < &GDI_Thunks[GDI_MAX_THUNKS]; thunk++)
106 thunk->popl_eax = 0x58; /* popl %eax */
107 thunk->pushl_pfn16 = 0x68; /* pushl pfn16 */
108 thunk->pfn16 = 0;
109 thunk->pushl_eax = 0x50; /* pushl %eax */
110 thunk->jmp = 0xe9; /* jmp GDI_Callback3216 */
111 thunk->callback = (char *)GDI_Callback3216 - (char *)(&thunk->callback + 1);
114 for (thunk = GDI_Thunks; thunk < &GDI_Thunks[GDI_MAX_THUNKS]; thunk++)
116 if (thunk->pfn16 == 0)
118 thunk->pfn16 = (DWORD)pfn16;
119 thunk->hdc = dc16;
120 return thunk;
123 FIXME("Out of mmdrv-thunks. Bump GDI_MAX_THUNKS\n");
124 return NULL;
127 /******************************************************************
128 * GDI_DeleteThunk
130 static void GDI_DeleteThunk(struct gdi_thunk* thunk)
132 thunk->pfn16 = 0;
135 /******************************************************************
136 * GDI_FindThunk
138 static struct gdi_thunk* GDI_FindThunk(HDC16 hdc)
140 struct gdi_thunk* thunk;
142 if (!GDI_Thunks) return NULL;
143 for (thunk = GDI_Thunks; thunk < &GDI_Thunks[GDI_MAX_THUNKS]; thunk++)
145 if (thunk->hdc == hdc) return thunk;
147 return NULL;
150 /**********************************************************************
151 * QueryAbort (GDI.155)
153 * Calls the app's AbortProc function if avail.
155 * RETURNS
156 * TRUE if no AbortProc avail or AbortProc wants to continue printing.
157 * FALSE if AbortProc wants to abort printing.
159 BOOL16 WINAPI QueryAbort16(HDC16 hdc16, INT16 reserved)
161 struct gdi_thunk* thunk = GDI_FindThunk(hdc16);
163 if (!thunk) {
164 ERR("Invalid hdc 0x%x\n", hdc16);
165 return FALSE;
167 return GDI_Callback3216( thunk->pfn16, HDC_32(hdc16), 0 );
171 /**********************************************************************
172 * SetAbortProc (GDI.381)
174 INT16 WINAPI SetAbortProc16(HDC16 hdc16, ABORTPROC16 abrtprc)
176 struct gdi_thunk* thunk;
178 thunk = GDI_AddThunk(hdc16, abrtprc);
179 if (!thunk) return FALSE;
180 if (!SetAbortProc(HDC_32( hdc16 ), (ABORTPROC)thunk))
182 GDI_DeleteThunk(thunk);
183 return FALSE;
185 return TRUE;
189 * ############################################################################
192 struct callback16_info
194 FARPROC16 proc;
195 LPARAM param;
198 /* callback for LineDDA16 */
199 static void CALLBACK linedda_callback( INT x, INT y, LPARAM param )
201 const struct callback16_info *info = (struct callback16_info *)param;
202 WORD args[4];
204 args[3] = x;
205 args[2] = y;
206 args[1] = HIWORD(info->param);
207 args[0] = LOWORD(info->param);
208 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, NULL );
211 /* callback for EnumObjects16 */
212 static INT CALLBACK enum_pens_callback( void *ptr, LPARAM param )
214 const struct callback16_info *info = (struct callback16_info *)param;
215 LOGPEN *pen = ptr;
216 LOGPEN16 pen16;
217 SEGPTR segptr;
218 DWORD ret;
219 WORD args[4];
221 pen16.lopnStyle = pen->lopnStyle;
222 pen16.lopnWidth.x = pen->lopnWidth.x;
223 pen16.lopnWidth.y = pen->lopnWidth.y;
224 pen16.lopnColor = pen->lopnColor;
225 segptr = MapLS( &pen16 );
226 args[3] = SELECTOROF(segptr);
227 args[2] = OFFSETOF(segptr);
228 args[1] = HIWORD(info->param);
229 args[0] = LOWORD(info->param);
230 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
231 UnMapLS( segptr );
232 return LOWORD(ret);
235 /* callback for EnumObjects16 */
236 static INT CALLBACK enum_brushes_callback( void *ptr, LPARAM param )
238 const struct callback16_info *info = (struct callback16_info *)param;
239 LOGBRUSH *brush = ptr;
240 LOGBRUSH16 brush16;
241 SEGPTR segptr;
242 DWORD ret;
243 WORD args[4];
245 brush16.lbStyle = brush->lbStyle;
246 brush16.lbColor = brush->lbColor;
247 brush16.lbHatch = brush->lbHatch;
248 segptr = MapLS( &brush16 );
249 args[3] = SELECTOROF(segptr);
250 args[2] = OFFSETOF(segptr);
251 args[1] = HIWORD(info->param);
252 args[0] = LOWORD(info->param);
253 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
254 UnMapLS( segptr );
255 return ret;
258 /* convert a LOGFONT16 to a LOGFONTW */
259 static void logfont_16_to_W( const LOGFONT16 *font16, LPLOGFONTW font32 )
261 font32->lfHeight = font16->lfHeight;
262 font32->lfWidth = font16->lfWidth;
263 font32->lfEscapement = font16->lfEscapement;
264 font32->lfOrientation = font16->lfOrientation;
265 font32->lfWeight = font16->lfWeight;
266 font32->lfItalic = font16->lfItalic;
267 font32->lfUnderline = font16->lfUnderline;
268 font32->lfStrikeOut = font16->lfStrikeOut;
269 font32->lfCharSet = font16->lfCharSet;
270 font32->lfOutPrecision = font16->lfOutPrecision;
271 font32->lfClipPrecision = font16->lfClipPrecision;
272 font32->lfQuality = font16->lfQuality;
273 font32->lfPitchAndFamily = font16->lfPitchAndFamily;
274 MultiByteToWideChar( CP_ACP, 0, font16->lfFaceName, -1, font32->lfFaceName, LF_FACESIZE );
275 font32->lfFaceName[LF_FACESIZE-1] = 0;
278 /* convert a LOGFONTW to a LOGFONT16 */
279 static void logfont_W_to_16( const LOGFONTW* font32, LPLOGFONT16 font16 )
281 font16->lfHeight = font32->lfHeight;
282 font16->lfWidth = font32->lfWidth;
283 font16->lfEscapement = font32->lfEscapement;
284 font16->lfOrientation = font32->lfOrientation;
285 font16->lfWeight = font32->lfWeight;
286 font16->lfItalic = font32->lfItalic;
287 font16->lfUnderline = font32->lfUnderline;
288 font16->lfStrikeOut = font32->lfStrikeOut;
289 font16->lfCharSet = font32->lfCharSet;
290 font16->lfOutPrecision = font32->lfOutPrecision;
291 font16->lfClipPrecision = font32->lfClipPrecision;
292 font16->lfQuality = font32->lfQuality;
293 font16->lfPitchAndFamily = font32->lfPitchAndFamily;
294 WideCharToMultiByte( CP_ACP, 0, font32->lfFaceName, -1, font16->lfFaceName, LF_FACESIZE, NULL, NULL );
295 font16->lfFaceName[LF_FACESIZE-1] = 0;
298 /* convert a ENUMLOGFONTEXW to a ENUMLOGFONTEX16 */
299 static void enumlogfontex_W_to_16( const ENUMLOGFONTEXW *fontW,
300 LPENUMLOGFONTEX16 font16 )
302 logfont_W_to_16( (const LOGFONTW *)fontW, (LPLOGFONT16)font16);
304 WideCharToMultiByte( CP_ACP, 0, fontW->elfFullName, -1,
305 (LPSTR) font16->elfFullName, LF_FULLFACESIZE, NULL, NULL );
306 font16->elfFullName[LF_FULLFACESIZE-1] = '\0';
307 WideCharToMultiByte( CP_ACP, 0, fontW->elfStyle, -1,
308 (LPSTR) font16->elfStyle, LF_FACESIZE, NULL, NULL );
309 font16->elfStyle[LF_FACESIZE-1] = '\0';
310 WideCharToMultiByte( CP_ACP, 0, fontW->elfScript, -1,
311 (LPSTR) font16->elfScript, LF_FACESIZE, NULL, NULL );
312 font16->elfScript[LF_FACESIZE-1] = '\0';
315 /* convert a NEWTEXTMETRICEXW to a NEWTEXTMETRICEX16 */
316 static void newtextmetricex_W_to_16( const NEWTEXTMETRICEXW *ptmW,
317 LPNEWTEXTMETRICEX16 ptm16 )
319 ptm16->ntmTm.tmHeight = ptmW->ntmTm.tmHeight;
320 ptm16->ntmTm.tmAscent = ptmW->ntmTm.tmAscent;
321 ptm16->ntmTm.tmDescent = ptmW->ntmTm.tmDescent;
322 ptm16->ntmTm.tmInternalLeading = ptmW->ntmTm.tmInternalLeading;
323 ptm16->ntmTm.tmExternalLeading = ptmW->ntmTm.tmExternalLeading;
324 ptm16->ntmTm.tmAveCharWidth = ptmW->ntmTm.tmAveCharWidth;
325 ptm16->ntmTm.tmMaxCharWidth = ptmW->ntmTm.tmMaxCharWidth;
326 ptm16->ntmTm.tmWeight = ptmW->ntmTm.tmWeight;
327 ptm16->ntmTm.tmOverhang = ptmW->ntmTm.tmOverhang;
328 ptm16->ntmTm.tmDigitizedAspectX = ptmW->ntmTm.tmDigitizedAspectX;
329 ptm16->ntmTm.tmDigitizedAspectY = ptmW->ntmTm.tmDigitizedAspectY;
330 ptm16->ntmTm.tmFirstChar = ptmW->ntmTm.tmFirstChar > 255 ? 255 : ptmW->ntmTm.tmFirstChar;
331 ptm16->ntmTm.tmLastChar = ptmW->ntmTm.tmLastChar > 255 ? 255 : ptmW->ntmTm.tmLastChar;
332 ptm16->ntmTm.tmDefaultChar = ptmW->ntmTm.tmDefaultChar > 255 ? 255 : ptmW->ntmTm.tmDefaultChar;
333 ptm16->ntmTm.tmBreakChar = ptmW->ntmTm.tmBreakChar > 255 ? 255 : ptmW->ntmTm.tmBreakChar;
334 ptm16->ntmTm.tmItalic = ptmW->ntmTm.tmItalic;
335 ptm16->ntmTm.tmUnderlined = ptmW->ntmTm.tmUnderlined;
336 ptm16->ntmTm.tmStruckOut = ptmW->ntmTm.tmStruckOut;
337 ptm16->ntmTm.tmPitchAndFamily = ptmW->ntmTm.tmPitchAndFamily;
338 ptm16->ntmTm.tmCharSet = ptmW->ntmTm.tmCharSet;
339 ptm16->ntmTm.ntmFlags = ptmW->ntmTm.ntmFlags;
340 ptm16->ntmTm.ntmSizeEM = ptmW->ntmTm.ntmSizeEM;
341 ptm16->ntmTm.ntmCellHeight = ptmW->ntmTm.ntmCellHeight;
342 ptm16->ntmTm.ntmAvgWidth = ptmW->ntmTm.ntmAvgWidth;
343 ptm16->ntmFontSig = ptmW->ntmFontSig;
347 * callback for EnumFontFamiliesEx16
348 * Note: plf is really an ENUMLOGFONTEXW, and ptm is a NEWTEXTMETRICEXW.
349 * We have to use other types because of the FONTENUMPROCW definition.
351 static INT CALLBACK enum_font_callback( const LOGFONTW *plf,
352 const TEXTMETRICW *ptm, DWORD fType,
353 LPARAM param )
355 const struct callback16_info *info = (struct callback16_info *)param;
356 ENUMLOGFONTEX16 elfe16;
357 NEWTEXTMETRICEX16 ntm16;
358 SEGPTR segelfe16;
359 SEGPTR segntm16;
360 WORD args[7];
361 DWORD ret;
363 enumlogfontex_W_to_16((const ENUMLOGFONTEXW *)plf, &elfe16);
364 newtextmetricex_W_to_16((const NEWTEXTMETRICEXW *)ptm, &ntm16);
365 segelfe16 = MapLS( &elfe16 );
366 segntm16 = MapLS( &ntm16 );
367 args[6] = SELECTOROF(segelfe16);
368 args[5] = OFFSETOF(segelfe16);
369 args[4] = SELECTOROF(segntm16);
370 args[3] = OFFSETOF(segntm16);
371 args[2] = fType;
372 args[1] = HIWORD(info->param);
373 args[0] = LOWORD(info->param);
375 WOWCallback16Ex( (DWORD)info->proc, WCB16_PASCAL, sizeof(args), args, &ret );
376 UnMapLS( segelfe16 );
377 UnMapLS( segntm16 );
378 return LOWORD(ret);
381 struct dib_segptr_bits
383 struct list entry;
384 HBITMAP16 bmp;
385 WORD sel;
386 WORD count;
389 static struct list dib_segptr_list = LIST_INIT( dib_segptr_list );
391 static SEGPTR alloc_segptr_bits( HBITMAP bmp, void *bits32 )
393 DIBSECTION dib;
394 unsigned int i, size;
395 struct dib_segptr_bits *bits;
397 if (!(bits = HeapAlloc( GetProcessHeap(), 0, sizeof(*bits) ))) return 0;
399 GetObjectW( bmp, sizeof(dib), &dib );
400 size = dib.dsBm.bmHeight * dib.dsBm.bmWidthBytes;
402 /* calculate number of sel's needed for size with 64K steps */
403 bits->bmp = HBITMAP_16( bmp );
404 bits->count = (size + 0xffff) / 0x10000;
405 bits->sel = AllocSelectorArray16( bits->count );
407 for (i = 0; i < bits->count; i++)
409 SetSelectorBase(bits->sel + (i << __AHSHIFT), (DWORD)bits32 + i * 0x10000);
410 SetSelectorLimit16(bits->sel + (i << __AHSHIFT), size - 1); /* yep, limit is correct */
411 size -= 0x10000;
413 list_add_head( &dib_segptr_list, &bits->entry );
414 return MAKESEGPTR( bits->sel, 0 );
417 static void free_segptr_bits( HBITMAP16 bmp )
419 unsigned int i;
420 struct dib_segptr_bits *bits;
422 LIST_FOR_EACH_ENTRY( bits, &dib_segptr_list, struct dib_segptr_bits, entry )
424 if (bits->bmp != bmp) continue;
425 for (i = 0; i < bits->count; i++) FreeSelector16( bits->sel + (i << __AHSHIFT) );
427 list_remove( &bits->entry );
428 HeapFree( GetProcessHeap(), 0, bits );
429 return;
433 /* window surface used to implement the DIB.DRV driver */
435 struct dib_window_surface
437 struct window_surface header;
438 RECT bounds;
439 void *bits;
440 UINT info_size;
441 BITMAPINFO info; /* variable size, must be last */
444 static struct dib_window_surface *get_dib_surface( struct window_surface *surface )
446 return (struct dib_window_surface *)surface;
449 /***********************************************************************
450 * dib_surface_lock
452 static void CDECL dib_surface_lock( struct window_surface *window_surface )
454 /* nothing to do */
457 /***********************************************************************
458 * dib_surface_unlock
460 static void CDECL dib_surface_unlock( struct window_surface *window_surface )
462 /* nothing to do */
465 /***********************************************************************
466 * dib_surface_get_bitmap_info
468 static void *CDECL dib_surface_get_bitmap_info( struct window_surface *window_surface, BITMAPINFO *info )
470 struct dib_window_surface *surface = get_dib_surface( window_surface );
472 memcpy( info, &surface->info, surface->info_size );
473 return surface->bits;
476 /***********************************************************************
477 * dib_surface_get_bounds
479 static RECT *CDECL dib_surface_get_bounds( struct window_surface *window_surface )
481 struct dib_window_surface *surface = get_dib_surface( window_surface );
483 return &surface->bounds;
486 /***********************************************************************
487 * dib_surface_set_region
489 static void CDECL dib_surface_set_region( struct window_surface *window_surface, HRGN region )
491 /* nothing to do */
494 /***********************************************************************
495 * dib_surface_flush
497 static void CDECL dib_surface_flush( struct window_surface *window_surface )
499 /* nothing to do */
502 /***********************************************************************
503 * dib_surface_destroy
505 static void CDECL dib_surface_destroy( struct window_surface *window_surface )
507 struct dib_window_surface *surface = get_dib_surface( window_surface );
509 TRACE( "freeing %p\n", surface );
510 HeapFree( GetProcessHeap(), 0, surface );
513 static const struct window_surface_funcs dib_surface_funcs =
515 dib_surface_lock,
516 dib_surface_unlock,
517 dib_surface_get_bitmap_info,
518 dib_surface_get_bounds,
519 dib_surface_set_region,
520 dib_surface_flush,
521 dib_surface_destroy
524 /***********************************************************************
525 * create_surface
527 static struct window_surface *create_surface( const BITMAPINFO *info )
529 struct dib_window_surface *surface;
530 int color = 0;
532 if (info->bmiHeader.biBitCount <= 8)
533 color = info->bmiHeader.biClrUsed ? info->bmiHeader.biClrUsed : (1 << info->bmiHeader.biBitCount);
534 else if (info->bmiHeader.biCompression == BI_BITFIELDS)
535 color = 3;
537 surface = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
538 offsetof( struct dib_window_surface, info.bmiColors[color] ));
539 if (!surface) return NULL;
541 surface->header.funcs = &dib_surface_funcs;
542 surface->header.rect.left = 0;
543 surface->header.rect.top = 0;
544 surface->header.rect.right = info->bmiHeader.biWidth;
545 surface->header.rect.bottom = abs(info->bmiHeader.biHeight);
546 surface->header.ref = 1;
547 surface->info_size = offsetof( BITMAPINFO, bmiColors[color] );
548 surface->bits = (char *)info + surface->info_size;
549 memcpy( &surface->info, info, surface->info_size );
551 TRACE( "created %p %ux%u for info %p bits %p\n",
552 surface, surface->header.rect.right, surface->header.rect.bottom, info, surface->bits );
553 return &surface->header;
557 /***********************************************************************
558 * SetBkColor (GDI.1)
560 COLORREF WINAPI SetBkColor16( HDC16 hdc, COLORREF color )
562 return SetBkColor( HDC_32(hdc), color );
566 /***********************************************************************
567 * SetBkMode (GDI.2)
569 INT16 WINAPI SetBkMode16( HDC16 hdc, INT16 mode )
571 return SetBkMode( HDC_32(hdc), mode );
575 /***********************************************************************
576 * SetMapMode (GDI.3)
578 INT16 WINAPI SetMapMode16( HDC16 hdc, INT16 mode )
580 return SetMapMode( HDC_32(hdc), mode );
584 /***********************************************************************
585 * SetROP2 (GDI.4)
587 INT16 WINAPI SetROP216( HDC16 hdc, INT16 mode )
589 return SetROP2( HDC_32(hdc), mode );
593 /***********************************************************************
594 * SetRelAbs (GDI.5)
596 INT16 WINAPI SetRelAbs16( HDC16 hdc, INT16 mode )
598 return SetRelAbs( HDC_32(hdc), mode );
602 /***********************************************************************
603 * SetPolyFillMode (GDI.6)
605 INT16 WINAPI SetPolyFillMode16( HDC16 hdc, INT16 mode )
607 return SetPolyFillMode( HDC_32(hdc), mode );
611 /***********************************************************************
612 * SetStretchBltMode (GDI.7)
614 INT16 WINAPI SetStretchBltMode16( HDC16 hdc, INT16 mode )
616 return SetStretchBltMode( HDC_32(hdc), mode );
620 /***********************************************************************
621 * SetTextCharacterExtra (GDI.8)
623 INT16 WINAPI SetTextCharacterExtra16( HDC16 hdc, INT16 extra )
625 return SetTextCharacterExtra( HDC_32(hdc), extra );
629 /***********************************************************************
630 * SetTextColor (GDI.9)
632 COLORREF WINAPI SetTextColor16( HDC16 hdc, COLORREF color )
634 return SetTextColor( HDC_32(hdc), color );
638 /***********************************************************************
639 * SetTextJustification (GDI.10)
641 INT16 WINAPI SetTextJustification16( HDC16 hdc, INT16 extra, INT16 breaks )
643 return SetTextJustification( HDC_32(hdc), extra, breaks );
647 /***********************************************************************
648 * SetWindowOrg (GDI.11)
650 DWORD WINAPI SetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
652 POINT pt;
653 if (!SetWindowOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
654 return MAKELONG( pt.x, pt.y );
658 /***********************************************************************
659 * SetWindowExt (GDI.12)
661 DWORD WINAPI SetWindowExt16( HDC16 hdc, INT16 x, INT16 y )
663 SIZE size;
664 if (!SetWindowExtEx( HDC_32(hdc), x, y, &size )) return 0;
665 return MAKELONG( size.cx, size.cy );
669 /***********************************************************************
670 * SetViewportOrg (GDI.13)
672 DWORD WINAPI SetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
674 POINT pt;
675 if (!SetViewportOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
676 return MAKELONG( pt.x, pt.y );
680 /***********************************************************************
681 * SetViewportExt (GDI.14)
683 DWORD WINAPI SetViewportExt16( HDC16 hdc, INT16 x, INT16 y )
685 SIZE size;
686 if (!SetViewportExtEx( HDC_32(hdc), x, y, &size )) return 0;
687 return MAKELONG( size.cx, size.cy );
691 /***********************************************************************
692 * OffsetWindowOrg (GDI.15)
694 DWORD WINAPI OffsetWindowOrg16( HDC16 hdc, INT16 x, INT16 y )
696 POINT pt;
697 if (!OffsetWindowOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
698 return MAKELONG( pt.x, pt.y );
702 /***********************************************************************
703 * ScaleWindowExt (GDI.16)
705 DWORD WINAPI ScaleWindowExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
706 INT16 yNum, INT16 yDenom )
708 SIZE size;
709 if (!ScaleWindowExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom, &size ))
710 return FALSE;
711 return MAKELONG( size.cx, size.cy );
715 /***********************************************************************
716 * OffsetViewportOrg (GDI.17)
718 DWORD WINAPI OffsetViewportOrg16( HDC16 hdc, INT16 x, INT16 y )
720 POINT pt;
721 if (!OffsetViewportOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
722 return MAKELONG( pt.x, pt.y );
726 /***********************************************************************
727 * ScaleViewportExt (GDI.18)
729 DWORD WINAPI ScaleViewportExt16( HDC16 hdc, INT16 xNum, INT16 xDenom,
730 INT16 yNum, INT16 yDenom )
732 SIZE size;
733 if (!ScaleViewportExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom, &size ))
734 return FALSE;
735 return MAKELONG( size.cx, size.cy );
739 /***********************************************************************
740 * LineTo (GDI.19)
742 BOOL16 WINAPI LineTo16( HDC16 hdc, INT16 x, INT16 y )
744 return LineTo( HDC_32(hdc), x, y );
748 /***********************************************************************
749 * MoveTo (GDI.20)
751 DWORD WINAPI MoveTo16( HDC16 hdc, INT16 x, INT16 y )
753 POINT pt;
755 if (!MoveToEx( HDC_32(hdc), x, y, &pt )) return 0;
756 return MAKELONG(pt.x,pt.y);
760 /***********************************************************************
761 * ExcludeClipRect (GDI.21)
763 INT16 WINAPI ExcludeClipRect16( HDC16 hdc, INT16 left, INT16 top,
764 INT16 right, INT16 bottom )
766 return ExcludeClipRect( HDC_32(hdc), left, top, right, bottom );
770 /***********************************************************************
771 * IntersectClipRect (GDI.22)
773 INT16 WINAPI IntersectClipRect16( HDC16 hdc, INT16 left, INT16 top,
774 INT16 right, INT16 bottom )
776 return IntersectClipRect( HDC_32(hdc), left, top, right, bottom );
780 /***********************************************************************
781 * Arc (GDI.23)
783 BOOL16 WINAPI Arc16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
784 INT16 bottom, INT16 xstart, INT16 ystart,
785 INT16 xend, INT16 yend )
787 return Arc( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
791 /***********************************************************************
792 * Ellipse (GDI.24)
794 BOOL16 WINAPI Ellipse16( HDC16 hdc, INT16 left, INT16 top,
795 INT16 right, INT16 bottom )
797 return Ellipse( HDC_32(hdc), left, top, right, bottom );
801 /**********************************************************************
802 * FloodFill (GDI.25)
804 BOOL16 WINAPI FloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
806 return ExtFloodFill( HDC_32(hdc), x, y, color, FLOODFILLBORDER );
810 /***********************************************************************
811 * Pie (GDI.26)
813 BOOL16 WINAPI Pie16( HDC16 hdc, INT16 left, INT16 top,
814 INT16 right, INT16 bottom, INT16 xstart, INT16 ystart,
815 INT16 xend, INT16 yend )
817 return Pie( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
821 /***********************************************************************
822 * Rectangle (GDI.27)
824 BOOL16 WINAPI Rectangle16( HDC16 hdc, INT16 left, INT16 top,
825 INT16 right, INT16 bottom )
827 return Rectangle( HDC_32(hdc), left, top, right, bottom );
831 /***********************************************************************
832 * RoundRect (GDI.28)
834 BOOL16 WINAPI RoundRect16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
835 INT16 bottom, INT16 ell_width, INT16 ell_height )
837 return RoundRect( HDC_32(hdc), left, top, right, bottom, ell_width, ell_height );
841 /***********************************************************************
842 * PatBlt (GDI.29)
844 BOOL16 WINAPI PatBlt16( HDC16 hdc, INT16 left, INT16 top,
845 INT16 width, INT16 height, DWORD rop)
847 return PatBlt( HDC_32(hdc), left, top, width, height, rop );
851 /***********************************************************************
852 * SaveDC (GDI.30)
854 INT16 WINAPI SaveDC16( HDC16 hdc )
856 return SaveDC( HDC_32(hdc) );
860 /***********************************************************************
861 * SetPixel (GDI.31)
863 COLORREF WINAPI SetPixel16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
865 return SetPixel( HDC_32(hdc), x, y, color );
869 /***********************************************************************
870 * OffsetClipRgn (GDI.32)
872 INT16 WINAPI OffsetClipRgn16( HDC16 hdc, INT16 x, INT16 y )
874 return OffsetClipRgn( HDC_32(hdc), x, y );
878 /***********************************************************************
879 * TextOut (GDI.33)
881 BOOL16 WINAPI TextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR str, INT16 count )
883 return TextOutA( HDC_32(hdc), x, y, str, count );
887 /***********************************************************************
888 * BitBlt (GDI.34)
890 BOOL16 WINAPI BitBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst, INT16 width,
891 INT16 height, HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
892 DWORD rop )
894 return BitBlt( HDC_32(hdcDst), xDst, yDst, width, height, HDC_32(hdcSrc), xSrc, ySrc, rop );
898 /***********************************************************************
899 * StretchBlt (GDI.35)
901 BOOL16 WINAPI StretchBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst,
902 INT16 widthDst, INT16 heightDst,
903 HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
904 INT16 widthSrc, INT16 heightSrc, DWORD rop )
906 return StretchBlt( HDC_32(hdcDst), xDst, yDst, widthDst, heightDst,
907 HDC_32(hdcSrc), xSrc, ySrc, widthSrc, heightSrc, rop );
911 /**********************************************************************
912 * Polygon (GDI.36)
914 BOOL16 WINAPI Polygon16( HDC16 hdc, const POINT16* pt, INT16 count )
916 int i;
917 BOOL ret;
918 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, count*sizeof(POINT) );
920 if (!pt32) return FALSE;
921 for (i=count;i--;)
923 pt32[i].x = pt[i].x;
924 pt32[i].y = pt[i].y;
926 ret = Polygon(HDC_32(hdc),pt32,count);
927 HeapFree( GetProcessHeap(), 0, pt32 );
928 return ret;
932 /**********************************************************************
933 * Polyline (GDI.37)
935 BOOL16 WINAPI Polyline16( HDC16 hdc, const POINT16* pt, INT16 count )
937 int i;
938 BOOL16 ret;
939 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, count*sizeof(POINT) );
941 if (!pt32) return FALSE;
942 for (i=count;i--;)
944 pt32[i].x = pt[i].x;
945 pt32[i].y = pt[i].y;
947 ret = Polyline(HDC_32(hdc),pt32,count);
948 HeapFree( GetProcessHeap(), 0, pt32 );
949 return ret;
953 /***********************************************************************
954 * Escape (GDI.38)
956 INT16 WINAPI Escape16( HDC16 hdc, INT16 escape, INT16 in_count, SEGPTR in_data, LPVOID out_data )
958 INT ret;
960 switch(escape)
962 /* Escape(hdc,CLIP_TO_PATH,LPINT16,NULL) */
963 /* Escape(hdc,DRAFTMODE,LPINT16,NULL) */
964 /* Escape(hdc,ENUMPAPERBINS,LPINT16,LPSTR); */
965 /* Escape(hdc,EPSPRINTING,LPINT16,NULL) */
966 /* Escape(hdc,EXT_DEVICE_CAPS,LPINT16,LPDWORD) */
967 /* Escape(hdc,GETCOLORTABLE,LPINT16,LPDWORD) */
968 /* Escape(hdc,MOUSETRAILS,LPINT16,NULL) */
969 /* Escape(hdc,POSTSCRIPT_IGNORE,LPINT16,NULL) */
970 /* Escape(hdc,QUERYESCSUPPORT,LPINT16,NULL) */
971 /* Escape(hdc,SET_ARC_DIRECTION,LPINT16,NULL) */
972 /* Escape(hdc,SET_POLY_MODE,LPINT16,NULL) */
973 /* Escape(hdc,SET_SCREEN_ANGLE,LPINT16,NULL) */
974 /* Escape(hdc,SET_SPREAD,LPINT16,NULL) */
975 case CLIP_TO_PATH:
976 case DRAFTMODE:
977 case ENUMPAPERBINS:
978 case EPSPRINTING:
979 case EXT_DEVICE_CAPS:
980 case GETCOLORTABLE:
981 case MOUSETRAILS:
982 case POSTSCRIPT_IGNORE:
983 case QUERYESCSUPPORT:
984 case SET_ARC_DIRECTION:
985 case SET_POLY_MODE:
986 case SET_SCREEN_ANGLE:
987 case SET_SPREAD:
989 INT16 *ptr = MapSL(in_data);
990 INT data = *ptr;
991 return Escape( HDC_32(hdc), escape, sizeof(data), (LPCSTR)&data, out_data );
994 /* Escape(hdc,ENABLEDUPLEX,LPUINT16,NULL) */
995 case ENABLEDUPLEX:
997 UINT16 *ptr = MapSL(in_data);
998 UINT data = *ptr;
999 return Escape( HDC_32(hdc), escape, sizeof(data), (LPCSTR)&data, NULL );
1002 /* Escape(hdc,GETPHYSPAGESIZE,NULL,LPPOINT16) */
1003 /* Escape(hdc,GETPRINTINGOFFSET,NULL,LPPOINT16) */
1004 /* Escape(hdc,GETSCALINGFACTOR,NULL,LPPOINT16) */
1005 case GETPHYSPAGESIZE:
1006 case GETPRINTINGOFFSET:
1007 case GETSCALINGFACTOR:
1009 POINT16 *ptr = out_data;
1010 POINT pt32;
1011 ret = Escape( HDC_32(hdc), escape, 0, NULL, &pt32 );
1012 ptr->x = pt32.x;
1013 ptr->y = pt32.y;
1014 return ret;
1017 /* Escape(hdc,ENABLEPAIRKERNING,LPINT16,LPINT16); */
1018 /* Escape(hdc,ENABLERELATIVEWIDTHS,LPINT16,LPINT16); */
1019 /* Escape(hdc,SETCOPYCOUNT,LPINT16,LPINT16) */
1020 /* Escape(hdc,SETKERNTRACK,LPINT16,LPINT16) */
1021 /* Escape(hdc,SETLINECAP,LPINT16,LPINT16) */
1022 /* Escape(hdc,SETLINEJOIN,LPINT16,LPINT16) */
1023 /* Escape(hdc,SETMITERLIMIT,LPINT16,LPINT16) */
1024 case ENABLEPAIRKERNING:
1025 case ENABLERELATIVEWIDTHS:
1026 case SETCOPYCOUNT:
1027 case SETKERNTRACK:
1028 case SETLINECAP:
1029 case SETLINEJOIN:
1030 case SETMITERLIMIT:
1032 INT16 *new = MapSL(in_data);
1033 INT16 *old = out_data;
1034 INT out, in = *new;
1035 ret = Escape( HDC_32(hdc), escape, sizeof(in), (LPCSTR)&in, &out );
1036 *old = out;
1037 return ret;
1040 /* Escape(hdc,SETABORTPROC,ABORTPROC,NULL); */
1041 case SETABORTPROC:
1042 return SetAbortProc16( hdc, (ABORTPROC16)in_data );
1044 /* Escape(hdc,STARTDOC,LPSTR,LPDOCINFO16);
1045 * lpvOutData is actually a pointer to the DocInfo structure and used as
1046 * a second input parameter */
1047 case STARTDOC:
1048 if (out_data)
1050 ret = StartDoc16( hdc, out_data );
1051 if (ret > 0) ret = StartPage( HDC_32(hdc) );
1052 return ret;
1054 return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), NULL );
1056 /* Escape(hdc,SET_BOUNDS,LPRECT16,NULL); */
1057 /* Escape(hdc,SET_CLIP_BOX,LPRECT16,NULL); */
1058 case SET_BOUNDS:
1059 case SET_CLIP_BOX:
1061 RECT16 *rc16 = MapSL(in_data);
1062 RECT rc;
1063 rc.left = rc16->left;
1064 rc.top = rc16->top;
1065 rc.right = rc16->right;
1066 rc.bottom = rc16->bottom;
1067 return Escape( HDC_32(hdc), escape, sizeof(rc), (LPCSTR)&rc, NULL );
1070 /* Escape(hdc,NEXTBAND,NULL,LPRECT16); */
1071 case NEXTBAND:
1073 RECT rc;
1074 RECT16 *rc16 = out_data;
1075 ret = Escape( HDC_32(hdc), escape, 0, NULL, &rc );
1076 rc16->left = rc.left;
1077 rc16->top = rc.top;
1078 rc16->right = rc.right;
1079 rc16->bottom = rc.bottom;
1080 return ret;
1082 /* Escape(hdc,DRAWPATTERNRECT,PRECT_STRUCT*,NULL); */
1083 case DRAWPATTERNRECT:
1085 DRAWPATRECT pr;
1086 DRAWPATRECT16 *pr16 = MapSL(in_data);
1088 pr.ptPosition.x = pr16->ptPosition.x;
1089 pr.ptPosition.y = pr16->ptPosition.y;
1090 pr.ptSize.x = pr16->ptSize.x;
1091 pr.ptSize.y = pr16->ptSize.y;
1092 pr.wStyle = pr16->wStyle;
1093 pr.wPattern = pr16->wPattern;
1094 return Escape( HDC_32(hdc), escape, sizeof(pr), (LPCSTR)&pr, NULL );
1097 /* Escape(hdc,ABORTDOC,NULL,NULL); */
1098 /* Escape(hdc,BANDINFO,BANDINFOSTRUCT*,BANDINFOSTRUCT*); */
1099 /* Escape(hdc,BEGIN_PATH,NULL,NULL); */
1100 /* Escape(hdc,ENDDOC,NULL,NULL); */
1101 /* Escape(hdc,END_PATH,PATHINFO,NULL); */
1102 /* Escape(hdc,EXTTEXTOUT,EXTTEXT_STRUCT*,NULL); */
1103 /* Escape(hdc,FLUSHOUTPUT,NULL,NULL); */
1104 /* Escape(hdc,GETFACENAME,NULL,LPSTR); */
1105 /* Escape(hdc,GETPAIRKERNTABLE,NULL,KERNPAIR*); */
1106 /* Escape(hdc,GETSETPAPERBINS,BinInfo*,BinInfo*); */
1107 /* Escape(hdc,GETSETPRINTORIENT,ORIENT*,NULL); */
1108 /* Escape(hdc,GETSETSCREENPARAMS,SCREENPARAMS*,SCREENPARAMS*); */
1109 /* Escape(hdc,GETTECHNOLOGY,NULL,LPSTR); */
1110 /* Escape(hdc,GETTRACKKERNTABLE,NULL,KERNTRACK*); */
1111 /* Escape(hdc,MFCOMMENT,LPSTR,NULL); */
1112 /* Escape(hdc,NEWFRAME,NULL,NULL); */
1113 /* Escape(hdc,PASSTHROUGH,LPSTR,NULL); */
1114 /* Escape(hdc,RESTORE_CTM,NULL,NULL); */
1115 /* Escape(hdc,SAVE_CTM,NULL,NULL); */
1116 /* Escape(hdc,SETALLJUSTVALUES,EXTTEXTDATA*,NULL); */
1117 /* Escape(hdc,SETCOLORTABLE,COLORTABLE_STRUCT*,LPDWORD); */
1118 /* Escape(hdc,SET_BACKGROUND_COLOR,LPDWORD,LPDWORD); */
1119 /* Escape(hdc,TRANSFORM_CTM,LPSTR,NULL); */
1120 case ABORTDOC:
1121 case BANDINFO:
1122 case BEGIN_PATH:
1123 case ENDDOC:
1124 case END_PATH:
1125 case EXTTEXTOUT:
1126 case FLUSHOUTPUT:
1127 case GETFACENAME:
1128 case GETPAIRKERNTABLE:
1129 case GETSETPAPERBINS:
1130 case GETSETPRINTORIENT:
1131 case GETSETSCREENPARAMS:
1132 case GETTECHNOLOGY:
1133 case GETTRACKKERNTABLE:
1134 case MFCOMMENT:
1135 case NEWFRAME:
1136 case PASSTHROUGH:
1137 case RESTORE_CTM:
1138 case SAVE_CTM:
1139 case SETALLJUSTVALUES:
1140 case SETCOLORTABLE:
1141 case SET_BACKGROUND_COLOR:
1142 case TRANSFORM_CTM:
1143 /* pass it unmodified to the 32-bit function */
1144 return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), out_data );
1146 /* Escape(hdc,ENUMPAPERMETRICS,LPINT16,LPRECT16); */
1147 /* Escape(hdc,GETEXTENDEDTEXTMETRICS,LPUINT16,EXTTEXTMETRIC*); */
1148 /* Escape(hdc,GETEXTENTTABLE,LPSTR,LPINT16); */
1149 /* Escape(hdc,GETSETPAPERMETRICS,LPRECT16,LPRECT16); */
1150 /* Escape(hdc,GETVECTORBRUSHSIZE,LPLOGBRUSH16,LPPOINT16); */
1151 /* Escape(hdc,GETVECTORPENSIZE,LPLOGPEN16,LPPOINT16); */
1152 case ENUMPAPERMETRICS:
1153 case GETEXTENDEDTEXTMETRICS:
1154 case GETEXTENTTABLE:
1155 case GETSETPAPERMETRICS:
1156 case GETVECTORBRUSHSIZE:
1157 case GETVECTORPENSIZE:
1158 default:
1159 FIXME("unknown/unsupported 16-bit escape %x (%d,%p,%p\n",
1160 escape, in_count, MapSL(in_data), out_data );
1161 return Escape( HDC_32(hdc), escape, in_count, MapSL(in_data), out_data );
1166 /***********************************************************************
1167 * RestoreDC (GDI.39)
1169 BOOL16 WINAPI RestoreDC16( HDC16 hdc, INT16 level )
1171 return RestoreDC( HDC_32(hdc), level );
1175 /***********************************************************************
1176 * FillRgn (GDI.40)
1178 BOOL16 WINAPI FillRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush )
1180 return FillRgn( HDC_32(hdc), HRGN_32(hrgn), HBRUSH_32(hbrush) );
1184 /***********************************************************************
1185 * FrameRgn (GDI.41)
1187 BOOL16 WINAPI FrameRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush,
1188 INT16 nWidth, INT16 nHeight )
1190 return FrameRgn( HDC_32(hdc), HRGN_32(hrgn), HBRUSH_32(hbrush), nWidth, nHeight );
1194 /***********************************************************************
1195 * InvertRgn (GDI.42)
1197 BOOL16 WINAPI InvertRgn16( HDC16 hdc, HRGN16 hrgn )
1199 return InvertRgn( HDC_32(hdc), HRGN_32(hrgn) );
1203 /***********************************************************************
1204 * PaintRgn (GDI.43)
1206 BOOL16 WINAPI PaintRgn16( HDC16 hdc, HRGN16 hrgn )
1208 return PaintRgn( HDC_32(hdc), HRGN_32(hrgn) );
1212 /***********************************************************************
1213 * SelectClipRgn (GDI.44)
1215 INT16 WINAPI SelectClipRgn16( HDC16 hdc, HRGN16 hrgn )
1217 return SelectClipRgn( HDC_32(hdc), HRGN_32(hrgn) );
1221 /***********************************************************************
1222 * SelectObject (GDI.45)
1224 HGDIOBJ16 WINAPI SelectObject16( HDC16 hdc, HGDIOBJ16 handle )
1226 return HGDIOBJ_16( SelectObject( HDC_32(hdc), HGDIOBJ_32(handle) ) );
1230 /***********************************************************************
1231 * CombineRgn (GDI.47)
1233 INT16 WINAPI CombineRgn16(HRGN16 hDest, HRGN16 hSrc1, HRGN16 hSrc2, INT16 mode)
1235 return CombineRgn( HRGN_32(hDest), HRGN_32(hSrc1), HRGN_32(hSrc2), mode );
1239 /***********************************************************************
1240 * CreateBitmap (GDI.48)
1242 HBITMAP16 WINAPI CreateBitmap16( INT16 width, INT16 height, UINT16 planes,
1243 UINT16 bpp, LPCVOID bits )
1245 return HBITMAP_16( CreateBitmap( width, height, planes & 0xff, bpp & 0xff, bits ) );
1249 /***********************************************************************
1250 * CreateBitmapIndirect (GDI.49)
1252 HBITMAP16 WINAPI CreateBitmapIndirect16( const BITMAP16 * bmp )
1254 return CreateBitmap16( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
1255 bmp->bmBitsPixel, MapSL( bmp->bmBits ) );
1259 /***********************************************************************
1260 * CreateBrushIndirect (GDI.50)
1262 HBRUSH16 WINAPI CreateBrushIndirect16( const LOGBRUSH16 * brush )
1264 LOGBRUSH brush32;
1266 if (brush->lbStyle == BS_DIBPATTERN || brush->lbStyle == BS_DIBPATTERN8X8)
1267 return CreateDIBPatternBrush16( brush->lbHatch, brush->lbColor );
1269 brush32.lbStyle = brush->lbStyle;
1270 brush32.lbColor = brush->lbColor;
1271 brush32.lbHatch = brush->lbHatch;
1272 return HBRUSH_16( CreateBrushIndirect(&brush32) );
1276 /***********************************************************************
1277 * CreateCompatibleBitmap (GDI.51)
1279 HBITMAP16 WINAPI CreateCompatibleBitmap16( HDC16 hdc, INT16 width, INT16 height )
1281 return HBITMAP_16( CreateCompatibleBitmap( HDC_32(hdc), width, height ) );
1285 /***********************************************************************
1286 * CreateCompatibleDC (GDI.52)
1288 HDC16 WINAPI CreateCompatibleDC16( HDC16 hdc )
1290 return HDC_16( CreateCompatibleDC( HDC_32(hdc) ) );
1294 /***********************************************************************
1295 * CreateDC (GDI.53)
1297 HDC16 WINAPI CreateDC16( LPCSTR driver, LPCSTR device, LPCSTR output,
1298 const DEVMODEA *initData )
1300 if (!lstrcmpiA( driver, "dib" ) || !lstrcmpiA( driver, "dirdib" ))
1302 struct window_surface *surface;
1303 HDC hdc;
1305 if (!(surface = create_surface( (const BITMAPINFO *)initData ))) return 0;
1307 if ((hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL )))
1309 __wine_set_visible_region( hdc, CreateRectRgnIndirect( &surface->rect ),
1310 &surface->rect, &surface->rect, surface );
1311 TRACE( "returning hdc %p surface %p\n", hdc, surface );
1313 window_surface_release( surface );
1314 return HDC_16( hdc );
1316 return HDC_16( CreateDCA( driver, device, output, initData ) );
1320 /***********************************************************************
1321 * CreateEllipticRgn (GDI.54)
1323 HRGN16 WINAPI CreateEllipticRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom )
1325 return HRGN_16( CreateEllipticRgn( left, top, right, bottom ) );
1329 /***********************************************************************
1330 * CreateEllipticRgnIndirect (GDI.55)
1332 HRGN16 WINAPI CreateEllipticRgnIndirect16( const RECT16 *rect )
1334 return HRGN_16( CreateEllipticRgn( rect->left, rect->top, rect->right, rect->bottom ) );
1338 /***********************************************************************
1339 * CreateFont (GDI.56)
1341 HFONT16 WINAPI CreateFont16(INT16 height, INT16 width, INT16 esc, INT16 orient,
1342 INT16 weight, BYTE italic, BYTE underline,
1343 BYTE strikeout, BYTE charset, BYTE outpres,
1344 BYTE clippres, BYTE quality, BYTE pitch,
1345 LPCSTR name )
1347 return HFONT_16( CreateFontA( height, width, esc, orient, weight, italic, underline,
1348 strikeout, charset, outpres, clippres, quality, pitch, name ));
1351 /***********************************************************************
1352 * CreateFontIndirect (GDI.57)
1354 HFONT16 WINAPI CreateFontIndirect16( const LOGFONT16 *plf16 )
1356 HFONT ret;
1358 if (plf16)
1360 LOGFONTW lfW;
1361 logfont_16_to_W( plf16, &lfW );
1362 ret = CreateFontIndirectW( &lfW );
1364 else ret = CreateFontIndirectW( NULL );
1365 return HFONT_16(ret);
1369 /***********************************************************************
1370 * CreateHatchBrush (GDI.58)
1372 HBRUSH16 WINAPI CreateHatchBrush16( INT16 style, COLORREF color )
1374 return HBRUSH_16( CreateHatchBrush( style, color ) );
1378 /***********************************************************************
1379 * CreatePatternBrush (GDI.60)
1381 HBRUSH16 WINAPI CreatePatternBrush16( HBITMAP16 hbitmap )
1383 return HBRUSH_16( CreatePatternBrush( HBITMAP_32(hbitmap) ));
1387 /***********************************************************************
1388 * CreatePen (GDI.61)
1390 HPEN16 WINAPI CreatePen16( INT16 style, INT16 width, COLORREF color )
1392 LOGPEN logpen;
1394 logpen.lopnStyle = style;
1395 logpen.lopnWidth.x = width;
1396 logpen.lopnWidth.y = 0;
1397 logpen.lopnColor = color;
1398 return HPEN_16( CreatePenIndirect( &logpen ) );
1402 /***********************************************************************
1403 * CreatePenIndirect (GDI.62)
1405 HPEN16 WINAPI CreatePenIndirect16( const LOGPEN16 * pen )
1407 LOGPEN logpen;
1409 if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
1410 logpen.lopnStyle = pen->lopnStyle;
1411 logpen.lopnWidth.x = pen->lopnWidth.x;
1412 logpen.lopnWidth.y = pen->lopnWidth.y;
1413 logpen.lopnColor = pen->lopnColor;
1414 return HPEN_16( CreatePenIndirect( &logpen ) );
1418 /***********************************************************************
1419 * CreatePolygonRgn (GDI.63)
1421 HRGN16 WINAPI CreatePolygonRgn16( const POINT16 * points, INT16 count, INT16 mode )
1423 return CreatePolyPolygonRgn16( points, &count, 1, mode );
1427 /***********************************************************************
1428 * CreateRectRgn (GDI.64)
1430 * NOTE: cf. SetRectRgn16
1432 HRGN16 WINAPI CreateRectRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom )
1434 HRGN hrgn;
1436 if (left < right) hrgn = CreateRectRgn( left, top, right, bottom );
1437 else hrgn = CreateRectRgn( 0, 0, 0, 0 );
1438 return HRGN_16(hrgn);
1442 /***********************************************************************
1443 * CreateRectRgnIndirect (GDI.65)
1445 HRGN16 WINAPI CreateRectRgnIndirect16( const RECT16* rect )
1447 return CreateRectRgn16( rect->left, rect->top, rect->right, rect->bottom );
1451 /***********************************************************************
1452 * CreateSolidBrush (GDI.66)
1454 HBRUSH16 WINAPI CreateSolidBrush16( COLORREF color )
1456 return HBRUSH_16( CreateSolidBrush( color ) );
1460 /***********************************************************************
1461 * DeleteDC (GDI.68)
1463 BOOL16 WINAPI DeleteDC16( HDC16 hdc )
1465 if (DeleteDC( HDC_32(hdc) ))
1467 struct saved_visrgn *saved, *next;
1468 struct gdi_thunk* thunk;
1470 if ((thunk = GDI_FindThunk(hdc))) GDI_DeleteThunk(thunk);
1472 LIST_FOR_EACH_ENTRY_SAFE( saved, next, &saved_regions, struct saved_visrgn, entry )
1474 if (saved->hdc != HDC_32(hdc)) continue;
1475 list_remove( &saved->entry );
1476 DeleteObject( saved->hrgn );
1477 HeapFree( GetProcessHeap(), 0, saved );
1479 return TRUE;
1481 return FALSE;
1485 /***********************************************************************
1486 * DeleteObject (GDI.69)
1487 * SysDeleteObject (GDI.605)
1489 BOOL16 WINAPI DeleteObject16( HGDIOBJ16 obj )
1491 if (GetObjectType( HGDIOBJ_32(obj) ) == OBJ_BITMAP) free_segptr_bits( obj );
1492 return DeleteObject( HGDIOBJ_32(obj) );
1496 /***********************************************************************
1497 * EnumFonts (GDI.70)
1499 INT16 WINAPI EnumFonts16( HDC16 hDC, LPCSTR lpName, FONTENUMPROC16 efproc,
1500 LPARAM lpData )
1502 return EnumFontFamilies16( hDC, lpName, efproc, lpData );
1506 /***********************************************************************
1507 * EnumObjects (GDI.71)
1509 INT16 WINAPI EnumObjects16( HDC16 hdc, INT16 obj, GOBJENUMPROC16 proc, LPARAM lParam )
1511 struct callback16_info info;
1513 info.proc = (FARPROC16)proc;
1514 info.param = lParam;
1515 switch(obj)
1517 case OBJ_PEN:
1518 return EnumObjects( HDC_32(hdc), OBJ_PEN, enum_pens_callback, (LPARAM)&info );
1519 case OBJ_BRUSH:
1520 return EnumObjects( HDC_32(hdc), OBJ_BRUSH, enum_brushes_callback, (LPARAM)&info );
1522 return 0;
1526 /***********************************************************************
1527 * EqualRgn (GDI.72)
1529 BOOL16 WINAPI EqualRgn16( HRGN16 rgn1, HRGN16 rgn2 )
1531 return EqualRgn( HRGN_32(rgn1), HRGN_32(rgn2) );
1535 /***********************************************************************
1536 * GetBitmapBits (GDI.74)
1538 LONG WINAPI GetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPVOID buffer )
1540 return GetBitmapBits( HBITMAP_32(hbitmap), count, buffer );
1544 /***********************************************************************
1545 * GetBkColor (GDI.75)
1547 COLORREF WINAPI GetBkColor16( HDC16 hdc )
1549 return GetBkColor( HDC_32(hdc) );
1553 /***********************************************************************
1554 * GetBkMode (GDI.76)
1556 INT16 WINAPI GetBkMode16( HDC16 hdc )
1558 return GetBkMode( HDC_32(hdc) );
1562 /***********************************************************************
1563 * GetClipBox (GDI.77)
1565 INT16 WINAPI GetClipBox16( HDC16 hdc, LPRECT16 rect )
1567 RECT rect32;
1568 INT ret = GetClipBox( HDC_32(hdc), &rect32 );
1570 if (ret != ERROR)
1572 rect->left = rect32.left;
1573 rect->top = rect32.top;
1574 rect->right = rect32.right;
1575 rect->bottom = rect32.bottom;
1577 return ret;
1581 /***********************************************************************
1582 * GetCurrentPosition (GDI.78)
1584 DWORD WINAPI GetCurrentPosition16( HDC16 hdc )
1586 POINT pt32;
1587 if (!GetCurrentPositionEx( HDC_32(hdc), &pt32 )) return 0;
1588 return MAKELONG( pt32.x, pt32.y );
1592 /***********************************************************************
1593 * GetDCOrg (GDI.79)
1595 DWORD WINAPI GetDCOrg16( HDC16 hdc )
1597 POINT pt;
1598 if (GetDCOrgEx( HDC_32(hdc), &pt )) return MAKELONG( pt.x, pt.y );
1599 return 0;
1603 /***********************************************************************
1604 * GetDeviceCaps (GDI.80)
1606 INT16 WINAPI GetDeviceCaps16( HDC16 hdc, INT16 cap )
1608 INT16 ret = GetDeviceCaps( HDC_32(hdc), cap );
1609 /* some apps don't expect -1 and think it's a B&W screen */
1610 if ((cap == NUMCOLORS) && (ret == -1)) ret = 2048;
1611 return ret;
1615 /***********************************************************************
1616 * GetMapMode (GDI.81)
1618 INT16 WINAPI GetMapMode16( HDC16 hdc )
1620 return GetMapMode( HDC_32(hdc) );
1624 /***********************************************************************
1625 * GetObject (GDI.82)
1627 INT16 WINAPI GetObject16( HGDIOBJ16 handle16, INT16 count, LPVOID buffer )
1629 HGDIOBJ handle = HGDIOBJ_32( handle16 );
1630 switch( GetObjectType( handle ))
1632 case OBJ_PEN:
1633 if (buffer)
1635 LOGPEN16 *pen16 = buffer;
1636 LOGPEN pen;
1638 if (count < sizeof(LOGPEN16)) return 0;
1639 if (!GetObjectW( handle, sizeof(pen), &pen )) return 0;
1641 pen16->lopnStyle = pen.lopnStyle;
1642 pen16->lopnColor = pen.lopnColor;
1643 pen16->lopnWidth.x = pen.lopnWidth.x;
1644 pen16->lopnWidth.y = pen.lopnWidth.y;
1646 return sizeof(LOGPEN16);
1648 case OBJ_BRUSH:
1649 if (buffer)
1651 LOGBRUSH brush;
1652 LOGBRUSH16 brush16;
1654 if (!GetObjectW( handle, sizeof(brush), &brush )) return 0;
1655 brush16.lbStyle = brush.lbStyle;
1656 brush16.lbColor = brush.lbColor;
1657 brush16.lbHatch = brush.lbHatch;
1658 if (count > sizeof(brush16)) count = sizeof(brush16);
1659 memcpy( buffer, &brush16, count );
1660 return count;
1662 return sizeof(LOGBRUSH16);
1664 case OBJ_PAL:
1665 return GetObjectW( handle, count, buffer );
1667 case OBJ_FONT:
1668 if (buffer)
1670 LOGFONTW font;
1671 LOGFONT16 font16;
1673 if (!GetObjectW( handle, sizeof(font), &font )) return 0;
1674 logfont_W_to_16( &font, &font16 );
1675 if (count > sizeof(font16)) count = sizeof(font16);
1676 memcpy( buffer, &font16, count );
1677 return count;
1679 return sizeof(LOGFONT16);
1681 case OBJ_BITMAP:
1683 DIBSECTION dib;
1684 INT size;
1685 BITMAP16 *bmp16 = buffer;
1687 if (!(size = GetObjectW( handle, sizeof(dib), &dib ))) return 0;
1688 if (size == sizeof(DIBSECTION) && count > sizeof(BITMAP16))
1690 FIXME("not implemented for DIBs: count %d\n", count);
1691 return 0;
1693 else
1695 if (count < sizeof(BITMAP16)) return 0;
1696 bmp16->bmType = dib.dsBm.bmType;
1697 bmp16->bmWidth = dib.dsBm.bmWidth;
1698 bmp16->bmHeight = dib.dsBm.bmHeight;
1699 bmp16->bmWidthBytes = dib.dsBm.bmWidthBytes;
1700 bmp16->bmPlanes = dib.dsBm.bmPlanes;
1701 bmp16->bmBitsPixel = dib.dsBm.bmBitsPixel;
1702 bmp16->bmBits = 0;
1703 return sizeof(BITMAP16);
1707 default:
1708 return 0;
1713 /***********************************************************************
1714 * GetPixel (GDI.83)
1716 COLORREF WINAPI GetPixel16( HDC16 hdc, INT16 x, INT16 y )
1718 return GetPixel( HDC_32(hdc), x, y );
1722 /***********************************************************************
1723 * GetPolyFillMode (GDI.84)
1725 INT16 WINAPI GetPolyFillMode16( HDC16 hdc )
1727 return GetPolyFillMode( HDC_32(hdc) );
1731 /***********************************************************************
1732 * GetROP2 (GDI.85)
1734 INT16 WINAPI GetROP216( HDC16 hdc )
1736 return GetROP2( HDC_32(hdc) );
1740 /***********************************************************************
1741 * GetRelAbs (GDI.86)
1743 INT16 WINAPI GetRelAbs16( HDC16 hdc )
1745 return GetRelAbs( HDC_32(hdc), 0 );
1749 /***********************************************************************
1750 * GetStockObject (GDI.87)
1752 HGDIOBJ16 WINAPI GetStockObject16( INT16 obj )
1754 return HGDIOBJ_16( GetStockObject( obj ) );
1758 /***********************************************************************
1759 * GetStretchBltMode (GDI.88)
1761 INT16 WINAPI GetStretchBltMode16( HDC16 hdc )
1763 return GetStretchBltMode( HDC_32(hdc) );
1767 /***********************************************************************
1768 * GetTextCharacterExtra (GDI.89)
1770 INT16 WINAPI GetTextCharacterExtra16( HDC16 hdc )
1772 return GetTextCharacterExtra( HDC_32(hdc) );
1776 /***********************************************************************
1777 * GetTextColor (GDI.90)
1779 COLORREF WINAPI GetTextColor16( HDC16 hdc )
1781 return GetTextColor( HDC_32(hdc) );
1785 /***********************************************************************
1786 * GetTextExtent (GDI.91)
1788 DWORD WINAPI GetTextExtent16( HDC16 hdc, LPCSTR str, INT16 count )
1790 SIZE size;
1791 if (!GetTextExtentPoint32A( HDC_32(hdc), str, count, &size )) return 0;
1792 return MAKELONG( size.cx, size.cy );
1796 /***********************************************************************
1797 * GetTextFace (GDI.92)
1799 INT16 WINAPI GetTextFace16( HDC16 hdc, INT16 count, LPSTR name )
1801 return GetTextFaceA( HDC_32(hdc), count, name );
1805 /***********************************************************************
1806 * GetTextMetrics (GDI.93)
1808 BOOL16 WINAPI GetTextMetrics16( HDC16 hdc, TEXTMETRIC16 *tm )
1810 TEXTMETRICW tm32;
1812 if (!GetTextMetricsW( HDC_32(hdc), &tm32 )) return FALSE;
1814 tm->tmHeight = tm32.tmHeight;
1815 tm->tmAscent = tm32.tmAscent;
1816 tm->tmDescent = tm32.tmDescent;
1817 tm->tmInternalLeading = tm32.tmInternalLeading;
1818 tm->tmExternalLeading = tm32.tmExternalLeading;
1819 tm->tmAveCharWidth = tm32.tmAveCharWidth;
1820 tm->tmMaxCharWidth = tm32.tmMaxCharWidth;
1821 tm->tmWeight = tm32.tmWeight;
1822 tm->tmOverhang = tm32.tmOverhang;
1823 tm->tmDigitizedAspectX = tm32.tmDigitizedAspectX;
1824 tm->tmDigitizedAspectY = tm32.tmDigitizedAspectY;
1825 tm->tmFirstChar = tm32.tmFirstChar;
1826 tm->tmLastChar = tm32.tmLastChar;
1827 tm->tmDefaultChar = tm32.tmDefaultChar;
1828 tm->tmBreakChar = tm32.tmBreakChar;
1829 tm->tmItalic = tm32.tmItalic;
1830 tm->tmUnderlined = tm32.tmUnderlined;
1831 tm->tmStruckOut = tm32.tmStruckOut;
1832 tm->tmPitchAndFamily = tm32.tmPitchAndFamily;
1833 tm->tmCharSet = tm32.tmCharSet;
1834 return TRUE;
1838 /***********************************************************************
1839 * GetViewportExt (GDI.94)
1841 DWORD WINAPI GetViewportExt16( HDC16 hdc )
1843 SIZE size;
1844 if (!GetViewportExtEx( HDC_32(hdc), &size )) return 0;
1845 return MAKELONG( size.cx, size.cy );
1849 /***********************************************************************
1850 * GetViewportOrg (GDI.95)
1852 DWORD WINAPI GetViewportOrg16( HDC16 hdc )
1854 POINT pt;
1855 if (!GetViewportOrgEx( HDC_32(hdc), &pt )) return 0;
1856 return MAKELONG( pt.x, pt.y );
1860 /***********************************************************************
1861 * GetWindowExt (GDI.96)
1863 DWORD WINAPI GetWindowExt16( HDC16 hdc )
1865 SIZE size;
1866 if (!GetWindowExtEx( HDC_32(hdc), &size )) return 0;
1867 return MAKELONG( size.cx, size.cy );
1871 /***********************************************************************
1872 * GetWindowOrg (GDI.97)
1874 DWORD WINAPI GetWindowOrg16( HDC16 hdc )
1876 POINT pt;
1877 if (!GetWindowOrgEx( HDC_32(hdc), &pt )) return 0;
1878 return MAKELONG( pt.x, pt.y );
1884 /**********************************************************************
1885 * LineDDA (GDI.100)
1887 void WINAPI LineDDA16( INT16 nXStart, INT16 nYStart, INT16 nXEnd,
1888 INT16 nYEnd, LINEDDAPROC16 proc, LPARAM lParam )
1890 struct callback16_info info;
1891 info.proc = (FARPROC16)proc;
1892 info.param = lParam;
1893 LineDDA( nXStart, nYStart, nXEnd, nYEnd, linedda_callback, (LPARAM)&info );
1897 /***********************************************************************
1898 * OffsetRgn (GDI.101)
1900 INT16 WINAPI OffsetRgn16( HRGN16 hrgn, INT16 x, INT16 y )
1902 return OffsetRgn( HRGN_32(hrgn), x, y );
1906 /***********************************************************************
1907 * PtVisible (GDI.103)
1909 BOOL16 WINAPI PtVisible16( HDC16 hdc, INT16 x, INT16 y )
1911 return PtVisible( HDC_32(hdc), x, y );
1915 /***********************************************************************
1916 * SelectVisRgn (GDI.105)
1918 INT16 WINAPI SelectVisRgn16( HDC16 hdc, HRGN16 hrgn )
1920 FIXME( "%04x %04x no longer supported\n", hdc, hrgn );
1921 return ERROR;
1925 /***********************************************************************
1926 * SetBitmapBits (GDI.106)
1928 LONG WINAPI SetBitmapBits16( HBITMAP16 hbitmap, LONG count, LPCVOID buffer )
1930 return SetBitmapBits( HBITMAP_32(hbitmap), count, buffer );
1934 /***********************************************************************
1935 * AddFontResource (GDI.119)
1937 INT16 WINAPI AddFontResource16( LPCSTR filename )
1939 return AddFontResourceA( filename );
1943 /***********************************************************************
1944 * Death (GDI.121)
1946 * Disables GDI, switches back to text mode.
1947 * We don't have to do anything here,
1948 * just let console support handle everything
1950 void WINAPI Death16(HDC16 hdc)
1952 MESSAGE("Death(%04x) called. Application enters text mode...\n", hdc);
1956 /***********************************************************************
1957 * Resurrection (GDI.122)
1959 * Restores GDI functionality
1961 void WINAPI Resurrection16(HDC16 hdc,
1962 WORD w1, WORD w2, WORD w3, WORD w4, WORD w5, WORD w6)
1964 MESSAGE("Resurrection(%04x, %04x, %04x, %04x, %04x, %04x, %04x) called. Application left text mode.\n",
1965 hdc, w1, w2, w3, w4, w5, w6);
1969 /***********************************************************************
1970 * MulDiv (GDI.128)
1972 INT16 WINAPI MulDiv16( INT16 nMultiplicand, INT16 nMultiplier, INT16 nDivisor)
1974 INT ret;
1975 if (!nDivisor) return -32768;
1976 /* We want to deal with a positive divisor to simplify the logic. */
1977 if (nDivisor < 0)
1979 nMultiplicand = - nMultiplicand;
1980 nDivisor = -nDivisor;
1982 /* If the result is positive, we "add" to round. else,
1983 * we subtract to round. */
1984 if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) ||
1985 ( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
1986 ret = (((int)nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
1987 else
1988 ret = (((int)nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
1989 if ((ret > 32767) || (ret < -32767)) return -32768;
1990 return (INT16) ret;
1994 /***********************************************************************
1995 * GetRgnBox (GDI.134)
1997 INT16 WINAPI GetRgnBox16( HRGN16 hrgn, LPRECT16 rect )
1999 RECT r;
2000 INT16 ret = GetRgnBox( HRGN_32(hrgn), &r );
2001 rect->left = r.left;
2002 rect->top = r.top;
2003 rect->right = r.right;
2004 rect->bottom = r.bottom;
2005 return ret;
2009 /***********************************************************************
2010 * RemoveFontResource (GDI.136)
2012 BOOL16 WINAPI RemoveFontResource16( LPCSTR str )
2014 return RemoveFontResourceA(str);
2018 /***********************************************************************
2019 * SetBrushOrg (GDI.148)
2021 DWORD WINAPI SetBrushOrg16( HDC16 hdc, INT16 x, INT16 y )
2023 POINT pt;
2025 if (!SetBrushOrgEx( HDC_32(hdc), x, y, &pt )) return 0;
2026 return MAKELONG( pt.x, pt.y );
2030 /***********************************************************************
2031 * GetBrushOrg (GDI.149)
2033 DWORD WINAPI GetBrushOrg16( HDC16 hdc )
2035 POINT pt;
2036 if (!GetBrushOrgEx( HDC_32(hdc), &pt )) return 0;
2037 return MAKELONG( pt.x, pt.y );
2041 /***********************************************************************
2042 * UnrealizeObject (GDI.150)
2044 BOOL16 WINAPI UnrealizeObject16( HGDIOBJ16 obj )
2046 return UnrealizeObject( HGDIOBJ_32(obj) );
2050 /***********************************************************************
2051 * CreateIC (GDI.153)
2053 HDC16 WINAPI CreateIC16( LPCSTR driver, LPCSTR device, LPCSTR output,
2054 const DEVMODEA* initData )
2056 return HDC_16( CreateICA( driver, device, output, initData ) );
2060 /***********************************************************************
2061 * GetNearestColor (GDI.154)
2063 COLORREF WINAPI GetNearestColor16( HDC16 hdc, COLORREF color )
2065 return GetNearestColor( HDC_32(hdc), color );
2069 /***********************************************************************
2070 * CreateDiscardableBitmap (GDI.156)
2072 HBITMAP16 WINAPI CreateDiscardableBitmap16( HDC16 hdc, INT16 width, INT16 height )
2074 return HBITMAP_16( CreateDiscardableBitmap( HDC_32(hdc), width, height ) );
2078 /***********************************************************************
2079 * PtInRegion (GDI.161)
2081 BOOL16 WINAPI PtInRegion16( HRGN16 hrgn, INT16 x, INT16 y )
2083 return PtInRegion( HRGN_32(hrgn), x, y );
2087 /***********************************************************************
2088 * GetBitmapDimension (GDI.162)
2090 DWORD WINAPI GetBitmapDimension16( HBITMAP16 hbitmap )
2092 SIZE16 size;
2093 if (!GetBitmapDimensionEx16( hbitmap, &size )) return 0;
2094 return MAKELONG( size.cx, size.cy );
2098 /***********************************************************************
2099 * SetBitmapDimension (GDI.163)
2101 DWORD WINAPI SetBitmapDimension16( HBITMAP16 hbitmap, INT16 x, INT16 y )
2103 SIZE16 size;
2104 if (!SetBitmapDimensionEx16( hbitmap, x, y, &size )) return 0;
2105 return MAKELONG( size.cx, size.cy );
2109 /***********************************************************************
2110 * SetRectRgn (GDI.172)
2112 * NOTE: Win 3.1 sets region to empty if left > right
2114 void WINAPI SetRectRgn16( HRGN16 hrgn, INT16 left, INT16 top, INT16 right, INT16 bottom )
2116 if (left < right) SetRectRgn( HRGN_32(hrgn), left, top, right, bottom );
2117 else SetRectRgn( HRGN_32(hrgn), 0, 0, 0, 0 );
2121 /******************************************************************
2122 * PlayMetaFileRecord (GDI.176)
2124 void WINAPI PlayMetaFileRecord16( HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr, UINT16 handles )
2126 HANDLETABLE *ht32 = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET(HANDLETABLE, objectHandle[handles] ));
2127 unsigned int i;
2129 for (i = 0; i < handles; i++) ht32->objectHandle[i] = HGDIOBJ_32(ht->objectHandle[i]);
2130 PlayMetaFileRecord( HDC_32(hdc), ht32, mr, handles );
2131 for (i = 0; i < handles; i++) ht->objectHandle[i] = HGDIOBJ_16(ht32->objectHandle[i]);
2132 HeapFree( GetProcessHeap(), 0, ht32 );
2136 /***********************************************************************
2137 * SetDCHook (GDI.190)
2139 BOOL16 WINAPI SetDCHook16( HDC16 hdc16, FARPROC16 hookProc, DWORD dwHookData )
2141 FIXME( "%04x %p %x: not supported\n", hdc16, hookProc, dwHookData );
2142 return FALSE;
2146 /***********************************************************************
2147 * GetDCHook (GDI.191)
2149 DWORD WINAPI GetDCHook16( HDC16 hdc16, FARPROC16 *phookProc )
2151 FIXME( "%04x: not supported\n", hdc16 );
2152 return 0;
2156 /***********************************************************************
2157 * SetHookFlags (GDI.192)
2159 WORD WINAPI SetHookFlags16( HDC16 hdc, WORD flags )
2161 FIXME( "%04x %x: not supported\n", hdc, flags );
2162 return 0;
2166 /***********************************************************************
2167 * SetBoundsRect (GDI.193)
2169 UINT16 WINAPI SetBoundsRect16( HDC16 hdc, const RECT16* rect, UINT16 flags )
2171 if (rect)
2173 RECT rect32;
2174 rect32.left = rect->left;
2175 rect32.top = rect->top;
2176 rect32.right = rect->right;
2177 rect32.bottom = rect->bottom;
2178 return SetBoundsRect( HDC_32( hdc ), &rect32, flags );
2180 else return SetBoundsRect( HDC_32( hdc ), NULL, flags );
2184 /***********************************************************************
2185 * GetBoundsRect (GDI.194)
2187 UINT16 WINAPI GetBoundsRect16( HDC16 hdc, LPRECT16 rect, UINT16 flags)
2189 RECT rect32;
2190 UINT ret = GetBoundsRect( HDC_32( hdc ), &rect32, flags );
2191 if (rect)
2193 rect->left = rect32.left;
2194 rect->top = rect32.top;
2195 rect->right = rect32.right;
2196 rect->bottom = rect32.bottom;
2198 return ret;
2202 /***********************************************************************
2203 * EngineEnumerateFont (GDI.300)
2205 WORD WINAPI EngineEnumerateFont16(LPSTR fontname, FARPROC16 proc, DWORD data )
2207 FIXME("(%s,%p,%x),stub\n",fontname,proc,data);
2208 return 0;
2212 /***********************************************************************
2213 * EngineDeleteFont (GDI.301)
2215 WORD WINAPI EngineDeleteFont16(LPFONTINFO16 lpFontInfo)
2217 WORD handle;
2219 /* untested, don't know if it works.
2220 We seem to access some structure that is located after the
2221 FONTINFO. The FONTINFO documentation says that there may
2222 follow some char-width table or font bitmap or vector info.
2223 I think it is some kind of font bitmap that begins at offset 0x52,
2224 as FONTINFO goes up to 0x51.
2225 If this is correct, everything should be implemented correctly.
2227 if ( ((lpFontInfo->dfType & (RASTER_FONTTYPE|DEVICE_FONTTYPE)) == (RASTER_FONTTYPE|DEVICE_FONTTYPE))
2228 && (LOWORD(lpFontInfo->dfFace) == LOWORD(lpFontInfo)+0x6e)
2229 && (handle = *(WORD *)(lpFontInfo+0x54)) )
2231 *(WORD *)(lpFontInfo+0x54) = 0;
2232 GlobalFree16(handle);
2234 return 1;
2238 /***********************************************************************
2239 * EngineRealizeFont (GDI.302)
2241 WORD WINAPI EngineRealizeFont16(LPLOGFONT16 lplogFont, LPTEXTXFORM16 lptextxform, LPFONTINFO16 lpfontInfo)
2243 FIXME("(%p,%p,%p),stub\n",lplogFont,lptextxform,lpfontInfo);
2245 return 0;
2249 /***********************************************************************
2250 * EngineRealizeFontExt (GDI.315)
2252 WORD WINAPI EngineRealizeFontExt16(LONG l1, LONG l2, LONG l3, LONG l4)
2254 FIXME("(%08x,%08x,%08x,%08x),stub\n",l1,l2,l3,l4);
2256 return 0;
2260 /***********************************************************************
2261 * EngineGetCharWidth (GDI.303)
2263 WORD WINAPI EngineGetCharWidth16(LPFONTINFO16 lpFontInfo, BYTE firstChar, BYTE lastChar, LPINT16 buffer)
2265 int i;
2267 for (i = firstChar; i <= lastChar; i++)
2268 FIXME(" returns font's average width for range %d to %d\n", firstChar, lastChar);
2269 *buffer++ = lpFontInfo->dfAvgWidth; /* insert some charwidth functionality here; use average width for now */
2270 return 1;
2274 /***********************************************************************
2275 * EngineSetFontContext (GDI.304)
2277 WORD WINAPI EngineSetFontContext16(LPFONTINFO16 lpFontInfo, WORD data)
2279 FIXME("stub?\n");
2280 return 0;
2283 /***********************************************************************
2284 * EngineGetGlyphBMP (GDI.305)
2286 WORD WINAPI EngineGetGlyphBMP16(WORD word, LPFONTINFO16 lpFontInfo, WORD w1, WORD w2,
2287 LPSTR string, DWORD dword, /*LPBITMAPMETRICS16*/ LPVOID metrics)
2289 FIXME("stub?\n");
2290 return 0;
2294 /***********************************************************************
2295 * EngineMakeFontDir (GDI.306)
2297 DWORD WINAPI EngineMakeFontDir16(HDC16 hdc, LPFONTDIR16 fontdir, LPCSTR string)
2299 FIXME(" stub! (always fails)\n");
2300 return ~0UL; /* error */
2304 /***********************************************************************
2305 * GetCharABCWidths (GDI.307)
2307 BOOL16 WINAPI GetCharABCWidths16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar, LPABC16 abc )
2309 BOOL ret;
2310 UINT i;
2311 LPABC abc32 = HeapAlloc( GetProcessHeap(), 0, sizeof(ABC) * (lastChar - firstChar + 1) );
2313 if ((ret = GetCharABCWidthsA( HDC_32(hdc), firstChar, lastChar, abc32 )))
2315 for (i = firstChar; i <= lastChar; i++)
2317 abc[i-firstChar].abcA = abc32[i-firstChar].abcA;
2318 abc[i-firstChar].abcB = abc32[i-firstChar].abcB;
2319 abc[i-firstChar].abcC = abc32[i-firstChar].abcC;
2322 HeapFree( GetProcessHeap(), 0, abc32 );
2323 return ret;
2327 /***********************************************************************
2328 * GetOutlineTextMetrics (GDI.308)
2330 * Gets metrics for TrueType fonts.
2332 * PARAMS
2333 * hdc [In] Handle of device context
2334 * cbData [In] Size of metric data array
2335 * lpOTM [Out] Address of metric data array
2337 * RETURNS
2338 * Success: Non-zero or size of required buffer
2339 * Failure: 0
2341 * NOTES
2342 * lpOTM should be LPOUTLINETEXTMETRIC
2344 UINT16 WINAPI GetOutlineTextMetrics16( HDC16 hdc, UINT16 cbData,
2345 LPOUTLINETEXTMETRIC16 lpOTM )
2347 FIXME("(%04x,%04x,%p): stub\n", hdc,cbData,lpOTM);
2348 return 0;
2352 /***********************************************************************
2353 * GetGlyphOutline (GDI.309)
2355 DWORD WINAPI GetGlyphOutline16( HDC16 hdc, UINT16 uChar, UINT16 fuFormat,
2356 LPGLYPHMETRICS16 lpgm, DWORD cbBuffer,
2357 LPVOID lpBuffer, const MAT2 *lpmat2 )
2359 DWORD ret;
2360 GLYPHMETRICS gm32;
2362 ret = GetGlyphOutlineA( HDC_32(hdc), uChar, fuFormat, &gm32, cbBuffer, lpBuffer, lpmat2);
2363 if (ret && ret != GDI_ERROR)
2365 lpgm->gmBlackBoxX = gm32.gmBlackBoxX;
2366 lpgm->gmBlackBoxY = gm32.gmBlackBoxY;
2367 lpgm->gmptGlyphOrigin.x = gm32.gmptGlyphOrigin.x;
2368 lpgm->gmptGlyphOrigin.y = gm32.gmptGlyphOrigin.y;
2369 lpgm->gmCellIncX = gm32.gmCellIncX;
2370 lpgm->gmCellIncY = gm32.gmCellIncY;
2372 return ret;
2376 /***********************************************************************
2377 * CreateScalableFontResource (GDI.310)
2379 BOOL16 WINAPI CreateScalableFontResource16( UINT16 fHidden, LPCSTR lpszResourceFile,
2380 LPCSTR fontFile, LPCSTR path )
2382 return CreateScalableFontResourceA( fHidden, lpszResourceFile, fontFile, path );
2386 /*************************************************************************
2387 * GetFontData (GDI.311)
2390 DWORD WINAPI GetFontData16( HDC16 hdc, DWORD table, DWORD offset, LPVOID buffer, DWORD count )
2392 return GetFontData( HDC_32(hdc), table, offset, buffer, count );
2396 /*************************************************************************
2397 * GetRasterizerCaps (GDI.313)
2399 BOOL16 WINAPI GetRasterizerCaps16( LPRASTERIZER_STATUS lprs, UINT16 cbNumBytes )
2401 return GetRasterizerCaps( lprs, cbNumBytes );
2405 /***********************************************************************
2406 * EnumFontFamilies (GDI.330)
2408 INT16 WINAPI EnumFontFamilies16( HDC16 hDC, LPCSTR lpFamily,
2409 FONTENUMPROC16 efproc, LPARAM lpData )
2411 LOGFONT16 lf, *plf;
2413 if (lpFamily)
2415 if (!*lpFamily) return 1;
2416 lstrcpynA( lf.lfFaceName, lpFamily, LF_FACESIZE );
2417 lf.lfCharSet = DEFAULT_CHARSET;
2418 lf.lfPitchAndFamily = 0;
2419 plf = &lf;
2421 else plf = NULL;
2423 return EnumFontFamiliesEx16( hDC, plf, efproc, lpData, 0 );
2427 /*************************************************************************
2428 * GetKerningPairs (GDI.332)
2431 INT16 WINAPI GetKerningPairs16( HDC16 hdc, INT16 count, LPKERNINGPAIR16 pairs )
2433 KERNINGPAIR *pairs32;
2434 INT i, ret;
2436 if (!count) return 0;
2438 if (!(pairs32 = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*pairs32) ))) return 0;
2439 if ((ret = GetKerningPairsA( HDC_32(hdc), count, pairs32 )))
2441 for (i = 0; i < ret; i++)
2443 pairs->wFirst = pairs32->wFirst;
2444 pairs->wSecond = pairs32->wSecond;
2445 pairs->iKernAmount = pairs32->iKernAmount;
2448 HeapFree( GetProcessHeap(), 0, pairs32 );
2449 return ret;
2454 /***********************************************************************
2455 * GetTextAlign (GDI.345)
2457 UINT16 WINAPI GetTextAlign16( HDC16 hdc )
2459 return GetTextAlign( HDC_32(hdc) );
2463 /***********************************************************************
2464 * SetTextAlign (GDI.346)
2466 UINT16 WINAPI SetTextAlign16( HDC16 hdc, UINT16 align )
2468 return SetTextAlign( HDC_32(hdc), align );
2472 /***********************************************************************
2473 * Chord (GDI.348)
2475 BOOL16 WINAPI Chord16( HDC16 hdc, INT16 left, INT16 top,
2476 INT16 right, INT16 bottom, INT16 xstart, INT16 ystart,
2477 INT16 xend, INT16 yend )
2479 return Chord( HDC_32(hdc), left, top, right, bottom, xstart, ystart, xend, yend );
2483 /***********************************************************************
2484 * SetMapperFlags (GDI.349)
2486 DWORD WINAPI SetMapperFlags16( HDC16 hdc, DWORD flags )
2488 return SetMapperFlags( HDC_32(hdc), flags );
2492 /***********************************************************************
2493 * GetCharWidth (GDI.350)
2495 BOOL16 WINAPI GetCharWidth16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar, LPINT16 buffer )
2497 BOOL retVal = FALSE;
2499 if( firstChar != lastChar )
2501 LPINT buf32 = HeapAlloc(GetProcessHeap(), 0, sizeof(INT)*(1 + (lastChar - firstChar)));
2502 if( buf32 )
2504 LPINT obuf32 = buf32;
2505 UINT i;
2507 retVal = GetCharWidth32A( HDC_32(hdc), firstChar, lastChar, buf32);
2508 if (retVal)
2510 for (i = firstChar; i <= lastChar; i++) *buffer++ = *buf32++;
2512 HeapFree(GetProcessHeap(), 0, obuf32);
2515 else /* happens quite often to warrant a special treatment */
2517 INT chWidth;
2518 retVal = GetCharWidth32A( HDC_32(hdc), firstChar, lastChar, &chWidth );
2519 *buffer = chWidth;
2521 return retVal;
2525 /***********************************************************************
2526 * ExtTextOut (GDI.351)
2528 BOOL16 WINAPI ExtTextOut16( HDC16 hdc, INT16 x, INT16 y, UINT16 flags,
2529 const RECT16 *lprect, LPCSTR str, UINT16 count,
2530 const INT16 *lpDx )
2532 BOOL ret;
2533 int i;
2534 RECT rect32;
2535 LPINT lpdx32 = NULL;
2537 if (lpDx) {
2538 lpdx32 = HeapAlloc( GetProcessHeap(),0, sizeof(INT)*count );
2539 if(lpdx32 == NULL) return FALSE;
2540 for (i=count;i--;) lpdx32[i]=lpDx[i];
2542 if (lprect)
2544 rect32.left = lprect->left;
2545 rect32.top = lprect->top;
2546 rect32.right = lprect->right;
2547 rect32.bottom = lprect->bottom;
2549 ret = ExtTextOutA(HDC_32(hdc),x,y,flags,lprect?&rect32:NULL,str,count,lpdx32);
2550 HeapFree( GetProcessHeap(), 0, lpdx32 );
2551 return ret;
2555 /***********************************************************************
2556 * CreatePalette (GDI.360)
2558 HPALETTE16 WINAPI CreatePalette16( const LOGPALETTE* palette )
2560 return HPALETTE_16( CreatePalette( palette ) );
2564 /***********************************************************************
2565 * GDISelectPalette (GDI.361)
2567 HPALETTE16 WINAPI GDISelectPalette16( HDC16 hdc, HPALETTE16 hpalette, WORD wBkg )
2569 HPALETTE16 ret = HPALETTE_16( SelectPalette( HDC_32(hdc), HPALETTE_32(hpalette), wBkg ));
2570 if (ret && !wBkg) hPrimaryPalette = hpalette;
2571 return ret;
2575 /***********************************************************************
2576 * GDIRealizePalette (GDI.362)
2578 UINT16 WINAPI GDIRealizePalette16( HDC16 hdc )
2580 return RealizePalette( HDC_32(hdc) );
2584 /***********************************************************************
2585 * GetPaletteEntries (GDI.363)
2587 UINT16 WINAPI GetPaletteEntries16( HPALETTE16 hpalette, UINT16 start,
2588 UINT16 count, LPPALETTEENTRY entries )
2590 return GetPaletteEntries( HPALETTE_32(hpalette), start, count, entries );
2594 /***********************************************************************
2595 * SetPaletteEntries (GDI.364)
2597 UINT16 WINAPI SetPaletteEntries16( HPALETTE16 hpalette, UINT16 start,
2598 UINT16 count, const PALETTEENTRY *entries )
2600 return SetPaletteEntries( HPALETTE_32(hpalette), start, count, entries );
2604 /**********************************************************************
2605 * UpdateColors (GDI.366)
2607 INT16 WINAPI UpdateColors16( HDC16 hdc )
2609 UpdateColors( HDC_32(hdc) );
2610 return TRUE;
2614 /***********************************************************************
2615 * AnimatePalette (GDI.367)
2617 void WINAPI AnimatePalette16( HPALETTE16 hpalette, UINT16 StartIndex,
2618 UINT16 NumEntries, const PALETTEENTRY* PaletteColors)
2620 AnimatePalette( HPALETTE_32(hpalette), StartIndex, NumEntries, PaletteColors );
2624 /***********************************************************************
2625 * ResizePalette (GDI.368)
2627 BOOL16 WINAPI ResizePalette16( HPALETTE16 hpalette, UINT16 cEntries )
2629 return ResizePalette( HPALETTE_32(hpalette), cEntries );
2633 /***********************************************************************
2634 * GetNearestPaletteIndex (GDI.370)
2636 UINT16 WINAPI GetNearestPaletteIndex16( HPALETTE16 hpalette, COLORREF color )
2638 return GetNearestPaletteIndex( HPALETTE_32(hpalette), color );
2642 /**********************************************************************
2643 * ExtFloodFill (GDI.372)
2645 BOOL16 WINAPI ExtFloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color,
2646 UINT16 fillType )
2648 return ExtFloodFill( HDC_32(hdc), x, y, color, fillType );
2652 /***********************************************************************
2653 * SetSystemPaletteUse (GDI.373)
2655 UINT16 WINAPI SetSystemPaletteUse16( HDC16 hdc, UINT16 use )
2657 return SetSystemPaletteUse( HDC_32(hdc), use );
2661 /***********************************************************************
2662 * GetSystemPaletteUse (GDI.374)
2664 UINT16 WINAPI GetSystemPaletteUse16( HDC16 hdc )
2666 return GetSystemPaletteUse( HDC_32(hdc) );
2670 /***********************************************************************
2671 * GetSystemPaletteEntries (GDI.375)
2673 UINT16 WINAPI GetSystemPaletteEntries16( HDC16 hdc, UINT16 start, UINT16 count,
2674 LPPALETTEENTRY entries )
2676 return GetSystemPaletteEntries( HDC_32(hdc), start, count, entries );
2680 /***********************************************************************
2681 * ResetDC (GDI.376)
2683 HDC16 WINAPI ResetDC16( HDC16 hdc, const DEVMODEA *devmode )
2685 return HDC_16( ResetDCA(HDC_32(hdc), devmode) );
2689 /******************************************************************
2690 * StartDoc (GDI.377)
2692 INT16 WINAPI StartDoc16( HDC16 hdc, const DOCINFO16 *lpdoc )
2694 DOCINFOA docA;
2696 docA.cbSize = lpdoc->cbSize;
2697 docA.lpszDocName = MapSL(lpdoc->lpszDocName);
2698 docA.lpszOutput = MapSL(lpdoc->lpszOutput);
2699 if(lpdoc->cbSize > offsetof(DOCINFO16,lpszDatatype))
2700 docA.lpszDatatype = MapSL(lpdoc->lpszDatatype);
2701 else
2702 docA.lpszDatatype = NULL;
2703 if(lpdoc->cbSize > offsetof(DOCINFO16,fwType))
2704 docA.fwType = lpdoc->fwType;
2705 else
2706 docA.fwType = 0;
2707 return StartDocA( HDC_32(hdc), &docA );
2711 /******************************************************************
2712 * EndDoc (GDI.378)
2714 INT16 WINAPI EndDoc16( HDC16 hdc )
2716 return EndDoc( HDC_32(hdc) );
2720 /******************************************************************
2721 * StartPage (GDI.379)
2723 INT16 WINAPI StartPage16( HDC16 hdc )
2725 return StartPage( HDC_32(hdc) );
2729 /******************************************************************
2730 * EndPage (GDI.380)
2732 INT16 WINAPI EndPage16( HDC16 hdc )
2734 return EndPage( HDC_32(hdc) );
2738 /******************************************************************************
2739 * AbortDoc (GDI.382)
2741 INT16 WINAPI AbortDoc16( HDC16 hdc )
2743 return AbortDoc( HDC_32(hdc) );
2747 /***********************************************************************
2748 * FastWindowFrame (GDI.400)
2750 BOOL16 WINAPI FastWindowFrame16( HDC16 hdc, const RECT16 *rect,
2751 INT16 width, INT16 height, DWORD rop )
2753 HDC hdc32 = HDC_32(hdc);
2754 HBRUSH hbrush = SelectObject( hdc32, GetStockObject( GRAY_BRUSH ) );
2755 PatBlt( hdc32, rect->left, rect->top,
2756 rect->right - rect->left - width, height, rop );
2757 PatBlt( hdc32, rect->left, rect->top + height, width,
2758 rect->bottom - rect->top - height, rop );
2759 PatBlt( hdc32, rect->left + width, rect->bottom - 1,
2760 rect->right - rect->left - width, -height, rop );
2761 PatBlt( hdc32, rect->right - 1, rect->top, -width,
2762 rect->bottom - rect->top - height, rop );
2763 SelectObject( hdc32, hbrush );
2764 return TRUE;
2768 /***********************************************************************
2769 * GdiInit2 (GDI.403)
2771 * See "Undocumented Windows"
2773 * PARAMS
2774 * h1 [I] GDI object
2775 * h2 [I] global data
2777 HANDLE16 WINAPI GdiInit216( HANDLE16 h1, HANDLE16 h2 )
2779 FIXME("(%04x, %04x), stub.\n", h1, h2);
2780 if (h2 == 0xffff) return 0xffff; /* undefined return value */
2781 return h1; /* FIXME: should be the memory handle of h1 */
2785 /***********************************************************************
2786 * FinalGdiInit (GDI.405)
2788 void WINAPI FinalGdiInit16( HBRUSH16 hPattern /* [in] fill pattern of desktop */ )
2793 /***********************************************************************
2794 * CreateUserBitmap (GDI.407)
2796 HBITMAP16 WINAPI CreateUserBitmap16( INT16 width, INT16 height, UINT16 planes,
2797 UINT16 bpp, LPCVOID bits )
2799 return CreateBitmap16( width, height, planes, bpp, bits );
2803 /***********************************************************************
2804 * CreateUserDiscardableBitmap (GDI.409)
2806 HBITMAP16 WINAPI CreateUserDiscardableBitmap16( WORD dummy, INT16 width, INT16 height )
2808 HDC hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
2809 HBITMAP ret = CreateCompatibleBitmap( hdc, width, height );
2810 DeleteDC( hdc );
2811 return HBITMAP_16(ret);
2815 /***********************************************************************
2816 * GetCurLogFont (GDI.411)
2818 HFONT16 WINAPI GetCurLogFont16( HDC16 hdc )
2820 return HFONT_16( GetCurrentObject( HDC_32(hdc), OBJ_FONT ) );
2824 /***********************************************************************
2825 * StretchDIBits (GDI.439)
2827 INT16 WINAPI StretchDIBits16( HDC16 hdc, INT16 xDst, INT16 yDst, INT16 widthDst,
2828 INT16 heightDst, INT16 xSrc, INT16 ySrc, INT16 widthSrc,
2829 INT16 heightSrc, const VOID *bits,
2830 const BITMAPINFO *info, UINT16 wUsage, DWORD dwRop )
2832 return StretchDIBits( HDC_32(hdc), xDst, yDst, widthDst, heightDst,
2833 xSrc, ySrc, widthSrc, heightSrc, bits,
2834 info, wUsage, dwRop );
2838 /***********************************************************************
2839 * SetDIBits (GDI.440)
2841 INT16 WINAPI SetDIBits16( HDC16 hdc, HBITMAP16 hbitmap, UINT16 startscan,
2842 UINT16 lines, LPCVOID bits, const BITMAPINFO *info,
2843 UINT16 coloruse )
2845 return SetDIBits( HDC_32(hdc), HBITMAP_32(hbitmap), startscan, lines, bits, info, coloruse );
2849 /***********************************************************************
2850 * GetDIBits (GDI.441)
2852 INT16 WINAPI GetDIBits16( HDC16 hdc, HBITMAP16 hbitmap, UINT16 startscan,
2853 UINT16 lines, LPVOID bits, BITMAPINFO * info,
2854 UINT16 coloruse )
2856 return GetDIBits( HDC_32(hdc), HBITMAP_32(hbitmap), startscan, lines, bits, info, coloruse );
2860 /***********************************************************************
2861 * CreateDIBitmap (GDI.442)
2863 HBITMAP16 WINAPI CreateDIBitmap16( HDC16 hdc, const BITMAPINFOHEADER * header,
2864 DWORD init, LPCVOID bits, const BITMAPINFO * data,
2865 UINT16 coloruse )
2867 return HBITMAP_16( CreateDIBitmap( HDC_32(hdc), header, init, bits, data, coloruse ) );
2871 /***********************************************************************
2872 * SetDIBitsToDevice (GDI.443)
2874 INT16 WINAPI SetDIBitsToDevice16( HDC16 hdc, INT16 xDest, INT16 yDest, INT16 cx,
2875 INT16 cy, INT16 xSrc, INT16 ySrc, UINT16 startscan,
2876 UINT16 lines, LPCVOID bits, const BITMAPINFO *info,
2877 UINT16 coloruse )
2879 return SetDIBitsToDevice( HDC_32(hdc), xDest, yDest, cx, cy, xSrc, ySrc,
2880 startscan, lines, bits, info, coloruse );
2884 /***********************************************************************
2885 * CreateRoundRectRgn (GDI.444)
2887 * If either ellipse dimension is zero we call CreateRectRgn16 for its
2888 * `special' behaviour. -ve ellipse dimensions can result in GPFs under win3.1
2889 * we just let CreateRoundRectRgn convert them to +ve values.
2892 HRGN16 WINAPI CreateRoundRectRgn16( INT16 left, INT16 top, INT16 right, INT16 bottom,
2893 INT16 ellipse_width, INT16 ellipse_height )
2895 if( ellipse_width == 0 || ellipse_height == 0 )
2896 return CreateRectRgn16( left, top, right, bottom );
2897 else
2898 return HRGN_16( CreateRoundRectRgn( left, top, right, bottom,
2899 ellipse_width, ellipse_height ));
2903 /***********************************************************************
2904 * CreateDIBPatternBrush (GDI.445)
2906 HBRUSH16 WINAPI CreateDIBPatternBrush16( HGLOBAL16 hbitmap, UINT16 coloruse )
2908 BITMAPINFO *bmi;
2909 HBRUSH16 ret;
2911 if (!(bmi = GlobalLock16( hbitmap ))) return 0;
2912 ret = HBRUSH_16( CreateDIBPatternBrushPt( bmi, coloruse ));
2913 GlobalUnlock16( hbitmap );
2914 return ret;
2918 /**********************************************************************
2919 * PolyPolygon (GDI.450)
2921 BOOL16 WINAPI PolyPolygon16( HDC16 hdc, const POINT16* pt, const INT16* counts,
2922 UINT16 polygons )
2924 int i,nrpts;
2925 LPPOINT pt32;
2926 LPINT counts32;
2927 BOOL16 ret;
2929 nrpts=0;
2930 for (i=polygons;i--;)
2931 nrpts+=counts[i];
2932 pt32 = HeapAlloc( GetProcessHeap(), 0, sizeof(POINT)*nrpts);
2933 if(pt32 == NULL) return FALSE;
2934 for (i=nrpts;i--;)
2936 pt32[i].x = pt[i].x;
2937 pt32[i].y = pt[i].y;
2939 counts32 = HeapAlloc( GetProcessHeap(), 0, polygons*sizeof(INT) );
2940 if(counts32 == NULL) {
2941 HeapFree( GetProcessHeap(), 0, pt32 );
2942 return FALSE;
2944 for (i=polygons;i--;) counts32[i]=counts[i];
2946 ret = PolyPolygon(HDC_32(hdc),pt32,counts32,polygons);
2947 HeapFree( GetProcessHeap(), 0, counts32 );
2948 HeapFree( GetProcessHeap(), 0, pt32 );
2949 return ret;
2953 /***********************************************************************
2954 * CreatePolyPolygonRgn (GDI.451)
2956 HRGN16 WINAPI CreatePolyPolygonRgn16( const POINT16 *points,
2957 const INT16 *count, INT16 nbpolygons, INT16 mode )
2959 HRGN hrgn;
2960 int i, npts = 0;
2961 INT *count32;
2962 POINT *points32;
2964 for (i = 0; i < nbpolygons; i++) npts += count[i];
2965 points32 = HeapAlloc( GetProcessHeap(), 0, npts * sizeof(POINT) );
2966 for (i = 0; i < npts; i++)
2968 points32[i].x = points[i].x;
2969 points32[i].y = points[i].y;
2972 count32 = HeapAlloc( GetProcessHeap(), 0, nbpolygons * sizeof(INT) );
2973 for (i = 0; i < nbpolygons; i++) count32[i] = count[i];
2974 hrgn = CreatePolyPolygonRgn( points32, count32, nbpolygons, mode );
2975 HeapFree( GetProcessHeap(), 0, count32 );
2976 HeapFree( GetProcessHeap(), 0, points32 );
2977 return HRGN_16(hrgn);
2981 /***********************************************************************
2982 * GdiSeeGdiDo (GDI.452)
2984 DWORD WINAPI GdiSeeGdiDo16( WORD wReqType, WORD wParam1, WORD wParam2,
2985 WORD wParam3 )
2987 DWORD ret = ~0U;
2989 switch (wReqType)
2991 case 0x0001: /* LocalAlloc */
2992 WARN("LocalAlloc16(%x, %x): ignoring\n", wParam1, wParam3);
2993 ret = 0;
2994 break;
2995 case 0x0002: /* LocalFree */
2996 WARN("LocalFree16(%x): ignoring\n", wParam1);
2997 ret = 0;
2998 break;
2999 case 0x0003: /* LocalCompact */
3000 WARN("LocalCompact16(%x): ignoring\n", wParam3);
3001 ret = 65000; /* lie about the amount of free space */
3002 break;
3003 case 0x0103: /* LocalHeap */
3004 WARN("LocalHeap16(): ignoring\n");
3005 break;
3006 default:
3007 WARN("(wReqType=%04x): Unknown\n", wReqType);
3008 break;
3010 return ret;
3014 /***********************************************************************
3015 * SetObjectOwner (GDI.461)
3017 void WINAPI SetObjectOwner16( HGDIOBJ16 handle, HANDLE16 owner )
3019 /* Nothing to do */
3023 /***********************************************************************
3024 * IsGDIObject (GDI.462)
3026 * returns type of object if valid (W95 system programming secrets p. 264-5)
3028 BOOL16 WINAPI IsGDIObject16( HGDIOBJ16 handle16 )
3030 static const BYTE type_map[] =
3032 0, /* bad */
3033 1, /* OBJ_PEN */
3034 2, /* OBJ_BRUSH */
3035 7, /* OBJ_DC */
3036 9, /* OBJ_METADC */
3037 4, /* OBJ_PAL */
3038 3, /* OBJ_FONT */
3039 5, /* OBJ_BITMAP */
3040 6, /* OBJ_REGION */
3041 10, /* OBJ_METAFILE */
3042 7, /* OBJ_MEMDC */
3043 0, /* OBJ_EXTPEN */
3044 9, /* OBJ_ENHMETADC */
3045 12, /* OBJ_ENHMETAFILE */
3046 0 /* OBJ_COLORSPACE */
3049 UINT type = GetObjectType( HGDIOBJ_32( handle16 ));
3051 if (type >= ARRAY_SIZE(type_map)) return FALSE;
3052 return type_map[type];
3056 /***********************************************************************
3057 * RectVisible (GDI.465)
3058 * RectVisibleOld (GDI.104)
3060 BOOL16 WINAPI RectVisible16( HDC16 hdc, const RECT16* rect16 )
3062 RECT rect;
3064 rect.left = rect16->left;
3065 rect.top = rect16->top;
3066 rect.right = rect16->right;
3067 rect.bottom = rect16->bottom;
3068 return RectVisible( HDC_32(hdc), &rect );
3072 /***********************************************************************
3073 * RectInRegion (GDI.466)
3074 * RectInRegionOld (GDI.181)
3076 BOOL16 WINAPI RectInRegion16( HRGN16 hrgn, const RECT16 *rect )
3078 RECT r32;
3080 r32.left = rect->left;
3081 r32.top = rect->top;
3082 r32.right = rect->right;
3083 r32.bottom = rect->bottom;
3084 return RectInRegion( HRGN_32(hrgn), &r32 );
3088 /***********************************************************************
3089 * GetBitmapDimensionEx (GDI.468)
3091 BOOL16 WINAPI GetBitmapDimensionEx16( HBITMAP16 hbitmap, LPSIZE16 size )
3093 SIZE size32;
3094 BOOL ret = GetBitmapDimensionEx( HBITMAP_32(hbitmap), &size32 );
3096 if (ret)
3098 size->cx = size32.cx;
3099 size->cy = size32.cy;
3101 return ret;
3105 /***********************************************************************
3106 * GetBrushOrgEx (GDI.469)
3108 BOOL16 WINAPI GetBrushOrgEx16( HDC16 hdc, LPPOINT16 pt )
3110 POINT pt32;
3111 if (!GetBrushOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
3112 pt->x = pt32.x;
3113 pt->y = pt32.y;
3114 return TRUE;
3118 /***********************************************************************
3119 * GetCurrentPositionEx (GDI.470)
3121 BOOL16 WINAPI GetCurrentPositionEx16( HDC16 hdc, LPPOINT16 pt )
3123 POINT pt32;
3124 if (!GetCurrentPositionEx( HDC_32(hdc), &pt32 )) return FALSE;
3125 pt->x = pt32.x;
3126 pt->y = pt32.y;
3127 return TRUE;
3131 /***********************************************************************
3132 * GetTextExtentPoint (GDI.471)
3134 * FIXME: Should this have a bug for compatibility?
3135 * Original Windows versions of GetTextExtentPoint{A,W} have documented
3136 * bugs (-> MSDN KB q147647.txt).
3138 BOOL16 WINAPI GetTextExtentPoint16( HDC16 hdc, LPCSTR str, INT16 count, LPSIZE16 size )
3140 SIZE size32;
3141 BOOL ret = GetTextExtentPoint32A( HDC_32(hdc), str, count, &size32 );
3143 if (ret)
3145 size->cx = size32.cx;
3146 size->cy = size32.cy;
3148 return ret;
3152 /***********************************************************************
3153 * GetViewportExtEx (GDI.472)
3155 BOOL16 WINAPI GetViewportExtEx16( HDC16 hdc, LPSIZE16 size )
3157 SIZE size32;
3158 if (!GetViewportExtEx( HDC_32(hdc), &size32 )) return FALSE;
3159 size->cx = size32.cx;
3160 size->cy = size32.cy;
3161 return TRUE;
3165 /***********************************************************************
3166 * GetViewportOrgEx (GDI.473)
3168 BOOL16 WINAPI GetViewportOrgEx16( HDC16 hdc, LPPOINT16 pt )
3170 POINT pt32;
3171 if (!GetViewportOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
3172 pt->x = pt32.x;
3173 pt->y = pt32.y;
3174 return TRUE;
3178 /***********************************************************************
3179 * GetWindowExtEx (GDI.474)
3181 BOOL16 WINAPI GetWindowExtEx16( HDC16 hdc, LPSIZE16 size )
3183 SIZE size32;
3184 if (!GetWindowExtEx( HDC_32(hdc), &size32 )) return FALSE;
3185 size->cx = size32.cx;
3186 size->cy = size32.cy;
3187 return TRUE;
3191 /***********************************************************************
3192 * GetWindowOrgEx (GDI.475)
3194 BOOL16 WINAPI GetWindowOrgEx16( HDC16 hdc, LPPOINT16 pt )
3196 POINT pt32;
3197 if (!GetWindowOrgEx( HDC_32(hdc), &pt32 )) return FALSE;
3198 pt->x = pt32.x;
3199 pt->y = pt32.y;
3200 return TRUE;
3204 /***********************************************************************
3205 * OffsetViewportOrgEx (GDI.476)
3207 BOOL16 WINAPI OffsetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt)
3209 POINT pt32;
3210 BOOL16 ret = OffsetViewportOrgEx( HDC_32(hdc), x, y, &pt32 );
3211 if (pt)
3213 pt->x = pt32.x;
3214 pt->y = pt32.y;
3216 return ret;
3220 /***********************************************************************
3221 * OffsetWindowOrgEx (GDI.477)
3223 BOOL16 WINAPI OffsetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
3225 POINT pt32;
3226 BOOL16 ret = OffsetWindowOrgEx( HDC_32(hdc), x, y, &pt32 );
3227 if (pt)
3229 pt->x = pt32.x;
3230 pt->y = pt32.y;
3232 return ret;
3236 /***********************************************************************
3237 * SetBitmapDimensionEx (GDI.478)
3239 BOOL16 WINAPI SetBitmapDimensionEx16( HBITMAP16 hbitmap, INT16 x, INT16 y, LPSIZE16 prevSize )
3241 SIZE size32;
3242 BOOL ret = SetBitmapDimensionEx( HBITMAP_32(hbitmap), x, y, &size32 );
3244 if (ret && prevSize)
3246 prevSize->cx = size32.cx;
3247 prevSize->cy = size32.cy;
3249 return ret;
3253 /***********************************************************************
3254 * SetViewportExtEx (GDI.479)
3256 BOOL16 WINAPI SetViewportExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
3258 SIZE size32;
3259 BOOL16 ret = SetViewportExtEx( HDC_32(hdc), x, y, &size32 );
3260 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
3261 return ret;
3265 /***********************************************************************
3266 * SetViewportOrgEx (GDI.480)
3268 BOOL16 WINAPI SetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
3270 POINT pt32;
3271 BOOL16 ret = SetViewportOrgEx( HDC_32(hdc), x, y, &pt32 );
3272 if (pt)
3274 pt->x = pt32.x;
3275 pt->y = pt32.y;
3277 return ret;
3281 /***********************************************************************
3282 * SetWindowExtEx (GDI.481)
3284 BOOL16 WINAPI SetWindowExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
3286 SIZE size32;
3287 BOOL16 ret = SetWindowExtEx( HDC_32(hdc), x, y, &size32 );
3288 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
3289 return ret;
3293 /***********************************************************************
3294 * SetWindowOrgEx (GDI.482)
3296 BOOL16 WINAPI SetWindowOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
3298 POINT pt32;
3299 BOOL16 ret = SetWindowOrgEx( HDC_32(hdc), x, y, &pt32 );
3300 if (pt)
3302 pt->x = pt32.x;
3303 pt->y = pt32.y;
3305 return ret;
3309 /***********************************************************************
3310 * MoveToEx (GDI.483)
3312 BOOL16 WINAPI MoveToEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
3314 POINT pt32;
3316 if (!MoveToEx( HDC_32(hdc), x, y, &pt32 )) return FALSE;
3317 if (pt)
3319 pt->x = pt32.x;
3320 pt->y = pt32.y;
3322 return TRUE;
3326 /***********************************************************************
3327 * ScaleViewportExtEx (GDI.484)
3329 BOOL16 WINAPI ScaleViewportExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
3330 INT16 yNum, INT16 yDenom, LPSIZE16 size )
3332 SIZE size32;
3333 BOOL16 ret = ScaleViewportExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom,
3334 &size32 );
3335 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
3336 return ret;
3340 /***********************************************************************
3341 * ScaleWindowExtEx (GDI.485)
3343 BOOL16 WINAPI ScaleWindowExtEx16( HDC16 hdc, INT16 xNum, INT16 xDenom,
3344 INT16 yNum, INT16 yDenom, LPSIZE16 size )
3346 SIZE size32;
3347 BOOL16 ret = ScaleWindowExtEx( HDC_32(hdc), xNum, xDenom, yNum, yDenom,
3348 &size32 );
3349 if (size) { size->cx = size32.cx; size->cy = size32.cy; }
3350 return ret;
3354 /***********************************************************************
3355 * GetAspectRatioFilterEx (GDI.486)
3357 BOOL16 WINAPI GetAspectRatioFilterEx16( HDC16 hdc, LPSIZE16 pAspectRatio )
3359 FIXME("(%04x, %p): -- Empty Stub !\n", hdc, pAspectRatio);
3360 return FALSE;
3364 /******************************************************************************
3365 * PolyBezier (GDI.502)
3367 BOOL16 WINAPI PolyBezier16( HDC16 hdc, const POINT16* lppt, INT16 cPoints )
3369 int i;
3370 BOOL16 ret;
3371 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0, cPoints*sizeof(POINT) );
3372 if(!pt32) return FALSE;
3373 for (i=cPoints;i--;)
3375 pt32[i].x = lppt[i].x;
3376 pt32[i].y = lppt[i].y;
3378 ret= PolyBezier(HDC_32(hdc), pt32, cPoints);
3379 HeapFree( GetProcessHeap(), 0, pt32 );
3380 return ret;
3384 /******************************************************************************
3385 * PolyBezierTo (GDI.503)
3387 BOOL16 WINAPI PolyBezierTo16( HDC16 hdc, const POINT16* lppt, INT16 cPoints )
3389 int i;
3390 BOOL16 ret;
3391 LPPOINT pt32 = HeapAlloc( GetProcessHeap(), 0,
3392 cPoints*sizeof(POINT) );
3393 if(!pt32) return FALSE;
3394 for (i=cPoints;i--;)
3396 pt32[i].x = lppt[i].x;
3397 pt32[i].y = lppt[i].y;
3399 ret= PolyBezierTo(HDC_32(hdc), pt32, cPoints);
3400 HeapFree( GetProcessHeap(), 0, pt32 );
3401 return ret;
3405 /******************************************************************************
3406 * ExtSelectClipRgn (GDI.508)
3408 INT16 WINAPI ExtSelectClipRgn16( HDC16 hdc, HRGN16 hrgn, INT16 fnMode )
3410 return ExtSelectClipRgn( HDC_32(hdc), HRGN_32(hrgn), fnMode);
3414 /***********************************************************************
3415 * AbortPath (GDI.511)
3417 BOOL16 WINAPI AbortPath16(HDC16 hdc)
3419 return AbortPath( HDC_32(hdc) );
3423 /***********************************************************************
3424 * BeginPath (GDI.512)
3426 BOOL16 WINAPI BeginPath16(HDC16 hdc)
3428 return BeginPath( HDC_32(hdc) );
3432 /***********************************************************************
3433 * CloseFigure (GDI.513)
3435 BOOL16 WINAPI CloseFigure16(HDC16 hdc)
3437 return CloseFigure( HDC_32(hdc) );
3441 /***********************************************************************
3442 * EndPath (GDI.514)
3444 BOOL16 WINAPI EndPath16(HDC16 hdc)
3446 return EndPath( HDC_32(hdc) );
3450 /***********************************************************************
3451 * FillPath (GDI.515)
3453 BOOL16 WINAPI FillPath16(HDC16 hdc)
3455 return FillPath( HDC_32(hdc) );
3459 /*******************************************************************
3460 * FlattenPath (GDI.516)
3462 BOOL16 WINAPI FlattenPath16(HDC16 hdc)
3464 return FlattenPath( HDC_32(hdc) );
3468 /***********************************************************************
3469 * GetPath (GDI.517)
3471 INT16 WINAPI GetPath16(HDC16 hdc, LPPOINT16 pPoints, LPBYTE pTypes, INT16 nSize)
3473 FIXME("(%d,%p,%p): stub\n",hdc,pPoints,pTypes);
3474 return 0;
3478 /***********************************************************************
3479 * PathToRegion (GDI.518)
3481 HRGN16 WINAPI PathToRegion16(HDC16 hdc)
3483 return HRGN_16( PathToRegion( HDC_32(hdc) ));
3487 /***********************************************************************
3488 * SelectClipPath (GDI.519)
3490 BOOL16 WINAPI SelectClipPath16(HDC16 hdc, INT16 iMode)
3492 return SelectClipPath( HDC_32(hdc), iMode );
3496 /*******************************************************************
3497 * StrokeAndFillPath (GDI.520)
3499 BOOL16 WINAPI StrokeAndFillPath16(HDC16 hdc)
3501 return StrokeAndFillPath( HDC_32(hdc) );
3505 /*******************************************************************
3506 * StrokePath (GDI.521)
3508 BOOL16 WINAPI StrokePath16(HDC16 hdc)
3510 return StrokePath( HDC_32(hdc) );
3514 /*******************************************************************
3515 * WidenPath (GDI.522)
3517 BOOL16 WINAPI WidenPath16(HDC16 hdc)
3519 return WidenPath( HDC_32(hdc) );
3523 /***********************************************************************
3524 * GetArcDirection (GDI.524)
3526 INT16 WINAPI GetArcDirection16( HDC16 hdc )
3528 return GetArcDirection( HDC_32(hdc) );
3532 /***********************************************************************
3533 * SetArcDirection (GDI.525)
3535 INT16 WINAPI SetArcDirection16( HDC16 hdc, INT16 nDirection )
3537 return SetArcDirection( HDC_32(hdc), (INT)nDirection );
3541 /***********************************************************************
3542 * CreateHalftonePalette (GDI.529)
3544 HPALETTE16 WINAPI CreateHalftonePalette16( HDC16 hdc )
3546 return HPALETTE_16( CreateHalftonePalette( HDC_32(hdc) ));
3550 /***********************************************************************
3551 * SetDIBColorTable (GDI.602)
3553 UINT16 WINAPI SetDIBColorTable16( HDC16 hdc, UINT16 startpos, UINT16 entries, RGBQUAD *colors )
3555 return SetDIBColorTable( HDC_32(hdc), startpos, entries, colors );
3559 /***********************************************************************
3560 * GetDIBColorTable (GDI.603)
3562 UINT16 WINAPI GetDIBColorTable16( HDC16 hdc, UINT16 startpos, UINT16 entries, RGBQUAD *colors )
3564 return GetDIBColorTable( HDC_32(hdc), startpos, entries, colors );
3568 /***********************************************************************
3569 * GetRegionData (GDI.607)
3571 * FIXME: is LPRGNDATA the same in Win16 and Win32 ?
3573 DWORD WINAPI GetRegionData16( HRGN16 hrgn, DWORD count, LPRGNDATA rgndata )
3575 return GetRegionData( HRGN_32(hrgn), count, rgndata );
3579 /***********************************************************************
3580 * GdiFreeResources (GDI.609)
3582 WORD WINAPI GdiFreeResources16( DWORD reserve )
3584 return 90; /* lie about it, it shouldn't matter */
3588 /***********************************************************************
3589 * GdiSignalProc32 (GDI.610)
3591 WORD WINAPI GdiSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
3592 DWORD dwFlags, HMODULE16 hModule )
3594 return 0;
3598 /***********************************************************************
3599 * GetTextCharset (GDI.612)
3601 UINT16 WINAPI GetTextCharset16( HDC16 hdc )
3603 return GetTextCharset( HDC_32(hdc) );
3607 /***********************************************************************
3608 * EnumFontFamiliesEx (GDI.613)
3610 INT16 WINAPI EnumFontFamiliesEx16( HDC16 hdc, LPLOGFONT16 plf,
3611 FONTENUMPROC16 proc, LPARAM lParam,
3612 DWORD dwFlags)
3614 struct callback16_info info;
3615 LOGFONTW lfW, *plfW;
3617 info.proc = (FARPROC16)proc;
3618 info.param = lParam;
3620 if (plf)
3622 logfont_16_to_W(plf, &lfW);
3623 plfW = &lfW;
3625 else plfW = NULL;
3627 return EnumFontFamiliesExW( HDC_32(hdc), plfW, enum_font_callback,
3628 (LPARAM)&info, dwFlags );
3632 /*************************************************************************
3633 * GetFontLanguageInfo (GDI.616)
3635 DWORD WINAPI GetFontLanguageInfo16( HDC16 hdc )
3637 return GetFontLanguageInfo( HDC_32(hdc) );
3641 /***********************************************************************
3642 * SetLayout (GDI.1000)
3644 * Sets left->right or right->left text layout flags of a dc.
3646 BOOL16 WINAPI SetLayout16( HDC16 hdc, DWORD layout )
3648 return SetLayout( HDC_32(hdc), layout );
3652 /***********************************************************************
3653 * SetSolidBrush (GDI.604)
3655 * Change the color of a solid brush.
3657 * PARAMS
3658 * hBrush [I] Brush to change the color of
3659 * newColor [I] New color for hBrush
3661 * RETURNS
3662 * Success: TRUE. The color of hBrush is set to newColor.
3663 * Failure: FALSE.
3665 * FIXME
3666 * This function is undocumented and untested. The implementation may
3667 * not be correct.
3669 BOOL16 WINAPI SetSolidBrush16(HBRUSH16 hBrush, COLORREF newColor )
3671 FIXME( "%04x %08x no longer supported\n", hBrush, newColor );
3672 return FALSE;
3676 /***********************************************************************
3677 * Copy (GDI.250)
3679 void WINAPI Copy16( LPVOID src, LPVOID dst, WORD size )
3681 memcpy( dst, src, size );
3684 /***********************************************************************
3685 * RealizeDefaultPalette (GDI.365)
3687 UINT16 WINAPI RealizeDefaultPalette16( HDC16 hdc )
3689 FIXME( "%04x semi-stub\n", hdc );
3690 return GDIRealizePalette16( hdc );
3693 /***********************************************************************
3694 * IsDCCurrentPalette (GDI.412)
3696 BOOL16 WINAPI IsDCCurrentPalette16(HDC16 hDC)
3698 return HPALETTE_16( GetCurrentObject( HDC_32(hDC), OBJ_PAL )) == hPrimaryPalette;
3701 /*********************************************************************
3702 * SetMagicColors (GDI.606)
3704 VOID WINAPI SetMagicColors16(HDC16 hDC, COLORREF color, UINT16 index)
3706 FIXME("(hDC %04x, color %04x, index %04x): stub\n", hDC, (int)color, index);
3711 /***********************************************************************
3712 * DPtoLP (GDI.67)
3714 BOOL16 WINAPI DPtoLP16( HDC16 hdc, LPPOINT16 points, INT16 count )
3716 POINT points32[8], *pt32 = points32;
3717 int i;
3718 BOOL ret;
3720 if (count > 8)
3722 if (!(pt32 = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*pt32) ))) return FALSE;
3724 for (i = 0; i < count; i++)
3726 pt32[i].x = points[i].x;
3727 pt32[i].y = points[i].y;
3729 if ((ret = DPtoLP( HDC_32(hdc), pt32, count )))
3731 for (i = 0; i < count; i++)
3733 points[i].x = pt32[i].x;
3734 points[i].y = pt32[i].y;
3737 if (pt32 != points32) HeapFree( GetProcessHeap(), 0, pt32 );
3738 return ret;
3742 /***********************************************************************
3743 * LPtoDP (GDI.99)
3745 BOOL16 WINAPI LPtoDP16( HDC16 hdc, LPPOINT16 points, INT16 count )
3747 POINT points32[8], *pt32 = points32;
3748 int i;
3749 BOOL ret;
3751 if (count > 8)
3753 if (!(pt32 = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*pt32) ))) return FALSE;
3755 for (i = 0; i < count; i++)
3757 pt32[i].x = points[i].x;
3758 pt32[i].y = points[i].y;
3760 if ((ret = LPtoDP( HDC_32(hdc), pt32, count )))
3762 for (i = 0; i < count; i++)
3764 points[i].x = pt32[i].x;
3765 points[i].y = pt32[i].y;
3768 if (pt32 != points32) HeapFree( GetProcessHeap(), 0, pt32 );
3769 return ret;
3773 /***********************************************************************
3774 * GetDCState (GDI.179)
3776 HDC16 WINAPI GetDCState16( HDC16 hdc )
3778 ERR( "no longer supported\n" );
3779 return 0;
3783 /***********************************************************************
3784 * SetDCState (GDI.180)
3786 void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs )
3788 ERR( "no longer supported\n" );
3791 /***********************************************************************
3792 * SetDCOrg (GDI.117)
3794 DWORD WINAPI SetDCOrg16( HDC16 hdc16, INT16 x, INT16 y )
3796 FIXME( "%04x %d,%d no longer supported\n", hdc16, x, y );
3797 return 0;
3801 /***********************************************************************
3802 * InquireVisRgn (GDI.131)
3804 HRGN16 WINAPI InquireVisRgn16( HDC16 hdc )
3806 static HRGN hrgn;
3808 if (!hrgn) hrgn = CreateRectRgn( 0, 0, 0, 0 );
3809 GetRandomRgn( HDC_32(hdc), hrgn, SYSRGN );
3810 return HRGN_16(hrgn);
3814 /***********************************************************************
3815 * OffsetVisRgn (GDI.102)
3817 INT16 WINAPI OffsetVisRgn16( HDC16 hdc16, INT16 x, INT16 y )
3819 FIXME( "%04x %d,%d no longer supported\n", hdc16, x, y );
3820 return ERROR;
3824 /***********************************************************************
3825 * ExcludeVisRect (GDI.73)
3827 INT16 WINAPI ExcludeVisRect16( HDC16 hdc16, INT16 left, INT16 top, INT16 right, INT16 bottom )
3829 FIXME( "%04x %d,%d-%d,%d no longer supported\n", hdc16, left, top, right, bottom );
3830 return ERROR;
3834 /***********************************************************************
3835 * IntersectVisRect (GDI.98)
3837 INT16 WINAPI IntersectVisRect16( HDC16 hdc16, INT16 left, INT16 top, INT16 right, INT16 bottom )
3839 FIXME( "%04x %d,%d-%d,%d no longer supported\n", hdc16, left, top, right, bottom );
3840 return ERROR;
3844 /***********************************************************************
3845 * SaveVisRgn (GDI.129)
3847 HRGN16 WINAPI SaveVisRgn16( HDC16 hdc16 )
3849 FIXME( "%04x no longer supported\n", hdc16 );
3850 return 0;
3854 /***********************************************************************
3855 * RestoreVisRgn (GDI.130)
3857 INT16 WINAPI RestoreVisRgn16( HDC16 hdc16 )
3859 FIXME( "%04x no longer supported\n", hdc16 );
3860 return ERROR;
3864 /***********************************************************************
3865 * GetClipRgn (GDI.173)
3867 HRGN16 WINAPI GetClipRgn16( HDC16 hdc )
3869 static HRGN hrgn;
3871 if (!hrgn) hrgn = CreateRectRgn( 0, 0, 0, 0 );
3872 GetClipRgn( HDC_32(hdc), hrgn );
3873 return HRGN_16(hrgn);
3877 /***********************************************************************
3878 * MakeObjectPrivate (GDI.463)
3880 * What does that mean ?
3881 * Some little docu can be found in "Undocumented Windows",
3882 * but this is basically useless.
3884 void WINAPI MakeObjectPrivate16( HGDIOBJ16 handle16, BOOL16 private )
3886 FIXME( "stub: %x %u\n", handle16, private );
3889 /***********************************************************************
3890 * CreateDIBSection (GDI.489)
3892 HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, const BITMAPINFO *bmi, UINT16 usage,
3893 SEGPTR *bits16, HANDLE section, DWORD offset)
3895 LPVOID bits32;
3896 HBITMAP hbitmap;
3898 hbitmap = CreateDIBSection( HDC_32(hdc), bmi, usage, &bits32, section, offset );
3899 if (hbitmap && bits32 && bits16) *bits16 = alloc_segptr_bits( hbitmap, bits32 );
3900 return HBITMAP_16(hbitmap);