Move the implementation of comctl32._TrackMouseEvent to
[wine.git] / dlls / user / text.c
blob3e1e3ef566542531958c7c1b8b793d00f7a1482f
1 /*
2 * USER text functions
4 * Copyright 1993, 1994 Alexandre Julliard
6 * Contains
7 * 1. DrawText functions
8 * 2. GrayString functions
9 * 3. TabbedText functions
12 #include <string.h>
14 #include "windef.h"
15 #include "wingdi.h"
16 #include "wine/winuser16.h"
17 #include "wine/unicode.h"
18 #include "winbase.h"
19 #include "winerror.h"
20 #include "winnls.h"
21 #include "user.h"
22 #include "debugtools.h"
24 DEFAULT_DEBUG_CHANNEL(text);
26 /*********************************************************************
28 * DrawText functions
31 #define TAB 9
32 #define LF 10
33 #define CR 13
34 #define SPACE 32
35 #define PREFIX 38
37 #define ELLIPSIS "..."
38 #define FORWARD_SLASH '/'
39 #define BACK_SLASH '\\'
41 static const WCHAR SPACEW[] = {' ', 0};
42 static const WCHAR oW[] = {'o', 0};
43 static const WCHAR ELLIPSISW[] = {'.','.','.', 0};
44 static const WCHAR FORWARD_SLASHW[] = {'/', 0};
45 static const WCHAR BACK_SLASHW[] = {'\\', 0};
47 static int tabstop;
48 static int tabwidth;
49 static int spacewidth;
50 static int prefix_offset;
53 /*********************************************************************
54 * Return next line of text from a string.
56 * hdc - handle to DC.
57 * str - string to parse into lines.
58 * count - length of str.
59 * dest - destination in which to return line.
60 * len - dest buffer size in chars on input, copied length into dest on output.
61 * width - maximum width of line in pixels.
62 * format - format type passed to DrawText.
64 * Returns pointer to next char in str after end of the line
65 * or NULL if end of str reached.
67 * FIXME:
68 * GetTextExtentPoint is used to get the width of each character,
69 * rather than GetCharABCWidth... So the whitespace between
70 * characters is ignored, and the reported len is too great.
72 static const WCHAR *TEXT_NextLineW( HDC hdc, const WCHAR *str, int *count,
73 WCHAR *dest, int *len, int width, WORD format)
75 int i = 0, j = 0, k;
76 int plen = 0;
77 int numspaces;
78 SIZE size;
79 int lasttab = 0;
80 int wb_i = 0, wb_j = 0, wb_count = 0;
81 int maxl = *len;
83 while (*count && j < maxl)
85 switch (str[i])
87 case CR:
88 case LF:
89 if (!(format & DT_SINGLELINE))
91 if ((*count > 1) && (str[i] == CR) && (str[i+1] == LF))
93 (*count)--;
94 i++;
96 i++;
97 *len = j;
98 (*count)--;
99 return (&str[i]);
101 dest[j++] = str[i++];
102 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
103 (format & DT_WORDBREAK))
105 if (!GetTextExtentPointW(hdc, &dest[j-1], 1, &size))
106 return NULL;
107 plen += size.cx;
109 break;
111 case PREFIX:
112 if (!(format & DT_NOPREFIX) && *count > 1)
114 if (str[++i] == PREFIX)
115 (*count)--;
116 else {
117 prefix_offset = j;
118 break;
121 dest[j++] = str[i++];
122 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
123 (format & DT_WORDBREAK))
125 if (!GetTextExtentPointW(hdc, &dest[j-1], 1, &size))
126 return NULL;
127 plen += size.cx;
129 break;
131 case TAB:
132 if (format & DT_EXPANDTABS)
134 wb_i = ++i;
135 wb_j = j;
136 wb_count = *count;
138 if (!GetTextExtentPointW(hdc, &dest[lasttab], j - lasttab, &size))
139 return NULL;
141 numspaces = (tabwidth - size.cx) / spacewidth;
142 for (k = 0; k < numspaces; k++)
143 dest[j++] = SPACE;
144 plen += tabwidth - size.cx;
145 lasttab = wb_j + numspaces;
147 else
149 dest[j++] = str[i++];
150 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
151 (format & DT_WORDBREAK))
153 if (!GetTextExtentPointW(hdc, &dest[j-1], 1, &size))
154 return NULL;
155 plen += size.cx;
158 break;
160 case SPACE:
161 dest[j++] = str[i++];
162 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
163 (format & DT_WORDBREAK))
165 wb_i = i;
166 wb_j = j - 1;
167 wb_count = *count;
168 if (!GetTextExtentPointW(hdc, &dest[j-1], 1, &size))
169 return NULL;
170 plen += size.cx;
172 break;
174 default:
175 dest[j++] = str[i++];
176 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
177 (format & DT_WORDBREAK))
179 if (!GetTextExtentPointW(hdc, &dest[j-1], 1, &size))
180 return NULL;
181 plen += size.cx;
185 (*count)--;
186 if (!(format & DT_NOCLIP) || (format & DT_WORDBREAK))
188 if (plen > width)
190 if (format & DT_WORDBREAK)
192 if (wb_j)
194 *len = wb_j;
195 *count = wb_count - 1;
196 return (&str[wb_i]);
199 else
201 *len = j;
202 return (&str[i]);
208 *len = j;
209 return NULL;
213 /***********************************************************************
214 * DrawTextExW (USER32.@)
216 #define MAX_STATIC_BUFFER 1024
217 INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
218 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
220 SIZE size;
221 const WCHAR *strPtr;
222 static WCHAR line[MAX_STATIC_BUFFER];
223 int len, lh, count=i_count;
224 int prefix_x = 0;
225 int prefix_end = 0;
226 TEXTMETRICW tm;
227 int lmargin = 0, rmargin = 0;
228 int x = rect->left, y = rect->top;
229 int width = rect->right - rect->left;
230 int max_width = 0;
232 TRACE("%s, %d , [(%d,%d),(%d,%d)]\n", debugstr_wn (str, count), count,
233 rect->left, rect->top, rect->right, rect->bottom);
235 if (dtp) TRACE("Params: iTabLength=%d, iLeftMargin=%d, iRightMargin=%d\n",
236 dtp->iTabLength, dtp->iLeftMargin, dtp->iRightMargin);
238 if (!str) return 0;
239 if (count == -1) count = strlenW(str);
240 if (count == 0) return 0;
241 strPtr = str;
243 GetTextMetricsW(hdc, &tm);
244 if (flags & DT_EXTERNALLEADING)
245 lh = tm.tmHeight + tm.tmExternalLeading;
246 else
247 lh = tm.tmHeight;
249 if (dtp)
251 lmargin = dtp->iLeftMargin * tm.tmAveCharWidth;
252 rmargin = dtp->iRightMargin * tm.tmAveCharWidth;
253 if (!(flags & (DT_CENTER | DT_RIGHT)))
254 x += lmargin;
255 dtp->uiLengthDrawn = 0; /* This param RECEIVES number of chars processed */
258 tabstop = ((flags & DT_TABSTOP) && dtp) ? dtp->iTabLength : 8;
260 if (flags & DT_EXPANDTABS)
262 GetTextExtentPointW(hdc, SPACEW, 1, &size);
263 spacewidth = size.cx;
264 GetTextExtentPointW(hdc, oW, 1, &size);
265 tabwidth = size.cx * tabstop;
268 if (flags & DT_CALCRECT) flags |= DT_NOCLIP;
272 prefix_offset = -1;
273 len = MAX_STATIC_BUFFER;
274 strPtr = TEXT_NextLineW(hdc, strPtr, &count, line, &len, width, flags);
276 if (prefix_offset != -1)
278 GetTextExtentPointW(hdc, line, prefix_offset, &size);
279 prefix_x = size.cx;
280 GetTextExtentPointW(hdc, line, prefix_offset + 1, &size);
281 prefix_end = size.cx - 1;
284 if (!GetTextExtentPointW(hdc, line, len, &size)) return 0;
285 if (flags & DT_CENTER) x = (rect->left + rect->right -
286 size.cx) / 2;
287 else if (flags & DT_RIGHT) x = rect->right - size.cx;
289 if (flags & DT_SINGLELINE)
291 if (flags & DT_VCENTER) y = rect->top +
292 (rect->bottom - rect->top) / 2 - size.cy / 2;
293 else if (flags & DT_BOTTOM) y = rect->bottom - size.cy;
295 if (flags & (DT_PATH_ELLIPSIS | DT_END_ELLIPSIS | DT_WORD_ELLIPSIS))
297 WCHAR swapStr[sizeof(line)];
298 WCHAR* fnameDelim = NULL;
299 int totalLen = i_count >= 0 ? i_count : strlenW(str);
301 if (size.cx > width)
303 int fnameLen = totalLen;
305 /* allow room for '...' */
306 count = min(totalLen+3, sizeof(line)-3);
308 if (flags & DT_WORD_ELLIPSIS)
309 flags |= DT_WORDBREAK;
311 if (flags & DT_PATH_ELLIPSIS)
313 WCHAR* lastBkSlash = NULL;
314 WCHAR* lastFwdSlash = NULL;
315 strncpyW(line, str, totalLen);
316 line[totalLen] = '\0';
317 lastBkSlash = strrchrW(line, BACK_SLASHW[0]);
318 lastFwdSlash = strrchrW(line, FORWARD_SLASHW[0]);
319 fnameDelim = lastBkSlash > lastFwdSlash ? lastBkSlash : lastFwdSlash;
321 if (fnameDelim)
322 fnameLen = &line[totalLen] - fnameDelim;
323 else
324 fnameDelim = (WCHAR*)str;
326 strcpyW(swapStr, ELLIPSISW);
327 strncpyW(swapStr+strlenW(swapStr), fnameDelim, fnameLen);
328 swapStr[fnameLen+3] = '\0';
329 strncpyW(swapStr+strlenW(swapStr), str, totalLen - fnameLen);
330 swapStr[totalLen+3] = '\0';
332 else /* DT_END_ELLIPSIS | DT_WORD_ELLIPSIS */
334 strcpyW(swapStr, ELLIPSISW);
335 strncpyW(swapStr+strlenW(swapStr), str, totalLen);
338 len = MAX_STATIC_BUFFER;
339 TEXT_NextLineW(hdc, swapStr, &count, line, &len, width, flags);
341 /* if only the ELLIPSIS will fit, just let it be clipped */
342 len = max(3, len);
343 GetTextExtentPointW(hdc, line, len, &size);
345 /* FIXME:
346 * NextLine uses GetTextExtentPoint for each character,
347 * rather than GetCharABCWidth... So the whitespace between
348 * characters is ignored in the width measurement, and the
349 * reported len is too great. To compensate, we must get
350 * the width of the entire line and adjust len accordingly.
352 while ((size.cx > width) && (len > 3))
354 line[--len] = '\0';
355 GetTextExtentPointW(hdc, line, len, &size);
358 if (fnameLen < len-3) /* some of the path will fit */
360 /* put the ELLIPSIS between the path and filename */
361 strncpyW(swapStr, &line[fnameLen+3], len-3-fnameLen);
362 swapStr[len-3-fnameLen] = '\0';
363 strcatW(swapStr, ELLIPSISW);
364 strncpyW(swapStr+strlenW(swapStr), &line[3], fnameLen);
366 else
368 /* move the ELLIPSIS to the end */
369 strncpyW(swapStr, &line[3], len-3);
370 swapStr[len-3] = '\0';
371 strcpyW(swapStr+strlenW(swapStr), ELLIPSISW);
374 strncpyW(line, swapStr, len);
375 line[len] = '\0';
376 strPtr = NULL;
378 if (flags & DT_MODIFYSTRING)
379 strcpyW(str, swapStr);
382 if (!(flags & DT_CALCRECT))
384 if (!ExtTextOutW( hdc, x, y,
385 ((flags & DT_NOCLIP) ? 0 : ETO_CLIPPED) |
386 ((flags & DT_RTLREADING) ? ETO_RTLREADING : 0),
387 rect, line, len, NULL )) return 0;
388 if (prefix_offset != -1)
390 HPEN hpen = CreatePen( PS_SOLID, 1, GetTextColor(hdc) );
391 HPEN oldPen = SelectObject( hdc, hpen );
392 MoveToEx(hdc, x + prefix_x, y + tm.tmAscent + 1, NULL );
393 LineTo(hdc, x + prefix_end + 1, y + tm.tmAscent + 1 );
394 SelectObject( hdc, oldPen );
395 DeleteObject( hpen );
398 else if (size.cx > max_width)
399 max_width = size.cx;
401 y += lh;
402 if (strPtr)
404 if (!(flags & DT_NOCLIP))
406 if (y > rect->bottom - lh)
407 break;
410 if (dtp)
411 dtp->uiLengthDrawn += len;
413 while (strPtr);
415 if (flags & DT_CALCRECT)
417 rect->right = rect->left + max_width;
418 rect->bottom = y;
419 if (dtp)
420 rect->right += lmargin + rmargin;
422 return y - rect->top;
425 /***********************************************************************
426 * DrawTextExA (USER32.@)
428 INT WINAPI DrawTextExA( HDC hdc, LPSTR str, INT count,
429 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
431 WCHAR *wstr;
432 INT ret = 0;
433 DWORD wcount;
435 if (count == -1) count = strlen(str);
436 if (!count) return 0;
437 wcount = MultiByteToWideChar( CP_ACP, 0, str, count, NULL, 0 );
438 wstr = HeapAlloc(GetProcessHeap(), 0, wcount * sizeof(WCHAR));
439 if (wstr)
441 MultiByteToWideChar( CP_ACP, 0, str, count, wstr, wcount );
442 ret = DrawTextExW( hdc, wstr, wcount, rect, flags, NULL );
443 if (flags & DT_MODIFYSTRING)
444 WideCharToMultiByte( CP_ACP, 0, wstr, -1, str, count, NULL, NULL );
445 HeapFree(GetProcessHeap(), 0, wstr);
447 return ret;
450 /***********************************************************************
451 * DrawTextW (USER32.@)
453 INT WINAPI DrawTextW( HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags )
455 DRAWTEXTPARAMS dtp;
457 memset (&dtp, 0, sizeof(dtp));
458 if (flags & DT_TABSTOP)
460 dtp.iTabLength = (flags >> 8) && 0xff;
461 flags &= 0xffff00ff;
463 return DrawTextExW(hdc, (LPWSTR)str, count, rect, flags, &dtp);
466 /***********************************************************************
467 * DrawTextA (USER32.@)
469 INT WINAPI DrawTextA( HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags )
471 DRAWTEXTPARAMS dtp;
473 memset (&dtp, 0, sizeof(dtp));
474 if (flags & DT_TABSTOP)
476 dtp.iTabLength = (flags >> 8) && 0xff;
477 flags &= 0xffff00ff;
479 return DrawTextExA( hdc, (LPSTR)str, count, rect, flags, &dtp );
482 /***********************************************************************
483 * DrawText (USER.85)
485 INT16 WINAPI DrawText16( HDC16 hdc, LPCSTR str, INT16 count, LPRECT16 rect, UINT16 flags )
487 INT16 ret;
489 if (rect)
491 RECT rect32;
492 CONV_RECT16TO32( rect, &rect32 );
493 ret = DrawTextA( hdc, str, count, &rect32, flags );
494 CONV_RECT32TO16( &rect32, rect );
496 else ret = DrawTextA( hdc, str, count, NULL, flags);
497 return ret;
501 /***********************************************************************
503 * GrayString functions
506 /* ### start build ### */
507 extern WORD CALLBACK TEXT_CallTo16_word_wlw(GRAYSTRINGPROC16,WORD,LONG,WORD);
508 /* ### stop build ### */
510 struct gray_string_info
512 GRAYSTRINGPROC16 proc;
513 LPARAM param;
516 /* callback for 16-bit gray string proc */
517 static BOOL CALLBACK gray_string_callback( HDC hdc, LPARAM param, INT len )
519 const struct gray_string_info *info = (struct gray_string_info *)param;
520 return TEXT_CallTo16_word_wlw( info->proc, hdc, info->param, len );
523 /***********************************************************************
524 * TEXT_GrayString
526 * FIXME: The call to 16-bit code only works because the wine GDI is a 16-bit
527 * heap and we can guarantee that the handles fit in an INT16. We have to
528 * rethink the strategy once the migration to NT handles is complete.
529 * We are going to get a lot of code-duplication once this migration is
530 * completed...
533 static BOOL TEXT_GrayString(HDC hdc, HBRUSH hb, GRAYSTRINGPROC fn, LPARAM lp, INT len,
534 INT x, INT y, INT cx, INT cy, BOOL unicode, BOOL _32bit)
536 HBITMAP hbm, hbmsave;
537 HBRUSH hbsave;
538 HFONT hfsave;
539 HDC memdc;
540 int slen = len;
541 BOOL retval = TRUE;
542 COLORREF fg, bg;
544 if(!hdc) return FALSE;
545 if (!(memdc = CreateCompatibleDC(hdc))) return FALSE;
547 if(len == 0)
549 if(unicode)
550 slen = lstrlenW((LPCWSTR)lp);
551 else if(_32bit)
552 slen = strlen((LPCSTR)lp);
553 else
554 slen = strlen(MapSL(lp));
557 if((cx == 0 || cy == 0) && slen != -1)
559 SIZE s;
560 if(unicode)
561 GetTextExtentPoint32W(hdc, (LPCWSTR)lp, slen, &s);
562 else if(_32bit)
563 GetTextExtentPoint32A(hdc, (LPCSTR)lp, slen, &s);
564 else
565 GetTextExtentPoint32A(hdc, MapSL(lp), slen, &s);
566 if(cx == 0) cx = s.cx;
567 if(cy == 0) cy = s.cy;
570 hbm = CreateBitmap(cx, cy, 1, 1, NULL);
571 hbmsave = (HBITMAP)SelectObject(memdc, hbm);
572 hbsave = SelectObject( memdc, GetStockObject(BLACK_BRUSH) );
573 PatBlt( memdc, 0, 0, cx, cy, PATCOPY );
574 SelectObject( memdc, hbsave );
575 SetTextColor(memdc, RGB(255, 255, 255));
576 SetBkColor(memdc, RGB(0, 0, 0));
577 hfsave = (HFONT)SelectObject(memdc, GetCurrentObject(hdc, OBJ_FONT));
579 if(fn)
581 if(_32bit)
582 retval = fn(memdc, lp, slen);
583 else
584 retval = (BOOL)((BOOL16)((GRAYSTRINGPROC16)fn)((HDC16)memdc, lp, (INT16)slen));
586 else
588 if(unicode)
589 TextOutW(memdc, 0, 0, (LPCWSTR)lp, slen);
590 else if(_32bit)
591 TextOutA(memdc, 0, 0, (LPCSTR)lp, slen);
592 else
593 TextOutA(memdc, 0, 0, MapSL(lp), slen);
596 SelectObject(memdc, hfsave);
599 * Windows doc says that the bitmap isn't grayed when len == -1 and
600 * the callback function returns FALSE. However, testing this on
601 * win95 showed otherwise...
603 #ifdef GRAYSTRING_USING_DOCUMENTED_BEHAVIOUR
604 if(retval || len != -1)
605 #endif
607 hbsave = (HBRUSH)SelectObject(memdc, CACHE_GetPattern55AABrush());
608 PatBlt(memdc, 0, 0, cx, cy, 0x000A0329);
609 SelectObject(memdc, hbsave);
612 if(hb) hbsave = (HBRUSH)SelectObject(hdc, hb);
613 fg = SetTextColor(hdc, RGB(0, 0, 0));
614 bg = SetBkColor(hdc, RGB(255, 255, 255));
615 BitBlt(hdc, x, y, cx, cy, memdc, 0, 0, 0x00E20746);
616 SetTextColor(hdc, fg);
617 SetBkColor(hdc, bg);
618 if(hb) SelectObject(hdc, hbsave);
620 SelectObject(memdc, hbmsave);
621 DeleteObject(hbm);
622 DeleteDC(memdc);
623 return retval;
627 /***********************************************************************
628 * GrayString (USER.185)
630 BOOL16 WINAPI GrayString16( HDC16 hdc, HBRUSH16 hbr, GRAYSTRINGPROC16 gsprc,
631 LPARAM lParam, INT16 cch, INT16 x, INT16 y,
632 INT16 cx, INT16 cy )
634 struct gray_string_info info;
636 if (!gsprc) return TEXT_GrayString(hdc, hbr, NULL, lParam, cch, x, y, cx, cy, FALSE, FALSE);
637 info.proc = gsprc;
638 info.param = lParam;
639 return TEXT_GrayString( hdc, hbr, gray_string_callback, (LPARAM)&info,
640 cch, x, y, cx, cy, FALSE, FALSE);
644 /***********************************************************************
645 * GrayStringA (USER32.@)
647 BOOL WINAPI GrayStringA( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
648 LPARAM lParam, INT cch, INT x, INT y,
649 INT cx, INT cy )
651 return TEXT_GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy,
652 FALSE, TRUE);
656 /***********************************************************************
657 * GrayStringW (USER32.@)
659 BOOL WINAPI GrayStringW( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
660 LPARAM lParam, INT cch, INT x, INT y,
661 INT cx, INT cy )
663 return TEXT_GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy,
664 TRUE, TRUE);
667 /***********************************************************************
669 * TabbedText functions
672 /***********************************************************************
673 * TEXT_TabbedTextOut
675 * Helper function for TabbedTextOut() and GetTabbedTextExtent().
676 * Note: this doesn't work too well for text-alignment modes other
677 * than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-)
679 static LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCSTR lpstr,
680 INT count, INT cTabStops, const INT16 *lpTabPos16,
681 const INT *lpTabPos32, INT nTabOrg,
682 BOOL fDisplayText )
684 INT defWidth;
685 SIZE extent;
686 int i, tabPos = x;
687 int start = x;
689 extent.cx = 0;
690 extent.cy = 0;
692 if (cTabStops == 1)
694 defWidth = lpTabPos32 ? *lpTabPos32 : *lpTabPos16;
695 cTabStops = 0;
697 else
699 TEXTMETRICA tm;
700 GetTextMetricsA( hdc, &tm );
701 defWidth = 8 * tm.tmAveCharWidth;
704 while (count > 0)
706 for (i = 0; i < count; i++)
707 if (lpstr[i] == '\t') break;
708 GetTextExtentPointA( hdc, lpstr, i, &extent );
709 if (lpTabPos32)
711 while ((cTabStops > 0) &&
712 (nTabOrg + *lpTabPos32 <= x + extent.cx))
714 lpTabPos32++;
715 cTabStops--;
718 else
720 while ((cTabStops > 0) &&
721 (nTabOrg + *lpTabPos16 <= x + extent.cx))
723 lpTabPos16++;
724 cTabStops--;
727 if (i == count)
728 tabPos = x + extent.cx;
729 else if (cTabStops > 0)
730 tabPos = nTabOrg + (lpTabPos32 ? *lpTabPos32 : *lpTabPos16);
731 else
732 tabPos = nTabOrg + ((x + extent.cx - nTabOrg) / defWidth + 1) * defWidth;
733 if (fDisplayText)
735 RECT r;
736 r.left = x;
737 r.top = y;
738 r.right = tabPos;
739 r.bottom = y + extent.cy;
740 ExtTextOutA( hdc, x, y,
741 GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0,
742 &r, lpstr, i, NULL );
744 x = tabPos;
745 count -= i+1;
746 lpstr += i+1;
748 return MAKELONG(tabPos - start, extent.cy);
752 /***********************************************************************
753 * TabbedTextOut (USER.196)
755 LONG WINAPI TabbedTextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR lpstr,
756 INT16 count, INT16 cTabStops,
757 const INT16 *lpTabPos, INT16 nTabOrg )
759 TRACE("%04x %d,%d %s %d\n", hdc, x, y, debugstr_an(lpstr,count), count );
760 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
761 lpTabPos, NULL, nTabOrg, TRUE );
765 /***********************************************************************
766 * TabbedTextOutA (USER32.@)
768 LONG WINAPI TabbedTextOutA( HDC hdc, INT x, INT y, LPCSTR lpstr, INT count,
769 INT cTabStops, const INT *lpTabPos, INT nTabOrg )
771 TRACE("%04x %d,%d %s %d\n", hdc, x, y, debugstr_an(lpstr,count), count );
772 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
773 NULL, lpTabPos, nTabOrg, TRUE );
777 /***********************************************************************
778 * TabbedTextOutW (USER32.@)
780 LONG WINAPI TabbedTextOutW( HDC hdc, INT x, INT y, LPCWSTR str, INT count,
781 INT cTabStops, const INT *lpTabPos, INT nTabOrg )
783 LONG ret;
784 LPSTR p;
785 INT acount;
786 UINT codepage = CP_ACP; /* FIXME: get codepage of font charset */
788 acount = WideCharToMultiByte(codepage,0,str,count,NULL,0,NULL,NULL);
789 p = HeapAlloc( GetProcessHeap(), 0, acount );
790 if(p == NULL) return 0; /* FIXME: is this the correct return on failure */
791 acount = WideCharToMultiByte(codepage,0,str,count,p,acount,NULL,NULL);
792 ret = TabbedTextOutA( hdc, x, y, p, acount, cTabStops, lpTabPos, nTabOrg );
793 HeapFree( GetProcessHeap(), 0, p );
794 return ret;
798 /***********************************************************************
799 * GetTabbedTextExtent (USER.197)
801 DWORD WINAPI GetTabbedTextExtent16( HDC16 hdc, LPCSTR lpstr, INT16 count,
802 INT16 cTabStops, const INT16 *lpTabPos )
804 TRACE("%04x %s %d\n", hdc, debugstr_an(lpstr,count), count );
805 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
806 lpTabPos, NULL, 0, FALSE );
810 /***********************************************************************
811 * GetTabbedTextExtentA (USER32.@)
813 DWORD WINAPI GetTabbedTextExtentA( HDC hdc, LPCSTR lpstr, INT count,
814 INT cTabStops, const INT *lpTabPos )
816 TRACE("%04x %s %d\n", hdc, debugstr_an(lpstr,count), count );
817 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
818 NULL, lpTabPos, 0, FALSE );
822 /***********************************************************************
823 * GetTabbedTextExtentW (USER32.@)
825 DWORD WINAPI GetTabbedTextExtentW( HDC hdc, LPCWSTR lpstr, INT count,
826 INT cTabStops, const INT *lpTabPos )
828 LONG ret;
829 LPSTR p;
830 INT acount;
831 UINT codepage = CP_ACP; /* FIXME: get codepage of font charset */
833 acount = WideCharToMultiByte(codepage,0,lpstr,count,NULL,0,NULL,NULL);
834 p = HeapAlloc( GetProcessHeap(), 0, acount );
835 if(p == NULL) return 0; /* FIXME: is this the correct failure value? */
836 acount = WideCharToMultiByte(codepage,0,lpstr,count,p,acount,NULL,NULL);
837 ret = GetTabbedTextExtentA( hdc, p, acount, cTabStops, lpTabPos );
838 HeapFree( GetProcessHeap(), 0, p );
839 return ret;