Documentation ordinal fixes.
[wine/hacks.git] / dlls / user / text.c
blobc4c7a6d49f44edb967072b4be68ec7823512c670
1 /*
2 * USER text functions
4 * Copyright 1993, 1994 Alexandre Julliard
6 */
8 #include <string.h>
10 #include "windef.h"
11 #include "wingdi.h"
12 #include "wine/winuser16.h"
13 #include "wine/unicode.h"
14 #include "winbase.h"
15 #include "winerror.h"
16 #include "winnls.h"
17 #include "user.h"
18 #include "debugtools.h"
20 DEFAULT_DEBUG_CHANNEL(text);
22 #define TAB 9
23 #define LF 10
24 #define CR 13
25 #define SPACE 32
26 #define PREFIX 38
28 #define ELLIPSIS "..."
29 #define FORWARD_SLASH '/'
30 #define BACK_SLASH '\\'
32 static const WCHAR SPACEW[] = {' ', 0};
33 static const WCHAR oW[] = {'o', 0};
34 static const WCHAR ELLIPSISW[] = {'.','.','.', 0};
35 static const WCHAR FORWARD_SLASHW[] = {'/', 0};
36 static const WCHAR BACK_SLASHW[] = {'\\', 0};
38 #define SWAP_INT(a,b) { int t = a; a = b; b = t; }
40 static int tabstop = 8;
41 static int tabwidth;
42 static int spacewidth;
43 static int prefix_offset;
45 /*********************************************************************
46 * Return next line of text from a string.
48 * hdc - handle to DC.
49 * str - string to parse into lines.
50 * count - length of str.
51 * dest - destination in which to return line.
52 * len - dest buffer size in chars on input, copied length into dest on output.
53 * width - maximum width of line in pixels.
54 * format - format type passed to DrawText.
56 * Returns pointer to next char in str after end of the line
57 * or NULL if end of str reached.
59 * FIXME:
60 * GetTextExtentPoint is used to get the width of each character,
61 * rather than GetCharABCWidth... So the whitespace between
62 * characters is ignored, and the reported len is too great.
64 static const WCHAR *TEXT_NextLineW( HDC hdc, const WCHAR *str, int *count,
65 WCHAR *dest, int *len, int width, WORD format)
67 int i = 0, j = 0, k;
68 int plen = 0;
69 int numspaces;
70 SIZE size;
71 int lasttab = 0;
72 int wb_i = 0, wb_j = 0, wb_count = 0;
73 int maxl = *len;
75 while (*count && j < maxl)
77 switch (str[i])
79 case CR:
80 case LF:
81 if (!(format & DT_SINGLELINE))
83 if ((*count > 1) && (str[i] == CR) && (str[i+1] == LF))
85 (*count)--;
86 i++;
88 i++;
89 *len = j;
90 (*count)--;
91 return (&str[i]);
93 dest[j++] = str[i++];
94 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
95 (format & DT_WORDBREAK))
97 if (!GetTextExtentPointW(hdc, &dest[j-1], 1, &size))
98 return NULL;
99 plen += size.cx;
101 break;
103 case PREFIX:
104 if (!(format & DT_NOPREFIX) && *count > 1)
106 if (str[++i] == PREFIX)
107 (*count)--;
108 else {
109 prefix_offset = j;
110 break;
113 dest[j++] = str[i++];
114 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
115 (format & DT_WORDBREAK))
117 if (!GetTextExtentPointW(hdc, &dest[j-1], 1, &size))
118 return NULL;
119 plen += size.cx;
121 break;
123 case TAB:
124 if (format & DT_EXPANDTABS)
126 wb_i = ++i;
127 wb_j = j;
128 wb_count = *count;
130 if (!GetTextExtentPointW(hdc, &dest[lasttab], j - lasttab, &size))
131 return NULL;
133 numspaces = (tabwidth - size.cx) / spacewidth;
134 for (k = 0; k < numspaces; k++)
135 dest[j++] = SPACE;
136 plen += tabwidth - size.cx;
137 lasttab = wb_j + numspaces;
139 else
141 dest[j++] = str[i++];
142 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
143 (format & DT_WORDBREAK))
145 if (!GetTextExtentPointW(hdc, &dest[j-1], 1, &size))
146 return NULL;
147 plen += size.cx;
150 break;
152 case SPACE:
153 dest[j++] = str[i++];
154 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
155 (format & DT_WORDBREAK))
157 wb_i = i;
158 wb_j = j - 1;
159 wb_count = *count;
160 if (!GetTextExtentPointW(hdc, &dest[j-1], 1, &size))
161 return NULL;
162 plen += size.cx;
164 break;
166 default:
167 dest[j++] = str[i++];
168 if (!(format & DT_NOCLIP) || !(format & DT_NOPREFIX) ||
169 (format & DT_WORDBREAK))
171 if (!GetTextExtentPointW(hdc, &dest[j-1], 1, &size))
172 return NULL;
173 plen += size.cx;
177 (*count)--;
178 if (!(format & DT_NOCLIP) || (format & DT_WORDBREAK))
180 if (plen > width)
182 if (format & DT_WORDBREAK)
184 if (wb_j)
186 *len = wb_j;
187 *count = wb_count - 1;
188 return (&str[wb_i]);
191 else
193 *len = j;
194 return (&str[i]);
200 *len = j;
201 return NULL;
205 /***********************************************************************
206 * DrawText16 (USER.85)
208 INT16 WINAPI DrawText16( HDC16 hdc, LPCSTR str, INT16 count, LPRECT16 rect, UINT16 flags )
210 INT16 ret;
212 if (rect)
214 RECT rect32;
215 CONV_RECT16TO32( rect, &rect32 );
216 ret = DrawTextA( hdc, str, count, &rect32, flags );
217 CONV_RECT32TO16( &rect32, rect );
219 else ret = DrawTextA( hdc, str, count, NULL, flags);
220 return ret;
224 /***********************************************************************
225 * DrawTextExW (USER32.@)
227 #define MAX_STATIC_BUFFER 1024
228 INT WINAPI DrawTextExW( HDC hdc, LPCWSTR str, INT i_count,
229 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
231 SIZE size;
232 const WCHAR *strPtr;
233 static WCHAR line[MAX_STATIC_BUFFER];
234 int len, lh, count=i_count;
235 int prefix_x = 0;
236 int prefix_end = 0;
237 TEXTMETRICW tm;
238 int x = rect->left, y = rect->top;
239 int width = rect->right - rect->left;
240 int max_width = 0;
242 TRACE("%s, %d , [(%d,%d),(%d,%d)]\n", debugstr_wn (str, count), count,
243 rect->left, rect->top, rect->right, rect->bottom);
245 if(dtp) {
246 FIXME("Ignores params:%d,%d,%d,%d\n", dtp->cbSize,
247 dtp->iTabLength, dtp->iLeftMargin, dtp->iRightMargin);
250 if (!str) return 0;
251 if (count == -1) count = strlenW(str);
252 if (count == 0) return 0;
253 strPtr = str;
255 GetTextMetricsW(hdc, &tm);
256 if (flags & DT_EXTERNALLEADING)
257 lh = tm.tmHeight + tm.tmExternalLeading;
258 else
259 lh = tm.tmHeight;
261 if (flags & DT_TABSTOP)
262 tabstop = flags >> 8;
264 if (flags & DT_EXPANDTABS)
266 GetTextExtentPointW(hdc, SPACEW, 1, &size);
267 spacewidth = size.cx;
268 GetTextExtentPointW(hdc, oW, 1, &size);
269 tabwidth = size.cx * tabstop;
272 if (flags & DT_CALCRECT) flags |= DT_NOCLIP;
276 prefix_offset = -1;
277 len = MAX_STATIC_BUFFER;
278 strPtr = TEXT_NextLineW(hdc, strPtr, &count, line, &len, width, flags);
280 if (prefix_offset != -1)
282 GetTextExtentPointW(hdc, line, prefix_offset, &size);
283 prefix_x = size.cx;
284 GetTextExtentPointW(hdc, line, prefix_offset + 1, &size);
285 prefix_end = size.cx - 1;
288 if (!GetTextExtentPointW(hdc, line, len, &size)) return 0;
289 if (flags & DT_CENTER) x = (rect->left + rect->right -
290 size.cx) / 2;
291 else if (flags & DT_RIGHT) x = rect->right - size.cx;
293 if (flags & DT_SINGLELINE)
295 if (flags & DT_VCENTER) y = rect->top +
296 (rect->bottom - rect->top) / 2 - size.cy / 2;
297 else if (flags & DT_BOTTOM) y = rect->bottom - size.cy;
299 if (flags & (DT_PATH_ELLIPSIS | DT_END_ELLIPSIS | DT_WORD_ELLIPSIS))
301 WCHAR swapStr[sizeof(line)];
302 WCHAR* fnameDelim = NULL;
303 int totalLen = i_count >= 0 ? i_count : strlenW(str);
305 if (size.cx > width)
307 int fnameLen = totalLen;
309 /* allow room for '...' */
310 count = min(totalLen+3, sizeof(line)-3);
312 if (flags & DT_WORD_ELLIPSIS)
313 flags |= DT_WORDBREAK;
315 if (flags & DT_PATH_ELLIPSIS)
317 WCHAR* lastBkSlash = NULL;
318 WCHAR* lastFwdSlash = NULL;
319 strncpyW(line, str, totalLen);
320 line[totalLen] = '\0';
321 lastBkSlash = strrchrW(line, BACK_SLASHW[0]);
322 lastFwdSlash = strrchrW(line, FORWARD_SLASHW[0]);
323 fnameDelim = lastFwdSlash ? lastFwdSlash : lastBkSlash;
324 if (lastBkSlash && lastFwdSlash) /* which is last? */
325 if (lastBkSlash > lastFwdSlash)
326 fnameDelim = lastBkSlash;
328 if (fnameDelim)
329 fnameLen = &line[totalLen] - fnameDelim;
330 else
331 fnameDelim = (WCHAR*)str;
333 strcpyW(swapStr, ELLIPSISW);
334 strncpyW(swapStr+strlenW(swapStr), fnameDelim, fnameLen);
335 swapStr[fnameLen+3] = '\0';
336 strncpyW(swapStr+strlenW(swapStr), str, totalLen - fnameLen);
337 swapStr[totalLen+3] = '\0';
339 else /* DT_END_ELLIPSIS | DT_WORD_ELLIPSIS */
341 strcpyW(swapStr, ELLIPSISW);
342 strncpyW(swapStr+strlenW(swapStr), str, totalLen);
345 len = MAX_STATIC_BUFFER;
346 TEXT_NextLineW(hdc, swapStr, &count, line, &len, width, flags);
348 /* if only the ELLIPSIS will fit, just let it be clipped */
349 len = max(3, len);
350 GetTextExtentPointW(hdc, line, len, &size);
352 /* FIXME:
353 * NextLine uses GetTextExtentPoint for each character,
354 * rather than GetCharABCWidth... So the whitespace between
355 * characters is ignored in the width measurement, and the
356 * reported len is too great. To compensate, we must get
357 * the width of the entire line and adjust len accordingly.
359 while ((size.cx > width) && (len > 3))
361 line[--len] = '\0';
362 GetTextExtentPointW(hdc, line, len, &size);
365 if (fnameLen < len-3) /* some of the path will fit */
367 /* put the ELLIPSIS between the path and filename */
368 strncpyW(swapStr, &line[fnameLen+3], len-3-fnameLen);
369 swapStr[len-3-fnameLen] = '\0';
370 strcatW(swapStr, ELLIPSISW);
371 strncpyW(swapStr+strlenW(swapStr), &line[3], fnameLen);
373 else
375 /* move the ELLIPSIS to the end */
376 strncpyW(swapStr, &line[3], len-3);
377 swapStr[len-3] = '\0';
378 strcpyW(swapStr+strlenW(swapStr), ELLIPSISW);
381 strncpyW(line, swapStr, len);
382 line[len] = '\0';
383 strPtr = NULL;
387 if (!(flags & DT_CALCRECT))
389 if (!ExtTextOutW(hdc, x, y, (flags & DT_NOCLIP) ? 0 : ETO_CLIPPED,
390 rect, line, len, NULL )) return 0;
391 if (prefix_offset != -1)
393 HPEN hpen = CreatePen( PS_SOLID, 1, GetTextColor(hdc) );
394 HPEN oldPen = SelectObject( hdc, hpen );
395 MoveToEx(hdc, x + prefix_x, y + tm.tmAscent + 1, NULL );
396 LineTo(hdc, x + prefix_end + 1, y + tm.tmAscent + 1 );
397 SelectObject( hdc, oldPen );
398 DeleteObject( hpen );
401 else if (size.cx > max_width)
402 max_width = size.cx;
404 y += lh;
405 if (strPtr)
407 if (!(flags & DT_NOCLIP))
409 if (y > rect->bottom - lh)
410 break;
414 while (strPtr);
415 if (flags & DT_CALCRECT)
417 rect->right = rect->left + max_width;
418 rect->bottom = y;
420 return y - rect->top;
423 /***********************************************************************
424 * DrawTextA (USER32.@)
426 INT WINAPI DrawTextA( HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags )
428 WCHAR *wstr;
429 INT ret = 0;
430 DWORD wcount;
432 if (count == -1) count = strlen(str);
433 if (!count) return 0;
434 wcount = MultiByteToWideChar( CP_ACP, 0, str, count, NULL, 0 );
435 wstr = HeapAlloc(GetProcessHeap(), 0, wcount * sizeof(WCHAR));
436 if (wstr)
438 MultiByteToWideChar( CP_ACP, 0, str, count, wstr, wcount );
439 ret = DrawTextExW( hdc, wstr, wcount, rect, flags, NULL );
440 HeapFree(GetProcessHeap(), 0, wstr);
442 return ret;
445 /***********************************************************************
446 * DrawTextW (USER32.@)
448 INT WINAPI DrawTextW( HDC hdc, LPCWSTR str, INT count,
449 LPRECT rect, UINT flags )
451 return DrawTextExW(hdc, str, count, rect, flags, NULL);
454 /***********************************************************************
455 * DrawTextExA (USER32.@)
457 INT WINAPI DrawTextExA( HDC hdc, LPCSTR str, INT count,
458 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp )
460 TRACE("(%d,'%s',%d,%p,0x%08x,%p)\n",hdc,str,count,rect,flags,dtp);
461 if(dtp) {
462 FIXME("Ignores params:%d,%d,%d,%d\n",dtp->cbSize,
463 dtp->iTabLength,dtp->iLeftMargin,dtp->iRightMargin);
465 return DrawTextA(hdc,str,count,rect,flags);
468 /***********************************************************************
469 * TEXT_GrayString
471 * FIXME: The call to 16-bit code only works because the wine GDI is a 16-bit
472 * heap and we can guarantee that the handles fit in an INT16. We have to
473 * rethink the strategy once the migration to NT handles is complete.
474 * We are going to get a lot of code-duplication once this migration is
475 * completed...
478 static BOOL TEXT_GrayString(HDC hdc, HBRUSH hb, GRAYSTRINGPROC fn, LPARAM lp, INT len,
479 INT x, INT y, INT cx, INT cy, BOOL unicode, BOOL _32bit)
481 HBITMAP hbm, hbmsave;
482 HBRUSH hbsave;
483 HFONT hfsave;
484 HDC memdc = CreateCompatibleDC(hdc);
485 int slen = len;
486 BOOL retval = TRUE;
487 COLORREF fg, bg;
489 if(!hdc) return FALSE;
491 if(len == 0)
493 if(unicode)
494 slen = lstrlenW((LPCWSTR)lp);
495 else if(_32bit)
496 slen = strlen((LPCSTR)lp);
497 else
498 slen = strlen(MapSL(lp));
501 if((cx == 0 || cy == 0) && slen != -1)
503 SIZE s;
504 if(unicode)
505 GetTextExtentPoint32W(hdc, (LPCWSTR)lp, slen, &s);
506 else if(_32bit)
507 GetTextExtentPoint32A(hdc, (LPCSTR)lp, slen, &s);
508 else
509 GetTextExtentPoint32A(hdc, MapSL(lp), slen, &s);
510 if(cx == 0) cx = s.cx;
511 if(cy == 0) cy = s.cy;
514 hbm = CreateBitmap(cx, cy, 1, 1, NULL);
515 hbmsave = (HBITMAP)SelectObject(memdc, hbm);
516 hbsave = SelectObject( memdc, GetStockObject(BLACK_BRUSH) );
517 PatBlt( memdc, 0, 0, cx, cy, PATCOPY );
518 SelectObject( memdc, hbsave );
519 SetTextColor(memdc, RGB(255, 255, 255));
520 SetBkColor(memdc, RGB(0, 0, 0));
521 hfsave = (HFONT)SelectObject(memdc, GetCurrentObject(hdc, OBJ_FONT));
523 if(fn)
525 if(_32bit)
526 retval = fn(memdc, lp, slen);
527 else
528 retval = (BOOL)((BOOL16)((GRAYSTRINGPROC16)fn)((HDC16)memdc, lp, (INT16)slen));
530 else
532 if(unicode)
533 TextOutW(memdc, 0, 0, (LPCWSTR)lp, slen);
534 else if(_32bit)
535 TextOutA(memdc, 0, 0, (LPCSTR)lp, slen);
536 else
537 TextOutA(memdc, 0, 0, MapSL(lp), slen);
540 SelectObject(memdc, hfsave);
543 * Windows doc says that the bitmap isn't grayed when len == -1 and
544 * the callback function returns FALSE. However, testing this on
545 * win95 showed otherwise...
547 #ifdef GRAYSTRING_USING_DOCUMENTED_BEHAVIOUR
548 if(retval || len != -1)
549 #endif
551 hbsave = (HBRUSH)SelectObject(memdc, CACHE_GetPattern55AABrush());
552 PatBlt(memdc, 0, 0, cx, cy, 0x000A0329);
553 SelectObject(memdc, hbsave);
556 if(hb) hbsave = (HBRUSH)SelectObject(hdc, hb);
557 fg = SetTextColor(hdc, RGB(0, 0, 0));
558 bg = SetBkColor(hdc, RGB(255, 255, 255));
559 BitBlt(hdc, x, y, cx, cy, memdc, 0, 0, 0x00E20746);
560 SetTextColor(hdc, fg);
561 SetBkColor(hdc, bg);
562 if(hb) SelectObject(hdc, hbsave);
564 SelectObject(memdc, hbmsave);
565 DeleteObject(hbm);
566 DeleteDC(memdc);
567 return retval;
571 /***********************************************************************
572 * GrayString16 (USER.185)
574 BOOL16 WINAPI GrayString16( HDC16 hdc, HBRUSH16 hbr, GRAYSTRINGPROC16 gsprc,
575 LPARAM lParam, INT16 cch, INT16 x, INT16 y,
576 INT16 cx, INT16 cy )
578 return TEXT_GrayString(hdc, hbr, (GRAYSTRINGPROC)gsprc, lParam, cch,
579 x, y, cx, cy, FALSE, FALSE);
583 /***********************************************************************
584 * GrayStringA (USER32.@)
586 BOOL WINAPI GrayStringA( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
587 LPARAM lParam, INT cch, INT x, INT y,
588 INT cx, INT cy )
590 return TEXT_GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy,
591 FALSE, TRUE);
595 /***********************************************************************
596 * GrayStringW (USER32.@)
598 BOOL WINAPI GrayStringW( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
599 LPARAM lParam, INT cch, INT x, INT y,
600 INT cx, INT cy )
602 return TEXT_GrayString(hdc, hbr, gsprc, lParam, cch, x, y, cx, cy,
603 TRUE, TRUE);
606 /***********************************************************************
607 * TEXT_TabbedTextOut
609 * Helper function for TabbedTextOut() and GetTabbedTextExtent().
610 * Note: this doesn't work too well for text-alignment modes other
611 * than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-)
613 static LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCSTR lpstr,
614 INT count, INT cTabStops, const INT16 *lpTabPos16,
615 const INT *lpTabPos32, INT nTabOrg,
616 BOOL fDisplayText )
618 INT defWidth;
619 SIZE extent;
620 int i, tabPos = x;
621 int start = x;
623 extent.cx = 0;
624 extent.cy = 0;
626 if (cTabStops == 1)
628 defWidth = lpTabPos32 ? *lpTabPos32 : *lpTabPos16;
629 cTabStops = 0;
631 else
633 TEXTMETRICA tm;
634 GetTextMetricsA( hdc, &tm );
635 defWidth = 8 * tm.tmAveCharWidth;
638 while (count > 0)
640 for (i = 0; i < count; i++)
641 if (lpstr[i] == '\t') break;
642 GetTextExtentPointA( hdc, lpstr, i, &extent );
643 if (lpTabPos32)
645 while ((cTabStops > 0) &&
646 (nTabOrg + *lpTabPos32 <= x + extent.cx))
648 lpTabPos32++;
649 cTabStops--;
652 else
654 while ((cTabStops > 0) &&
655 (nTabOrg + *lpTabPos16 <= x + extent.cx))
657 lpTabPos16++;
658 cTabStops--;
661 if (i == count)
662 tabPos = x + extent.cx;
663 else if (cTabStops > 0)
664 tabPos = nTabOrg + (lpTabPos32 ? *lpTabPos32 : *lpTabPos16);
665 else
666 tabPos = nTabOrg + ((x + extent.cx - nTabOrg) / defWidth + 1) * defWidth;
667 if (fDisplayText)
669 RECT r;
670 r.left = x;
671 r.top = y;
672 r.right = tabPos;
673 r.bottom = y + extent.cy;
674 ExtTextOutA( hdc, x, y,
675 GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0,
676 &r, lpstr, i, NULL );
678 x = tabPos;
679 count -= i+1;
680 lpstr += i+1;
682 return MAKELONG(tabPos - start, extent.cy);
686 /***********************************************************************
687 * TabbedTextOut16 (USER.196)
689 LONG WINAPI TabbedTextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR lpstr,
690 INT16 count, INT16 cTabStops,
691 const INT16 *lpTabPos, INT16 nTabOrg )
693 TRACE("%04x %d,%d '%.*s' %d\n", hdc, x, y, count, lpstr, count );
694 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
695 lpTabPos, NULL, nTabOrg, TRUE );
699 /***********************************************************************
700 * TabbedTextOutA (USER32.@)
702 LONG WINAPI TabbedTextOutA( HDC hdc, INT x, INT y, LPCSTR lpstr, INT count,
703 INT cTabStops, const INT *lpTabPos, INT nTabOrg )
705 TRACE("%04x %d,%d '%.*s' %d\n", hdc, x, y, count, lpstr, count );
706 return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
707 NULL, lpTabPos, nTabOrg, TRUE );
711 /***********************************************************************
712 * TabbedTextOutW (USER32.@)
714 LONG WINAPI TabbedTextOutW( HDC hdc, INT x, INT y, LPCWSTR str, INT count,
715 INT cTabStops, const INT *lpTabPos, INT nTabOrg )
717 LONG ret;
718 LPSTR p;
719 INT acount;
720 UINT codepage = CP_ACP; /* FIXME: get codepage of font charset */
722 acount = WideCharToMultiByte(codepage,0,str,count,NULL,0,NULL,NULL);
723 p = HeapAlloc( GetProcessHeap(), 0, acount );
724 if(p == NULL) return 0; /* FIXME: is this the correct return on failure */
725 acount = WideCharToMultiByte(codepage,0,str,count,p,acount,NULL,NULL);
726 ret = TabbedTextOutA( hdc, x, y, p, acount, cTabStops, lpTabPos, nTabOrg );
727 HeapFree( GetProcessHeap(), 0, p );
728 return ret;
732 /***********************************************************************
733 * GetTabbedTextExtent16 (USER.197)
735 DWORD WINAPI GetTabbedTextExtent16( HDC16 hdc, LPCSTR lpstr, INT16 count,
736 INT16 cTabStops, const INT16 *lpTabPos )
738 TRACE("%04x '%.*s' %d\n", hdc, count, lpstr, count );
739 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
740 lpTabPos, NULL, 0, FALSE );
744 /***********************************************************************
745 * GetTabbedTextExtentA (USER32.@)
747 DWORD WINAPI GetTabbedTextExtentA( HDC hdc, LPCSTR lpstr, INT count,
748 INT cTabStops, const INT *lpTabPos )
750 TRACE("%04x '%.*s' %d\n", hdc, count, lpstr, count );
751 return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
752 NULL, lpTabPos, 0, FALSE );
756 /***********************************************************************
757 * GetTabbedTextExtentW (USER32.@)
759 DWORD WINAPI GetTabbedTextExtentW( HDC hdc, LPCWSTR lpstr, INT count,
760 INT cTabStops, const INT *lpTabPos )
762 LONG ret;
763 LPSTR p;
764 INT acount;
765 UINT codepage = CP_ACP; /* FIXME: get codepage of font charset */
767 acount = WideCharToMultiByte(codepage,0,lpstr,count,NULL,0,NULL,NULL);
768 p = HeapAlloc( GetProcessHeap(), 0, acount );
769 if(p == NULL) return 0; /* FIXME: is this the correct failure value? */
770 acount = WideCharToMultiByte(codepage,0,lpstr,count,p,acount,NULL,NULL);
771 ret = GetTabbedTextExtentA( hdc, p, acount, cTabStops, lpTabPos );
772 HeapFree( GetProcessHeap(), 0, p );
773 return ret;