Removed the DUMMY_UNION_NAME in favor of DUMMYUNIONNAME.
[wine.git] / objects / text.c
blob9a599b856702e1aad4c4479e5ffd0e55cf7d828c
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 "dc.h"
16 #include "gdi.h"
17 #include "heap.h"
18 #include "debugtools.h"
19 #include "winnls.h"
21 DEFAULT_DEBUG_CHANNEL(text);
24 /***********************************************************************
25 * ExtTextOut16 (GDI.351)
27 BOOL16 WINAPI ExtTextOut16( HDC16 hdc, INT16 x, INT16 y, UINT16 flags,
28 const RECT16 *lprect, LPCSTR str, UINT16 count,
29 const INT16 *lpDx )
31 BOOL ret;
32 int i;
33 RECT rect32;
34 LPINT lpdx32 = NULL;
36 if (lpDx) {
37 lpdx32 = (LPINT)HeapAlloc( GetProcessHeap(),0, sizeof(INT)*count );
38 if(lpdx32 == NULL) return FALSE;
39 for (i=count;i--;) lpdx32[i]=lpDx[i];
41 if (lprect) CONV_RECT16TO32(lprect,&rect32);
42 ret = ExtTextOutA(hdc,x,y,flags,lprect?&rect32:NULL,str,count,lpdx32);
43 if (lpdx32) HeapFree( GetProcessHeap(), 0, lpdx32 );
44 return ret;
48 /***********************************************************************
49 * ExtTextOutA (GDI32.98)
51 BOOL WINAPI ExtTextOutA( HDC hdc, INT x, INT y, UINT flags,
52 const RECT *lprect, LPCSTR str, UINT count,
53 const INT *lpDx )
55 DC * dc = DC_GetDCUpdate( hdc );
56 LPWSTR p;
57 UINT codepage = CP_ACP; /* FIXME: get codepage of font charset */
58 BOOL ret = FALSE;
59 LPINT lpDxW = NULL;
61 if (!dc) return FALSE;
63 if (dc->funcs->pExtTextOut)
65 UINT wlen = MultiByteToWideChar(codepage,0,str,count,NULL,0);
66 if (lpDx)
68 int i = 0, j = 0;
70 lpDxW = (LPINT)HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(INT));
71 while(i < count)
73 if(IsDBCSLeadByteEx(codepage, str[i]))
75 lpDxW[j++] = lpDx[i] + lpDx[i+1];
76 i = i + 2;
78 else
80 lpDxW[j++] = lpDx[i];
81 i = i + 1;
85 if ((p = HeapAlloc( GetProcessHeap(), 0, wlen * sizeof(WCHAR) )))
87 wlen = MultiByteToWideChar(codepage,0,str,count,p,wlen);
88 ret = dc->funcs->pExtTextOut( dc, x, y, flags, lprect, p, wlen, lpDxW );
89 HeapFree( GetProcessHeap(), 0, p );
91 if (lpDxW) HeapFree( GetProcessHeap(), 0, lpDxW );
93 GDI_ReleaseObj( hdc );
94 return ret;
98 /***********************************************************************
99 * ExtTextOutW (GDI32.99)
101 BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
102 const RECT *lprect, LPCWSTR str, UINT count,
103 const INT *lpDx )
105 BOOL ret = FALSE;
106 DC * dc = DC_GetDCUpdate( hdc );
107 if (dc)
109 if(dc->funcs->pExtTextOut)
110 ret = dc->funcs->pExtTextOut(dc,x,y,flags,lprect,str,count,lpDx);
111 GDI_ReleaseObj( hdc );
113 return ret;
117 /***********************************************************************
118 * TextOut16 (GDI.33)
120 BOOL16 WINAPI TextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR str, INT16 count )
122 return ExtTextOut16( hdc, x, y, 0, NULL, str, count, NULL );
126 /***********************************************************************
127 * TextOutA (GDI32.355)
129 BOOL WINAPI TextOutA( HDC hdc, INT x, INT y, LPCSTR str, INT count )
131 return ExtTextOutA( hdc, x, y, 0, NULL, str, count, NULL );
135 /***********************************************************************
136 * TextOutW (GDI32.356)
138 BOOL WINAPI TextOutW(HDC hdc, INT x, INT y, LPCWSTR str, INT count)
140 return ExtTextOutW( hdc, x, y, 0, NULL, str, count, NULL );
144 /***********************************************************************
145 * GetTextCharset [GDI32.226] Gets character set for font in DC
147 * NOTES
148 * Should it return a UINT32 instead of an INT32?
149 * => YES, as GetTextCharsetInfo returns UINT32
151 * RETURNS
152 * Success: Character set identifier
153 * Failure: DEFAULT_CHARSET
155 UINT WINAPI GetTextCharset(
156 HDC hdc) /* [in] Handle to device context */
158 /* MSDN docs say this is equivalent */
159 return GetTextCharsetInfo(hdc, NULL, 0);
162 /***********************************************************************
163 * GetTextCharset16 [GDI.612]
165 UINT16 WINAPI GetTextCharset16(HDC16 hdc)
167 return (UINT16)GetTextCharset(hdc);
170 /***********************************************************************
171 * GetTextCharsetInfo [GDI32.381] Gets character set for font
173 * NOTES
174 * Should csi be an LPFONTSIGNATURE instead of an LPCHARSETINFO?
175 * Should it return a UINT32 instead of an INT32?
176 * => YES and YES, from win32.hlp from Borland
178 * RETURNS
179 * Success: Character set identifier
180 * Failure: DEFAULT_CHARSET
182 UINT WINAPI GetTextCharsetInfo(
183 HDC hdc, /* [in] Handle to device context */
184 LPFONTSIGNATURE fs, /* [out] Pointer to struct to receive data */
185 DWORD flags) /* [in] Reserved - must be 0 */
187 HGDIOBJ hFont;
188 UINT charSet = DEFAULT_CHARSET;
189 LOGFONTW lf;
190 CHARSETINFO csinfo;
192 hFont = GetCurrentObject(hdc, OBJ_FONT);
193 if (hFont == 0)
194 return(DEFAULT_CHARSET);
195 if ( GetObjectW(hFont, sizeof(LOGFONTW), &lf) != 0 )
196 charSet = lf.lfCharSet;
198 if (fs != NULL) {
199 if (!TranslateCharsetInfo((LPDWORD)charSet, &csinfo, TCI_SRCCHARSET))
200 return (DEFAULT_CHARSET);
201 memcpy(fs, &csinfo.fs, sizeof(FONTSIGNATURE));
203 return charSet;
206 /***********************************************************************
207 * PolyTextOutA [GDI.402] Draw several Strings
209 BOOL WINAPI PolyTextOutA (
210 HDC hdc, /* Handle to device context */
211 PPOLYTEXTA pptxt, /* array of strings */
212 INT cStrings /* Number of strings in array */
215 FIXME("stub!\n");
216 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED );
217 return 0;
222 /***********************************************************************
223 * PolyTextOutW [GDI.403] Draw several Strings
225 BOOL WINAPI PolyTextOutW (
226 HDC hdc, /* Handle to device context */
227 PPOLYTEXTW pptxt, /* array of strings */
228 INT cStrings /* Number of strings in array */
231 FIXME("stub!\n");
232 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED );
233 return 0;