Made the Interlocked*Pointer functions static inline since they aren't
[wine/multimedia.git] / objects / text.c
blobb4b15a4c9fc76c0adb0e610211a857c9e83b41ab
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 "debugtools.h"
17 #include "winnls.h"
19 DEFAULT_DEBUG_CHANNEL(text);
22 /***********************************************************************
23 * ExtTextOut (GDI.351)
25 BOOL16 WINAPI ExtTextOut16( HDC16 hdc, INT16 x, INT16 y, UINT16 flags,
26 const RECT16 *lprect, LPCSTR str, UINT16 count,
27 const INT16 *lpDx )
29 BOOL ret;
30 int i;
31 RECT rect32;
32 LPINT lpdx32 = NULL;
34 if (lpDx) {
35 lpdx32 = (LPINT)HeapAlloc( GetProcessHeap(),0, sizeof(INT)*count );
36 if(lpdx32 == NULL) return FALSE;
37 for (i=count;i--;) lpdx32[i]=lpDx[i];
39 if (lprect) CONV_RECT16TO32(lprect,&rect32);
40 ret = ExtTextOutA(hdc,x,y,flags,lprect?&rect32:NULL,str,count,lpdx32);
41 if (lpdx32) HeapFree( GetProcessHeap(), 0, lpdx32 );
42 return ret;
46 /***********************************************************************
47 * ExtTextOutA (GDI32.@)
49 BOOL WINAPI ExtTextOutA( HDC hdc, INT x, INT y, UINT flags,
50 const RECT *lprect, LPCSTR str, UINT count,
51 const INT *lpDx )
53 DC * dc = DC_GetDCUpdate( hdc );
54 LPWSTR p;
55 UINT codepage = CP_ACP; /* FIXME: get codepage of font charset */
56 BOOL ret = FALSE;
57 LPINT lpDxW = NULL;
59 if (!dc) return FALSE;
61 if (dc->funcs->pExtTextOut)
63 UINT wlen = MultiByteToWideChar(codepage,0,str,count,NULL,0);
64 if (lpDx)
66 unsigned int i = 0, j = 0;
68 lpDxW = (LPINT)HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(INT));
69 while(i < count)
71 if(IsDBCSLeadByteEx(codepage, str[i]))
73 lpDxW[j++] = lpDx[i] + lpDx[i+1];
74 i = i + 2;
76 else
78 lpDxW[j++] = lpDx[i];
79 i = i + 1;
83 if ((p = HeapAlloc( GetProcessHeap(), 0, wlen * sizeof(WCHAR) )))
85 wlen = MultiByteToWideChar(codepage,0,str,count,p,wlen);
86 ret = dc->funcs->pExtTextOut( dc, x, y, flags, lprect, p, wlen, lpDxW );
87 HeapFree( GetProcessHeap(), 0, p );
89 if (lpDxW) HeapFree( GetProcessHeap(), 0, lpDxW );
91 GDI_ReleaseObj( hdc );
92 return ret;
96 /***********************************************************************
97 * ExtTextOutW (GDI32.@)
99 BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
100 const RECT *lprect, LPCWSTR str, UINT count,
101 const INT *lpDx )
103 BOOL ret = FALSE;
104 DC * dc = DC_GetDCUpdate( hdc );
105 if (dc)
107 if(dc->funcs->pExtTextOut)
108 ret = dc->funcs->pExtTextOut(dc,x,y,flags,lprect,str,count,lpDx);
109 GDI_ReleaseObj( hdc );
111 return ret;
115 /***********************************************************************
116 * TextOut (GDI.33)
118 BOOL16 WINAPI TextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR str, INT16 count )
120 return ExtTextOut16( hdc, x, y, 0, NULL, str, count, NULL );
124 /***********************************************************************
125 * TextOutA (GDI32.@)
127 BOOL WINAPI TextOutA( HDC hdc, INT x, INT y, LPCSTR str, INT count )
129 return ExtTextOutA( hdc, x, y, 0, NULL, str, count, NULL );
133 /***********************************************************************
134 * TextOutW (GDI32.@)
136 BOOL WINAPI TextOutW(HDC hdc, INT x, INT y, LPCWSTR str, INT count)
138 return ExtTextOutW( hdc, x, y, 0, NULL, str, count, NULL );
142 /***********************************************************************
143 * GetTextCharset [GDI32.@] Gets character set for font in DC
145 * NOTES
146 * Should it return a UINT32 instead of an INT32?
147 * => YES, as GetTextCharsetInfo returns UINT32
149 * RETURNS
150 * Success: Character set identifier
151 * Failure: DEFAULT_CHARSET
153 UINT WINAPI GetTextCharset(
154 HDC hdc) /* [in] Handle to device context */
156 /* MSDN docs say this is equivalent */
157 return GetTextCharsetInfo(hdc, NULL, 0);
160 /***********************************************************************
161 * GetTextCharset [GDI.612]
163 UINT16 WINAPI GetTextCharset16(HDC16 hdc)
165 return (UINT16)GetTextCharset(hdc);
168 /***********************************************************************
169 * GetTextCharsetInfo [GDI32.@] Gets character set for font
171 * NOTES
172 * Should csi be an LPFONTSIGNATURE instead of an LPCHARSETINFO?
173 * Should it return a UINT32 instead of an INT32?
174 * => YES and YES, from win32.hlp from Borland
176 * RETURNS
177 * Success: Character set identifier
178 * Failure: DEFAULT_CHARSET
180 UINT WINAPI GetTextCharsetInfo(
181 HDC hdc, /* [in] Handle to device context */
182 LPFONTSIGNATURE fs, /* [out] Pointer to struct to receive data */
183 DWORD flags) /* [in] Reserved - must be 0 */
185 HGDIOBJ hFont;
186 UINT charSet = DEFAULT_CHARSET;
187 LOGFONTW lf;
188 CHARSETINFO csinfo;
190 hFont = GetCurrentObject(hdc, OBJ_FONT);
191 if (hFont == 0)
192 return(DEFAULT_CHARSET);
193 if ( GetObjectW(hFont, sizeof(LOGFONTW), &lf) != 0 )
194 charSet = lf.lfCharSet;
196 if (fs != NULL) {
197 if (!TranslateCharsetInfo((LPDWORD)charSet, &csinfo, TCI_SRCCHARSET))
198 return (DEFAULT_CHARSET);
199 memcpy(fs, &csinfo.fs, sizeof(FONTSIGNATURE));
201 return charSet;
204 /***********************************************************************
205 * PolyTextOutA (GDI32.@)
207 * Draw several Strings
209 BOOL WINAPI PolyTextOutA (
210 HDC hdc, /* [in] Handle to device context */
211 PPOLYTEXTA pptxt, /* [in] Array of strings */
212 INT cStrings /* [in] Number of strings in array */
215 FIXME("stub!\n");
216 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED );
217 return 0;
222 /***********************************************************************
223 * PolyTextOutW (GDI32.@)
225 * Draw several Strings
227 BOOL WINAPI PolyTextOutW (
228 HDC hdc, /* [in] Handle to device context */
229 PPOLYTEXTW pptxt, /* [in] Array of strings */
230 INT cStrings /* [in] Number of strings in array */
233 FIXME("stub!\n");
234 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED );
235 return 0;