reshuffling of dlls
[reactos.git] / reactos / dll / win32 / gdi32 / objects / text.c
1 #include "precomp.h"
2
3
4
5 /*
6 * @implemented
7 */
8 BOOL
9 STDCALL
10 TextOutA(
11 HDC hdc,
12 int nXStart,
13 int nYStart,
14 LPCSTR lpString,
15 int cbString)
16 {
17 ANSI_STRING StringA;
18 UNICODE_STRING StringU;
19 BOOL ret;
20
21 if (NULL != lpString)
22 {
23 RtlInitAnsiString(&StringA, (LPSTR)lpString);
24 RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
25 } else
26 StringU.Buffer = NULL;
27
28 ret = TextOutW(hdc, nXStart, nYStart, StringU.Buffer, cbString);
29 RtlFreeUnicodeString(&StringU);
30 return ret;
31 }
32
33
34 /*
35 * @implemented
36 */
37 BOOL
38 STDCALL
39 TextOutW(
40 HDC hdc,
41 int nXStart,
42 int nYStart,
43 LPCWSTR lpString,
44 int cbString)
45 {
46 return NtGdiTextOut(hdc, nXStart, nYStart, lpString, cbString);
47 }
48
49
50 /*
51 * @implemented
52 */
53 int
54 STDCALL
55 GetTextCharset(
56 HDC hdc
57 )
58 {
59 /* MSDN docs say this is equivalent */
60 return GetTextCharsetInfo(hdc, NULL, 0);
61 }
62
63
64 /*
65 * @implemented
66 */
67 int
68 STDCALL
69 GetTextCharsetInfo(
70 HDC hdc,
71 LPFONTSIGNATURE lpSig,
72 DWORD dwFlags
73 )
74 {
75 return NtGdiGetTextCharsetInfo(hdc, lpSig, dwFlags);
76 }
77
78
79 /*
80 * @implemented
81 */
82 BOOL
83 STDCALL
84 GetTextMetricsA(
85 HDC hdc,
86 LPTEXTMETRICA lptm
87 )
88 {
89 TEXTMETRICW tmw;
90
91 if (! NtGdiGetTextMetrics(hdc, &tmw))
92 {
93 return FALSE;
94 }
95
96 return TextMetricW2A(lptm, &tmw);
97 }
98
99
100 /*
101 * @implemented
102 */
103 BOOL
104 STDCALL
105 GetTextMetricsW(
106 HDC hdc,
107 LPTEXTMETRICW lptm
108 )
109 {
110 return NtGdiGetTextMetrics(hdc, lptm);
111 }
112
113
114 /*
115 * @implemented
116 */
117 BOOL
118 APIENTRY
119 GetTextExtentPointA(
120 HDC hdc,
121 LPCSTR lpString,
122 int cbString,
123 LPSIZE lpSize
124 )
125 {
126 ANSI_STRING StringA;
127 UNICODE_STRING StringU;
128 BOOL ret;
129
130 RtlInitAnsiString(&StringA, (LPSTR)lpString);
131 RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
132
133 ret = GetTextExtentPointW(hdc, StringU.Buffer, cbString, lpSize);
134
135 RtlFreeUnicodeString(&StringU);
136
137 return ret;
138 }
139
140
141 /*
142 * @implemented
143 */
144 BOOL
145 APIENTRY
146 GetTextExtentPointW(
147 HDC hdc,
148 LPCWSTR lpString,
149 int cbString,
150 LPSIZE lpSize
151 )
152 {
153 return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cbString, lpSize, 0);
154 }
155
156
157 /*
158 * @implemented
159 */
160 BOOL
161 APIENTRY
162 GetTextExtentExPointW(
163 HDC hdc,
164 LPCWSTR lpszStr,
165 int cchString,
166 int nMaxExtent,
167 LPINT lpnFit,
168 LPINT alpDx,
169 LPSIZE lpSize
170 )
171 {
172 return NtGdiGetTextExtentExPoint (
173 hdc, lpszStr, cchString, nMaxExtent, lpnFit, alpDx, lpSize );
174 }
175
176
177 /*
178 * @implemented
179 */
180 BOOL
181 APIENTRY
182 GetTextExtentExPointA(
183 HDC hdc,
184 LPCSTR lpszStr,
185 int cchString,
186 int nMaxExtent,
187 LPINT lpnFit,
188 LPINT alpDx,
189 LPSIZE lpSize
190 )
191 {
192 NTSTATUS Status;
193 LPWSTR lpszStrW;
194 BOOL rc = 0;
195
196 Status = HEAP_strdupA2W ( &lpszStrW, lpszStr );
197 if (!NT_SUCCESS (Status))
198 SetLastError (RtlNtStatusToDosError(Status));
199 else
200 {
201 rc = NtGdiGetTextExtentExPoint (
202 hdc, lpszStrW, cchString, nMaxExtent, lpnFit, alpDx, lpSize );
203
204 HEAP_free ( lpszStrW );
205 }
206
207 return rc;
208 }
209
210
211 /*
212 * @implemented
213 */
214 BOOL
215 APIENTRY
216 GetTextExtentPoint32A(
217 HDC hdc,
218 LPCSTR lpString,
219 int cbString,
220 LPSIZE lpSize
221 )
222 {
223 ANSI_STRING StringA;
224 UNICODE_STRING StringU;
225 BOOL ret;
226
227 RtlInitAnsiString(&StringA, (LPSTR)lpString);
228 RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
229
230 ret = GetTextExtentPoint32W(hdc, StringU.Buffer, cbString, lpSize);
231
232 RtlFreeUnicodeString(&StringU);
233
234 return ret;
235 }
236
237
238 /*
239 * @implemented
240 */
241 BOOL
242 APIENTRY
243 GetTextExtentPoint32W(
244 HDC hdc,
245 LPCWSTR lpString,
246 int cbString,
247 LPSIZE lpSize
248 )
249 {
250 return NtGdiGetTextExtentPoint32(hdc, lpString, cbString, lpSize);
251 }
252
253
254 /*
255 * @implemented
256 */
257 BOOL
258 STDCALL
259 ExtTextOutA(
260 HDC hdc,
261 int X,
262 int Y,
263 UINT fuOptions,
264 CONST RECT *lprc,
265 LPCSTR lpString,
266 UINT cbCount,
267 CONST INT *lpDx
268 )
269 {
270 ANSI_STRING StringA;
271 UNICODE_STRING StringU;
272 BOOL ret;
273
274 RtlInitAnsiString(&StringA, (LPSTR)lpString);
275 RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
276
277 ret = ExtTextOutW(hdc, X, Y, fuOptions, lprc, StringU.Buffer, cbCount, lpDx);
278
279 RtlFreeUnicodeString(&StringU);
280
281 return ret;
282 }
283
284
285 /*
286 * @implemented
287 */
288 BOOL
289 STDCALL
290 ExtTextOutW(
291 HDC hdc,
292 int X,
293 int Y,
294 UINT fuOptions,
295 CONST RECT *lprc,
296 LPCWSTR lpString,
297 UINT cbCount,
298 CONST INT *lpDx
299 )
300 {
301 return NtGdiExtTextOut(hdc, X, Y, fuOptions, lprc, lpString, cbCount, lpDx);
302 }
303
304
305 /*
306 * @implemented
307 */
308 int
309 STDCALL
310 GetTextFaceW(
311 HDC a0,
312 int a1,
313 LPWSTR a2
314 )
315 {
316 return NtGdiGetTextFace(a0, a1, a2);
317 }
318
319
320 /*
321 * @implemented
322 */
323 int
324 STDCALL
325 GetTextFaceA( HDC hdc, INT count, LPSTR name )
326 {
327 INT res = GetTextFaceW(hdc, 0, NULL);
328 LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, res * 2 );
329 GetTextFaceW( hdc, res, nameW );
330
331 if (name)
332 {
333 if (count && !WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, count, NULL, NULL))
334 name[count-1] = 0;
335 res = strlen(name);
336 }
337 else
338 res = WideCharToMultiByte( CP_ACP, 0, nameW, -1, NULL, 0, NULL, NULL);
339 HeapFree( GetProcessHeap(), 0, nameW );
340 return res;
341 }
342
343