user32: Convert source files to utf-8.
[wine/multimedia.git] / dlls / user32 / text.c
blobb09d085bccb66c911262e9bea990dc13b9ccab29
1 /*
2 * USER text functions
4 * Copyright 1993, 1994 Alexandre Julliard
5 * Copyright 2002 Bill Medland
7 * Contains
8 * 1. DrawText functions
9 * 2. GrayString functions
10 * 3. TabbedText functions
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "config.h"
28 #include "wine/port.h"
30 #include <stdarg.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <assert.h>
35 #include "windef.h"
36 #include "winbase.h"
37 #include "wingdi.h"
38 #include "wine/unicode.h"
39 #include "winnls.h"
40 #include "controls.h"
41 #include "user_private.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(text);
46 /*********************************************************************
48 * DrawText functions
50 * Design issues
51 * How many buffers to use
52 * While processing in DrawText there are potentially three different forms
53 * of the text that need to be held. How are they best held?
54 * 1. The original text is needed, of course, to see what to display.
55 * 2. The text that will be returned to the user if the DT_MODIFYSTRING is
56 * in effect.
57 * 3. The buffered text that is about to be displayed e.g. the current line.
58 * Typically this will exclude the ampersands used for prefixing etc.
60 * Complications.
61 * a. If the buffered text to be displayed includes the ampersands then
62 * we will need special measurement and draw functions that will ignore
63 * the ampersands (e.g. by copying to a buffer without the prefix and
64 * then using the normal forms). This may involve less space but may
65 * require more processing. e.g. since a line containing tabs may
66 * contain several underlined characters either we need to carry around
67 * a list of prefix locations or we may need to locate them several
68 * times.
69 * b. If we actually directly modify the "original text" as we go then we
70 * will need some special "caching" to handle the fact that when we
71 * ellipsify the text the ellipsis may modify the next line of text,
72 * which we have not yet processed. (e.g. ellipsification of a W at the
73 * end of a line will overwrite the W, the \n and the first character of
74 * the next line, and a \0 will overwrite the second. Try it!!)
76 * Option 1. Three separate storages. (To be implemented)
77 * If DT_MODIFYSTRING is in effect then allocate an extra buffer to hold
78 * the edited string in some form, either as the string itself or as some
79 * sort of "edit list" to be applied just before returning.
80 * Use a buffer that holds the ellipsified current line sans ampersands
81 * and accept the need occasionally to recalculate the prefixes (if
82 * DT_EXPANDTABS and not DT_NOPREFIX and not DT_HIDEPREFIX)
85 #define TAB 9
86 #define LF 10
87 #define CR 13
88 #define SPACE 32
89 #define PREFIX 38
91 #define FORWARD_SLASH '/'
92 #define BACK_SLASH '\\'
94 static const WCHAR ELLIPSISW[] = {'.','.','.', 0};
96 typedef struct tag_ellipsis_data
98 int before;
99 int len;
100 int under;
101 int after;
102 } ellipsis_data;
104 /*********************************************************************
105 * TEXT_Ellipsify (static)
107 * Add an ellipsis to the end of the given string whilst ensuring it fits.
109 * If the ellipsis alone doesn't fit then it will be returned anyway.
111 * See Also TEXT_PathEllipsify
113 * Arguments
114 * hdc [in] The handle to the DC that defines the font.
115 * str [in/out] The string that needs to be modified.
116 * max_str [in] The dimension of str (number of WCHAR).
117 * len_str [in/out] The number of characters in str
118 * width [in] The maximum width permitted (in logical coordinates)
119 * size [out] The dimensions of the text
120 * modstr [out] The modified form of the string, to be returned to the
121 * calling program. It is assumed that the caller has
122 * made sufficient space available so we don't need to
123 * know the size of the space. This pointer may be NULL if
124 * the modified string is not required.
125 * len_before [out] The number of characters before the ellipsis.
126 * len_ellip [out] The number of characters in the ellipsis.
128 * See for example Microsoft article Q249678.
130 * For now we will simply use three dots rather than worrying about whether
131 * the font contains an explicit ellipsis character.
133 static void TEXT_Ellipsify (HDC hdc, WCHAR *str, unsigned int max_len,
134 unsigned int *len_str, int width, SIZE *size,
135 WCHAR *modstr,
136 int *len_before, int *len_ellip)
138 unsigned int len_ellipsis;
139 unsigned int lo, mid, hi;
141 len_ellipsis = strlenW (ELLIPSISW);
142 if (len_ellipsis > max_len) len_ellipsis = max_len;
143 if (*len_str > max_len - len_ellipsis)
144 *len_str = max_len - len_ellipsis;
146 /* First do a quick binary search to get an upper bound for *len_str. */
147 if (*len_str > 0 &&
148 GetTextExtentExPointW(hdc, str, *len_str, width, NULL, NULL, size) &&
149 size->cx > width)
151 for (lo = 0, hi = *len_str; lo < hi; )
153 mid = (lo + hi) / 2;
154 if (!GetTextExtentExPointW(hdc, str, mid, width, NULL, NULL, size))
155 break;
156 if (size->cx > width)
157 hi = mid;
158 else
159 lo = mid + 1;
161 *len_str = hi;
163 /* Now this should take only a couple iterations at most. */
164 for ( ; ; )
166 memcpy(str + *len_str, ELLIPSISW, len_ellipsis*sizeof(WCHAR));
168 if (!GetTextExtentExPointW (hdc, str, *len_str + len_ellipsis, width,
169 NULL, NULL, size)) break;
171 if (!*len_str || size->cx <= width) break;
173 (*len_str)--;
175 *len_ellip = len_ellipsis;
176 *len_before = *len_str;
177 *len_str += len_ellipsis;
179 if (modstr)
181 memcpy (modstr, str, *len_str * sizeof(WCHAR));
182 modstr[*len_str] = '\0';
186 /*********************************************************************
187 * TEXT_PathEllipsify (static)
189 * Add an ellipsis to the provided string in order to make it fit within
190 * the width. The ellipsis is added as specified for the DT_PATH_ELLIPSIS
191 * flag.
193 * See Also TEXT_Ellipsify
195 * Arguments
196 * hdc [in] The handle to the DC that defines the font.
197 * str [in/out] The string that needs to be modified
198 * max_str [in] The dimension of str (number of WCHAR).
199 * len_str [in/out] The number of characters in str
200 * width [in] The maximum width permitted (in logical coordinates)
201 * size [out] The dimensions of the text
202 * modstr [out] The modified form of the string, to be returned to the
203 * calling program. It is assumed that the caller has
204 * made sufficient space available so we don't need to
205 * know the size of the space. This pointer may be NULL if
206 * the modified string is not required.
207 * pellip [out] The ellipsification results
209 * For now we will simply use three dots rather than worrying about whether
210 * the font contains an explicit ellipsis character.
212 * The following applies, I think to Win95. We will need to extend it for
213 * Win98 which can have both path and end ellipsis at the same time (e.g.
214 * C:\MyLongFileName.Txt becomes ...\MyLongFileN...)
216 * The resulting string consists of as much as possible of the following:
217 * 1. The ellipsis itself
218 * 2. The last \ or / of the string (if any)
219 * 3. Everything after the last \ or / of the string (if any) or the whole
220 * string if there is no / or \. I believe that under Win95 this would
221 * include everything even though some might be clipped off the end whereas
222 * under Win98 that might be ellipsified too.
223 * Yet to be investigated is whether this would include wordbreaking if the
224 * filename is more than 1 word and splitting if DT_EDITCONTROL was in
225 * effect. (If DT_EDITCONTROL is in effect then on occasions text will be
226 * broken within words).
227 * 4. All the stuff before the / or \, which is placed before the ellipsis.
229 static void TEXT_PathEllipsify (HDC hdc, WCHAR *str, unsigned int max_len,
230 unsigned int *len_str, int width, SIZE *size,
231 WCHAR *modstr, ellipsis_data *pellip)
233 int len_ellipsis;
234 int len_trailing;
235 int len_under;
236 WCHAR *lastBkSlash, *lastFwdSlash, *lastSlash;
238 len_ellipsis = strlenW (ELLIPSISW);
239 if (!max_len) return;
240 if (len_ellipsis >= max_len) len_ellipsis = max_len - 1;
241 if (*len_str + len_ellipsis >= max_len)
242 *len_str = max_len - len_ellipsis-1;
243 /* Hopefully this will never happen, otherwise it would probably lose
244 * the wrong character
246 str[*len_str] = '\0'; /* to simplify things */
248 lastBkSlash = strrchrW (str, BACK_SLASH);
249 lastFwdSlash = strrchrW (str, FORWARD_SLASH);
250 lastSlash = lastBkSlash > lastFwdSlash ? lastBkSlash : lastFwdSlash;
251 if (!lastSlash) lastSlash = str;
252 len_trailing = *len_str - (lastSlash - str);
254 /* overlap-safe movement to the right */
255 memmove (lastSlash+len_ellipsis, lastSlash, len_trailing * sizeof(WCHAR));
256 memcpy (lastSlash, ELLIPSISW, len_ellipsis*sizeof(WCHAR));
257 len_trailing += len_ellipsis;
258 /* From this point on lastSlash actually points to the ellipsis in front
259 * of the last slash and len_trailing includes the ellipsis
262 len_under = 0;
263 for ( ; ; )
265 if (!GetTextExtentExPointW (hdc, str, *len_str + len_ellipsis, width,
266 NULL, NULL, size)) break;
268 if (lastSlash == str || size->cx <= width) break;
270 /* overlap-safe movement to the left */
271 memmove (lastSlash-1, lastSlash, len_trailing * sizeof(WCHAR));
272 lastSlash--;
273 len_under++;
275 assert (*len_str);
276 (*len_str)--;
278 pellip->before = lastSlash-str;
279 pellip->len = len_ellipsis;
280 pellip->under = len_under;
281 pellip->after = len_trailing - len_ellipsis;
282 *len_str += len_ellipsis;
284 if (modstr)
286 memcpy(modstr, str, *len_str * sizeof(WCHAR));
287 modstr[*len_str] = '\0';
291 /*********************************************************************
292 * TEXT_WordBreak (static)
294 * Perform wordbreak processing on the given string
296 * Assumes that DT_WORDBREAK has been specified and not all the characters
297 * fit. Note that this function should even be called when the first character
298 * that doesn't fit is known to be a space or tab, so that it can swallow them.
300 * Note that the Windows processing has some strange properties.
301 * 1. If the text is left-justified and there is room for some of the spaces
302 * that follow the last word on the line then those that fit are included on
303 * the line.
304 * 2. If the text is centred or right-justified and there is room for some of
305 * the spaces that follow the last word on the line then all but one of those
306 * that fit are included on the line.
307 * 3. (Reasonable behaviour) If the word breaking causes a space to be the first
308 * character of a new line it will be skipped.
310 * Arguments
311 * hdc [in] The handle to the DC that defines the font.
312 * str [in/out] The string that needs to be broken.
313 * max_str [in] The dimension of str (number of WCHAR).
314 * len_str [in/out] The number of characters in str
315 * width [in] The maximum width permitted
316 * format [in] The format flags in effect
317 * chars_fit [in] The maximum number of characters of str that are already
318 * known to fit; chars_fit+1 is known not to fit.
319 * chars_used [out] The number of characters of str that have been "used" and
320 * do not need to be included in later text. For example this will
321 * include any spaces that have been discarded from the start of
322 * the next line.
323 * size [out] The size of the returned text in logical coordinates
325 * Pedantic assumption - Assumes that the text length is monotonically
326 * increasing with number of characters (i.e. no weird kernings)
328 * Algorithm
330 * Work back from the last character that did fit to either a space or the last
331 * character of a word, whichever is met first.
332 * If there was one or the first character didn't fit then
333 * If the text is centred or right justified and that one character was a
334 * space then break the line before that character
335 * Otherwise break the line after that character
336 * and if the next character is a space then discard it.
337 * Suppose there was none (and the first character did fit).
338 * If Break Within Word is permitted
339 * break the word after the last character that fits (there must be
340 * at least one; none is caught earlier).
341 * Otherwise
342 * discard any trailing space.
343 * include the whole word; it may be ellipsified later
345 * Break Within Word is permitted under a set of circumstances that are not
346 * totally clear yet. Currently our best guess is:
347 * If DT_EDITCONTROL is in effect and neither DT_WORD_ELLIPSIS nor
348 * DT_PATH_ELLIPSIS is
351 static void TEXT_WordBreak (HDC hdc, WCHAR *str, unsigned int max_str,
352 unsigned int *len_str,
353 int width, int format, unsigned int chars_fit,
354 unsigned int *chars_used, SIZE *size)
356 WCHAR *p;
357 int word_fits;
358 assert (format & DT_WORDBREAK);
359 assert (chars_fit < *len_str);
361 /* Work back from the last character that did fit to either a space or the
362 * last character of a word, whichever is met first.
364 p = str + chars_fit; /* The character that doesn't fit */
365 word_fits = TRUE;
366 if (!chars_fit)
367 ; /* we pretend that it fits anyway */
368 else if (*p == SPACE) /* chars_fit < *len_str so this is valid */
369 p--; /* the word just fitted */
370 else
372 while (p > str && *(--p) != SPACE)
374 word_fits = (p != str || *p == SPACE);
376 /* If there was one or the first character didn't fit then */
377 if (word_fits)
379 int next_is_space;
380 /* break the line before/after that character */
381 if (!(format & (DT_RIGHT | DT_CENTER)) || *p != SPACE)
382 p++;
383 next_is_space = (p - str) < *len_str && *p == SPACE;
384 *len_str = p - str;
385 /* and if the next character is a space then discard it. */
386 *chars_used = *len_str;
387 if (next_is_space)
388 (*chars_used)++;
390 /* Suppose there was none. */
391 else
393 if ((format & (DT_EDITCONTROL | DT_WORD_ELLIPSIS | DT_PATH_ELLIPSIS)) ==
394 DT_EDITCONTROL)
396 /* break the word after the last character that fits (there must be
397 * at least one; none is caught earlier).
399 *len_str = chars_fit;
400 *chars_used = chars_fit;
402 /* FIXME - possible error. Since the next character is now removed
403 * this could make the text longer so that it no longer fits, and
404 * so we need a loop to test and shrink.
407 /* Otherwise */
408 else
410 /* discard any trailing space. */
411 const WCHAR *e = str + *len_str;
412 p = str + chars_fit;
413 while (p < e && *p != SPACE)
414 p++;
415 *chars_used = p - str;
416 if (p < e) /* i.e. loop failed because *p == SPACE */
417 (*chars_used)++;
419 /* include the whole word; it may be ellipsified later */
420 *len_str = p - str;
421 /* Possible optimisation; if DT_WORD_ELLIPSIS only use chars_fit+1
422 * so that it will be too long
426 /* Remeasure the string */
427 GetTextExtentExPointW (hdc, str, *len_str, 0, NULL, NULL, size);
430 /*********************************************************************
431 * TEXT_SkipChars
433 * Skip over the given number of characters, bearing in mind prefix
434 * substitution and the fact that a character may take more than one
435 * WCHAR (Unicode surrogates are two words long) (and there may have been
436 * a trailing &)
438 * Parameters
439 * new_count [out] The updated count
440 * new_str [out] The updated pointer
441 * start_count [in] The count of remaining characters corresponding to the
442 * start of the string
443 * start_str [in] The starting point of the string
444 * max [in] The number of characters actually in this segment of the
445 * string (the & counts)
446 * n [in] The number of characters to skip (if prefix then
447 * &c counts as one)
448 * prefix [in] Apply prefix substitution
450 * Return Values
451 * none
453 * Remarks
454 * There must be at least n characters in the string
455 * We need max because the "line" may have ended with a & followed by a tab
456 * or newline etc. which we don't want to swallow
459 static void TEXT_SkipChars (int *new_count, const WCHAR **new_str,
460 int start_count, const WCHAR *start_str,
461 int max, int n, int prefix)
463 /* This is specific to wide characters, MSDN doesn't say anything much
464 * about Unicode surrogates yet and it isn't clear if _wcsinc will
465 * correctly handle them so we'll just do this the easy way for now
468 if (prefix)
470 const WCHAR *str_on_entry = start_str;
471 assert (max >= n);
472 max -= n;
473 while (n--)
475 if (*start_str++ == PREFIX && max--)
476 start_str++;
478 start_count -= (start_str - str_on_entry);
480 else
482 start_str += n;
483 start_count -= n;
485 *new_str = start_str;
486 *new_count = start_count;
489 /*********************************************************************
490 * TEXT_Reprefix
492 * Reanalyse the text to find the prefixed character. This is called when
493 * wordbreaking or ellipsification has shortened the string such that the
494 * previously noted prefixed character is no longer visible.
496 * Parameters
497 * str [in] The original string segment (including all characters)
498 * ns [in] The number of characters in str (including prefixes)
499 * pe [in] The ellipsification data
501 * Return Values
502 * The prefix offset within the new string segment (the one that contains the
503 * ellipses and does not contain the prefix characters) (-1 if none)
506 static int TEXT_Reprefix (const WCHAR *str, unsigned int ns,
507 const ellipsis_data *pe)
509 int result = -1;
510 unsigned int i = 0;
511 unsigned int n = pe->before + pe->under + pe->after;
512 assert (n <= ns);
513 while (i < n)
515 if (i == pe->before)
517 /* Reached the path ellipsis; jump over it */
518 if (ns < pe->under) break;
519 str += pe->under;
520 ns -= pe->under;
521 i += pe->under;
522 if (!pe->after) break; /* Nothing after the path ellipsis */
524 if (!ns) break;
525 ns--;
526 if (*str++ == PREFIX)
528 if (!ns) break;
529 if (*str != PREFIX)
530 result = (i < pe->before || pe->under == 0) ? i : i - pe->under + pe->len;
531 /* pe->len may be non-zero while pe_under is zero */
532 str++;
533 ns--;
535 i++;
537 return result;
540 /*********************************************************************
541 * Returns true if and only if the remainder of the line is a single
542 * newline representation or nothing
545 static int remainder_is_none_or_newline (int num_chars, const WCHAR *str)
547 if (!num_chars) return TRUE;
548 if (*str != LF && *str != CR) return FALSE;
549 if (!--num_chars) return TRUE;
550 if (*str == *(str+1)) return FALSE;
551 str++;
552 if (*str != CR && *str != LF) return FALSE;
553 if (--num_chars) return FALSE;
554 return TRUE;
557 /*********************************************************************
558 * Return next line of text from a string.
560 * hdc - handle to DC.
561 * str - string to parse into lines.
562 * count - length of str.
563 * dest - destination in which to return line.
564 * len - dest buffer size in chars on input, copied length into dest on output.
565 * width - maximum width of line in pixels.
566 * format - format type passed to DrawText.
567 * retsize - returned size of the line in pixels.
568 * last_line - TRUE if is the last line that will be processed
569 * p_retstr - If DT_MODIFYSTRING this points to a cursor in the buffer in which
570 * the return string is built.
571 * tabwidth - The width of a tab in logical coordinates
572 * pprefix_offset - Here is where we return the offset within dest of the first
573 * prefixed (underlined) character. -1 is returned if there
574 * are none. Note that there may be more; the calling code
575 * will need to use TEXT_Reprefix to find any later ones.
576 * pellip - Here is where we return the information about any ellipsification
577 * that was carried out. Note that if tabs are being expanded then
578 * this data will correspond to the last text segment actually
579 * returned in dest; by definition there would not have been any
580 * ellipsification in earlier text segments of the line.
582 * Returns pointer to next char in str after end of the line
583 * or NULL if end of str reached.
585 static const WCHAR *TEXT_NextLineW( HDC hdc, const WCHAR *str, int *count,
586 WCHAR *dest, int *len, int width, DWORD format,
587 SIZE *retsize, int last_line, WCHAR **p_retstr,
588 int tabwidth, int *pprefix_offset,
589 ellipsis_data *pellip)
591 int i = 0, j = 0;
592 int plen = 0;
593 SIZE size;
594 int maxl = *len;
595 int seg_i, seg_count, seg_j;
596 int max_seg_width;
597 int num_fit;
598 int word_broken;
599 int line_fits;
600 unsigned int j_in_seg;
601 int ellipsified;
602 *pprefix_offset = -1;
604 /* For each text segment in the line */
606 retsize->cy = 0;
607 while (*count)
610 /* Skip any leading tabs */
612 if (str[i] == TAB && (format & DT_EXPANDTABS))
614 plen = ((plen/tabwidth)+1)*tabwidth;
615 (*count)--; if (j < maxl) dest[j++] = str[i++]; else i++;
616 while (*count && str[i] == TAB)
618 plen += tabwidth;
619 (*count)--; if (j < maxl) dest[j++] = str[i++]; else i++;
624 /* Now copy as far as the next tab or cr/lf or eos */
626 seg_i = i;
627 seg_count = *count;
628 seg_j = j;
630 while (*count &&
631 (str[i] != TAB || !(format & DT_EXPANDTABS)) &&
632 ((str[i] != CR && str[i] != LF) || (format & DT_SINGLELINE)))
634 if (str[i] == PREFIX && !(format & DT_NOPREFIX) && *count > 1)
636 (*count)--, i++; /* Throw away the prefix itself */
637 if (str[i] == PREFIX)
639 /* Swallow it before we see it again */
640 (*count)--; if (j < maxl) dest[j++] = str[i++]; else i++;
642 else if (*pprefix_offset == -1 || *pprefix_offset >= seg_j)
644 *pprefix_offset = j;
646 /* else the previous prefix was in an earlier segment of the
647 * line; we will leave it to the drawing code to catch this
648 * one.
651 else
653 (*count)--; if (j < maxl) dest[j++] = str[i++]; else i++;
658 /* Measure the whole text segment and possibly WordBreak and
659 * ellipsify it
662 j_in_seg = j - seg_j;
663 max_seg_width = width - plen;
664 GetTextExtentExPointW (hdc, dest + seg_j, j_in_seg, max_seg_width, &num_fit, NULL, &size);
666 /* The Microsoft handling of various combinations of formats is weird.
667 * The following may very easily be incorrect if several formats are
668 * combined, and may differ between versions (to say nothing of the
669 * several bugs in the Microsoft versions).
671 word_broken = 0;
672 line_fits = (num_fit >= j_in_seg);
673 if (!line_fits && (format & DT_WORDBREAK))
675 const WCHAR *s;
676 unsigned int chars_used;
677 TEXT_WordBreak (hdc, dest+seg_j, maxl-seg_j, &j_in_seg,
678 max_seg_width, format, num_fit, &chars_used, &size);
679 line_fits = (size.cx <= max_seg_width);
680 /* and correct the counts */
681 TEXT_SkipChars (count, &s, seg_count, str+seg_i, i-seg_i,
682 chars_used, !(format & DT_NOPREFIX));
683 i = s - str;
684 word_broken = 1;
686 pellip->before = j_in_seg;
687 pellip->under = 0;
688 pellip->after = 0;
689 pellip->len = 0;
690 ellipsified = 0;
691 if (!line_fits && (format & DT_PATH_ELLIPSIS))
693 TEXT_PathEllipsify (hdc, dest + seg_j, maxl-seg_j, &j_in_seg,
694 max_seg_width, &size, *p_retstr, pellip);
695 line_fits = (size.cx <= max_seg_width);
696 ellipsified = 1;
698 /* NB we may end up ellipsifying a word-broken or path_ellipsified
699 * string */
700 if ((!line_fits && (format & DT_WORD_ELLIPSIS)) ||
701 ((format & DT_END_ELLIPSIS) &&
702 ((last_line && *count) ||
703 (remainder_is_none_or_newline (*count, &str[i]) && !line_fits))))
705 int before, len_ellipsis;
706 TEXT_Ellipsify (hdc, dest + seg_j, maxl-seg_j, &j_in_seg,
707 max_seg_width, &size, *p_retstr, &before, &len_ellipsis);
708 if (before > pellip->before)
710 /* We must have done a path ellipsis too */
711 pellip->after = before - pellip->before - pellip->len;
712 /* Leave the len as the length of the first ellipsis */
714 else
716 /* If we are here after a path ellipsification it must be
717 * because even the ellipsis itself didn't fit.
719 assert (pellip->under == 0 && pellip->after == 0);
720 pellip->before = before;
721 pellip->len = len_ellipsis;
722 /* pellip->after remains as zero as does
723 * pellip->under
726 line_fits = (size.cx <= max_seg_width);
727 ellipsified = 1;
729 /* As an optimisation if we have ellipsified and we are expanding
730 * tabs and we haven't reached the end of the line we can skip to it
731 * now rather than going around the loop again.
733 if ((format & DT_EXPANDTABS) && ellipsified)
735 if (format & DT_SINGLELINE)
736 *count = 0;
737 else
739 while ((*count) && str[i] != CR && str[i] != LF)
741 (*count)--, i++;
746 j = seg_j + j_in_seg;
747 if (*pprefix_offset >= seg_j + pellip->before)
749 *pprefix_offset = TEXT_Reprefix (str + seg_i, i - seg_i, pellip);
750 if (*pprefix_offset != -1)
751 *pprefix_offset += seg_j;
754 plen += size.cx;
755 if (size.cy > retsize->cy)
756 retsize->cy = size.cy;
758 if (word_broken)
759 break;
760 else if (!*count)
761 break;
762 else if (str[i] == CR || str[i] == LF)
764 (*count)--, i++;
765 if (*count && (str[i] == CR || str[i] == LF) && str[i] != str[i-1])
767 (*count)--, i++;
769 break;
771 /* else it was a Tab and we go around again */
774 retsize->cx = plen;
775 *len = j;
776 if (*count)
777 return (&str[i]);
778 else
779 return NULL;
783 /***********************************************************************
784 * TEXT_DrawUnderscore
786 * Draw the underline under the prefixed character
788 * Parameters
789 * hdc [in] The handle of the DC for drawing
790 * x [in] The x location of the line segment (logical coordinates)
791 * y [in] The y location of where the underscore should appear
792 * (logical coordinates)
793 * str [in] The text of the line segment
794 * offset [in] The offset of the underscored character within str
795 * rect [in] Clipping rectangle (if not NULL)
798 static void TEXT_DrawUnderscore (HDC hdc, int x, int y, const WCHAR *str, int offset, const RECT *rect)
800 int prefix_x;
801 int prefix_end;
802 SIZE size;
803 HPEN hpen;
804 HPEN oldPen;
806 GetTextExtentPointW (hdc, str, offset, &size);
807 prefix_x = x + size.cx;
808 GetTextExtentPointW (hdc, str, offset+1, &size);
809 prefix_end = x + size.cx - 1;
810 /* The above method may eventually be slightly wrong due to kerning etc. */
812 /* Check for clipping */
813 if (rect){
814 if (prefix_x > rect->right || prefix_end < rect->left || y < rect->top || y > rect->bottom)
815 return; /* Completely outside */
816 /* Partially outside */
817 if (prefix_x < rect->left ) prefix_x = rect->left;
818 if (prefix_end > rect->right) prefix_end = rect->right;
821 hpen = CreatePen (PS_SOLID, 1, GetTextColor (hdc));
822 oldPen = SelectObject (hdc, hpen);
823 MoveToEx (hdc, prefix_x, y, NULL);
824 LineTo (hdc, prefix_end, y);
825 SelectObject (hdc, oldPen);
826 DeleteObject (hpen);
829 /***********************************************************************
830 * DrawTextExW (USER32.@)
832 * The documentation on the extra space required for DT_MODIFYSTRING at MSDN
833 * is not quite complete, especially with regard to \0. We will assume that
834 * the returned string could have a length of up to i_count+3 and also have
835 * a trailing \0 (which would be 4 more than a not-null-terminated string but
836 * 3 more than a null-terminated string). If this is not so then increase
837 * the allowance in DrawTextExA.
839 #define MAX_BUFFER 1024
840 INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
841 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
843 SIZE size;
844 const WCHAR *strPtr;
845 WCHAR *retstr, *p_retstr;
846 size_t size_retstr;
847 WCHAR line[MAX_BUFFER];
848 int len, lh, count=i_count;
849 TEXTMETRICW tm;
850 int lmargin = 0, rmargin = 0;
851 int x = rect->left, y = rect->top;
852 int width = rect->right - rect->left;
853 int max_width = 0;
854 int last_line;
855 int tabwidth /* to keep gcc happy */ = 0;
856 int prefix_offset;
857 ellipsis_data ellip;
859 TRACE("%s, %d, [%s] %08x\n", debugstr_wn (str, count), count,
860 wine_dbgstr_rect(rect), flags);
862 if (dtp) TRACE("Params: iTabLength=%d, iLeftMargin=%d, iRightMargin=%d\n",
863 dtp->iTabLength, dtp->iLeftMargin, dtp->iRightMargin);
865 if (!str) return 0;
867 strPtr = str;
869 if (flags & DT_SINGLELINE)
870 flags &= ~DT_WORDBREAK;
872 GetTextMetricsW(hdc, &tm);
873 if (flags & DT_EXTERNALLEADING)
874 lh = tm.tmHeight + tm.tmExternalLeading;
875 else
876 lh = tm.tmHeight;
878 if (str[0] && count == 0)
879 return lh;
881 if (dtp && dtp->cbSize != sizeof(DRAWTEXTPARAMS))
882 return 0;
884 if (count == -1)
886 count = strlenW(str);
887 if (count == 0)
889 if( flags & DT_CALCRECT)
891 rect->right = rect->left;
892 if( flags & DT_SINGLELINE)
893 rect->bottom = rect->top + lh;
894 else
895 rect->bottom = rect->top;
897 return lh;
901 if (dtp)
903 lmargin = dtp->iLeftMargin * tm.tmAveCharWidth;
904 rmargin = dtp->iRightMargin * tm.tmAveCharWidth;
905 if (!(flags & (DT_CENTER | DT_RIGHT)))
906 x += lmargin;
907 dtp->uiLengthDrawn = 0; /* This param RECEIVES number of chars processed */
910 if (flags & DT_EXPANDTABS)
912 int tabstop = ((flags & DT_TABSTOP) && dtp) ? dtp->iTabLength : 8;
913 tabwidth = tm.tmAveCharWidth * tabstop;
916 if (flags & DT_CALCRECT) flags |= DT_NOCLIP;
918 if (flags & DT_MODIFYSTRING)
920 size_retstr = (count + 4) * sizeof (WCHAR);
921 retstr = HeapAlloc(GetProcessHeap(), 0, size_retstr);
922 if (!retstr) return 0;
923 memcpy (retstr, str, size_retstr);
925 else
927 size_retstr = 0;
928 retstr = NULL;
930 p_retstr = retstr;
934 len = sizeof(line)/sizeof(line[0]);
935 last_line = !(flags & DT_NOCLIP) && y + ((flags & DT_EDITCONTROL) ? 2*lh-1 : lh) > rect->bottom;
936 strPtr = TEXT_NextLineW(hdc, strPtr, &count, line, &len, width, flags, &size, last_line, &p_retstr, tabwidth, &prefix_offset, &ellip);
938 if (flags & DT_CENTER) x = (rect->left + rect->right -
939 size.cx) / 2;
940 else if (flags & DT_RIGHT) x = rect->right - size.cx;
942 if (flags & DT_SINGLELINE)
944 if (flags & DT_VCENTER) y = rect->top +
945 (rect->bottom - rect->top) / 2 - size.cy / 2;
946 else if (flags & DT_BOTTOM) y = rect->bottom - size.cy;
949 if (!(flags & DT_CALCRECT))
951 const WCHAR *str = line;
952 int xseg = x;
953 while (len)
955 int len_seg;
956 SIZE size;
957 if ((flags & DT_EXPANDTABS))
959 const WCHAR *p;
960 p = str; while (p < str+len && *p != TAB) p++;
961 len_seg = p - str;
962 if (len_seg != len && !GetTextExtentPointW(hdc, str, len_seg, &size))
963 return 0;
965 else
966 len_seg = len;
968 if (!ExtTextOutW( hdc, xseg, y,
969 ((flags & DT_NOCLIP) ? 0 : ETO_CLIPPED) |
970 ((flags & DT_RTLREADING) ? ETO_RTLREADING : 0),
971 rect, str, len_seg, NULL )) return 0;
972 if (prefix_offset != -1 && prefix_offset < len_seg)
974 TEXT_DrawUnderscore (hdc, xseg, y + tm.tmAscent + 1, str, prefix_offset, (flags & DT_NOCLIP) ? NULL : rect);
976 len -= len_seg;
977 str += len_seg;
978 if (len)
980 assert ((flags & DT_EXPANDTABS) && *str == TAB);
981 len--; str++;
982 xseg += ((size.cx/tabwidth)+1)*tabwidth;
983 if (prefix_offset != -1)
985 if (prefix_offset < len_seg)
987 /* We have just drawn an underscore; we ought to
988 * figure out where the next one is. I am going
989 * to leave it for now until I have a better model
990 * for the line, which will make reprefixing easier.
991 * This is where ellip would be used.
993 prefix_offset = -1;
995 else
996 prefix_offset -= len_seg;
1001 else if (size.cx > max_width)
1002 max_width = size.cx;
1004 y += lh;
1005 if (dtp)
1006 dtp->uiLengthDrawn += len;
1008 while (strPtr && !last_line);
1010 if (flags & DT_CALCRECT)
1012 rect->right = rect->left + max_width;
1013 rect->bottom = y;
1014 if (dtp)
1015 rect->right += lmargin + rmargin;
1017 if (retstr)
1019 memcpy (str, retstr, size_retstr);
1020 HeapFree (GetProcessHeap(), 0, retstr);
1022 return y - rect->top;
1025 /***********************************************************************
1026 * DrawTextExA (USER32.@)
1028 * If DT_MODIFYSTRING is specified then there must be room for up to
1029 * 4 extra characters. We take great care about just how much modified
1030 * string we return.
1032 INT WINAPI DrawTextExA( HDC hdc, LPSTR str, INT count,
1033 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
1035 WCHAR *wstr;
1036 WCHAR *p;
1037 INT ret = 0;
1038 int i;
1039 DWORD wcount;
1040 DWORD wmax;
1041 DWORD amax;
1042 UINT cp;
1044 if (!count) return 0;
1045 if (!str && count > 0) return 0;
1046 if( !str || ((count == -1) && !(count = strlen(str))))
1048 int lh;
1049 TEXTMETRICA tm;
1051 if (dtp && dtp->cbSize != sizeof(DRAWTEXTPARAMS))
1052 return 0;
1054 GetTextMetricsA(hdc, &tm);
1055 if (flags & DT_EXTERNALLEADING)
1056 lh = tm.tmHeight + tm.tmExternalLeading;
1057 else
1058 lh = tm.tmHeight;
1060 if( flags & DT_CALCRECT)
1062 rect->right = rect->left;
1063 if( flags & DT_SINGLELINE)
1064 rect->bottom = rect->top + lh;
1065 else
1066 rect->bottom = rect->top;
1068 return lh;
1070 cp = GdiGetCodePage( hdc );
1071 wcount = MultiByteToWideChar( cp, 0, str, count, NULL, 0 );
1072 wmax = wcount;
1073 amax = count;
1074 if (flags & DT_MODIFYSTRING)
1076 wmax += 4;
1077 amax += 4;
1079 wstr = HeapAlloc(GetProcessHeap(), 0, wmax * sizeof(WCHAR));
1080 if (wstr)
1082 MultiByteToWideChar( cp, 0, str, count, wstr, wcount );
1083 if (flags & DT_MODIFYSTRING)
1084 for (i=4, p=wstr+wcount; i--; p++) *p=0xFFFE;
1085 /* Initialise the extra characters so that we can see which ones
1086 * change. U+FFFE is guaranteed to be not a unicode character and
1087 * so will not be generated by DrawTextEx itself.
1089 ret = DrawTextExW( hdc, wstr, wcount, rect, flags, dtp );
1090 if (flags & DT_MODIFYSTRING)
1092 /* Unfortunately the returned string may contain multiple \0s
1093 * and so we need to measure it ourselves.
1095 for (i=4, p=wstr+wcount; i-- && *p != 0xFFFE; p++) wcount++;
1096 WideCharToMultiByte( cp, 0, wstr, wcount, str, amax, NULL, NULL );
1098 HeapFree(GetProcessHeap(), 0, wstr);
1100 return ret;
1103 /***********************************************************************
1104 * DrawTextW (USER32.@)
1106 INT WINAPI DrawTextW( HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags )
1108 DRAWTEXTPARAMS dtp;
1110 memset (&dtp, 0, sizeof(dtp));
1111 dtp.cbSize = sizeof(dtp);
1112 if (flags & DT_TABSTOP)
1114 dtp.iTabLength = (flags >> 8) & 0xff;
1115 flags &= 0xffff00ff;
1117 return DrawTextExW(hdc, (LPWSTR)str, count, rect, flags, &dtp);
1120 /***********************************************************************
1121 * DrawTextA (USER32.@)
1123 INT WINAPI DrawTextA( HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags )
1125 DRAWTEXTPARAMS dtp;
1127 memset (&dtp, 0, sizeof(dtp));
1128 dtp.cbSize = sizeof(dtp);
1129 if (flags & DT_TABSTOP)
1131 dtp.iTabLength = (flags >> 8) & 0xff;
1132 flags &= 0xffff00ff;
1134 return DrawTextExA( hdc, (LPSTR)str, count, rect, flags, &dtp );
1137 /***********************************************************************
1139 * GrayString functions
1142 /* callback for ASCII gray string proc */
1143 static BOOL CALLBACK gray_string_callbackA( HDC hdc, LPARAM param, INT len )
1145 return TextOutA( hdc, 0, 0, (LPCSTR)param, len );
1148 /* callback for Unicode gray string proc */
1149 static BOOL CALLBACK gray_string_callbackW( HDC hdc, LPARAM param, INT len )
1151 return TextOutW( hdc, 0, 0, (LPCWSTR)param, len );
1154 /***********************************************************************
1155 * TEXT_GrayString
1157 static BOOL TEXT_GrayString(HDC hdc, HBRUSH hb, GRAYSTRINGPROC fn, LPARAM lp, INT len,
1158 INT x, INT y, INT cx, INT cy )
1160 HBITMAP hbm, hbmsave;
1161 HBRUSH hbsave;
1162 HFONT hfsave;
1163 HDC memdc;
1164 int slen = len;
1165 BOOL retval = TRUE;
1166 COLORREF fg, bg;
1168 if(!hdc) return FALSE;
1169 if (!(memdc = CreateCompatibleDC(hdc))) return FALSE;
1171 hbm = CreateBitmap(cx, cy, 1, 1, NULL);
1172 hbmsave = (HBITMAP)SelectObject(memdc, hbm);
1173 hbsave = SelectObject( memdc, GetStockObject(BLACK_BRUSH) );
1174 PatBlt( memdc, 0, 0, cx, cy, PATCOPY );
1175 SelectObject( memdc, hbsave );
1176 SetTextColor(memdc, RGB(255, 255, 255));
1177 SetBkColor(memdc, RGB(0, 0, 0));
1178 hfsave = (HFONT)SelectObject(memdc, GetCurrentObject(hdc, OBJ_FONT));
1180 retval = fn(memdc, lp, slen);
1181 SelectObject(memdc, hfsave);
1184 * Windows doc says that the bitmap isn't grayed when len == -1 and
1185 * the callback function returns FALSE. However, testing this on
1186 * win95 showed otherwise...
1188 #ifdef GRAYSTRING_USING_DOCUMENTED_BEHAVIOUR
1189 if(retval || len != -1)
1190 #endif
1192 hbsave = (HBRUSH)SelectObject(memdc, SYSCOLOR_55AABrush);
1193 PatBlt(memdc, 0, 0, cx, cy, 0x000A0329);
1194 SelectObject(memdc, hbsave);
1197 if(hb) hbsave = (HBRUSH)SelectObject(hdc, hb);
1198 fg = SetTextColor(hdc, RGB(0, 0, 0));
1199 bg = SetBkColor(hdc, RGB(255, 255, 255));
1200 BitBlt(hdc, x, y, cx, cy, memdc, 0, 0, 0x00E20746);
1201 SetTextColor(hdc, fg);
1202 SetBkColor(hdc, bg);
1203 if(hb) SelectObject(hdc, hbsave);
1205 SelectObject(memdc, hbmsave);
1206 DeleteObject(hbm);
1207 DeleteDC(memdc);
1208 return retval;
1212 /***********************************************************************
1213 * GrayStringA (USER32.@)
1215 BOOL WINAPI GrayStringA( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
1216 LPARAM lParam, INT cch, INT x, INT y,
1217 INT cx, INT cy )
1219 if (!cch) cch = strlen( (LPCSTR)lParam );
1220 if ((cx == 0 || cy == 0) && cch != -1)
1222 SIZE s;
1223 GetTextExtentPoint32A( hdc, (LPCSTR)lParam, cch, &s );
1224 if (cx == 0) cx = s.cx;
1225 if (cy == 0) cy = s.cy;
1227 if (!gsprc) gsprc = gray_string_callbackA;
1228 return TEXT_GrayString( hdc, hbr, gsprc, lParam, cch, x, y, cx, cy );
1232 /***********************************************************************
1233 * GrayStringW (USER32.@)
1235 BOOL WINAPI GrayStringW( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
1236 LPARAM lParam, INT cch, INT x, INT y,
1237 INT cx, INT cy )
1239 if (!cch) cch = strlenW( (LPCWSTR)lParam );
1240 if ((cx == 0 || cy == 0) && cch != -1)
1242 SIZE s;
1243 GetTextExtentPoint32W( hdc, (LPCWSTR)lParam, cch, &s );
1244 if (cx == 0) cx = s.cx;
1245 if (cy == 0) cy = s.cy;
1247 if (!gsprc) gsprc = gray_string_callbackW;
1248 return TEXT_GrayString( hdc, hbr, gsprc, lParam, cch, x, y, cx, cy );
1252 /***********************************************************************
1253 * TEXT_TabbedTextOut
1255 * Helper function for TabbedTextOut() and GetTabbedTextExtent().
1256 * Note: this doesn't work too well for text-alignment modes other
1257 * than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-)
1259 static LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCWSTR lpstr,
1260 INT count, INT cTabStops, const INT *lpTabPos, INT nTabOrg,
1261 BOOL fDisplayText )
1263 INT defWidth;
1264 SIZE extent;
1265 int i, j;
1266 int start = x;
1268 if (!lpTabPos)
1269 cTabStops=0;
1271 if (cTabStops == 1)
1273 defWidth = *lpTabPos;
1274 cTabStops = 0;
1276 else
1278 TEXTMETRICW tm;
1279 GetTextMetricsW( hdc, &tm );
1280 defWidth = 8 * tm.tmAveCharWidth;
1283 while (count > 0)
1285 RECT r;
1286 INT x0;
1287 x0 = x;
1288 r.left = x0;
1289 /* chop the string into substrings of 0 or more <tabs>
1290 * possibly followed by 1 or more normal characters */
1291 for (i = 0; i < count; i++)
1292 if (lpstr[i] != '\t') break;
1293 for (j = i; j < count; j++)
1294 if (lpstr[j] == '\t') break;
1295 /* get the extent of the normal character part */
1296 GetTextExtentPointW( hdc, lpstr + i, j - i , &extent );
1297 /* and if there is a <tab>, calculate its position */
1298 if( i) {
1299 /* get x coordinate for the drawing of this string */
1300 for (; cTabStops >= i; lpTabPos++, cTabStops--)
1302 if( nTabOrg + abs( *lpTabPos) > x) {
1303 if( lpTabPos[ i - 1] >= 0) {
1304 /* a left aligned tab */
1305 x0 = nTabOrg + lpTabPos[i-1];
1306 x = x0 + extent.cx;
1307 break;
1309 else
1311 /* if tab pos is negative then text is right-aligned
1312 * to tab stop meaning that the string extends to the
1313 * left, so we must subtract the width of the string */
1314 if (nTabOrg - lpTabPos[ i - 1] - extent.cx > x)
1316 x = nTabOrg - lpTabPos[ i - 1];
1317 x0 = x - extent.cx;
1318 break;
1323 /* if we have run out of tab stops and we have a valid default tab
1324 * stop width then round x up to that width */
1325 if ((cTabStops < i) && (defWidth > 0)) {
1326 x0 = nTabOrg + ((x - nTabOrg) / defWidth + i) * defWidth;
1327 x = x0 + extent.cx;
1328 } else if ((cTabStops < i) && (defWidth < 0)) {
1329 x = nTabOrg + ((x - nTabOrg + extent.cx) / -defWidth + i)
1330 * -defWidth;
1331 x0 = x - extent.cx;
1333 } else
1334 x += extent.cx;
1336 if (fDisplayText)
1338 r.top = y;
1339 r.right = x;
1340 r.bottom = y + extent.cy;
1341 ExtTextOutW( hdc, x0, y, GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0,
1342 &r, lpstr + i, j - i, NULL );
1344 count -= j;
1345 lpstr += j;
1347 return MAKELONG(x - start, extent.cy);
1351 /***********************************************************************
1352 * TabbedTextOutA (USER32.@)
1354 * See TabbedTextOutW.
1356 LONG WINAPI TabbedTextOutA( HDC hdc, INT x, INT y, LPCSTR lpstr, INT count,
1357 INT cTabStops, const INT *lpTabPos, INT nTabOrg )
1359 LONG ret;
1360 DWORD len = MultiByteToWideChar( CP_ACP, 0, lpstr, count, NULL, 0 );
1361 LPWSTR strW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
1362 if (!strW) return 0;
1363 MultiByteToWideChar( CP_ACP, 0, lpstr, count, strW, len );
1364 ret = TabbedTextOutW( hdc, x, y, strW, len, cTabStops, lpTabPos, nTabOrg );
1365 HeapFree( GetProcessHeap(), 0, strW );
1366 return ret;
1370 /***********************************************************************
1371 * TabbedTextOutW (USER32.@)
1373 * Draws tabbed text aligned using the specified tab stops.
1375 * PARAMS
1376 * hdc [I] Handle to device context to draw to.
1377 * x [I] X co-ordinate to start drawing the text at in logical units.
1378 * y [I] Y co-ordinate to start drawing the text at in logical units.
1379 * str [I] Pointer to the characters to draw.
1380 * count [I] Number of WCHARs pointed to by str.
1381 * cTabStops [I] Number of tab stops pointed to by lpTabPos.
1382 * lpTabPos [I] Tab stops in logical units. Should be sorted in ascending order.
1383 * nTabOrg [I] Starting position to expand tabs from in logical units.
1385 * RETURNS
1386 * The dimensions of the string drawn. The height is in the high-order word
1387 * and the width is in the low-order word.
1389 * NOTES
1390 * The tabs stops can be negative, in which case the text is right aligned to
1391 * that tab stop and, despite what MSDN says, this is supported on
1392 * Windows XP SP2.
1394 * BUGS
1395 * MSDN says that the TA_UPDATECP from GetTextAlign causes this function to
1396 * ignore the x and y co-ordinates, but this is unimplemented at the moment.
1398 LONG WINAPI TabbedTextOutW( HDC hdc, INT x, INT y, LPCWSTR str, INT count,
1399 INT cTabStops, const INT *lpTabPos, INT nTabOrg )
1401 TRACE("%p %d,%d %s %d\n", hdc, x, y, debugstr_wn(str,count), count );
1402 return TEXT_TabbedTextOut( hdc, x, y, str, count, cTabStops, lpTabPos, nTabOrg, TRUE );
1406 /***********************************************************************
1407 * GetTabbedTextExtentA (USER32.@)
1409 DWORD WINAPI GetTabbedTextExtentA( HDC hdc, LPCSTR lpstr, INT count,
1410 INT cTabStops, const INT *lpTabPos )
1412 LONG ret;
1413 DWORD len = MultiByteToWideChar( CP_ACP, 0, lpstr, count, NULL, 0 );
1414 LPWSTR strW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
1415 if (!strW) return 0;
1416 MultiByteToWideChar( CP_ACP, 0, lpstr, count, strW, len );
1417 ret = GetTabbedTextExtentW( hdc, strW, len, cTabStops, lpTabPos );
1418 HeapFree( GetProcessHeap(), 0, strW );
1419 return ret;
1423 /***********************************************************************
1424 * GetTabbedTextExtentW (USER32.@)
1426 DWORD WINAPI GetTabbedTextExtentW( HDC hdc, LPCWSTR lpstr, INT count,
1427 INT cTabStops, const INT *lpTabPos )
1429 TRACE("%p %s %d\n", hdc, debugstr_wn(lpstr,count), count );
1430 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops, lpTabPos, 0, FALSE );