blob: 76c82d6d0ed13e31aa308a3b962d6bdd3f81464c [file] [log] [blame]
Alexandre Julliard401710d1993-09-04 10:09:32 +00001/*
2 * text functions
3 *
Alexandre Julliardaca05781994-10-17 18:12:41 +00004 * Copyright 1993, 1994 Alexandre Julliard
Alexandre Julliard234bc241994-12-10 13:02:28 +00005 *
Alexandre Julliard7e56f681996-01-31 19:02:28 +00006 */
7
David Luyeree517e81999-02-28 12:27:56 +00008#include <string.h>
Patrik Stridvallfdcfdb91999-06-12 14:55:11 +00009
10#include "wine/winuser16.h"
Michael Vekslerff5ae3d1999-04-22 15:26:11 +000011#include "winbase.h"
Marcus Meissner61afa331999-02-22 10:16:00 +000012#include "winuser.h"
Peter Ganten87d95b71999-09-19 14:17:14 +000013#include "winerror.h"
Alexandre Julliard234bc241994-12-10 13:02:28 +000014#include "dc.h"
Alexandre Julliard401710d1993-09-04 10:09:32 +000015#include "gdi.h"
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +000016#include "heap.h"
Alexandre Julliard15657091999-05-23 10:25:25 +000017#include "debugtools.h"
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000018#include "cache.h"
Alexandre Julliard401710d1993-09-04 10:09:32 +000019
Alexandre Julliard0dd36552000-01-29 19:49:58 +000020DEFAULT_DEBUG_CHANNEL(text);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000021
Alexandre Julliard0e607781993-11-03 19:23:37 +000022#define TAB 9
23#define LF 10
24#define CR 13
25#define SPACE 32
26#define PREFIX 38
27
Alexandre Julliardaca05781994-10-17 18:12:41 +000028#define SWAP_INT(a,b) { int t = a; a = b; b = t; }
29
Alexandre Julliard0e607781993-11-03 19:23:37 +000030static int tabstop = 8;
31static int tabwidth;
32static int spacewidth;
33static int prefix_offset;
34
Alexandre Julliard530ee841996-10-23 16:59:13 +000035static const char *TEXT_NextLine( HDC16 hdc, const char *str, int *count,
Alexandre Julliard7e56f681996-01-31 19:02:28 +000036 char *dest, int *len, int width, WORD format)
Alexandre Julliard0e607781993-11-03 19:23:37 +000037{
38 /* Return next line of text from a string.
39 *
40 * hdc - handle to DC.
41 * str - string to parse into lines.
42 * count - length of str.
43 * dest - destination in which to return line.
44 * len - length of resultant line in dest in chars.
45 * width - maximum width of line in pixels.
46 * format - format type passed to DrawText.
47 *
48 * Returns pointer to next char in str after end of the line
49 * or NULL if end of str reached.
50 */
51
52 int i = 0, j = 0, k;
53 int plen = 0;
54 int numspaces;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000055 SIZE16 size;
Alexandre Julliard0e607781993-11-03 19:23:37 +000056 int lasttab = 0;
Alexandre Julliard7cbe6571995-01-09 18:21:16 +000057 int wb_i = 0, wb_j = 0, wb_count = 0;
Alexandre Julliard0e607781993-11-03 19:23:37 +000058
59 while (*count)
60 {
61 switch (str[i])
62 {
63 case CR:
64 case LF:
65 if (!(format & DT_SINGLELINE))
66 {
Alexandre Julliard491502b1997-11-01 19:08:16 +000067 if ((*count > 1) && (str[i] == CR) && (str[i+1] == LF))
68 {
69 (*count)--;
70 i++;
71 }
Alexandre Julliard3a405ba1994-10-30 16:25:19 +000072 i++;
Alexandre Julliard0e607781993-11-03 19:23:37 +000073 *len = j;
Alexandre Julliarde2abbb11995-03-19 17:39:39 +000074 (*count)--;
Alexandre Julliard0e607781993-11-03 19:23:37 +000075 return (&str[i]);
76 }
77 dest[j++] = str[i++];
Alexandre Julliard490a27e1994-06-08 13:57:50 +000078 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
79 (format & DT_WORDBREAK))
Alexandre Julliard0e607781993-11-03 19:23:37 +000080 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000081 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
Alexandre Julliard0e607781993-11-03 19:23:37 +000082 return NULL;
83 plen += size.cx;
84 }
85 break;
Alexandre Julliard490a27e1994-06-08 13:57:50 +000086
Alexandre Julliard0e607781993-11-03 19:23:37 +000087 case PREFIX:
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000088 if (!(format & DT_NOPREFIX) && *count > 1)
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +000089 {
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000090 if (str[++i] == PREFIX)
91 (*count)--;
92 else {
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +000093 prefix_offset = j;
94 break;
95 }
Alexandre Julliard0e607781993-11-03 19:23:37 +000096 }
Alexandre Julliard7e6ae4b1996-12-08 19:25:27 +000097 dest[j++] = str[i++];
98 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
99 (format & DT_WORDBREAK))
100 {
101 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
102 return NULL;
103 plen += size.cx;
104 }
Alexandre Julliard0e607781993-11-03 19:23:37 +0000105 break;
Alexandre Julliard490a27e1994-06-08 13:57:50 +0000106
Alexandre Julliard0e607781993-11-03 19:23:37 +0000107 case TAB:
108 if (format & DT_EXPANDTABS)
109 {
110 wb_i = ++i;
111 wb_j = j;
112 wb_count = *count;
113
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000114 if (!GetTextExtentPoint16(hdc, &dest[lasttab], j - lasttab,
Alexandre Julliard0e607781993-11-03 19:23:37 +0000115 &size))
116 return NULL;
117
118 numspaces = (tabwidth - size.cx) / spacewidth;
119 for (k = 0; k < numspaces; k++)
120 dest[j++] = SPACE;
121 plen += tabwidth - size.cx;
122 lasttab = wb_j + numspaces;
123 }
124 else
125 {
126 dest[j++] = str[i++];
Alexandre Julliard490a27e1994-06-08 13:57:50 +0000127 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
128 (format & DT_WORDBREAK))
Alexandre Julliard0e607781993-11-03 19:23:37 +0000129 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000130 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
Alexandre Julliard0e607781993-11-03 19:23:37 +0000131 return NULL;
132 plen += size.cx;
133 }
134 }
135 break;
136
137 case SPACE:
138 dest[j++] = str[i++];
Alexandre Julliard490a27e1994-06-08 13:57:50 +0000139 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
140 (format & DT_WORDBREAK))
Alexandre Julliard0e607781993-11-03 19:23:37 +0000141 {
142 wb_i = i;
143 wb_j = j - 1;
144 wb_count = *count;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000145 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
Alexandre Julliard0e607781993-11-03 19:23:37 +0000146 return NULL;
147 plen += size.cx;
148 }
149 break;
150
151 default:
152 dest[j++] = str[i++];
Alexandre Julliard490a27e1994-06-08 13:57:50 +0000153 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
154 (format & DT_WORDBREAK))
Alexandre Julliard0e607781993-11-03 19:23:37 +0000155 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000156 if (!GetTextExtentPoint16(hdc, &dest[j-1], 1, &size))
Alexandre Julliard0e607781993-11-03 19:23:37 +0000157 return NULL;
158 plen += size.cx;
159 }
160 }
161
162 (*count)--;
163 if (!(format & DT_NOCLIP) || (format & DT_WORDBREAK))
164 {
165 if (plen > width)
166 {
167 if (format & DT_WORDBREAK)
168 {
Alexandre Julliardecc37121994-11-22 16:31:29 +0000169 if (wb_j)
170 {
171 *len = wb_j;
172 *count = wb_count - 1;
173 return (&str[wb_i]);
174 }
Alexandre Julliard0e607781993-11-03 19:23:37 +0000175 }
176 else
177 {
178 *len = j;
179 return (&str[i]);
180 }
181 }
182 }
183 }
184
185 *len = j;
186 return NULL;
187}
188
Alexandre Julliard401710d1993-09-04 10:09:32 +0000189
190/***********************************************************************
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000191 * DrawText16 (USER.85)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000192 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000193INT16 WINAPI DrawText16( HDC16 hdc, LPCSTR str, INT16 i_count,
194 LPRECT16 rect, UINT16 flags )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000195{
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000196 SIZE16 size;
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000197 const char *strPtr;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000198 static char line[1024];
Alexandre Julliard0c126c71996-02-18 18:44:41 +0000199 int len, lh, count=i_count;
Alexandre Julliarde2991ea1995-07-29 13:09:43 +0000200 int prefix_x = 0;
201 int prefix_end = 0;
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000202 TEXTMETRIC16 tm;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000203 int x = rect->left, y = rect->top;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000204 int width = rect->right - rect->left;
Alexandre Julliard3a405ba1994-10-30 16:25:19 +0000205 int max_width = 0;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000206
Alexandre Julliard15657091999-05-23 10:25:25 +0000207 TRACE("%s, %d , [(%d,%d),(%d,%d)]\n",
Alexandre Julliardf90efa91998-06-14 15:24:15 +0000208 debugstr_an (str, count), count,
209 rect->left, rect->top, rect->right, rect->bottom);
Eric Pouecha35e3451999-12-12 19:38:17 +0000210
211 if (!str) return 0;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000212 if (count == -1) count = strlen(str);
Alexandre Julliard0e607781993-11-03 19:23:37 +0000213 strPtr = str;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000214
Alexandre Julliard3051b641996-07-05 17:14:13 +0000215 GetTextMetrics16(hdc, &tm);
Alexandre Julliard0e607781993-11-03 19:23:37 +0000216 if (flags & DT_EXTERNALLEADING)
217 lh = tm.tmHeight + tm.tmExternalLeading;
218 else
219 lh = tm.tmHeight;
Alexandre Julliardf41aeca1993-09-14 16:47:10 +0000220
Alexandre Julliard0e607781993-11-03 19:23:37 +0000221 if (flags & DT_TABSTOP)
222 tabstop = flags >> 8;
223
224 if (flags & DT_EXPANDTABS)
225 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000226 GetTextExtentPoint16(hdc, " ", 1, &size);
Alexandre Julliard0e607781993-11-03 19:23:37 +0000227 spacewidth = size.cx;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000228 GetTextExtentPoint16(hdc, "o", 1, &size);
Alexandre Julliard0e607781993-11-03 19:23:37 +0000229 tabwidth = size.cx * tabstop;
230 }
231
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000232 if (flags & DT_CALCRECT) flags |= DT_NOCLIP;
233
Alexandre Julliard0e607781993-11-03 19:23:37 +0000234 do
235 {
236 prefix_offset = -1;
237 strPtr = TEXT_NextLine(hdc, strPtr, &count, line, &len, width, flags);
238
239 if (prefix_offset != -1)
240 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000241 GetTextExtentPoint16(hdc, line, prefix_offset, &size);
Alexandre Julliard0e607781993-11-03 19:23:37 +0000242 prefix_x = size.cx;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000243 GetTextExtentPoint16(hdc, line, prefix_offset + 1, &size);
Alexandre Julliard2d159fb1994-07-15 16:04:31 +0000244 prefix_end = size.cx - 1;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000245 }
246
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000247 if (!GetTextExtentPoint16(hdc, line, len, &size)) return 0;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000248 if (flags & DT_CENTER) x = (rect->left + rect->right -
249 size.cx) / 2;
250 else if (flags & DT_RIGHT) x = rect->right - size.cx;
251
252 if (flags & DT_SINGLELINE)
253 {
Alexandre Julliardcdd09231994-01-12 11:12:51 +0000254 if (flags & DT_VCENTER) y = rect->top +
255 (rect->bottom - rect->top) / 2 - size.cy / 2;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000256 else if (flags & DT_BOTTOM) y = rect->bottom - size.cy;
257 }
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000258 if (!(flags & DT_CALCRECT))
Alexandre Julliard3a405ba1994-10-30 16:25:19 +0000259 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000260 if (!ExtTextOut16(hdc, x, y, (flags & DT_NOCLIP) ? 0 : ETO_CLIPPED,
261 rect, line, len, NULL )) return 0;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000262 if (prefix_offset != -1)
263 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000264 HPEN hpen = CreatePen( PS_SOLID, 1, GetTextColor(hdc) );
265 HPEN oldPen = SelectObject( hdc, hpen );
266 MoveTo16(hdc, x + prefix_x, y + tm.tmAscent + 1 );
267 LineTo(hdc, x + prefix_end + 1, y + tm.tmAscent + 1 );
268 SelectObject( hdc, oldPen );
269 DeleteObject( hpen );
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000270 }
Alexandre Julliard3a405ba1994-10-30 16:25:19 +0000271 }
272 else if (size.cx > max_width)
273 max_width = size.cx;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000274
Alexandre Julliard3a405ba1994-10-30 16:25:19 +0000275 y += lh;
Alexandre Julliard0e607781993-11-03 19:23:37 +0000276 if (strPtr)
277 {
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000278 if (!(flags & DT_NOCLIP))
Alexandre Julliard0e607781993-11-03 19:23:37 +0000279 {
280 if (y > rect->bottom - lh)
281 break;
282 }
283 }
284 }
285 while (strPtr);
Alexandre Julliard3a405ba1994-10-30 16:25:19 +0000286 if (flags & DT_CALCRECT)
287 {
288 rect->right = rect->left + max_width;
289 rect->bottom = y;
290 }
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000291 return y - rect->top;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000292}
293
294
295/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000296 * DrawText32A (USER32.164)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000297 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000298INT WINAPI DrawTextA( HDC hdc, LPCSTR str, INT count,
299 LPRECT rect, UINT flags )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000300{
301 RECT16 rect16;
302 INT16 ret;
303
304 if (!rect)
305 return DrawText16( (HDC16)hdc, str, (INT16)count, NULL, (UINT16)flags);
306 CONV_RECT32TO16( rect, &rect16 );
307 ret = DrawText16( (HDC16)hdc, str, (INT16)count, &rect16, (UINT16)flags );
308 CONV_RECT16TO32( &rect16, rect );
309 return ret;
310}
311
312
313/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000314 * DrawText32W (USER32.167)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000315 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000316INT WINAPI DrawTextW( HDC hdc, LPCWSTR str, INT count,
317 LPRECT rect, UINT flags )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000318{
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000319 LPSTR p = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000320 INT ret = DrawTextA( hdc, p, count, rect, flags );
Alexandre Julliard7ebe1a41996-12-22 18:27:48 +0000321 HeapFree( GetProcessHeap(), 0, p );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000322 return ret;
323}
324
Alexandre Julliard77b99181997-09-14 17:17:23 +0000325/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000326 * DrawTextEx32A (USER32.165)
Alexandre Julliard77b99181997-09-14 17:17:23 +0000327 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000328INT WINAPI DrawTextExA( HDC hdc, LPCSTR str, INT count,
329 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000330{
Alexandre Julliard15657091999-05-23 10:25:25 +0000331 TRACE("(%d,'%s',%d,%p,0x%08x,%p)\n",hdc,str,count,rect,flags,dtp);
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000332 if(dtp) {
Alexandre Julliard15657091999-05-23 10:25:25 +0000333 FIXME("Ignores params:%d,%d,%d,%d,%d\n",dtp->cbSize,
Alexandre Julliardd30dfd21998-09-27 18:28:36 +0000334 dtp->iTabLength,dtp->iLeftMargin,dtp->iRightMargin,
335 dtp->uiLengthDrawn);
336 }
Alexandre Julliarda3960291999-02-26 11:11:13 +0000337 return DrawTextA(hdc,str,count,rect,flags);
Alexandre Julliard77b99181997-09-14 17:17:23 +0000338}
339
340/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000341 * DrawTextEx32W (USER32.166)
Alexandre Julliard77b99181997-09-14 17:17:23 +0000342 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000343INT WINAPI DrawTextExW( HDC hdc, LPCWSTR str, INT count,
344 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000345{
Alexandre Julliard15657091999-05-23 10:25:25 +0000346 TRACE("(%d,%p,%d,%p,0x%08x,%p)\n",hdc,str,count,rect,flags,dtp);
347 FIXME("ignores extended functionality\n");
Alexandre Julliarda3960291999-02-26 11:11:13 +0000348 return DrawTextW(hdc,str,count,rect,flags);
Alexandre Julliard77b99181997-09-14 17:17:23 +0000349}
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000350
351/***********************************************************************
352 * ExtTextOut16 (GDI.351)
353 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000354BOOL16 WINAPI ExtTextOut16( HDC16 hdc, INT16 x, INT16 y, UINT16 flags,
355 const RECT16 *lprect, LPCSTR str, UINT16 count,
356 const INT16 *lpDx )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000357{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000358 BOOL ret;
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000359 int i;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000360 RECT rect32;
361 LPINT lpdx32 = NULL;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000362
Alexandre Julliarda3960291999-02-26 11:11:13 +0000363 if (lpDx) lpdx32 = (LPINT)HEAP_xalloc( GetProcessHeap(), 0,
364 sizeof(INT)*count );
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000365 if (lprect) CONV_RECT16TO32(lprect,&rect32);
366 if (lpdx32) for (i=count;i--;) lpdx32[i]=lpDx[i];
Alexandre Julliarda3960291999-02-26 11:11:13 +0000367 ret = ExtTextOutA(hdc,x,y,flags,lprect?&rect32:NULL,str,count,lpdx32);
Alexandre Julliard491502b1997-11-01 19:08:16 +0000368 if (lpdx32) HeapFree( GetProcessHeap(), 0, lpdx32 );
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000369 return ret;
Alexandre Julliard73450d61994-05-18 18:29:32 +0000370
Alexandre Julliard401710d1993-09-04 10:09:32 +0000371
Alexandre Julliard401710d1993-09-04 10:09:32 +0000372}
Alexandre Julliard58199531994-04-21 01:20:00 +0000373
Alexandre Julliardaca05781994-10-17 18:12:41 +0000374
375/***********************************************************************
Huw D M Daviesc5539241999-12-26 00:47:03 +0000376 * ExtTextOutA (GDI32.98)
Alexandre Julliardaca05781994-10-17 18:12:41 +0000377 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000378BOOL WINAPI ExtTextOutA( HDC hdc, INT x, INT y, UINT flags,
379 const RECT *lprect, LPCSTR str, UINT count,
380 const INT *lpDx )
Alexandre Julliardaca05781994-10-17 18:12:41 +0000381{
Huw D M Daviesc5539241999-12-26 00:47:03 +0000382 /* str need not be \0 terminated but lstrcpynAtoW adds \0 so we allocate one
383 more byte */
384 LPWSTR p = HeapAlloc( GetProcessHeap(), 0, (count+1) * sizeof(WCHAR) );
385 INT ret;
386 lstrcpynAtoW( p, str, count+1 );
387 ret = ExtTextOutW( hdc, x, y, flags, lprect, p, count, lpDx );
388 HeapFree( GetProcessHeap(), 0, p );
389 return ret;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000390}
391
392
393/***********************************************************************
Huw D M Daviesc5539241999-12-26 00:47:03 +0000394 * ExtTextOutW (GDI32.99)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000395 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000396BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
397 const RECT *lprect, LPCWSTR str, UINT count,
398 const INT *lpDx )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000399{
Huw D M Daviesc5539241999-12-26 00:47:03 +0000400 DC * dc = DC_GetDCPtr( hdc );
401 return dc && dc->funcs->pExtTextOut &&
402 dc->funcs->pExtTextOut(dc,x,y,flags,lprect,str,count,lpDx);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000403}
404
405
406/***********************************************************************
407 * TextOut16 (GDI.33)
408 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000409BOOL16 WINAPI TextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR str, INT16 count )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000410{
411 return ExtTextOut16( hdc, x, y, 0, NULL, str, count, NULL );
412}
413
414
415/***********************************************************************
416 * TextOut32A (GDI32.355)
417 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000418BOOL WINAPI TextOutA( HDC hdc, INT x, INT y, LPCSTR str, INT count )
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000419{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000420 return ExtTextOutA( hdc, x, y, 0, NULL, str, count, NULL );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000421}
422
423
424/***********************************************************************
425 * TextOut32W (GDI32.356)
426 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000427BOOL WINAPI TextOutW(HDC hdc, INT x, INT y, LPCWSTR str, INT count)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000428{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000429 return ExtTextOutW( hdc, x, y, 0, NULL, str, count, NULL );
Alexandre Julliardaca05781994-10-17 18:12:41 +0000430}
431
432
Alexandre Julliard58199531994-04-21 01:20:00 +0000433/***********************************************************************
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000434 * TEXT_GrayString
435 *
436 * FIXME: The call to 16-bit code only works because the wine GDI is a 16-bit
437 * heap and we can guarantee that the handles fit in an INT16. We have to
438 * rethink the strategy once the migration to NT handles is complete.
439 * We are going to get a lot of code-duplication once this migration is
440 * completed...
441 *
442 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000443static BOOL TEXT_GrayString(HDC hdc, HBRUSH hb,
444 GRAYSTRINGPROC fn, LPARAM lp, INT len,
445 INT x, INT y, INT cx, INT cy,
446 BOOL unicode, BOOL _32bit)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000447{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000448 HBITMAP hbm, hbmsave;
449 HBRUSH hbsave;
450 HFONT hfsave;
451 HDC memdc = CreateCompatibleDC(hdc);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000452 int slen = len;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000453 BOOL retval = TRUE;
454 RECT r;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000455 COLORREF fg, bg;
456
457 if(!hdc) return FALSE;
458
459 if(len == 0)
460 {
461 if(unicode)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000462 slen = lstrlenW((LPCWSTR)lp);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000463 else if(_32bit)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000464 slen = lstrlenA((LPCSTR)lp);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000465 else
Alexandre Julliarda3960291999-02-26 11:11:13 +0000466 slen = lstrlenA((LPCSTR)PTR_SEG_TO_LIN(lp));
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000467 }
468
469 if((cx == 0 || cy == 0) && slen != -1)
470 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000471 SIZE s;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000472 if(unicode)
473 GetTextExtentPoint32W(hdc, (LPCWSTR)lp, slen, &s);
474 else if(_32bit)
475 GetTextExtentPoint32A(hdc, (LPCSTR)lp, slen, &s);
476 else
477 GetTextExtentPoint32A(hdc, (LPCSTR)PTR_SEG_TO_LIN(lp), slen, &s);
478 if(cx == 0) cx = s.cx;
479 if(cy == 0) cy = s.cy;
480 }
481
482 r.left = r.top = 0;
483 r.right = cx;
484 r.bottom = cy;
485
Alexandre Julliarda3960291999-02-26 11:11:13 +0000486 hbm = CreateBitmap(cx, cy, 1, 1, NULL);
487 hbmsave = (HBITMAP)SelectObject(memdc, hbm);
488 FillRect(memdc, &r, (HBRUSH)GetStockObject(BLACK_BRUSH));
489 SetTextColor(memdc, RGB(255, 255, 255));
490 SetBkColor(memdc, RGB(0, 0, 0));
491 hfsave = (HFONT)SelectObject(memdc, GetCurrentObject(hdc, OBJ_FONT));
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000492
493 if(fn)
494 if(_32bit)
495 retval = fn(memdc, lp, slen);
496 else
Alexandre Julliarda3960291999-02-26 11:11:13 +0000497 retval = (BOOL)((BOOL16)((GRAYSTRINGPROC16)fn)((HDC16)memdc, lp, (INT16)slen));
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000498 else
499 if(unicode)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000500 TextOutW(memdc, 0, 0, (LPCWSTR)lp, slen);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000501 else if(_32bit)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000502 TextOutA(memdc, 0, 0, (LPCSTR)lp, slen);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000503 else
Alexandre Julliarda3960291999-02-26 11:11:13 +0000504 TextOutA(memdc, 0, 0, (LPCSTR)PTR_SEG_TO_LIN(lp), slen);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000505
Alexandre Julliarda3960291999-02-26 11:11:13 +0000506 SelectObject(memdc, hfsave);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000507
508/*
509 * Windows doc says that the bitmap isn't grayed when len == -1 and
510 * the callback function returns FALSE. However, testing this on
511 * win95 showed otherwise...
512*/
513#ifdef GRAYSTRING_USING_DOCUMENTED_BEHAVIOUR
514 if(retval || len != -1)
515#endif
516 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000517 hbsave = (HBRUSH)SelectObject(memdc, CACHE_GetPattern55AABrush());
518 PatBlt(memdc, 0, 0, cx, cy, 0x000A0329);
519 SelectObject(memdc, hbsave);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000520 }
521
Alexandre Julliarda3960291999-02-26 11:11:13 +0000522 if(hb) hbsave = (HBRUSH)SelectObject(hdc, hb);
523 fg = SetTextColor(hdc, RGB(0, 0, 0));
524 bg = SetBkColor(hdc, RGB(255, 255, 255));
525 BitBlt(hdc, x, y, cx, cy, memdc, 0, 0, 0x00E20746);
526 SetTextColor(hdc, fg);
527 SetBkColor(hdc, bg);
528 if(hb) SelectObject(hdc, hbsave);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000529
Alexandre Julliarda3960291999-02-26 11:11:13 +0000530 SelectObject(memdc, hbmsave);
531 DeleteObject(hbm);
532 DeleteDC(memdc);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000533 return retval;
534}
535
536
537/***********************************************************************
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000538 * GrayString16 (USER.185)
Alexandre Julliard58199531994-04-21 01:20:00 +0000539 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000540BOOL16 WINAPI GrayString16( HDC16 hdc, HBRUSH16 hbr, GRAYSTRINGPROC16 gsprc,
541 LPARAM lParam, INT16 cch, INT16 x, INT16 y,
542 INT16 cx, INT16 cy )
Alexandre Julliard58199531994-04-21 01:20:00 +0000543{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000544 return TEXT_GrayString(hdc, hbr, (GRAYSTRINGPROC)gsprc, lParam, cch, x, y, cx, cy, FALSE, FALSE);
Alexandre Julliard58199531994-04-21 01:20:00 +0000545}
Alexandre Julliard73450d61994-05-18 18:29:32 +0000546
Alexandre Julliardaca05781994-10-17 18:12:41 +0000547
Alexandre Julliard73450d61994-05-18 18:29:32 +0000548/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000549 * GrayString32A (USER32.315)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000550 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000551BOOL WINAPI GrayStringA( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
552 LPARAM lParam, INT cch, INT x, INT y,
553 INT cx, INT cy )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000554{
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000555 return TEXT_GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy, FALSE, TRUE);
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000556}
557
558
559/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000560 * GrayString32W (USER32.316)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000561 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000562BOOL WINAPI GrayStringW( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
563 LPARAM lParam, INT cch, INT x, INT y,
564 INT cx, INT cy )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000565{
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000566 return TEXT_GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy, TRUE, TRUE);
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000567}
568
569
570/***********************************************************************
Alexandre Julliard234bc241994-12-10 13:02:28 +0000571 * TEXT_TabbedTextOut
572 *
573 * Helper function for TabbedTextOut() and GetTabbedTextExtent().
574 * Note: this doesn't work too well for text-alignment modes other
575 * than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-)
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +0000576 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000577LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCSTR lpstr,
578 INT count, INT cTabStops, const INT16 *lpTabPos16,
579 const INT *lpTabPos32, INT nTabOrg,
580 BOOL fDisplayText )
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +0000581{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000582 INT defWidth;
Alexandre Julliardc981d0b1996-03-31 16:40:13 +0000583 DWORD extent = 0;
584 int i, tabPos = x;
585 int start = x;
Alexandre Julliard234bc241994-12-10 13:02:28 +0000586
Alexandre Julliardc981d0b1996-03-31 16:40:13 +0000587 if (cTabStops == 1)
588 {
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000589 defWidth = lpTabPos32 ? *lpTabPos32 : *lpTabPos16;
Alexandre Julliardc981d0b1996-03-31 16:40:13 +0000590 cTabStops = 0;
591 }
Alexandre Julliard234bc241994-12-10 13:02:28 +0000592 else
593 {
Alexandre Julliardd90840e1996-06-11 16:02:08 +0000594 TEXTMETRIC16 tm;
Alexandre Julliard3051b641996-07-05 17:14:13 +0000595 GetTextMetrics16( hdc, &tm );
Alexandre Julliard234bc241994-12-10 13:02:28 +0000596 defWidth = 8 * tm.tmAveCharWidth;
597 }
598
599 while (count > 0)
600 {
601 for (i = 0; i < count; i++)
602 if (lpstr[i] == '\t') break;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000603 extent = GetTextExtent16( hdc, lpstr, i );
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000604 if (lpTabPos32)
Alexandre Julliard234bc241994-12-10 13:02:28 +0000605 {
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000606 while ((cTabStops > 0) &&
607 (nTabOrg + *lpTabPos32 <= x + LOWORD(extent)))
608 {
609 lpTabPos32++;
610 cTabStops--;
611 }
612 }
613 else
614 {
615 while ((cTabStops > 0) &&
616 (nTabOrg + *lpTabPos16 <= x + LOWORD(extent)))
617 {
618 lpTabPos16++;
619 cTabStops--;
620 }
Alexandre Julliard234bc241994-12-10 13:02:28 +0000621 }
Alexandre Julliardc981d0b1996-03-31 16:40:13 +0000622 if (i == count)
Alexandre Julliard234bc241994-12-10 13:02:28 +0000623 tabPos = x + LOWORD(extent);
624 else if (cTabStops > 0)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000625 tabPos = nTabOrg + (lpTabPos32 ? *lpTabPos32 : *lpTabPos16);
Alexandre Julliard234bc241994-12-10 13:02:28 +0000626 else
Alexandre Julliardc981d0b1996-03-31 16:40:13 +0000627 tabPos = nTabOrg + ((x + LOWORD(extent) - nTabOrg) / defWidth + 1) * defWidth;
Alexandre Julliard234bc241994-12-10 13:02:28 +0000628 if (fDisplayText)
629 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000630 RECT r;
631 SetRect( &r, x, y, tabPos, y+HIWORD(extent) );
632 ExtTextOutA( hdc, x, y,
633 GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0,
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000634 &r, lpstr, i, NULL );
Alexandre Julliard234bc241994-12-10 13:02:28 +0000635 }
636 x = tabPos;
637 count -= i+1;
638 lpstr += i+1;
639 }
Alexandre Julliardc981d0b1996-03-31 16:40:13 +0000640 return MAKELONG(tabPos - start, HIWORD(extent));
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +0000641}
642
643
644/***********************************************************************
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000645 * TabbedTextOut16 (USER.196)
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +0000646 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000647LONG WINAPI TabbedTextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR lpstr,
648 INT16 count, INT16 cTabStops,
649 const INT16 *lpTabPos, INT16 nTabOrg )
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +0000650{
Alexandre Julliard15657091999-05-23 10:25:25 +0000651 TRACE("%04x %d,%d '%.*s' %d\n",
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000652 hdc, x, y, count, lpstr, count );
Alexandre Julliard234bc241994-12-10 13:02:28 +0000653 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000654 lpTabPos, NULL, nTabOrg, TRUE );
Alexandre Julliard3f2abfa1994-08-16 15:43:11 +0000655}
656
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +0000657
Alexandre Julliard234bc241994-12-10 13:02:28 +0000658/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000659 * TabbedTextOut32A (USER32.542)
Alexandre Julliard234bc241994-12-10 13:02:28 +0000660 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000661LONG WINAPI TabbedTextOutA( HDC hdc, INT x, INT y, LPCSTR lpstr,
662 INT count, INT cTabStops,
663 const INT *lpTabPos, INT nTabOrg )
Alexandre Julliard234bc241994-12-10 13:02:28 +0000664{
Alexandre Julliard15657091999-05-23 10:25:25 +0000665 TRACE("%04x %d,%d '%.*s' %d\n",
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000666 hdc, x, y, count, lpstr, count );
667 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
668 NULL, lpTabPos, nTabOrg, TRUE );
669}
670
671
672/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000673 * TabbedTextOut32W (USER32.543)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000674 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000675LONG WINAPI TabbedTextOutW( HDC hdc, INT x, INT y, LPCWSTR str,
676 INT count, INT cTabStops,
677 const INT *lpTabPos, INT nTabOrg )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000678{
679 LONG ret;
680 LPSTR p = HEAP_xalloc( GetProcessHeap(), 0, count + 1 );
681 lstrcpynWtoA( p, str, count + 1 );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000682 ret = TabbedTextOutA( hdc, x, y, p, count, cTabStops,
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000683 lpTabPos, nTabOrg );
684 HeapFree( GetProcessHeap(), 0, p );
685 return ret;
686}
687
688
689/***********************************************************************
690 * GetTabbedTextExtent16 (USER.197)
691 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000692DWORD WINAPI GetTabbedTextExtent16( HDC16 hdc, LPCSTR lpstr, INT16 count,
693 INT16 cTabStops, const INT16 *lpTabPos )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000694{
Alexandre Julliard15657091999-05-23 10:25:25 +0000695 TRACE("%04x '%.*s' %d\n",
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000696 hdc, count, lpstr, count );
Alexandre Julliard234bc241994-12-10 13:02:28 +0000697 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000698 lpTabPos, NULL, 0, FALSE );
699}
700
701
702/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000703 * GetTabbedTextExtent32A (USER32.293)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000704 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000705DWORD WINAPI GetTabbedTextExtentA( HDC hdc, LPCSTR lpstr, INT count,
706 INT cTabStops, const INT *lpTabPos )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000707{
Alexandre Julliard15657091999-05-23 10:25:25 +0000708 TRACE("%04x '%.*s' %d\n",
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000709 hdc, count, lpstr, count );
710 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
711 NULL, lpTabPos, 0, FALSE );
712}
713
714
715/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000716 * GetTabbedTextExtent32W (USER32.294)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000717 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000718DWORD WINAPI GetTabbedTextExtentW( HDC hdc, LPCWSTR lpstr, INT count,
719 INT cTabStops, const INT *lpTabPos )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000720{
721 LONG ret;
722 LPSTR p = HEAP_xalloc( GetProcessHeap(), 0, count + 1 );
723 lstrcpynWtoA( p, lpstr, count + 1 );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000724 ret = GetTabbedTextExtentA( hdc, p, count, cTabStops, lpTabPos );
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000725 HeapFree( GetProcessHeap(), 0, p );
726 return ret;
Alexandre Julliard234bc241994-12-10 13:02:28 +0000727}
Alexandre Julliard33072e11997-06-29 18:08:02 +0000728
729/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000730 * GetTextCharset32 [GDI32.226] Gets character set for font in DC
731 *
732 * NOTES
733 * Should it return a UINT32 instead of an INT32?
Gael de Chalendard5af0171998-11-22 12:19:49 +0000734 * => YES, as GetTextCharsetInfo returns UINT32
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000735 *
736 * RETURNS
737 * Success: Character set identifier
738 * Failure: DEFAULT_CHARSET
Alexandre Julliard33072e11997-06-29 18:08:02 +0000739 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000740UINT WINAPI GetTextCharset(
741 HDC hdc) /* [in] Handle to device context */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000742{
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000743 /* MSDN docs say this is equivalent */
744 return GetTextCharsetInfo(hdc, NULL, 0);
Alexandre Julliard33072e11997-06-29 18:08:02 +0000745}
746
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000747/***********************************************************************
748 * GetTextCharset16 [GDI.612]
749 */
Gael de Chalendard5af0171998-11-22 12:19:49 +0000750UINT16 WINAPI GetTextCharset16(HDC16 hdc)
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000751{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000752 return (UINT16)GetTextCharset(hdc);
Alexandre Julliard33072e11997-06-29 18:08:02 +0000753}
Alexandre Julliarde658d821997-11-30 17:45:40 +0000754
755/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000756 * GetTextCharsetInfo [GDI32.381] Gets character set for font
757 *
758 * NOTES
759 * Should csi be an LPFONTSIGNATURE instead of an LPCHARSETINFO?
760 * Should it return a UINT32 instead of an INT32?
Gael de Chalendard5af0171998-11-22 12:19:49 +0000761 * => YES and YES, from win32.hlp from Borland
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000762 *
763 * RETURNS
764 * Success: Character set identifier
765 * Failure: DEFAULT_CHARSET
Alexandre Julliarde658d821997-11-30 17:45:40 +0000766 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000767UINT WINAPI GetTextCharsetInfo(
768 HDC hdc, /* [in] Handle to device context */
Gael de Chalendard5af0171998-11-22 12:19:49 +0000769 LPFONTSIGNATURE fs, /* [out] Pointer to struct to receive data */
770 DWORD flags) /* [in] Reserved - must be 0 */
Alexandre Julliarde658d821997-11-30 17:45:40 +0000771{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000772 HGDIOBJ hFont;
773 UINT charSet = DEFAULT_CHARSET;
774 LOGFONTW lf;
Guy Albertelli53292171999-01-24 09:50:09 +0000775 CHARSETINFO csinfo;
Gael de Chalendard5af0171998-11-22 12:19:49 +0000776
Gael de Chalendard5af0171998-11-22 12:19:49 +0000777 hFont = GetCurrentObject(hdc, OBJ_FONT);
778 if (hFont == 0)
779 return(DEFAULT_CHARSET);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000780 if ( GetObjectW(hFont, sizeof(LOGFONTW), &lf) != 0 )
Gael de Chalendard5af0171998-11-22 12:19:49 +0000781 charSet = lf.lfCharSet;
782
783 if (fs != NULL) {
Marcus Meissner03479f81999-01-28 10:06:38 +0000784 if (!TranslateCharsetInfo((LPDWORD)charSet, &csinfo, TCI_SRCCHARSET))
Guy Albertelli53292171999-01-24 09:50:09 +0000785 return (DEFAULT_CHARSET);
786 memcpy(fs, &csinfo.fs, sizeof(FONTSIGNATURE));
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000787 }
Gael de Chalendard5af0171998-11-22 12:19:49 +0000788 return charSet;
Alexandre Julliarde658d821997-11-30 17:45:40 +0000789}
Peter Ganten87d95b71999-09-19 14:17:14 +0000790
791/***********************************************************************
792 * PolyTextOutA [GDI.402] Draw several Strings
793 */
794BOOL WINAPI PolyTextOutA (
795 HDC hdc, /* Handle to device context */
796 PPOLYTEXTA pptxt, /* array of strings */
797 INT cStrings /* Number of strings in array */
798 )
799{
800 FIXME("stub!\n");
801 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED );
802 return 0;
803}
804
805
806
807/***********************************************************************
808 * PolyTextOutW [GDI.403] Draw several Strings
809 */
810BOOL WINAPI PolyTextOutW (
811 HDC hdc, /* Handle to device context */
812 PPOLYTEXTW pptxt, /* array of strings */
813 INT cStrings /* Number of strings in array */
814 )
815{
816 FIXME("stub!\n");
817 SetLastError ( ERROR_CALL_NOT_IMPLEMENTED );
818 return 0;
819}