The COM virtual tables must use the
[wine.git] / graphics / metafiledrv / text.c
blob16e6624186c0722a1e7961fec076282eefb99529
1 /*
2 * metafile driver text functions
4 * Copyright 1993, 1994 Alexandre Julliard
6 */
8 #include <string.h>
10 #include "windef.h"
11 #include "metafiledrv.h"
12 #include "debugtools.h"
13 #include "heap.h"
15 DEFAULT_DEBUG_CHANNEL(metafile)
18 /******************************************************************
19 * MFDRV_MetaExtTextOut
21 static BOOL MFDRV_MetaExtTextOut(DC*dc, short x, short y, UINT16 flags,
22 const RECT16 *rect, LPCSTR str, short count,
23 const INT16 *lpDx)
25 BOOL ret;
26 DWORD len;
27 METARECORD *mr;
29 if((!flags && rect) || (flags && !rect))
30 WARN("Inconsistent flags and rect\n");
31 len = sizeof(METARECORD) + (((count + 1) >> 1) * 2) + 2 * sizeof(short)
32 + sizeof(UINT16);
33 if(rect)
34 len += sizeof(RECT16);
35 if (lpDx)
36 len+=count*sizeof(INT16);
37 if (!(mr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len)))
38 return FALSE;
40 mr->rdSize = len / 2;
41 mr->rdFunction = META_EXTTEXTOUT;
42 *(mr->rdParm) = y;
43 *(mr->rdParm + 1) = x;
44 *(mr->rdParm + 2) = count;
45 *(mr->rdParm + 3) = flags;
46 if (rect) memcpy(mr->rdParm + 4, rect, sizeof(RECT16));
47 memcpy(mr->rdParm + (rect ? 8 : 4), str, count);
48 if (lpDx)
49 memcpy(mr->rdParm + (rect ? 8 : 4) + ((count + 1) >> 1),lpDx,
50 count*sizeof(INT16));
51 ret = MFDRV_WriteRecord( dc, mr, mr->rdSize * 2);
52 HeapFree( GetProcessHeap(), 0, mr);
53 return ret;
58 /***********************************************************************
59 * MFDRV_ExtTextOut
61 BOOL
62 MFDRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags,
63 const RECT *lprect, LPCWSTR str, UINT count,
64 const INT *lpDx )
66 RECT16 rect16;
67 LPINT16 lpdx16 = NULL;
68 BOOL ret;
69 int i;
70 LPSTR ascii;
72 if(lpDx)
73 lpdx16 = HeapAlloc( GetProcessHeap(), 0, sizeof(INT16)*count );
74 if (lprect) CONV_RECT32TO16(lprect,&rect16);
75 if (lpdx16)
76 for (i=count;i--;)
77 lpdx16[i]=lpDx[i];
78 ascii = HeapAlloc( GetProcessHeap(), 0, count+1 );
79 lstrcpynWtoA(ascii, str, count+1);
80 ret = MFDRV_MetaExtTextOut(dc,x,y,flags,lprect?&rect16:NULL,ascii,count,
81 lpdx16);
82 HeapFree( GetProcessHeap(), 0, ascii );
83 if (lpdx16) HeapFree( GetProcessHeap(), 0, lpdx16 );
84 return ret;