Added DM_REPOSITION.
[wine/multimedia.git] / objects / text.c
blobe814bbb767b1532323b6bf47d4320a3817d84eb0
1 /*
2 * text functions
4 * Copyright 1993, 1994 Alexandre Julliard
6 */
8 #include <string.h>
10 #include "windef.h"
11 #include "wingdi.h"
12 #include "wine/winuser16.h"
13 #include "winbase.h"
14 #include "winerror.h"
15 #include "gdi.h"
16 #include "heap.h"
17 #include "debugtools.h"
18 #include "winnls.h"
20 DEFAULT_DEBUG_CHANNEL(text);
23 /***********************************************************************
24 * ExtTextOut16 (GDI.351)
26 BOOL16 WINAPI ExtTextOut16( HDC16 hdc, INT16 x, INT16 y, UINT16 flags,
27 const RECT16 *lprect, LPCSTR str, UINT16 count,
28 const INT16 *lpDx )
30 BOOL ret;
31 int i;
32 RECT rect32;
33 LPINT lpdx32 = NULL;
35 if (lpDx) {
36 lpdx32 = (LPINT)HeapAlloc( GetProcessHeap(),0, sizeof(INT)*count );
37 if(lpdx32 == NULL) return FALSE;
38 for (i=count;i--;) lpdx32[i]=lpDx[i];
40 if (lprect) CONV_RECT16TO32(lprect,&rect32);
41 ret = ExtTextOutA(hdc,x,y,flags,lprect?&rect32:NULL,str,count,lpdx32);
42 if (lpdx32) HeapFree( GetProcessHeap(), 0, lpdx32 );
43 return ret;
47 /***********************************************************************
48 * ExtTextOutA (GDI32.98)
50 BOOL WINAPI ExtTextOutA( HDC hdc, INT x, INT y, UINT flags,
51 const RECT *lprect, LPCSTR str, UINT count,
52 const INT *lpDx )
54 DC * dc = DC_GetDCUpdate( hdc );
55 LPWSTR p;
56 UINT codepage = CP_ACP; /* FIXME: get codepage of font charset */
57 BOOL ret = FALSE;
58 LPINT lpDxW = NULL;
60 if (!dc) return FALSE;
62 if (dc->funcs->pExtTextOut)
64 UINT wlen = MultiByteToWideChar(codepage,0,str,count,NULL,0);
65 if (lpDx)
67 int i = 0, j = 0;
69 lpDxW = (LPINT)HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(INT));
70 while(i < count)
72 if(IsDBCSLeadByteEx(codepage, str[i]))
74 lpDxW[j++] = lpDx[i] + lpDx[i+1];
75 i = i + 2;
77 else
79 lpDxW[j++] = lpDx[i];
80 i = i + 1;
84 if ((p = HeapAlloc( GetProcessHeap(), 0, wlen * sizeof(WCHAR) )))
86 wlen = MultiByteToWideChar(codepage,0,str,count,p,wlen);
87 ret = dc->funcs->pExtTextOut( dc, x, y, flags, lprect, p, wlen, lpDxW );
88 HeapFree( GetProcessHeap(), 0, p );
90 if (lpDxW) HeapFree( GetProcessHeap(), 0, lpDxW );
92 GDI_ReleaseObj( hdc );
93 return ret;
97 /***********************************************************************
98 * ExtTextOutW (GDI32.99)
100 BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
101 const RECT *lprect, LPCWSTR str, UINT count,
102 const INT *lpDx )
104 BOOL ret = FALSE;
105 DC * dc = DC_GetDCUpdate( hdc );
106 if (dc)
108 if(dc->funcs->pExtTextOut)
109 ret = dc->funcs->pExtTextOut(dc,x,y,flags,lprect,str,count,lpDx);
110 GDI_ReleaseObj( hdc );
112 return ret;
116 /***********************************************************************
117 * TextOut16 (GDI.33)
119 BOOL16 WINAPI TextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR str, INT16 count )
121 return ExtTextOut16( hdc, x, y, 0, NULL, str, count, NULL );
125 /***********************************************************************
126 * TextOutA (GDI32.355)
128 BOOL WINAPI TextOutA( HDC hdc, INT x, INT y, LPCSTR str, INT count )
130 return ExtTextOutA( hdc, x, y, 0, NULL, str, count, NULL );
134 /***********************************************************************
135 * TextOutW (GDI32.356)
137 BOOL WINAPI TextOutW(HDC hdc, INT x, INT y, LPCWSTR str, INT count)
139 return ExtTextOutW( hdc, x, y, 0, NULL, str, count, NULL );
143 /***********************************************************************
144 * GetTextCharset [GDI32.226] Gets character set for font in DC
146 * NOTES
147 * Should it return a UINT32 instead of an INT32?
148 * => YES, as GetTextCharsetInfo returns UINT32
150 * RETURNS
151 * Success: Character set identifier
152 * Failure: DEFAULT_CHARSET
154 UINT WINAPI GetTextCharset(
155 HDC hdc) /* [in] Handle to device context */
157 /* MSDN docs say this is equivalent */
158 return GetTextCharsetInfo(hdc, NULL, 0);
161 /***********************************************************************
162 * GetTextCharset16 [GDI.612]
164 UINT16 WINAPI GetTextCharset16(HDC16 hdc)
166 return (UINT16)GetTextCharset(hdc);
169 /***********************************************************************
170 * GetTextCharsetInfo [GDI32.381] Gets character set for font
172 * NOTES
173 * Should csi be an LPFONTSIGNATURE instead of an LPCHARSETINFO?
174 * Should it return a UINT32 instead of an INT32?
175 * => YES and YES, from win32.hlp from Borland
177 * RETURNS
178 * Success: Character set identifier
179 * Failure: DEFAULT_CHARSET
181 UINT WINAPI GetTextCharsetInfo(
182 HDC hdc, /* [in] Handle to device context */
183 LPFONTSIGNATURE fs, /* [out] Pointer to struct to receive data */
184 DWORD flags) /* [in] Reserved - must be 0 */
186 HGDIOBJ hFont;
187 UINT charSet = DEFAULT_CHARSET;
188 LOGFONTW lf;
189 CHARSETINFO csinfo;
191 hFont = GetCurrentObject(hdc, OBJ_FONT);
192 if (hFont == 0)
193 return(DEFAULT_CHARSET);
194 if ( GetObjectW(hFont, sizeof(LOGFONTW), &lf) != 0 )
195 charSet = lf.lfCharSet;
197 if (fs != NULL) {
198 if (!TranslateCharsetInfo((LPDWORD)charSet, &csinfo, TCI_SRCCHARSET))
199 return (DEFAULT_CHARSET);
200 memcpy(fs, &csinfo.fs, sizeof(FONTSIGNATURE));
202 return charSet;
205 /***********************************************************************
206 * PolyTextOutA [GDI.402] Draw several Strings
208 BOOL WINAPI PolyTextOutA (
209 HDC hdc, /* Handle to device context */
210 PPOLYTEXTA pptxt, /* array of strings */
211 INT cStrings /* Number of strings in array */
214 FIXME("stub!\n");
215 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED );
216 return 0;
221 /***********************************************************************
222 * PolyTextOutW [GDI.403] Draw several Strings
224 BOOL WINAPI PolyTextOutW (
225 HDC hdc, /* Handle to device context */
226 PPOLYTEXTW pptxt, /* array of strings */
227 INT cStrings /* Number of strings in array */
230 FIXME("stub!\n");
231 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED );
232 return 0;