Store print dlg structure in a property instead of DWL_USER.
[wine/multimedia.git] / dlls / gdi / mfdrv / text.c
blobb185d9cdf71a804ededb94ef4e530ab4aa8cd908
1 /*
2 * metafile driver text functions
4 * Copyright 1993, 1994 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <string.h>
23 #include "windef.h"
24 #include "mfdrv/metafiledrv.h"
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(metafile);
30 /******************************************************************
31 * MFDRV_MetaExtTextOut
33 static BOOL MFDRV_MetaExtTextOut( PHYSDEV dev, short x, short y, UINT16 flags,
34 const RECT16 *rect, LPCSTR str, short count,
35 const INT16 *lpDx)
37 BOOL ret;
38 DWORD len;
39 METARECORD *mr;
41 if (flags && !rect)
42 WARN("Inconsistent flags and rect\n");
43 len = sizeof(METARECORD) + (((count + 1) >> 1) * 2) + 2 * sizeof(short)
44 + sizeof(UINT16);
45 if (rect&&flags)
46 len += sizeof(RECT16);
47 if (lpDx)
48 len+=count*sizeof(INT16);
49 if (!(mr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len)))
50 return FALSE;
52 mr->rdSize = len / 2;
53 mr->rdFunction = META_EXTTEXTOUT;
54 *(mr->rdParm) = y;
55 *(mr->rdParm + 1) = x;
56 *(mr->rdParm + 2) = count;
57 *(mr->rdParm + 3) = flags;
58 if (rect&&flags) memcpy(mr->rdParm + 4, rect, sizeof(RECT16));
59 memcpy(mr->rdParm + ((rect&&flags) ? 8 : 4), str, count);
60 if (lpDx)
61 memcpy(mr->rdParm + ((rect&&flags) ? 8 : 4) + ((count + 1) >> 1),lpDx,
62 count*sizeof(INT16));
63 ret = MFDRV_WriteRecord( dev, mr, mr->rdSize * 2);
64 HeapFree( GetProcessHeap(), 0, mr);
65 return ret;
70 /***********************************************************************
71 * MFDRV_ExtTextOut
73 BOOL
74 MFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
75 const RECT *lprect, LPCWSTR str, UINT count,
76 const INT *lpDx )
78 RECT16 rect16;
79 LPINT16 lpdx16 = NULL;
80 BOOL ret;
81 int i;
82 LPSTR ascii;
83 DWORD len;
85 if(lpDx)
86 lpdx16 = HeapAlloc( GetProcessHeap(), 0, sizeof(INT16)*count );
87 if (lprect) CONV_RECT32TO16(lprect,&rect16);
88 if (lpdx16)
89 for (i=count;i--;)
90 lpdx16[i]=lpDx[i];
91 len = WideCharToMultiByte( CP_ACP, 0, str, count, NULL, 0, NULL, NULL );
92 ascii = HeapAlloc( GetProcessHeap(), 0, len );
93 WideCharToMultiByte( CP_ACP, 0, str, count, ascii, len, NULL, NULL );
94 ret = MFDRV_MetaExtTextOut(dev,x,y,flags,lprect?&rect16:NULL,ascii,len,lpdx16);
95 HeapFree( GetProcessHeap(), 0, ascii );
96 if (lpdx16) HeapFree( GetProcessHeap(), 0, lpdx16 );
97 return ret;